/* Celestia Fibre Observatory — self-contained dashboard styles.
   No external fonts, frameworks or CDNs: the dashboard must work from any
   static host, including offline mirrors. */

:root {
  --bg: #0b1020;
  --bg-raised: #121a30;
  --bg-hover: #1a2440;
  --border: #223052;
  --text: #e8edf7;
  --text-dim: #9aa8c7;
  --text-faint: #6b7a9c;
  --accent: #7c6cf5;
  --accent-2: #58e0c4;
  --ok: #35c283;
  --fail: #f0566a;
  --warn: #e8b23f;
  --unknown: #8d97b0;
  --na: #55617e;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7fb; --bg-raised: #ffffff; --bg-hover: #eef1f8;
    --border: #d9deeb; --text: #1c2438;
    --text-dim: #4d5a77; --text-faint: #7a86a1; --unknown: #77809a; --na: #9aa4bd;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; width: 100%; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--border); background: var(--bg-raised); position: sticky; top: 0; z-index: 10; }
.bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 17px; }
.brand-mark { font-size: 22px; }
.brand-text strong { font-weight: 700; }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav-link { color: var(--text-dim); text-decoration: none; font-size: 14px; }
.nav-link:hover { color: var(--text); }

.net-switch { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.net-btn {
  border: 0; background: transparent; color: var(--text-dim); padding: 5px 14px; border-radius: 999px;
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.net-btn.active { background: var(--accent); color: #fff; }

/* Disclaimer notice */
.notice { background: linear-gradient(90deg, rgba(124,108,245,.18), rgba(88,224,196,.12)); border-bottom: 1px solid var(--border); color: var(--text); font-size: 13.5px; padding: 8px 0; }
.notice .wrap { display: flex; align-items: center; justify-content: center; gap: 10px; }
.notice-close { margin-left: auto; background: none; border: 0; color: var(--text-dim); font-size: 16px; cursor: pointer; }
.notice.hidden { display: none; }

/* Freshness line */
.freshness { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 13.5px; padding: 14px 0 4px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.freshness.stale .spinner { border-top-color: var(--fail); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; padding: 14px 0; }
.stat { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { color: var(--text-dim); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-value.ok { color: var(--ok); }
.stat-sub { color: var(--text-faint); font-size: 12px; margin-top: 2px; }

/* Data quality */
.quality { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin: 8px 0; }
.quality h2 { font-size: 15px; margin: 0 0 8px; }
.quality ul { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 13.5px; }
.quality li { margin: 3px 0; }

/* Table */
.table-section { padding: 10px 0 30px; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; }
.table-head h2 { margin: 0; font-size: 19px; }
.search { background: var(--bg-raised); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 12px; font: inherit; width: min(320px, 100%); }
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--text-dim); cursor: pointer; user-select: none; }
.chip input { accent-color: var(--accent); }
.chip:has(input:not(:checked)) { opacity: .55; }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised); }
.valtable { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.valtable th, .valtable td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.valtable th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; background: var(--bg-raised); }
.valtable th.sortable { cursor: pointer; }
.valtable th.sortable:hover { color: var(--text); }
.valtable tbody tr:hover { background: var(--bg-hover); }
.valtable tbody tr { cursor: pointer; }
.valtable td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
.valtable td.empty { text-align: center; color: var(--text-faint); padding: 30px; }
.table-foot { color: var(--text-faint); font-size: 12.5px; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.pass, .pill.ok { color: var(--ok); background: rgba(53,194,131,.12); }
.pill.fail { color: var(--fail); background: rgba(240,86,106,.12); }
.pill.warn { color: var(--warn); background: rgba(232,178,63,.14); }
.pill.unknown { color: var(--unknown); background: rgba(141,151,176,.14); }
.pill.na { color: var(--na); background: rgba(85,97,126,.14); }

.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score.good { color: var(--ok); }
.score.mid { color: var(--warn); }
.score.low { color: var(--fail); }

.spark { vertical-align: middle; }

a { color: var(--accent-2); }

/* Detail page */
.detail-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding: 18px 0 6px; }
.detail-head h1 { margin: 0; font-size: 24px; }
.back { color: var(--text-dim); text-decoration: none; font-size: 13.5px; }
.detail-meta { color: var(--text-dim); font-size: 13.5px; padding-bottom: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; padding: 10px 0; }
.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; overflow-x: auto; }
.card h2 { margin: 0 0 10px; font-size: 15px; }
.card table { border-collapse: collapse; width: 100%; font-size: 13px; }
.card table td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.card table td:first-child { color: var(--text-dim); white-space: nowrap; }
.card table tr:last-child td { border-bottom: 0; }

.rule-detail { font-size: 12.5px; color: var(--text-dim); }
.rule-detail code { font-family: var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

.btn { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; padding: 7px 14px; border-radius: 8px; font-size: 13.5px; border: 0; cursor: pointer; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }

.history-list { list-style: none; padding: 0; margin: 0; font-size: 13px; max-height: 260px; overflow-y: auto; }
.history-list li { padding: 4px 0; border-bottom: 1px solid var(--border); }
.history-list li:last-child { border-bottom: 0; }

/* Methodology page */
.doc { max-width: 860px; }
.doc h1 { font-size: 26px; margin: 24px 0 8px; }
.doc h2 { font-size: 19px; margin: 28px 0 8px; }
.doc p, .doc li { color: var(--text-dim); font-size: 14.5px; }
.doc code { font-family: var(--mono); background: var(--bg-raised); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; color: var(--text); }
.doc strong { color: var(--text); }
.callout { background: var(--bg-raised); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin: 14px 0; }

/* Footer */
.footer { border-top: 1px solid var(--border); margin-top: auto; padding: 16px 0; color: var(--text-faint); font-size: 13px; }
.foot-inner { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.foot-links a { color: var(--text-dim); }

@media (max-width: 720px) {
  .bar-inner { justify-content: center; }
  .stat-value { font-size: 22px; }
  .valtable { font-size: 12.5px; }
  .valtable th, .valtable td { padding: 7px 8px; }
}
