:root {
  --bg: #0b0c1a;
  --bg-2: #0f1124;
  --panel: #161a33;
  --panel-2: #1c2040;
  --line: rgba(255,255,255,.08);
  --line-2: rgba(255,255,255,.05);

  --ink: #eef0ff;
  --ink-2: #b6bce4;
  --muted: #757caa;

  --cyan: #22d3ee;
  --purple: #a855f7;
  --pink: #ec4899;
  --amber: #fbbf24;
  --green: #34d399;

  --grad-purple: linear-gradient(135deg, #a855f7, #ec4899);
  --grad-cyan: linear-gradient(135deg, #22d3ee, #3b82f6);

  --warn-tint: rgba(251,191,36,.10);
  --warn-bd: rgba(251,191,36,.45);
  --warn-accent: #fbbf24;
  --warn-ink: #fcd34d;

  --crit-tint: rgba(236,72,153,.13);
  --crit-bd: rgba(236,72,153,.5);
  --crit-accent: #ec4899;
  --crit-ink: #f9a8d4;

  --radius: 16px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 12% -5%, rgba(168,85,247,.16), transparent 55%),
    radial-gradient(1100px 600px at 95% 0%, rgba(34,211,238,.12), transparent 50%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: rgba(13,15,34,.75); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand h1 {
  font-size: 23px; font-weight: 800; margin: 0; letter-spacing: -.01em;
  background: linear-gradient(90deg, #d8b4fe, #67e8f9);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dot-live {
  width: 11px; height: 11px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 4px rgba(52,211,153,.18), 0 0 12px rgba(52,211,153,.7);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.meta { display: flex; gap: 20px; align-items: center; color: var(--muted); font-size: 14px; }
.auto { display: flex; gap: 7px; align-items: center; cursor: pointer; user-select: none; }
.auto input { accent-color: var(--purple); }
.logout {
  color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 9px; transition: all .15s;
}
.logout:hover { color: #fff; border-color: var(--crit-bd); background: var(--crit-tint); }

/* Login page */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: 18px; padding: 32px 30px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 4px; }
.login-brand h1 {
  font-size: 20px; font-weight: 800; margin: 0;
  background: linear-gradient(90deg, #d8b4fe, #67e8f9);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.login-err {
  background: var(--crit-tint); color: var(--crit-ink); border: 1px solid var(--crit-bd);
  border-radius: 10px; padding: 10px 13px; font-size: 14px; margin-bottom: 18px;
}
.fld { display: block; margin-bottom: 16px; }
.fld span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 7px; font-weight: 600; }
.fld input {
  width: 100%; padding: 12px 14px; font-size: 15px; color: var(--ink);
  background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 11px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.fld input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(168,85,247,.25); }
.remember {
  display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px;
  margin-bottom: 22px; cursor: pointer; user-select: none;
}
.remember input { accent-color: var(--purple); }
.login-btn {
  width: 100%; padding: 13px; font-size: 16px; font-weight: 700; color: #fff; cursor: pointer;
  background: var(--grad-purple); border: none; border-radius: 12px;
  box-shadow: 0 6px 20px rgba(168,85,247,.35); transition: transform .1s, box-shadow .15s;
}
.login-btn:hover { box-shadow: 0 8px 26px rgba(236,72,153,.45); }
.login-btn:active { transform: translateY(1px); }

/* Panels */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin: 20px 28px; box-shadow: var(--shadow);
}
.panel > h2 { font-size: 16px; font-weight: 700; margin: 0 0 16px; letter-spacing: .01em; }
.panel .count {
  background: var(--grad-purple); -webkit-background-clip: text; background-clip: text;
  color: transparent; font-weight: 800;
}
.sub { color: var(--muted); font-weight: 400; font-size: 13px; }

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; }

/* Overview: compact table + donuts */
.overview { padding: 16px 20px; }
.overview-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; align-items: center; }
@media (max-width: 1150px) { .overview-grid { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,.03); }
#summaryTable tbody td { font-size: 14px; color: var(--ink-2); }
.line-cell { font-weight: 600; color: var(--ink) !important; }
.ldot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 9px; vertical-align: -1px; box-shadow: 0 0 8px currentColor; }
td.strong { font-weight: 800; font-size: 16px; color: var(--ink) !important; }
.q { color: var(--muted); font-size: 12px; font-weight: 400; }
.rating { color: var(--amber); font-weight: 700; }

/* Donuts (compact) */
.donuts { display: flex; gap: 18px; justify-content: center; }
.donut { text-align: center; }
.donut-wrap { position: relative; width: 118px; height: 118px; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut-center b {
  font-size: 26px; font-weight: 800; line-height: 1;
  background: linear-gradient(90deg, #c4b5fd, #67e8f9);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.donut-center span { font-size: 11px; color: var(--muted); margin-top: 2px; }
.donut-cap { margin-top: 8px; font-size: 12px; color: var(--ink-2); font-weight: 600; }

/* Legend chips */
.legend { display: flex; gap: 16px; }
.chip { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.chip::before { content: ""; width: 15px; height: 15px; border-radius: 4px; border: 1px solid; }
.chip.warn::before { background: var(--warn-tint); border-color: var(--warn-bd); box-shadow: 0 0 8px rgba(251,191,36,.4); }
.chip.crit::before { background: var(--crit-tint); border-color: var(--crit-bd); box-shadow: 0 0 8px rgba(236,72,153,.4); }

/* Treatment boxes */
.boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.box {
  position: relative; border-radius: 14px; padding: 16px 18px 14px;
  display: flex; flex-direction: column; gap: 9px;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--line); border-left: 5px solid var(--line);
  backdrop-filter: blur(4px);
}
.box-warn {
  background: var(--warn-tint); border-color: var(--warn-bd); border-left-color: var(--warn-accent);
  box-shadow: 0 0 24px rgba(251,191,36,.10);
}
.box-crit {
  background: var(--crit-tint); border-color: var(--crit-bd); border-left-color: var(--crit-accent);
  box-shadow: 0 0 26px rgba(236,72,153,.16);
}
.box-top { display: flex; align-items: center; gap: 12px; }
.box-age {
  font-size: 21px; font-weight: 800; line-height: 1; padding: 7px 12px; border-radius: 10px;
  white-space: nowrap; background: rgba(0,0,0,.25);
}
.box-warn .box-age { color: var(--warn-ink); }
.box-crit .box-age { color: var(--crit-ink); }
.box-line { font-size: 12px; color: var(--ink-2); font-weight: 600; opacity: .8; }

.box-person { font-size: 22px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; color: var(--ink); }
.box-org { font-size: 14px; color: var(--ink-2); }

.box-meta {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 4px; padding-top: 11px; border-top: 1px solid rgba(255,255,255,.10);
}
.box-exec, .box-time {
  display: flex; align-items: center; gap: 7px;
  font-size: 17px; font-weight: 700; color: var(--ink);
}
.box-time { font-variant-numeric: tabular-nums; }
.box-meta .ic { font-size: 16px; font-weight: 400; }

.empty { color: var(--muted); padding: 14px 2px; }
.empty.big { font-size: 22px; text-align: center; padding: 48px; color: var(--ink-2); }

footer#errbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(236,72,153,.16); color: #f9a8d4; padding: 10px 28px; font-size: 14px;
  border-top: 1px solid var(--crit-bd); backdrop-filter: blur(8px); z-index: 10;
}

/* Large screens / TV — scale up for distance reading */
@media (min-width: 1700px) {
  html { font-size: 18px; }
  .brand h1 { font-size: 27px; }
  .box-person { font-size: 25px; }
  .box-age { font-size: 24px; }
  .box-exec, .box-time { font-size: 19px; }
  #summaryTable tbody td { font-size: 16px; }
  .donut-wrap { width: 134px; height: 134px; }
  .donut-center b { font-size: 30px; }
}
