:root {
  --bg: #080d16;
  --bg-2: #0e1624;
  --bg-3: #131f31;
  --panel: rgba(19, 31, 49, 0.82);
  --line: #223149;
  --line-strong: #335079;
  --text: #e8eef8;
  --muted: #93a4bd;
  --dim: #64748b;
  --accent: #4da3ff;
  --accent-2: #7c5cff;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --radius: 16px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(77, 163, 255, 0.14), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(124, 92, 255, 0.12), transparent 55%),
    var(--bg);
  padding-bottom: calc(76px + var(--safe-bottom));
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 16px;
  color: var(--muted);
  text-align: center;
}
.boot-mark {
  width: 46px; height: 46px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: rgba(8, 13, 22, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 22px rgba(77, 163, 255, 0.45);
}
#page-title { font-weight: 650; font-size: 16px; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg-2);
}

.view {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 14px 28px;
  outline: none;
}

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  background: rgba(8, 13, 22, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(20px);
}
.bottom-nav a {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 12px;
  color: var(--dim);
  font-size: 10.5px;
  text-decoration: none;
}
.bottom-nav a .nav-icon { font-size: 17px; line-height: 1.2; }
.bottom-nav a.active { color: var(--accent); background: rgba(77, 163, 255, 0.1); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-head h1 { margin: 0; font-size: 22px; line-height: 1.25; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 15px; }
.card h3 { font-size: 14px; }
.card p { line-height: 1.6; }
.card.tight { padding: 12px; }
.card.flat { box-shadow: none; background: var(--bg-2); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; line-height: 1.55; }
.tiny { font-size: 11px; line-height: 1.5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.stack { display: grid; gap: 10px; }
.stack-lg { display: grid; gap: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat {
  background: linear-gradient(160deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
}
.stat .label { color: var(--muted); font-size: 11.5px; }
.stat .value { font-size: 25px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat .hint { color: var(--dim); font-size: 11px; margin-top: 2px; }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(77, 163, 255, 0.08);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.09); }
.badge.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.38); background: rgba(251, 191, 36, 0.08); }
.badge.bad { color: var(--danger); border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.09); }
.badge.info { color: var(--accent); border-color: rgba(77, 163, 255, 0.4); }
.badge.plain { color: var(--dim); border-color: var(--line); background: transparent; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 22px rgba(77, 163, 255, 0.25);
}
.btn.danger { color: var(--danger); border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.08); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 12px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

label.field { display: grid; gap: 6px; margin-bottom: 12px; }
label.field > span { color: var(--muted); font-size: 12px; }
input[type="text"], input[type="password"], input[type="number"], input[type="tel"],
input[type="email"], input[type="url"], input[type="search"], input[type="file"], textarea, select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #0a1220;
  color: var(--text);
  outline: none;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.12); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.check { display: flex; align-items: flex-start; gap: 9px; margin: 9px 0; font-size: 13px; line-height: 1.5; }
.check input { flex: none; margin-top: 1px; }
.check span { color: var(--muted); }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { color: var(--dim); font-size: 11.5px; line-height: 1.55; margin: -4px 0 12px; }
.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: rgba(77, 163, 255, 0.06);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 10px 0;
}
.notice.warn { border-left-color: var(--warn); background: rgba(251, 191, 36, 0.06); }
.notice.bad { border-left-color: var(--danger); background: rgba(251, 113, 133, 0.06); }
.notice.ok { border-left-color: var(--ok); background: rgba(52, 211, 153, 0.06); }

.list { display: grid; gap: 8px; }
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
.item.clickable:hover { border-color: var(--line-strong); background: var(--bg-3); }
.item .grow { min-width: 0; flex: 1; }
.item .title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--dim); font-size: 11.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #1b3553, #16263e);
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 2px 9px; }
.section-title h2 { margin: 0; font-size: 14px; letter-spacing: 0.02em; color: var(--muted); font-weight: 650; }

.empty { padding: 26px 12px; text-align: center; color: var(--dim); font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; font-size: 12.5px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; color: var(--text); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin: 0 0 12px; }
.tab {
  flex: none;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.tab.active { color: var(--accent); border-color: var(--accent); background: rgba(77, 163, 255, 0.08); }

.auth-screen {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 14px;
  padding: max(24px, var(--safe-top)) 18px 30px;
}
.auth-wrap { width: 100%; max-width: 430px; margin: 0 auto; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head .brand-mark { width: 44px; height: 44px; border-radius: 14px; margin: 0 auto 14px; }
.auth-head h1 { margin: 0 0 6px; font-size: 22px; }
.auth-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}
.auth-card .btn { width: 100%; }
.auth-foot { margin-top: 14px; text-align: center; color: var(--dim); font-size: 11.5px; line-height: 1.6; }
.qr { display: block; width: min(230px, 70vw); height: auto; margin: 12px auto; border-radius: 12px; background: #fff; padding: 8px; }
.secret-box {
  display: block;
  padding: 10px;
  border-radius: 9px;
  border: 1px dashed var(--line-strong);
  background: #0a1220;
  color: var(--accent);
  font-family: ui-monospace, monospace;
  font-size: 12px;
  word-break: break-all;
  user-select: all;
}
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 12px 0; }
.codes code { padding: 8px; border-radius: 8px; background: #0a1220; border: 1px solid var(--line); font-size: 12px; text-align: center; }

.chat-list .item { border-radius: 13px; }
.chat-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 180px);
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 2px 14px;
}
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 92%; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 9px 12px;
  border-radius: 14px 14px 14px 5px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg.out .bubble {
  border-radius: 14px 14px 5px 14px;
  background: linear-gradient(150deg, #1b4b7d, #1b3557);
  border-color: #285b8d;
}
.msg-meta { color: var(--dim); font-size: 10.5px; margin: 3px 4px 0; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.msg-actions { margin-top: 3px; }
.msg-media { max-width: 100%; border-radius: 10px; margin-top: 6px; display: block; }
.msg-file {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.2); color: var(--accent); font-size: 12px;
}
.composer { position: sticky; bottom: calc(64px + var(--safe-bottom)); z-index: 20; }
.composer .card { margin: 0; border-radius: 16px; }
.composer textarea { min-height: 52px; max-height: 140px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea { flex: 1; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(4px);
  padding: 0;
}
.modal {
  width: 100%; max-width: 640px;
  max-height: 88vh;
  overflow: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + var(--safe-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.4);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-close { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-3); color: var(--muted); }

.toast-root {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 100; display: grid; gap: 8px; width: min(440px, calc(100vw - 28px));
  pointer-events: none;
}
.toast {
  padding: 11px 14px;
  border-radius: 12px;
  background: #16263e;
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.18s ease-out;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.45); }
.toast.bad { border-color: rgba(251, 113, 133, 0.5); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.timeline { display: grid; gap: 8px; }
.event {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg-2);
}
.event.critical { border-color: rgba(251, 113, 133, 0.4); }
.event.warning { border-color: rgba(251, 191, 36, 0.3); }
.event .event-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.event .event-title { font-weight: 600; font-size: 13px; }
.event .event-body { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.alert-row { display: flex; gap: 10px; align-items: flex-start; }
.alert-row .grow { flex: 1; min-width: 0; }
.alert-row .title { font-weight: 600; font-size: 13px; }
.alert-row .body { color: var(--muted); font-size: 12px; line-height: 1.55; margin-top: 3px; }
.unread { border-left: 3px solid var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

details { border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); padding: 10px 12px; }
details + details { margin-top: 8px; }
summary { cursor: pointer; font-size: 13px; font-weight: 600; }
details .details-body { margin-top: 10px; }

.account-card .item + .item { margin-top: 8px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quick-grid .btn { min-height: 46px; }
.gate { display: grid; gap: 8px; }
.gate .gate-item { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); line-height: 1.5; }

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .view { padding: 22px 20px 40px; }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 20px; max-height: 86vh; }
}
@media (max-width: 360px) {
  .bottom-nav a { font-size: 9.5px; }
  .inline-fields { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
