/* ==========================================================================
   Mockr Monitor — data-dense dashboard
   ========================================================================== */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fbfe;
  --line: #e6ebf3;
  --line-2: #d6deea;

  --ink: #0e1726;
  --ink-2: #42536b;
  --ink-3: #7c8ba1;
  --ink-4: #9aa8bc;

  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eef4ff;
  --cyan: #0ea5e9;
  --orange: #f97316;
  --violet: #7c3aed;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;

  --sidebar: #0b1220;
  --sidebar-2: #0f1a2e;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(14, 23, 38, .05), 0 2px 8px rgba(14, 23, 38, .03);
  --shadow-md: 0 8px 24px rgba(14, 23, 38, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.nav-open { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
code, pre, .mono { font-family: var(--mono); }
h1, h2, h3, strong { color: var(--ink); }
::selection { background: rgba(37, 99, 235, .16); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.icon { flex: 0 0 auto; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.strong { font-weight: 650; color: var(--ink); }
.text-orange { color: var(--orange); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-warn { color: var(--amber); }
.mt { margin-top: 16px; }

/* ---------------- shell ---------------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #c7d2e2;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  z-index: 50;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px 20px;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
  flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 14.5px; letter-spacing: .01em; }
.brand-text small { color: #7f8ea6; font-size: 11px; margin-top: 2px; }

.nav-label {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: #64748b; padding: 0 10px 8px;
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: #aebbd0; font-size: 13.5px; font-weight: 500;
  transition: background .18s ease, color .18s ease;
  width: 100%; text-align: left;
}
.nav-item .icon { color: #7c8ba1; transition: color .18s ease; }
.nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-item:hover .icon { color: #cbd5e1; }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(37, 99, 235, .28), rgba(37, 99, 235, .10));
  color: #fff;
  box-shadow: inset 2px 0 0 #3b82f6;
}
.nav-item.is-active .icon { color: #7eb0ff; }

.sidebar-foot { margin-top: auto; padding-top: 18px; }
.side-site {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 11px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
  margin-bottom: 10px;
}
.side-site-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #34d399; margin-top: 5px; flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .15);
}
.side-site div { display: flex; flex-direction: column; min-width: 0; }
.side-site strong { color: #e2e8f0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-site small { color: #7f8ea6; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-form { display: block; }
.nav-logout { color: #8fa0b8; font-size: 13px; }
.side-version { color: #526179; font-size: 10.5px; padding: 14px 10px 0; }

.main { margin-left: 232px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  background: rgba(245, 247, 251, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn {
  display: none; width: 38px; height: 38px; border-radius: 10px;
  align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.page-head h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.page-sub { color: var(--ink-3); font-size: 12px; margin-top: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: 9px;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent; background: transparent;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.btn-primary {
  background: var(--brand); color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .2);
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--line-2); background: #fff; color: var(--ink); }
.btn-danger { background: #fff; border-color: #f3d0d0; color: var(--red); }
.btn-danger:hover { background: #fef2f2; border-color: #f0b9b9; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; height: 42px; font-size: 14px; }
.btn-icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.filterbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 0 28px 14px;
}
.filter-form { display: flex; align-items: center; gap: 8px; }
.select-wrap { position: relative; display: inline-flex; }
.select-wrap::after {
  content: ""; position: absolute; right: 11px; top: 50%; width: 7px; height: 7px;
  border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
select, .select-wrap select {
  appearance: none; height: 34px; padding: 0 30px 0 11px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink); font-size: 13px; cursor: pointer; max-width: 260px;
}
select:hover { border-color: var(--line-2); }

.range-tabs { display: inline-flex; background: #eceff5; border-radius: 10px; padding: 3px; gap: 2px; }
.range-tab {
  padding: 5px 11px; border-radius: 7px; font-size: 12.5px; color: var(--ink-2);
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.range-tab:hover { color: var(--ink); }
.range-tab.is-active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: var(--shadow-sm); }

.custom-range {
  display: none; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 4px 6px 4px 10px;
}
.custom-range.is-open { display: inline-flex; }
.custom-range label { font-size: 12px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 5px; }
.custom-range input[type=date] {
  border: 0; background: transparent; font-size: 12.5px; color: var(--ink); height: 26px; padding: 0 2px;
}
.custom-range input[type=date]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }

.content { padding: 6px 28px 32px; display: flex; flex-direction: column; gap: 16px; }
.app-foot {
  margin-top: auto; padding: 0 28px 22px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--ink-4);
}

/* ---------------- KPI ---------------- */
.kpi-grid { display: grid; gap: 12px; }
.kpi-grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kpi {
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 16px 14px; box-shadow: var(--shadow-sm);
  overflow: hidden; min-width: 0;
}
.kpi::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--cyan));
  opacity: .55;
}
.kpi.tone-orange::before { background: linear-gradient(90deg, var(--orange), #fbbf24); }
.kpi.tone-violet::before { background: linear-gradient(90deg, var(--violet), #a78bfa); }
.kpi.tone-red::before { background: linear-gradient(90deg, var(--red), #f87171); opacity: .8; }
.kpi-label { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.kpi-value {
  margin-top: 6px; display: flex; align-items: baseline; gap: 8px;
  font-size: 27px; line-height: 1.15; font-weight: 700; color: var(--ink);
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.kpi-sub { margin-top: 3px; font-size: 11.5px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--ink-4); }

/* ---------------- panels ---------------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  min-width: 0; overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 15px 18px 0;
}
.panel-head h2 { font-size: 14.5px; font-weight: 650; letter-spacing: -.005em; }
.panel-head p { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }
.panel-head .panel-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.panel-body { padding: 14px 18px 16px; }
.panel-body.no-pad { padding: 10px 0 0; overflow-x: auto; }
.legend-note { font-size: 11.5px; color: var(--ink-4); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ---------------- tables ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.table th {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  text-align: left; padding: 9px 16px; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #f8fafd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-compact td { padding: 7px 10px; }
.table-compact th { padding: 7px 10px; }
.path-cell { max-width: 430px; }
.path-cell > a, .path-cell > span, .path-cell {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.path-cell a { color: var(--ink-2); }
.path-cell a:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.bot-num { color: var(--orange); font-weight: 600; }
.ref-host { display: block; font-size: 10.5px; color: var(--ink-4); margin-top: 1px; }

.spider-link:hover { text-decoration: none; }
.spider-link:hover .chip { filter: brightness(.96); }

.actions-cell { text-align: right; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 5px; justify-content: flex-end; }
.inline-form { display: inline-flex; }
.detail-row td { padding: 0 16px 10px; background: var(--surface-2); }
.detail-row:hover td { background: var(--surface-2); }
.site-edit summary {
  cursor: pointer; font-size: 12px; color: var(--brand); padding: 4px 0;
  list-style: none; display: inline-flex; align-items: center; gap: 4px;
}
.site-edit summary::-webkit-details-marker { display: none; }
.site-edit summary::before { content: "›"; font-size: 15px; transition: transform .18s ease; }
.site-edit[open] summary::before { transform: rotate(90deg); }

/* ---------------- chips / badges ---------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  background: #f1f5f9; color: var(--ink-2);
}
.chip-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip-blue { background: #eaf1ff; color: #1d4ed8; }
.chip-violet { background: #f2ecff; color: #6d28d9; }
.chip-amber { background: #fff4e5; color: #b45309; }
.chip-teal { background: #e6fbf7; color: #0f766e; }
.chip-green { background: #e8f9f1; color: #047857; }
.chip-gray { background: #f1f5f9; color: #526179; }
.chip-ok { background: #e8f9f1; color: #047857; }
.chip-warn { background: #fff6e6; color: #b45309; }
.chip-bad { background: #fdecec; color: #b91c1c; }
.chip-muted { background: #f1f5f9; color: #7c8ba1; }

.status-code {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 21px; padding: 0 6px; border-radius: 5px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  background: #f1f5f9; color: var(--ink-2);
}
.status-ok { background: #e8f9f1; color: #047857; }
.status-warn { background: #fff6e6; color: #b45309; }
.status-bad { background: #fdecec; color: #b91c1c; }
.status-muted { background: #f1f5f9; color: #7c8ba1; }

/* ---------------- charts ---------------- */
.chart { position: relative; width: 100%; min-height: 280px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: #eef2f8; stroke-width: 1; }
.chart .axis-label { fill: var(--ink-4); font-size: 10.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .hover-line { stroke: #b6c2d4; stroke-width: 1; stroke-dasharray: 3 3; }
.chart .bar { opacity: .92; }
.chart .bar:hover { opacity: 1; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); }
.legend-item i { width: 8px; height: 8px; border-radius: 3px; }
.chart-tip {
  position: absolute; z-index: 6; min-width: 140px;
  background: #0e1726; color: #fff; border-radius: 10px;
  padding: 9px 11px; font-size: 12px; pointer-events: none;
  box-shadow: 0 10px 30px rgba(14, 23, 38, .22);
}
.chart-tip-title { color: #a9b6c9; font-size: 11px; margin-bottom: 5px; }
.chart-tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.7; }
.chart-tip-row i { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.chart-tip-row span { color: #cbd5e1; }
.chart-tip-row b { margin-left: auto; font-variant-numeric: tabular-nums; padding-left: 14px; }
.chart-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-4); font-size: 12.5px; pointer-events: none;
}

/* ---------------- lists ---------------- */
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: grid; grid-template-columns: minmax(88px, 38%) 1fr auto; align-items: center; gap: 9px; }
.rank-label { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { height: 7px; background: #f0f4fa; border-radius: 99px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.rank-val { font-size: 12px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.rank-val em { font-style: normal; color: var(--ink-4); font-weight: 400; font-size: 10px; margin-left: 2px; }

.status-list { display: flex; flex-direction: column; gap: 7px; }
.status-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 9px; }
.status-bar { height: 6px; background: #f0f4fa; border-radius: 99px; overflow: hidden; }
.status-bar span { display: block; height: 100%; background: linear-gradient(90deg, #93c5fd, #60a5fa); border-radius: 99px; }
.status-num { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: right; }

.block-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-4); margin: 0 0 9px; font-weight: 600; }
.split-block + .split-block { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 30px 16px; color: var(--ink-4); text-align: center;
}
.empty p { font-size: 12.5px; color: var(--ink-3); }
.empty span { font-size: 11.5px; color: var(--ink-4); }
.empty .icon { color: #b8c4d6; }

/* ---------------- live ---------------- */
.live-hero {
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
  padding: 18px 20px; border-radius: var(--r-lg);
  background: linear-gradient(120deg, #0e1726, #16233b 60%, #1b2c4a);
  color: #e2e8f0; box-shadow: var(--shadow-md);
}
.live-hero-main { display: flex; align-items: center; gap: 16px; }
.live-dot {
  width: 12px; height: 12px; border-radius: 50%; background: #34d399;
  box-shadow: 0 0 0 5px rgba(52, 211, 153, .16);
}
.live-dot.pulse { animation: pulse .6s ease; }
@keyframes pulse { 0% { box-shadow: 0 0 0 5px rgba(52, 211, 153, .16); } 40% { box-shadow: 0 0 0 12px rgba(52, 211, 153, .05); } 100% { box-shadow: 0 0 0 5px rgba(52, 211, 153, .16); } }
.live-big { font-size: 34px; font-weight: 700; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.live-caption { font-size: 11.5px; color: #93a4bd; margin-top: 6px; }
.live-caption small { color: #64748b; margin-left: 5px; }
.live-hero-stats { display: flex; gap: 26px; margin-left: 6px; }
.live-hero-stats div { display: flex; flex-direction: column; gap: 2px; }
.live-hero-stats strong { font-size: 20px; color: #fff; font-variant-numeric: tabular-nums; }
.live-hero-stats span { font-size: 11px; color: #8fa0b8; }
.live-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.segmented { display: inline-flex; background: rgba(255, 255, 255, .08); border-radius: 9px; padding: 3px; }
.seg { padding: 5px 11px; border-radius: 7px; font-size: 12px; color: #a9b6c9; }
.seg.is-active { background: rgba(255, 255, 255, .16); color: #fff; }
.live-panel .panel-head { padding-top: 14px; }
.live-updated { font-size: 11.5px; color: var(--ink-4); }
.live-table td { padding-top: 8px; padding-bottom: 8px; }
.live-empty { padding: 26px; text-align: center; color: var(--ink-4); font-size: 12.5px; }

.live-stats { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0 12px; border-bottom: 1px dashed var(--line); }
.live-stats div { display: flex; flex-direction: column; }
.live-stats strong { font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.live-stats span { font-size: 10.5px; color: var(--ink-4); }
.mini-feed { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.mini-feed-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; min-width: 0; }
.mini-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--orange); flex: 0 0 auto; }
.mini-feed-text { color: var(--ink-2); white-space: nowrap; }
.mini-feed-path { color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.mini-feed-time { color: var(--ink-4); font-variant-numeric: tabular-nums; }

/* ---------------- keyword / source ---------------- */
.kw-list { display: flex; flex-direction: column; }
.kw-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.kw-row:last-child { border-bottom: 0; }
.kw-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.kw-num { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 11.5px; }

.source-donut { display: flex; flex-direction: column; gap: 10px; }
.source-line { display: grid; grid-template-columns: 74px 1fr 48px 60px; align-items: center; gap: 8px; font-size: 12px; }
.source-name { color: var(--ink-2); }
.source-track { height: 7px; background: #f0f4fa; border-radius: 99px; overflow: hidden; }
.source-track span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #2563eb, #38bdf8); }
.source-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.source-pv { text-align: right; color: var(--ink-4); font-size: 11px; }

/* ---------------- pagination & notes ---------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.pager .muted { font-size: 11.5px; }
.pager-btns { display: flex; gap: 6px; }
.page-note { font-size: 11.5px; color: var(--ink-4); line-height: 1.7; padding: 0 2px; }
.link { color: var(--brand); font-size: 12px; display: inline-flex; align-items: center; gap: 3px; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------------- forms ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.field.grow { flex: 1; }
input[type=text], input[type=password], input[type=date], input[type=search] {
  height: 36px; padding: 0 11px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 13px; transition: border-color .15s ease, box-shadow .15s ease;
}
input[type=text]:focus, input[type=password]:focus, input[type=date]:focus {
  border-color: #9db8f5; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); outline: none;
}
.add-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.add-form .field { flex: 0 1 210px; }
.add-form .field.grow { flex: 1 1 320px; }
.edit-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 8px 0 4px; }
.edit-form .field { flex: 0 1 220px; }
.edit-form .field.grow { flex: 1 1 320px; }
.hint { font-size: 11.5px; color: var(--ink-4); line-height: 1.7; margin-top: 10px; }
.hint code { background: #f1f5f9; border-radius: 4px; padding: 1px 5px; font-size: 11px; color: var(--ink-2); }
.code-block {
  background: #0e1726; color: #cbd5e1; border-radius: 9px;
  padding: 10px 12px; font-size: 11.5px; line-height: 1.65;
  overflow-x: auto; margin-top: 6px; white-space: pre-wrap; word-break: break-all;
}
.health-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.health-grid div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--line); }
.health-grid span { font-size: 11px; color: var(--ink-3); }
.health-grid strong { font-size: 12.5px; font-weight: 600; }
.kv-list { display: flex; flex-direction: column; }
.kv-list div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.kv-list div:last-child { border-bottom: 0; }
.kv-list span { color: var(--ink-3); }
.kv-list strong { font-weight: 500; text-align: right; word-break: break-all; }
.site-cell { display: flex; flex-direction: column; }
.site-cell strong { font-size: 13px; }
.site-cell small { color: var(--ink-3); font-size: 11.5px; }

.alert {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 11px 14px; border-radius: 10px; font-size: 12.5px;
  background: var(--brand-soft); color: #1e40af; border: 1px solid #dbe7ff;
}
.alert .icon { margin-top: 1px; }
.alert-error { background: #fdf1f1; color: #991b1b; border-color: #f5d5d5; }
.alert-ok { background: #eafaf3; color: #065f46; border-color: #cdeee1; }
.alert-warn { background: #fff8ea; color: #92400e; border-color: #f3dfb8; }
.alert b { font-weight: 650; }

/* ---------------- login ---------------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #0b1220; padding: 24px; position: relative; overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(760px 420px at 18% 12%, rgba(37, 99, 235, .30), transparent 62%),
    radial-gradient(620px 380px at 84% 86%, rgba(14, 165, 233, .18), transparent 60%),
    linear-gradient(120deg, #070d1a, #0b1220 55%, #101c31);
}
.login-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 74%);
}
.login-wrap { position: relative; z-index: 1; width: 100%; max-width: 400px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 42px; height: 42px; font-size: 21px; }
.login-brand strong { display: block; color: #fff; font-size: 16px; }
.login-brand small { color: #8fa0b8; font-size: 11.5px; }
.login-card {
  background: rgba(255, 255, 255, .98); border-radius: 18px;
  padding: 26px 24px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .38);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--ink-3); font-size: 12.5px; margin-bottom: 18px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-card .alert { margin-bottom: 16px; }
.password-wrap { position: relative; display: flex; }
.password-wrap input { flex: 1; height: 44px; padding-right: 58px; font-size: 14px; }
.pwd-toggle {
  position: absolute; right: 4px; top: 4px; height: 36px; padding: 0 10px;
  font-size: 12px; color: var(--ink-3); border-radius: 7px;
}
.pwd-toggle:hover { background: #f1f5f9; color: var(--ink); }
.login-hint { display: flex; align-items: center; gap: 6px; color: var(--ink-4); font-size: 11px; margin-top: 2px; }
.login-foot { text-align: center; color: #64748b; font-size: 11px; margin-top: 20px; }

/* ---------------- responsive ---------------- */
@media (max-width: 1240px) {
  .kpi-grid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid-3 > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar-scrim {
    display: none; position: fixed; inset: 0; z-index: 45;
    background: rgba(7, 13, 26, .5); backdrop-filter: blur(2px);
  }
  body.nav-open .sidebar-scrim { display: block; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .filterbar { padding: 0 16px 12px; }
  .content { padding: 4px 16px 26px; }
  .app-foot { padding: 0 16px 18px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .kpi-grid.cols-6, .kpi-grid.cols-5, .kpi-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 23px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 > :last-child { grid-column: auto; }
  .topbar { gap: 10px; }
  .page-head h1 { font-size: 17px; }
  .btn-label { display: none; }
  .filterbar { gap: 8px; }
  .select-wrap select { max-width: 100%; width: 100%; }
  .filter-form { width: 100%; }
  .custom-range.is-open { width: 100%; flex-wrap: wrap; }
  .range-tabs { overflow-x: auto; max-width: 100%; }
  .range-tab { padding: 5px 9px; }
  .live-hero { gap: 16px; padding: 16px; }
  .live-hero-stats { gap: 18px; margin-left: 0; }
  .live-tools { margin-left: 0; width: 100%; justify-content: space-between; }
  .panel-head { flex-wrap: wrap; }
  .add-form .field, .edit-form .field, .add-form .field.grow, .edit-form .field.grow { flex: 1 1 100%; }
  .source-line { grid-template-columns: 66px 1fr 42px 52px; }
  .table { font-size: 12px; }
  .table th, .table td { padding-left: 12px; padding-right: 12px; }
  .rank-row { grid-template-columns: minmax(80px, 42%) 1fr auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
