:root {
  --bg: #070b10;
  --panel: rgba(16, 23, 33, 0.88);
  --panel-solid: #101721;
  --panel-soft: rgba(255, 255, 255, 0.025);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #e9eff7;
  --muted: #8c99aa;
  --faint: #5d6a7a;
  --accent: #2dd4bf;
  --accent-deep: #0d9488;
  --blue: #60a5fa;
  --danger: #f87171;
  --warn: #fbbf24;
  --success: #34d399;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
  --font: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1000px 520px at 92% -12%, rgba(45, 212, 191, 0.09), transparent 62%),
    radial-gradient(820px 560px at -8% 102%, rgba(96, 165, 250, 0.07), transparent 60%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #5eead4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
code, .mono { font-family: var(--mono); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.danger-text { color: var(--danger); }
.help { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin-top: 12px; }

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.svg-defs { display: none; }

/* ---------- layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: none;
  padding: 24px 18px 18px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 18, 26, 0.92), rgba(8, 12, 18, 0.78));
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.2), rgba(96, 165, 250, 0.08));
  border: 1px solid rgba(45, 212, 191, 0.25);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 8px 22px rgba(13, 148, 136, 0.12);
  flex: none;
}
.brand-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15.5px; letter-spacing: 0.2px; }
.brand-text small { color: var(--faint); font-size: 10.5px; letter-spacing: 0.4px; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 34px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-link .icon { width: 17px; height: 17px; opacity: 0.85; }
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.035); }
.nav-link.active {
  color: #d9fbf6;
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.14), rgba(45, 212, 191, 0.04));
  border-color: rgba(45, 212, 191, 0.16);
  box-shadow: inset 2px 0 var(--accent);
}

.sidebar-foot { margin-top: auto; padding: 15px 8px 4px; border-top: 1px solid var(--line); }
.server-mini { display: flex; align-items: center; gap: 9px; }
.server-mini strong { display: block; font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.2px; }
.server-mini small { display: block; color: var(--faint); font-size: 10.5px; margin-top: 2px; }
.sidebar-note { margin-top: 10px; font-size: 10.5px; color: var(--faint); }

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12);
  flex: none;
  display: inline-block;
}
.pulse.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.12); }
.pulse.mini { width: 5px; height: 5px; margin-right: 5px; }

.main { flex: 1; min-width: 0; padding: 26px 34px 28px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.topbar-title h1 { font-size: 25px; line-height: 1.25; letter-spacing: -0.3px; }
.topbar-title p { color: var(--muted); margin-top: 5px; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-actions form { display: inline-flex; }

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.live-chip.offline .pulse { background: var(--warn); }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 11px;
  flex-wrap: wrap;
}

/* ---------- primitives ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid rgba(45, 212, 191, 0.55); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(135deg, #2dd4bf, #14b8a6 60%, #0d9488);
  color: #042521;
  box-shadow: 0 8px 22px rgba(20, 184, 166, 0.16), inset 0 1px rgba(255, 255, 255, 0.22);
}
.btn-primary:hover { color: #03201d; box-shadow: 0 10px 26px rgba(20, 184, 166, 0.24); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--line-strong); color: var(--text); }
.btn-danger {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.26);
  color: #fca5a5;
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.15); color: #fecaca; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.6; transform: none; cursor: wait; }

.icon-btn {
  width: 31px;
  height: 31px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { color: var(--accent); border-color: rgba(45, 212, 191, 0.28); background: rgba(45, 212, 191, 0.06); }
.icon-btn .icon { width: 15px; height: 15px; }

.card {
  background: linear-gradient(180deg, rgba(19, 27, 38, 0.92), rgba(14, 21, 30, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  padding: 19px 22px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.card-head h2 { font-size: 15px; letter-spacing: -0.1px; }
.card-head p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card-head .muted { font-size: 11.5px; white-space: nowrap; }
.card-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 11px;
  flex-wrap: wrap;
}

.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  border: 1px solid transparent;
}
.alert-mark { width: 6px; height: 6px; border-radius: 50%; margin-top: 7px; flex: none; }
.alert-success { background: rgba(52, 211, 153, 0.07); border-color: rgba(52, 211, 153, 0.18); color: #a7f3d0; }
.alert-success .alert-mark { background: var(--success); }
.alert-error { background: rgba(248, 113, 113, 0.07); border-color: rgba(248, 113, 113, 0.2); color: #fecaca; }
.alert-error .alert-mark { background: var(--danger); }
.alert-warn { background: rgba(251, 191, 36, 0.06); border-color: rgba(251, 191, 36, 0.18); color: #fde68a; }
.alert-warn .alert-mark { background: var(--warn); }
.alert.compact { margin: 2px 0 4px; }

/* ---------- dashboard ---------- */

#dashboard-page { display: none; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.stat-card {
  position: relative;
  overflow: hidden;
  padding: 17px 18px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(21, 30, 42, 0.94), rgba(13, 20, 29, 0.92));
  box-shadow: var(--shadow);
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(45, 212, 191, 0.35), transparent);
  opacity: 0.6;
}
.stat-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  color: var(--muted);
}
.stat-icon.accent { color: var(--accent); background: rgba(45, 212, 191, 0.07); border-color: rgba(45, 212, 191, 0.14); }
.stat-icon .icon { width: 15px; height: 15px; }
.stat-value {
  font-size: clamp(22px, 2.1vw, 29px);
  font-weight: 650;
  letter-spacing: -0.7px;
  line-height: 1.15;
  margin: 10px 0 8px;
  font-variant-numeric: tabular-nums;
}
.stat-foot { color: var(--faint); font-size: 10.5px; line-height: 1.5; }

.server-strip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(16, 24, 34, 0.82), rgba(11, 17, 25, 0.8));
  padding: 14px 18px;
  margin-bottom: 14px;
}
.server-strip-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.server-title { display: flex; align-items: center; gap: 10px; }
.server-title strong { font-size: 12.5px; display: block; }
.server-title span { color: var(--faint); font-size: 10.5px; }
.service-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.service-pill {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}
.service-pill.ok { color: #a7f3d0; border-color: rgba(52, 211, 153, 0.16); background: rgba(52, 211, 153, 0.05); }
.service-pill.bad { color: #fecaca; border-color: rgba(248, 113, 113, 0.2); background: rgba(248, 113, 113, 0.06); }
.server-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.metric-mini { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric-mini > span:first-child { color: var(--faint); font-size: 10px; }
.metric-mini strong { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-sub { color: var(--faint); font-size: 9.5px; }
.mini-bar { height: 4px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); overflow: hidden; margin-top: 5px; }
.mini-bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #2dd4bf, #38bdf8); }
.mini-bar i.hot { background: linear-gradient(90deg, #fbbf24, #f87171); }

.legacy-bar {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(96, 165, 250, 0.16);
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.06), rgba(96, 165, 250, 0.015));
  border-radius: 13px;
}
.legacy-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(96, 165, 250, 0.09);
  color: var(--blue);
  flex: none;
}
.legacy-icon .icon { width: 16px; height: 16px; }
.legacy-text { flex: 1; min-width: 0; }
.legacy-text strong { display: block; font-size: 12.5px; }
.legacy-text span { color: var(--muted); font-size: 11px; }

.table-card { overflow: hidden; }
.table-head { padding-bottom: 16px; flex-wrap: wrap; }
.table-tools { display: flex; align-items: center; gap: 10px; }
.search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  color: var(--faint);
}
.search:focus-within { border-color: rgba(45, 212, 191, 0.35); }
.search .icon { width: 14px; height: 14px; }
.search input { background: none; border: none; outline: none; width: 190px; font-size: 12px; color: var(--text); }
.search input::placeholder { color: var(--faint); }

.table-wrap { overflow-x: auto; }
.subs-table, .audit-table { width: 100%; border-collapse: collapse; }
.subs-table th, .audit-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--faint);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.014);
  white-space: nowrap;
}
.subs-table th:first-child, .subs-table td:first-child,
.audit-table th:first-child, .audit-table td:first-child { padding-left: 22px; }
.subs-table th:last-child, .subs-table td:last-child,
.audit-table th:last-child, .audit-table td:last-child { padding-right: 22px; }
.subs-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.subs-table tbody tr { transition: background 0.12s ease; }
.subs-table tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.subs-table tbody tr:last-child td { border-bottom: none; }
.subs-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.subs-table .actions-col { width: 100px; }
.sub-name { font-weight: 600; color: var(--text); font-size: 13.5px; }
.sub-name:hover { color: var(--accent); }
.sub-meta { color: var(--faint); font-size: 10.5px; margin-top: 3px; max-width: 290px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-meta .mono { font-size: 10px; color: var(--muted); }
.flow-mini { color: var(--faint); font-size: 9.5px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.status-cell { display: flex; align-items: center; gap: 6px; }
.conn-count {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 9.5px;
  white-space: nowrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-online { color: #6ee7b7; background: rgba(52, 211, 153, 0.07); border-color: rgba(52, 211, 153, 0.2); }
.badge-idle { color: #a5b4c8; background: rgba(148, 163, 184, 0.06); border-color: rgba(148, 163, 184, 0.14); }
.badge-new { color: #93c5fd; background: rgba(96, 165, 250, 0.07); border-color: rgba(96, 165, 250, 0.16); }
.badge-disabled { color: #8b98a9; background: rgba(148, 163, 184, 0.05); border-color: rgba(148, 163, 184, 0.12); }
.badge-expired, .badge-quota { color: #fcd34d; background: rgba(251, 191, 36, 0.06); border-color: rgba(251, 191, 36, 0.2); }

.progress { height: 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); overflow: hidden; width: 90px; }
.progress i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2dd4bf, #38bdf8); }
.progress i.hot { background: linear-gradient(90deg, #fbbf24, #f87171); }
.progress-lg { height: 8px; width: 100%; }
.quota-cell { display: flex; align-items: center; gap: 8px; }
.quota-label { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }

.empty-state { padding: 52px 24px 56px; text-align: center; }
.empty-mark {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  background: rgba(45, 212, 191, 0.07);
  border: 1px solid rgba(45, 212, 191, 0.16);
  color: var(--accent);
}
.empty-mark .icon { width: 22px; height: 22px; }
.empty-state h3 { font-size: 15px; margin-bottom: 6px; }
.empty-state p { color: var(--muted); font-size: 12.5px; max-width: 440px; margin: 0 auto 18px; }

/* ---------- detail ---------- */

.detail-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(300px, 0.85fr); gap: 14px; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-main .card, .detail-side .card { padding-bottom: 20px; }
.detail-main .card > .card-head, .detail-side .card > .card-head { margin-bottom: 2px; }

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 17px 22px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.metric { padding: 13px 15px; border-right: 1px solid var(--line); min-width: 0; }
.metric:last-child { border-right: none; }
.metric > span { color: var(--faint); font-size: 10px; display: block; }
.metric strong { display: block; font-size: 17px; font-weight: 650; letter-spacing: -0.3px; margin: 3px 0 2px; font-variant-numeric: tabular-nums; }
.metric strong.text-value { font-size: 13.5px; letter-spacing: 0; padding-top: 3px; }
.metric small { color: var(--faint); font-size: 9.5px; display: block; }
.quota-block { margin: 17px 22px 0; }
.quota-summary { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.quota-summary strong { color: var(--text); font-variant-numeric: tabular-nums; }
.quota-foot { display: flex; justify-content: space-between; margin-top: 7px; color: var(--faint); font-size: 10.5px; }
.quota-empty { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--line-strong); color: var(--muted); font-size: 12px; }
.quota-empty small { color: var(--faint); font-size: 10px; }

.chart-head { align-items: center; }
.chart-head > div:first-child { min-width: 0; }
.segmented { display: inline-flex; padding: 3px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.025); gap: 2px; flex-wrap: wrap; }
.segmented button, .segmented a {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.segmented button:hover, .segmented a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.segmented button.active, .segmented a.active { color: #d9fbf6; background: rgba(45, 212, 191, 0.12); box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.16); }
.chart-wrap { position: relative; margin: 14px 16px 0; height: 240px; }
#traffic-chart { width: 100%; height: 240px; display: block; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(9, 14, 21, 0.94);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  font-size: 10px;
  color: var(--muted);
  min-width: 120px;
  z-index: 3;
}
.chart-tip strong { color: var(--text); display: block; font-size: 10.5px; margin-bottom: 3px; }
.chart-tip .tip-row { display: flex; justify-content: space-between; gap: 14px; }
.chart-foot { display: flex; justify-content: space-between; gap: 14px; margin: 8px 22px 0; flex-wrap: wrap; align-items: center; }
.legend { display: flex; gap: 14px; color: var(--faint); font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.dot-up { background: #2dd4bf; }
.dot-down { background: #60a5fa; }
.chart-totals { display: flex; gap: 15px; color: var(--faint); font-size: 10px; flex-wrap: wrap; }
.chart-totals strong { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

.link-row { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 10px; align-items: center; margin: 13px 22px 0; }
.link-label { color: var(--muted); font-size: 11px; }
.link-input { display: flex; gap: 7px; min-width: 0; }
.link-input input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  outline: none;
}
.link-input input:focus { border-color: rgba(45, 212, 191, 0.35); color: var(--text); }
.qr-row { display: flex; gap: 14px; margin: 18px 22px 0; align-items: stretch; flex-wrap: wrap; }
.qr-card {
  margin: 0;
  padding: 8px 8px 7px;
  background: #fff;
  border-radius: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 118px;
  flex: none;
}
.qr-card img { width: 102px; height: 102px; display: block; }
.qr-card figcaption { color: #334155; font-size: 9.5px; font-weight: 600; }
.qr-note {
  flex: 1;
  min-width: 180px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.014);
}
.qr-note strong { font-size: 11.5px; display: block; margin-bottom: 4px; }
.qr-note p { color: var(--muted); font-size: 11px; line-height: 1.65; }

.kv { margin: 14px 22px 0; display: flex; flex-direction: column; }
.kv > div { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: none; }
.kv dt { color: var(--faint); font-size: 10.5px; flex: none; }
.kv dd { text-align: right; font-size: 11.5px; margin: 0; min-width: 0; word-break: break-all; }
.kv dd.mono { font-size: 10.5px; color: var(--muted); }
.kv dd.small { font-size: 9.5px; }
.kv dd .badge { font-size: 9.5px; }
.secret-row { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.secret-row .icon-btn { width: 24px; height: 24px; border-radius: 6px; }
.kv.compact > div { padding: 6px 0; }

.danger-card { border-color: rgba(248, 113, 113, 0.13); }
.danger-actions { margin: 14px 22px 0; display: flex; flex-direction: column; gap: 8px; }

/* ---------- forms ---------- */

.form-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.8fr); gap: 14px; align-items: start; }
.form-aside { display: flex; flex-direction: column; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 15px; padding: 18px 22px 22px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 11.5px; font-weight: 600; color: #c0cbd9; }
.field > span em { font-style: normal; color: var(--accent); font-size: 9.5px; margin-left: 4px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field textarea { resize: vertical; min-height: 66px; line-height: 1.6; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(45, 212, 191, 0.42); background: rgba(0, 0, 0, 0.28); }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.field input[type="date"] { color-scheme: dark; }
.field small { color: var(--faint); font-size: 10px; line-height: 1.55; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 9px; align-items: center; padding-top: 3px; }
.input-with-actions { display: flex; gap: 6px; align-items: center; }
.input-with-actions input { flex: 1; min-width: 0; }
.input-with-actions .btn { flex: none; }

.feature-list { padding: 15px 22px 20px; display: flex; flex-direction: column; gap: 15px; }
.feature-list li { display: flex; gap: 11px; }
.feature-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(45, 212, 191, 0.06);
  border: 1px solid rgba(45, 212, 191, 0.14);
  color: var(--accent);
  flex: none;
}
.feature-icon .icon { width: 15px; height: 15px; }
.feature-list strong { display: block; font-size: 12px; margin-bottom: 2px; }
.feature-list p { color: var(--muted); font-size: 10.5px; line-height: 1.6; }
.tip-card { padding: 16px 18px 18px; }
.tip-card > strong { font-size: 12px; display: block; margin-bottom: 5px; }
.tip-card p { color: var(--muted); font-size: 11px; line-height: 1.65; }

/* ---------- settings ---------- */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.settings-grid > .card { padding-bottom: 20px; }
.settings-wide { grid-column: 1 / -1; }
.settings-grid .stack { padding-bottom: 0; }
.link-preview { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 9px; border: 1px dashed var(--line-strong); }
.link-preview span { color: var(--faint); font-size: 9.5px; }
.link-preview code { color: var(--muted); font-size: 10.5px; word-break: break-all; }
.cert-state { margin: 15px 22px 0; display: flex; flex-direction: column; gap: 5px; }
.cert-state strong { font-size: 13px; word-break: break-all; }
.cert-state span { font-size: 11px; }
.cert-badge { align-self: flex-start; padding: 3px 8px; border-radius: 999px; font-size: 9.5px; font-weight: 600; margin-bottom: 2px; }
.cert-badge.trusted { color: #6ee7b7; background: rgba(52, 211, 153, 0.07); border: 1px solid rgba(52, 211, 153, 0.2); }
.cert-badge.self { color: #fcd34d; background: rgba(251, 191, 36, 0.06); border: 1px solid rgba(251, 191, 36, 0.2); }
.settings-grid .help { margin: 12px 22px 0; }
.legacy-status { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 15px 22px 0; }
.legacy-status > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255, 255, 255, 0.018); }
.legacy-status span { display: block; color: var(--faint); font-size: 9.5px; }
.legacy-status strong { display: block; font-size: 14px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.switch-row { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; }
.switch-row strong { display: block; font-size: 12px; font-weight: 600; }
.switch-row small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.switch { position: relative; width: 36px; height: 21px; flex: none; margin-top: 2px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch-track { display: block; width: 100%; height: 100%; border-radius: 999px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); transition: background 0.15s ease; }
.switch-track::after { content: ""; position: absolute; top: 4px; left: 4px; width: 13px; height: 13px; border-radius: 50%; background: #94a3b8; transition: transform 0.15s ease, background 0.15s ease; }
.switch input:checked + .switch-track { background: rgba(45, 212, 191, 0.22); border-color: rgba(45, 212, 191, 0.35); }
.switch input:checked + .switch-track::after { transform: translateX(15px); background: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 2px solid rgba(45, 212, 191, 0.5); outline-offset: 2px; }
.backup-list { margin: 14px 22px 0; display: flex; flex-direction: column; gap: 6px; }
.backup-list li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, 0.015); }
.backup-list strong { display: block; color: var(--muted); font-weight: 500; word-break: break-all; }
.backup-list span { color: var(--faint); font-size: 9.5px; }
.settings-grid > .card > .btn { margin: 15px 22px 0; }
.security-note { margin: 14px 22px 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.016); }
.security-note strong { font-size: 11px; display: block; margin-bottom: 3px; }
.security-note p { color: var(--muted); font-size: 10.5px; line-height: 1.65; }

/* ---------- audit ---------- */

.audit-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 11.5px; }
.audit-table tbody tr:last-child td { border-bottom: none; }
.audit-table tbody tr:hover { background: rgba(255, 255, 255, 0.016); }
.audit-action { display: inline-flex; padding: 2px 7px; border-radius: 999px; font-size: 9.5px; border: 1px solid var(--line); color: var(--muted); background: rgba(255, 255, 255, 0.025); white-space: nowrap; }
.audit-action.danger { color: #fca5a5; border-color: rgba(248, 113, 113, 0.18); background: rgba(248, 113, 113, 0.05); }

/* ---------- auth ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}
.auth-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.33; }
.orb-a { width: 480px; height: 480px; background: #0f766e; top: -140px; right: -80px; }
.orb-b { width: 420px; height: 420px; background: #1d4ed8; bottom: -160px; left: -100px; opacity: 0.17; }
.auth-wrap { position: relative; z-index: 2; width: min(400px, calc(100vw - 36px)); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.auth-card {
  width: 100%;
  padding: 27px 27px 22px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(165deg, rgba(19, 28, 39, 0.94), rgba(10, 16, 24, 0.94));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), inset 0 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.auth-brand strong { display: block; font-size: 14.5px; line-height: 1.3; }
.auth-brand small { display: block; color: var(--faint); font-family: var(--mono); font-size: 10px; margin-top: 2px; }
.auth-card h1 { font-size: 21px; letter-spacing: -0.4px; }
.auth-sub { color: var(--muted); font-size: 12px; margin: 5px 0 19px; }
.auth-card .alert { margin-bottom: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .field > span { font-size: 11px; }
.auth-form input { height: 40px; }
.auth-form .btn { height: 40px; margin-top: 2px; }
.auth-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--faint); font-size: 9.5px; flex-wrap: wrap; }
.auth-tip { color: var(--faint); font-size: 10px; text-align: center; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 18px);
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid rgba(45, 212, 191, 0.28);
  background: rgba(9, 17, 22, 0.96);
  color: #ccfbf1;
  font-size: 11.5px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 200;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */

@media (max-width: 1240px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1.45fr) minmax(285px, 0.85fr); }
  .main { padding: 24px 24px 26px; }
}

@media (max-width: 1060px) {
  .detail-grid, .form-layout, .settings-grid { grid-template-columns: 1fr; }
  .settings-wide { grid-column: auto; }
  .detail-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .detail-side .danger-card { grid-column: 1 / -1; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: none; }
  .metric:nth-child(1), .metric:nth-child(2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 11px 16px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 13, 20, 0.9);
  }
  .brand { padding: 0; gap: 9px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .brand-mark svg { width: 21px; height: 21px; }
  .brand-text strong { font-size: 13.5px; }
  .brand-text small { display: none; }
  .nav { flex-direction: row; margin: 0 0 0 auto; gap: 2px; overflow-x: auto; }
  .nav-link { padding: 8px 10px; font-size: 11.5px; white-space: nowrap; }
  .nav-link .icon { width: 15px; height: 15px; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 16px 24px; }
  .topbar { margin-bottom: 18px; }
  .topbar-title h1 { font-size: 21px; }
  .topbar-title p { font-size: 11.5px; }
  .server-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 13px; }
  .table-tools { width: 100%; }
  .search { width: 100%; }
  .search input { width: 100%; }
  .detail-side { display: flex; }
  .row-actions .btn { display: none; }
}

@media (max-width: 680px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 21px; }
  .stat-foot { font-size: 9.5px; }
  .nav-link span { display: none; }
  .nav-link { padding: 8px 9px; }
  .topbar-actions .live-chip { display: none; }
  .only-wide { display: none; }
  .subs-table th:nth-child(3), .subs-table td:nth-child(3),
  .subs-table th:nth-child(5), .subs-table td:nth-child(5) { display: none; }
  .subs-table th:first-child, .subs-table td:first-child { padding-left: 15px; }
  .subs-table th:last-child, .subs-table td:last-child { padding-right: 15px; }
  .subs-table td { padding: 11px 8px; }
  .sub-meta { max-width: 170px; }
  .flow-mini { display: none; }
  .row-actions .icon-btn { width: 29px; height: 29px; }
  .link-row { grid-template-columns: 1fr; gap: 4px; }
  .link-input input { font-size: 10px; }
  .qr-row { flex-direction: column; }
  .qr-card { width: 108px; }
  .qr-note { width: 100%; }
  .metric-row { margin: 14px 15px 0; }
  .metric { padding: 11px 12px; }
  .metric strong { font-size: 15px; }
  .quota-block, .link-row, .qr-row, .kv, .danger-actions { margin-left: 15px; margin-right: 15px; }
  .chart-foot, .chart-wrap { margin-left: 13px; margin-right: 13px; }
  .chart-totals { gap: 9px; }
  .chart-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .chart-head .segmented { width: 100%; }
  .chart-head .segmented button { flex: 1; }
  .card-head { padding-left: 15px; padding-right: 15px; }
  .card-foot { padding-left: 15px; padding-right: 15px; }
  .stack { padding-left: 15px; padding-right: 15px; }
  .field-row { grid-template-columns: 1fr; }
  .settings-grid .legacy-status { margin-left: 15px; margin-right: 15px; }
  .legacy-status { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .legacy-status > div { padding: 8px; }
  .legacy-status strong { font-size: 12px; }
  .auth-card { padding: 22px 20px 18px; }
  .legacy-bar { align-items: flex-start; }
  .legacy-bar .btn { display: none; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr; }
  .sub-meta { max-width: 135px; }
}
