/* ---------- design tokens ---------- */
/* Light theme inspired by Tydal's dashboard: near-black top bar over a
   neutral light-gray canvas, pure white cards with a large soft shadow,
   electric blue as the single accent (swapped in for Tydal's yellow). */
:root {
  --bg: #f2f2f0;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #f6f6f4;
  --bg-nav: rgba(10, 10, 12, .92);
  --border: rgba(15,15,20,.1);
  --border-strong: rgba(15,15,20,.22);
  --text: #0e0e12;
  --text-muted: #63636b;
  --text-faint: #97979e;

  --accent: #2f6fed;
  --accent-deep: #1d4fd1;
  --accent-glow: rgba(47,111,237,.14);
  --red: #dc3d3d;
  --red-glow: rgba(220,61,61,.10);
  --amber: #c07a10;
  --amber-glow: rgba(192,122,16,.12);
  --blue: #2f6fed;
  --blue-glow: rgba(47,111,237,.14);

  --overlay-1: rgba(15,15,20,.035);
  --overlay-2: rgba(15,15,20,.06);
  --overlay-3: rgba(15,15,20,.09);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(20,20,20,.04), 0 1px 0 rgba(15,15,20,.03);
  --shadow-pop: 0 10px 30px rgba(20,20,20,.1), 0 2px 8px rgba(20,20,20,.06);

  --ease: cubic-bezier(.4,0,.2,1);
  --dur-fast: 120ms;
  --dur-base: 200ms;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;

  /* aliases for the pre-redesign token names still used across a few
     view files — keeps this a pure visual system change, no need to
     touch every inline style to get the new palette applied. */
  --card: var(--bg-elevated);
  --green: var(--accent);
  --ink: var(--text);
  --line: var(--border);
  --muted: var(--text-muted);
  --paper: var(--bg);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 650; letter-spacing: -.01em; color: var(--text); margin: 0 0 6px; }
h1 { font-size: 24px; }
h2 { font-size: 15px; color: var(--text-muted); font-weight: 600; }
p { color: var(--text-muted); }

/* ---------- top bar ---------- */
/* The one dark surface left in an otherwise light theme (mirrors Tydal's
   black sidebar) — re-scopes the text/border tokens to their light-on-dark
   equivalents for every descendant, rather than hardcoding colors on each
   child element individually. */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 28px;
  padding: 0 22px; height: 56px;
  background: var(--bg-nav);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid rgba(255,255,255,.08);
  --text: #f4f4f6;
  --text-muted: #a8a8b3;
  --text-faint: #74747f;
  --border: rgba(255,255,255,.1);
  --border-strong: rgba(255,255,255,.2);
}
.brand { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand::before {
  content: ""; width: 18px; height: 18px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  box-shadow: 0 0 14px var(--accent-glow);
}
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--text-muted); font-size: 13.5px; font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.nav a:hover { color: var(--text); background: rgba(255,255,255,.05); text-decoration: none; }
.nav a.active { color: var(--text); background: rgba(255,255,255,.07); }
.nav-spacer { flex: 1; }
.palette-hint {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 8px; cursor: pointer; background: rgba(255,255,255,.02);
  transition: border-color var(--dur-fast) var(--ease);
}
.palette-hint:hover { border-color: var(--border-strong); color: var(--text-muted); }

main#view { max-width: 1440px; margin: 0 auto; padding: 28px 32px 80px; }

/* ---------- cards ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.card:hover { border-color: var(--border-strong); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* ---------- buttons ---------- */
button {
  font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--overlay-1);
  color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
button:hover { background: var(--overlay-3); border-color: var(--text-faint); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }
button.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-color: transparent; color: #ffffff; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 4px 16px var(--accent-glow);
}
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--red); }
button.danger:hover { background: var(--red-glow); border-color: rgba(220,61,61,.4); }
button .icon { flex: 0 0 auto; }

/* ---------- inputs ---------- */
input, select, textarea {
  font: inherit; font-size: 13.5px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated-2);
  color: var(--text);
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
label { display: block; font-size: 12px; color: var(--text-muted); margin: 12px 0 5px; font-weight: 500; }

/* ---------- tags / badges ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 3px 9px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); color: var(--text-muted);
}
.tag.ok { color: var(--accent-deep); border-color: rgba(47,111,237,.3); background: var(--accent-glow); }
.tag.warn { color: var(--amber); border-color: rgba(192,122,16,.3); background: var(--amber-glow); }
.tag.bad { color: var(--red); border-color: rgba(220,61,61,.3); background: var(--red-glow); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 600; }

/* ---------- misc ---------- */
.err { color: var(--red); font-size: 13px; margin-top: 8px; }
.icon { display: inline-block; vertical-align: -3px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* skeleton loading */
.skel { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--overlay-1), var(--overlay-3), var(--overlay-1)); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- command palette ---------- */
.palette-overlay {
  position: fixed; inset: 0; background: rgba(4,6,9,.6); backdrop-filter: blur(3px);
  z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.palette {
  width: 100%; max-width: 520px; background: var(--bg-elevated-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); overflow: hidden;
}
.palette input {
  border: none; border-bottom: 1px solid var(--border); border-radius: 0;
  background: transparent; padding: 16px 18px; font-size: 15px;
}
.palette input:focus { box-shadow: none; }
.palette-results { max-height: 320px; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); font-size: 13.5px;
}
.palette-item.active { background: var(--overlay-2); color: var(--text); }
.palette-item .icon { color: var(--text-faint); }

@media (max-width: 700px) {
  .nav { display: none; }
  main#view { padding: 20px 16px 60px; }
}

/* ---------- charts ---------- */
.spark { display: block; }
.trend-chart { display: block; }
.chart-empty { color: var(--text-faint); font-size: 12.5px; padding: 30px 0; text-align: center; }
.chart-legend { display: flex; gap: 14px; margin-bottom: 6px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); }
.chart-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bar-compare text { font-family: var(--font-sans); }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  font-family: var(--font-mono);
}
.delta.good { color: var(--accent); background: var(--accent-glow); }
.delta.bad { color: var(--red); background: var(--red-glow); }
.delta.flat { color: var(--text-faint); background: rgba(255,255,255,.04); }

/* ---------- bento dashboard ---------- */
.bento { display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); margin-bottom: 14px; }
.bento .card { margin-bottom: 0; }
.bento .span-4 { grid-column: span 4; }
.bento .span-6 { grid-column: span 6; }
.bento .span-8 { grid-column: span 8; }
.bento .span-12 { grid-column: span 12; }
@media (max-width: 900px) {
  .bento .span-4, .bento .span-6, .bento .span-8, .bento .span-12 { grid-column: span 12; }
}
.metric-card { display: flex; flex-direction: column; gap: 8px; }
.metric-card .mc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.metric-card .mc-value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.metric-card .mc-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.metric-card .mc-chart { margin-top: 2px; }

.customize-bar { display: flex; justify-content: flex-end; margin: 0 0 10px; }
.card-hidden { display: none !important; }
.customize-panel { display: flex; flex-direction: column; gap: 2px; }
.customize-panel .cp-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 4px; border-bottom: 1px solid var(--border);
}
.customize-panel .cp-row:last-child { border-bottom: none; }
.customize-panel .cp-move { display: flex; gap: 4px; }
.customize-panel .cp-move button { padding: 4px 8px; font-size: 11px; }
.customize-panel label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }

/* ---------- scan-grid (dashboard campaign tables) ---------- */
.scan-kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 18px; }
.scan-kpi-strip .k { background: var(--card); padding: 12px 16px; }
.scan-kpi-strip .k .l { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.scan-kpi-strip .k .v { font-size: 19px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.scan-group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 14px; box-shadow: var(--shadow-card); }
.scan-group-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; background: var(--bg-elevated-2); border-bottom: 1px solid var(--line); }
.scan-group-head .src { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.scan-group-head .src .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.scan-group-head .host { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }
.scan-table-wrap { overflow-x: auto; }
.scan-table { width: 100%; border-collapse: collapse; }
.scan-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); font-weight: 600; padding: 8px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.scan-table th.num, .scan-table td.num { text-align: right; }
.scan-table td { padding: 10px 18px; font-size: 13px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: middle; }
.scan-table tr:last-child td { border-bottom: none; }
.scan-table tr:hover td { background: var(--overlay-1); }
.scan-table td.name { font-weight: 600; }
.scan-table td.name .cap { display: block; font-size: 11.5px; color: var(--text-faint); font-weight: 400; margin-top: 2px; }
.scan-table td.rate { font-weight: 700; font-size: 14.5px; }
.scan-table td.actions { text-align: right; }
.scan-table td.actions button { padding: 5px 10px; font-size: 11.5px; }
.scan-draft-row td { background: var(--bg-elevated-2); }

/* ---------- connection cards (dashboard) ---------- */
.conn-card { display: flex; flex-direction: column; gap: 10px; }
.conn-card-top { display: flex; align-items: flex-start; gap: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; }
.status-dot.ok { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.status-dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-glow); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-glow); }
.conn-card-sync { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-faint); }
