/* SunCharts v2 design system (web admin). Tokens mirror the app Asset Catalog / Compose ColorScheme
   (design/v2/design-spec.md): ink scale, navy primary, single cobalt accent, semantic crit/caution/normal/info.
   Linked after each page's own <style>, so these element rules restyle every admin page. */
:root {
  --ink900: #0A1628; --ink800: #1B2638; --ink700: #2E3A4D; --ink600: #4A5568; --ink500: #6B7588; --ink400: #98A1B2;
  --ink300: #C9CFD9; --ink200: #E3E7ED; --ink100: #EEF1F5; --ink50: #F4F5F7;
  --navy: #0F1E3D; --accent: #2457F5; --accent-weak: #E8EEFF;
  --crit: #C8102E; --crit-bg: #FDECEE; --caution: #B45309; --caution-bg: #FEF3E2; --normal: #12805C; --normal-bg: #E6F5EE; --info: #2457F5; --info-bg: #E8EEFF;
  --bg: #F4F5F7; --card: #FFFFFF; --card2: #F8F9FB; --line: #E3E7ED; --text: var(--ink900); --text2: var(--ink600); --text3: var(--ink500);
  --side: #0A1628; --side-text: #C9CFD9; --side-active: #1B2638;
  --primary: var(--navy); --primary-text: #fff;
  --radius: 10px; --radius-sm: 6px; --row: 36px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #06090F; --card: #11161F; --card2: #161C27; --line: #232B37; --text: #E8ECF2; --text2: #A3ADBD; --text3: #7D8799;
  --ink100: #1A212C; --ink50: #0D121A; --ink200: #232B37;
  --accent: #5B84FF; --accent-weak: #1A2647; --primary: #5B84FF; --primary-text: #fff;
  --crit: #FF6B7D; --crit-bg: #3A1218; --caution: #F5A524; --caution-bg: #33230A; --normal: #34C38F; --normal-bg: #0E2A20; --info: #5B84FF; --info-bg: #1A2647;
  --side: #0B0F16; --side-active: #161C27;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #06090F; --card: #11161F; --card2: #161C27; --line: #232B37; --text: #E8ECF2; --text2: #A3ADBD; --text3: #7D8799;
    --ink100: #1A212C; --ink50: #0D121A; --ink200: #232B37;
    --accent: #5B84FF; --accent-weak: #1A2647; --primary: #5B84FF; --primary-text: #fff;
    --crit: #FF6B7D; --crit-bg: #3A1218; --caution: #F5A524; --caution-bg: #33230A; --normal: #34C38F; --normal-bg: #0E2A20; --info: #5B84FF; --info-bg: #1A2647;
    --side: #0B0F16; --side-active: #161C27;
    color-scheme: dark;
  }
}

html, :root { font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
body { color: var(--text); background: var(--bg); font-feature-settings: "tnum" 1, "cv11" 1; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
h2 { font-size: 1rem; font-weight: 650; color: var(--text); }
h3 { font-size: .9rem; font-weight: 650; color: var(--text); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 a, h1 a:hover { color: inherit; text-decoration: none; }
.muted { color: var(--text3) !important; }
code { background: var(--ink100); color: var(--text); font-family: var(--mono); border-radius: 4px; }
pre { background: #0A1628; color: #E3E7ED; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--mono); }
hr { border: 0; border-top: 1px solid var(--line); }

.card, .panel, section.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text3); background: transparent; border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap; }
td { border-bottom: 1px solid var(--line); padding: 7px 10px; height: var(--row); box-sizing: border-box; vertical-align: middle; color: var(--text); }
tbody tr:hover td { background: var(--card2); }
tbody tr:last-child td { border-bottom: 0; }

input, select, textarea { font: inherit; font-size: 13px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 9px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
label { color: var(--text2); font-size: 12px; font-weight: 550; }

button, .btn { font: inherit; font-size: 13px; font-weight: 600; background: var(--primary); color: var(--primary-text); border: 1px solid transparent; border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; line-height: 1.3; }
button:hover, .btn:hover { filter: brightness(1.12); text-decoration: none; }
button.secondary, .btn.secondary { background: var(--card); color: var(--text); border-color: var(--line); }
button.danger, .btn.danger { background: var(--card); color: var(--crit); border-color: var(--line); }
button.danger:hover { background: var(--crit-bg); }
button.small, .btn.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .45; cursor: default; filter: none; }

.badge, .pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 18px; border: 1px solid transparent; background: var(--ink100); color: var(--text2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.nodot::before { display: none; }
.b-connected, .b-ok, .b-active, .b-healthy, .b-linked, .b-normal { background: var(--normal-bg); color: var(--normal); }
.b-pending_authorization, .b-pending, .b-degraded, .b-caution, .b-warning { background: var(--caution-bg); color: var(--caution); }
.b-error, .b-reauthorization_required, .b-fail, .b-down, .b-crit, .b-critical, .b-disabled, .b-suspended { background: var(--crit-bg); color: var(--crit); }
.b-info, .b-accent { background: var(--info-bg); color: var(--info); }
.msg { border-radius: var(--radius-sm); border: 1px solid var(--line); }
.msg.err { background: var(--crit-bg); color: var(--crit); } .msg.ok { background: var(--normal-bg); color: var(--normal); }

/* ---- app shell (admin.html) ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 16px 12px; min-height: 100vh; box-sizing: border-box; }
.side-inner { position: sticky; top: 16px; display: flex; flex-direction: column; min-height: calc(100vh - 32px); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 15px; padding: 4px 8px 14px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: #2457F5; color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.org { background: #1B2638; border: 1px solid #2E3A4D; border-radius: 8px; color: #E3E7ED; padding: 8px 10px; font-size: 13px; margin: 0 0 14px; display: flex; justify-content: space-between; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 7px 10px; border-radius: 7px; font-size: 13px; font-weight: 500; text-decoration: none; }
.nav a:hover { background: #131C2B; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav a .ico { width: 16px; text-align: center; opacity: .8; font-size: 13px; }
.nav .sep { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #6B7588; padding: 14px 10px 6px; }
.side-foot { margin-top: auto; font-size: 11px; color: #98A1B2; line-height: 1.6; padding: 0 8px; }
.content { padding: 22px 28px 40px; min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); }
.topbar h1 { margin: 2px 0 0; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--text3); font-size: 13px; min-width: 260px; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--text3); background: var(--card2); margin-left: auto; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; align-items: end; }
.kpi .lbl { font-size: 12px; color: var(--text2); grid-column: 1 / -1; }
.kpi .val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 6px; }
.kpi svg { width: 96px; height: 30px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.grid2b { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 14px; }
.panel { padding: 0; overflow: hidden; }
.panel-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.panel-h h2 { margin: 0; font-size: 14px; }
.panel-b { padding: 0 14px 12px; }
.cell-main { font-weight: 600; } .cell-sub { font-size: 11.5px; color: var(--text3); }
.mono { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.panel { overflow-x: auto; }
.panel td .badge, .panel td.mono { white-space: nowrap; }
.panel th, .panel td { padding-left: 8px; padding-right: 8px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--ink100); color: var(--text2); display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 700; margin-right: 8px; vertical-align: middle; }
.ico-tile { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); display: inline-grid; place-items: center; margin-right: 8px; vertical-align: middle; color: var(--text2); font-size: 12px; }
.uptime { display: flex; gap: 2px; height: 26px; align-items: stretch; margin: 6px 0 4px; }
.uptime i { flex: 1; border-radius: 2px; background: var(--normal); opacity: .85; }
.uptime i.warn { background: var(--caution); } .uptime i.bad { background: var(--crit); } .uptime i.none { background: var(--ink200); }
.chart { width: 100%; height: 130px; }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--text3); align-items: center; }
.legend b { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 4px; }
.theme-toggle { background: transparent; color: var(--side-text); border: 1px solid #2E3A4D; width: 100%; margin-top: 10px; }
@media (max-width: 1100px) { .grid2, .grid2b { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } }

/* ---- legacy page chrome (clinic, consoles, workspace, account) ---- */
body > header, header.top { background: var(--card); border-bottom: 1px solid var(--line); }
header h1 { font-size: 1.15rem; }
