/* Easy Assistance admin panel - vendored, no CDN. Dark, information-dense, calm. */
:root {
  --bg: #0e1116; --bg-elev: #161b22; --bg-elev2: #1c2230; --border: #2a313c;
  --fg: #e6edf3; --muted: #8b96a5; --muted2: #5d6675;
  --accent: #4c9aff; --accent-dim: #2d5fa8;
  --ok: #3fb950; --warn: #d29922; --crit: #f85149;
  --in: #4c9aff; --out: #a371f7;
  --series-a: #4c9aff; --series-b: #a371f7; --series-c: #3fb950; --series-d: #d29922;
  --series-e: #f85149; --series-f: #56d4dd;
  --radius: 10px; --gap: 16px; --sidebar-width: 256px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans);
  font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.88em; color: var(--fg); background: var(--bg-elev2);
  padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.0rem; margin: 0 0 12px; font-weight: 600; color: var(--fg); }

/* dashboard shell */
.app-body { min-width: 0; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column;
  width: var(--sidebar-width); padding: 20px 12px; background: var(--bg-elev); border-right: 1px solid var(--border); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; margin: 0 8px 28px; color: var(--fg); text-decoration: none; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand strong { font-size: 0.95rem; }
.sidebar-brand small { margin-top: 1px; color: var(--muted); font-size: 0.77rem; }
.brand-mark { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: #08121f; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.4px; }
.app-main { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); }
.page-topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  min-height: 64px; padding: 10px 32px; background: rgba(14,17,22,0.94); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px); }
.page-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.health-pill, .user-chip, .logout-link { display: inline-flex; align-items: center; min-height: 30px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.health-pill { gap: 6px; padding: 0 10px; color: var(--muted); background: var(--bg-elev); border: 1px solid var(--border); }
.health-pill.ok { color: var(--ok); }
.health-pill.info { color: var(--accent); }
.health-pill.warn { color: var(--warn); }
.health-pill.crit { color: var(--crit); }
.health-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.user-chip { max-width: 220px; padding: 0 11px; overflow: hidden; text-overflow: ellipsis; color: var(--fg);
  background: var(--bg-elev); border: 1px solid var(--border); }
.logout-link { padding: 0 10px; color: var(--muted); }
.logout-link:hover { color: var(--fg); background: var(--bg-elev); text-decoration: none; }
.sidebar-toggle { display: none; flex: none; width: 36px; height: 36px; padding: 0; color: var(--fg); background: transparent;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 1.05rem; }
.sidebar-close, .sidebar-backdrop { display: none; }
.sidebar-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; padding: 0;
  place-items: center; color: var(--muted); background: transparent; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-size: 1.3rem; }
.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; }
.brand { font-weight: 700; letter-spacing: 0.5px; }
.brand.big { font-size: 1.4rem; margin-bottom: 8px; }
.nav { display: grid; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 8px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 600; }
.nav-icon { display: grid; place-items: center; width: 18px; color: var(--muted2); font-size: 1rem; }
.nav-link:hover { color: var(--fg); background: var(--bg-elev2); text-decoration: none; }
.nav-link.active { color: var(--fg); background: rgba(76,154,255,0.14); box-shadow: inset 2px 0 0 var(--accent); }
.nav-link.active .nav-icon { color: var(--accent); }
.nav-link:focus-visible, .logout-link:focus-visible, .sidebar-brand:focus-visible, .sidebar-toggle:focus-visible,
.sidebar-close:focus-visible,
.login-card input:focus-visible, .login-card button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The wider measure is intentional for dashboard content beside the fixed navigation rail. */
.container { max-width: 1440px; margin: 0 auto; padding: 28px 32px; }
.footer { padding: 24px 32px; text-align: center; }

/* banners */
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: var(--gap);
  border: 1px solid var(--border); font-size: 0.92em; }
.banner.info { background: rgba(76,154,255,0.10); border-color: var(--accent-dim); }
.banner.warn { background: rgba(210,153,34,0.12); border-color: var(--warn); color: #f0c674; }
.banner.crit { background: rgba(248,81,73,0.12); border-color: var(--crit); color: #ff8a82; }

/* cards + grids */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: var(--gap); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; gap: var(--gap); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.stats { grid-template-columns: repeat(4, 1fr); margin-bottom: var(--gap); }
@media (max-width: 820px) { .grid.two, .grid.stats { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid.stats { grid-template-columns: 1fr; } }

/* stat cards */
.stat { padding: 16px; }
.stat-label { color: var(--muted); font-size: 0.82em; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 0.85em; margin-top: 2px; }
.stat-spark { margin-top: 8px; }
.stat.crit .stat-value { color: var(--crit); }
.balance-na { font-size: 1.05rem; color: var(--muted); font-weight: 500; }

/* tables */
.table-scroll { overflow-x: auto; width: 100%; min-width: 0; }
.table-scroll svg.gauge { width: 180px; max-width: none; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.8em;
  text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 10px; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: var(--bg-elev2); }
table.data tbody tr:last-child td { border-bottom: none; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.78em; font-weight: 600;
  background: var(--bg-elev2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: rgba(63,185,80,0.4); }
.badge.warn { color: var(--warn); border-color: rgba(210,153,34,0.4); }
.badge.crit { color: var(--crit); border-color: rgba(248,81,73,0.4); }
.badge.scope { color: var(--accent); border-color: var(--accent-dim); }
.badge.muted-badge { opacity: 0.7; }

/* key-value */
.kv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 24px; }
@media (max-width: 700px) { .kv-grid { grid-template-columns: 1fr 1fr; } }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv .k { color: var(--muted); font-size: 0.8em; }
.kv .v { font-weight: 500; }

.detail-head { margin-bottom: 16px; }
.back { color: var(--muted); font-size: 0.9em; }
.control-flags { margin-bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.gauges { align-items: start; }

/* filter input */
.filter { background: var(--bg); border: 1px solid var(--border); color: var(--fg); border-radius: 8px;
  padding: 6px 10px; font-size: 0.9em; width: 220px; }
.filter:focus { outline: none; border-color: var(--accent); }

/* charts (SVG classes from charts.py) */
svg.chart, svg.gauge { display: block; }
.chart-wrap { display: block; }
.spark-line { stroke: var(--accent); stroke-width: 1.5; }
.bar { fill: var(--accent); }
.bar:hover { fill: #6ab0ff; }
.bar-label { fill: var(--muted2); font-size: 9px; font-family: var(--sans); }
.chart-title { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart-axis { fill: var(--muted2); font-size: 10px; font-family: var(--sans); }
.chart.empty .muted { fill: var(--muted2); font-size: 13px; }
.series-in { fill: var(--in); } .series-out { fill: var(--out); }
.series-pro { fill: var(--accent); } .series-flash { fill: var(--series-c); }
.series-a { fill: var(--series-a); } .series-b { fill: var(--series-b); }
.series-c { fill: var(--series-c); } .series-d { fill: var(--series-d); }
.series-e { fill: var(--series-e); } .series-f { fill: var(--series-f); }
.series-other { fill: var(--muted2); }

/* chart legend (colour key) - HTML row above a multi-series chart, swatch reuses the .series-* fill */
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; padding: 0; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82em;
  color: var(--muted); white-space: nowrap; }
.legend-swatch { flex: none; border-radius: 2px; }
.gauge-track { fill: var(--bg-elev2); }
.gauge-fill { fill: var(--accent); }
.gauge-fill.warn { fill: var(--warn); }
.gauge-fill.crit { fill: var(--crit); }
.gauge-label { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.gauge-sub { fill: var(--muted); font-size: 10px; font-family: var(--sans); opacity: 0.75; }

/* balances & limits page - one card per external dependency */
.balances-intro { margin: 0 0 var(--gap); max-width: 70ch; line-height: 1.5; }
.grid.balances { grid-template-columns: repeat(3, 1fr); margin-bottom: var(--gap); align-items: start; }
@media (max-width: 980px) { .grid.balances { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .grid.balances { grid-template-columns: 1fr; } }
.balance-card { display: flex; flex-direction: column; }
.balance-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.balance-head h2 { margin: 0; }
.balance-value { font-size: 1.7rem; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }
.balance-sub { font-size: 0.85em; margin-top: 2px; }
.balance-gauge { margin-top: 12px; }
.balance-note { margin: 12px 0 0; line-height: 1.45; }
/* status dot - mirrors the badge colour scheme */
.dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: var(--muted2);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.18); }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-crit { background: var(--crit); }
.dot-muted { background: var(--muted2); }
/* inline status word next to the dot on non-ok cards (self-labelling without consulting the legend) */
.balance-head { gap: 6px; }
.status-word { margin-left: auto; font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.4px;
  font-weight: 700; }
.status-word.warn { color: var(--warn); }
.status-word.crit { color: var(--crit); }
/* frozen-snapshot flag: a balance whose poll has stalled must look stale, not current */
.balance-stale { color: var(--warn); font-size: 0.8em; margin-top: 4px; }
/* card severity accents (shared by the balances cards) */
.card.warn { border-color: rgba(210,153,34,0.5); }
.card.crit { border-color: rgba(248,81,73,0.55); }
.card.info { border-color: var(--accent-dim); }
.balance-card.crit .balance-value { color: var(--crit); }
.balance-card.warn .balance-value { color: #f0c674; }

/* login */
/* Login restyling is intentional; this shell owns the only full-height centering context. */
.login-shell { display: grid; place-items: center; width: 100%; min-height: 100vh; padding: 24px; }
.login-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: min(100%, 360px); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 16px 40px rgba(0,0,0,0.2); }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85em; color: var(--muted); }
.login-card input { background: var(--bg); border: 1px solid var(--border); color: var(--fg);
  border-radius: 8px; padding: 9px 11px; font-size: 0.95em; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button { background: var(--accent); color: #08121f; border: none; border-radius: 8px;
  padding: 10px; font-weight: 700; cursor: pointer; font-size: 0.95em; margin-top: 4px; }
.login-card button:hover { background: #6ab0ff; }

/* Below 1024px the persistent rail becomes the off-canvas navigation drawer. */
@media (max-width: 1023px) {
  .sidebar { position: static; width: 100%; padding: 16px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-brand { margin-bottom: 16px; }
  .js .sidebar { position: fixed; inset: 0 auto 0 0; width: min(288px, calc(100vw - 48px));
    height: 100vh; padding: 20px 12px; visibility: hidden; pointer-events: none;
    transform: translateX(-100%); transition: transform 180ms ease, visibility 0s linear 180ms; }
  .js .app-shell.sidebar-open .sidebar { visibility: visible; pointer-events: auto; transform: translateX(0);
    box-shadow: 18px 0 40px rgba(0,0,0,0.32); transition-delay: 0s; }
  .js .app-shell.sidebar-open .sidebar-close { display: grid; }
  .js .sidebar-backdrop { position: fixed; inset: 0; z-index: 15; display: block; visibility: hidden;
    pointer-events: none; opacity: 0; background: rgba(0,0,0,0.55); transition: opacity 180ms ease, visibility 0s linear 180ms; }
  .js .app-shell.sidebar-open .sidebar-backdrop { visibility: visible; pointer-events: auto; opacity: 1;
    transition-delay: 0s; }
  .app-body.sidebar-visible { overflow: hidden; }
  .app-main { margin-left: 0; }
  .page-topbar { padding: 10px 20px; }
  .js .sidebar-toggle { display: inline-grid; place-items: center; }
}

@media (max-width: 700px) {
  .container { padding: 20px 16px; }
  .footer { padding: 20px 16px; }
  .health-pill { padding: 0 8px; }
  .user-chip { max-width: 120px; }
  .card { padding: 14px; }
  .grid.two { grid-template-columns: 1fr; }
  table.data { min-width: max-content; }
  table.data th, table.data td { white-space: nowrap; }
}

@media (max-width: 460px) {
  .page-topbar { gap: 10px; padding: 10px 12px; }
  .page-heading { gap: 0; }
  /* The pill is supplemental here; critical health banners remain visible in page content. */
  .health-pill { display: none; }
  .topbar-actions { gap: 2px; }
  .logout-link { padding: 0 6px; }
  .user-chip { display: none; }
}
