/* FiberSight UI — warm neutral surfaces, soft grid, gold accents, dark pill buttons. */
:root {
  --bg: #f3f2ee;
  --bg-grid: rgba(20, 20, 10, 0.045);
  --surface: #fbfaf7;
  --surface-2: #f0eee8;
  --line: #e4e1d9;
  --text: #121212;
  --muted: #85827a;
  --faint: #b3afa5;
  --ink: #1a1a1a;           /* dark pill buttons */
  --ink-text: #ffffff;
  --gold-1: #f6dc8a;
  --gold-2: #e3b23c;
  --gold-3: #b98516;
  --gold-soft: rgba(227, 178, 60, 0.16);
  --crit: #e5484d;
  --major: #f08c2e;
  --minor: #d8b12b;
  --info: #5b8def;
  --ok: #2f9e6b;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 12px 32px -18px rgba(40, 30, 0, 0.25);
  --radius: 22px;
  --radius-sm: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0a; --bg-grid: rgba(255, 240, 200, 0.035); --surface: #151513; --surface-2: #1d1d1a; --line: #2a2925;
    --text: #f2f0ea; --muted: #8f8b80; --faint: #5d5a52; --ink: #f2f0ea; --ink-text: #121212;
    --gold-soft: rgba(227, 178, 60, 0.14);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 40px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0a; --bg-grid: rgba(255, 240, 200, 0.035); --surface: #151513; --surface-2: #1d1d1a; --line: #2a2925;
  --text: #f2f0ea; --muted: #8f8b80; --faint: #5d5a52; --ink: #f2f0ea; --ink-text: #121212;
  --gold-soft: rgba(227, 178, 60, 0.14);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 40px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "ss01", "cv11";
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    radial-gradient(1200px 500px at 50% 110%, var(--gold-soft), transparent 70%);
  background-size: 48px 48px, 48px 48px, 100% 100%;
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; font-size: 15px; white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, var(--gold-1), var(--gold-2) 55%, var(--gold-3));
  box-shadow: 0 6px 18px -6px var(--gold-2);
}
.nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px; }
.nav::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; white-space: nowrap; color: var(--muted);
  transition: color .15s, background .15s, border-color .15s; text-decoration: none;
}
.chip:hover { color: var(--text); }
.chip.active { color: var(--text); background: var(--surface-2); border-color: var(--faint); }
.chip .count { margin-left: 6px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--crit); color: #fff; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border-radius: 999px; padding: 9px 18px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; font-size: 13px; white-space: nowrap;
  transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ink { background: var(--ink); color: var(--ink-text); border-color: var(--ink); box-shadow: 0 8px 20px -10px rgba(0,0,0,.5); }
.btn-gold { background: linear-gradient(180deg, var(--gold-1), var(--gold-2)); color: #2a1d00; border-color: var(--gold-2); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.icon-btn { width: 36px; height: 36px; padding: 0; }

/* ---------- layout ---------- */
main { max-width: 1320px; margin: 0 auto; padding: 28px 24px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; margin-bottom: 12px;
}
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 500; letter-spacing: -0.035em; line-height: 1.05; margin: 0; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0; }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3, .g-main { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .g4, .g2 { grid-template-columns: 1fr; } main { padding: 20px 16px 60px; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; row-gap: 10px; }
  .topbar .brand { flex: 1; }
  .topbar .nav { order: 10; flex-basis: 100%; }
  .topbar .btn { padding: 8px 12px; }
}

.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
/* the notched tab corner from the reference design */
.card.tab::before {
  content: ""; position: absolute; top: -1px; right: 28px; width: 90px; height: 10px;
  background: var(--bg); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px;
}

/* ---------- KPI ---------- */
.kpi { overflow: hidden; min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-label { font-size: 12px; color: var(--muted); }
.delta { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.delta.up { color: var(--ok); } .delta.down { color: var(--crit); }
.kpi-value { display: flex; align-items: center; gap: 12px; margin-top: 24px; position: relative; z-index: 1; }
.kpi-value .num { font-size: clamp(30px, 3.2vw, 42px); font-weight: 400; letter-spacing: -0.04em; line-height: 1; }
.kpi-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-3); flex: none; }
.kpi-art { position: absolute; right: 0; bottom: 0; width: 60%; height: 70%; pointer-events: none; opacity: .95; }

/* ---------- lists / tables ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid transparent; min-width: 0;
}
.row:hover { border-color: var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sev { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sev-critical { background: var(--crit); box-shadow: 0 0 0 4px color-mix(in srgb, var(--crit) 18%, transparent); }
.sev-major { background: var(--major); } .sev-minor { background: var(--minor); } .sev-info { background: var(--info); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.pill.online { color: var(--ok); } .pill.offline { color: var(--crit); }
.pill.critical { color: var(--crit); } .pill.major { color: var(--major); } .pill.minor { color: var(--gold-3); } .pill.info { color: var(--info); }

.table-wrap { overflow-x: auto; margin: 0 -20px -20px; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; } tbody tr:hover td { background: var(--surface-2); }
.num-cell { font-variant-numeric: tabular-nums; }
.bad { color: var(--crit); } .warn { color: var(--major); } .good { color: var(--ok); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.input, select.input, textarea.input {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 16px; outline: none; min-width: 0;
}
textarea.input { border-radius: 16px; resize: vertical; }
.input:focus { border-color: var(--gold-2); box-shadow: 0 0 0 4px var(--gold-soft); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

.health-bar { width: 70px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: inline-block; vertical-align: middle; }
.health-bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold-2), var(--gold-1)); }

/* PON heat grid */
.ports { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.port { border-radius: 12px; padding: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; }
.port b { display: block; font-size: 15px; font-weight: 500; letter-spacing: -0.02em; margin-top: 4px; }
.port.p-bad { background: color-mix(in srgb, var(--crit) 14%, var(--surface)); border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); }
.port.p-warn { background: color-mix(in srgb, var(--major) 12%, var(--surface)); }

/* OLT cards */
.olt-card .big { font-size: 34px; font-weight: 400; letter-spacing: -0.04em; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; gap: 2px; }
.bar i { display: block; height: 100%; }

/* ---------- auth (hero) ---------- */
.hero { min-height: 100vh; display: grid; place-items: center; padding: 40px 16px; }
.hero-inner { width: 100%; max-width: 560px; text-align: center; }
.hero h1 { font-size: clamp(36px, 6vw, 60px); margin-bottom: 14px; }
.hero p.lead { color: var(--muted); font-size: 16px; max-width: 440px; margin: 0 auto 28px; }
.auth-card { text-align: left; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.auth-card .input { width: 100%; }
.trusted { display: inline-flex; gap: 14px; align-items: center; font-size: 12px; color: var(--muted); border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; margin-bottom: 24px; flex-wrap: wrap; justify-content: center; }
.trusted b { color: var(--text); font-weight: 600; }

/* ---------- AI chat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 460px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px; }
.msg { max-width: 82%; padding: 12px 16px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.msg.ai { align-self: flex-start; }
.msg h1, .msg h2, .msg h3 { font-size: 14px; color: var(--text); margin: 10px 0 4px; }
.msg ul { margin: 6px 0; padding-left: 20px; }
.msg code { background: var(--surface); padding: 1px 5px; border-radius: 6px; font-size: 12px; }
.msg pre { background: var(--surface); padding: 10px; border-radius: 10px; overflow-x: auto; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input .input { flex: 1; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 40; }
.drawer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(520px, calc(100vw - 24px)); z-index: 41;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 30px 80px -20px rgba(0,0,0,.4);
  padding: 22px; overflow-y: auto;
}
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.kv div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.kv span { display: block; font-size: 11px; color: var(--muted); }
.kv b { font-weight: 500; font-size: 15px; }
.kv b em { font-style: normal; }
.note { background: var(--surface-2); border-radius: 14px; padding: 14px; font-size: 13px; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--ink-text); padding: 12px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 18px 40px -16px rgba(0,0,0,.5); max-width: calc(100vw - 32px);
}
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
svg text { fill: var(--muted); font-size: 10px; }
