:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #172033;
  --line: #222c3f;
  --line-strong: #33415c;
  --text: #e6ebf5;
  --text-2: #c9d1e0;
  --muted: #8a96ad;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #4f8cff;
  --on-accent: #ffffff;
  --topbar-bg: rgba(11,15,23,.92);
  --row-hover: rgba(255,255,255,.025);
  --focus: rgba(79,140,255,.35);
  --green-soft: rgba(34,197,94,.13);  --green-edge: rgba(34,197,94,.4);
  --red-soft: rgba(239,68,68,.12);    --red-edge: rgba(239,68,68,.4);
  --neutral-soft: rgba(138,150,173,.12);
  --chart-card-bg: radial-gradient(1200px 260px at 0% 0%, rgba(79,140,255,.07), transparent 60%),
                   linear-gradient(180deg, #141b2b 0%, #121826 55%);
  --chart-card-edge: #1f2940;
  --card-shadow: 0 10px 30px rgba(0,0,0,.25);
  --chip-bg: rgba(11,15,23,.6);
  --chip-hover: rgba(23,32,51,.9);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #eef2f8;
  --line: #e1e6ef;
  --line-strong: #c7d0de;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --green: #15803d;
  --red: #dc2626;
  --amber: #b45309;
  --blue: #2563eb;
  --on-accent: #ffffff;
  --topbar-bg: rgba(255,255,255,.88);
  --row-hover: rgba(15,23,42,.03);
  --focus: rgba(37,99,235,.25);
  --green-soft: rgba(22,163,74,.10);  --green-edge: rgba(22,163,74,.35);
  --red-soft: rgba(220,38,38,.08);    --red-edge: rgba(220,38,38,.35);
  --neutral-soft: rgba(100,116,139,.10);
  --chart-card-bg: radial-gradient(1200px 260px at 0% 0%, rgba(37,99,235,.06), transparent 60%),
                   linear-gradient(180deg, #ffffff 0%, #ffffff 100%);
  --chart-card-edge: #e1e6ef;
  --card-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --chip-bg: #f8fafc;
  --chip-hover: #eef2f8;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--green); } .neg { color: var(--red); } .muted { color: var(--muted); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px;
  padding: 10px 24px; background: var(--topbar-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 12px var(--blue); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.nav a:hover, .nav a.active { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.who { color: var(--muted); display: flex; gap: 10px; align-items: center; }
.demo-pill { background: var(--amber); color: #111; font-weight: 700; font-size: 11px; padding: 2px 8px; border-radius: 99px; }

main { max-width: 1400px; margin: 0 auto; padding: 22px 24px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.sub { color: var(--muted); margin-bottom: 18px; }

/* cards */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpis.five { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .kpis, .kpis.five { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .kpis, .kpis.five { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 4px; font-family: var(--mono); }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 340px; }
.chart-box.small { height: 240px; }

/* controls */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 5px 10px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 12px; }
.seg button.on { background: var(--panel-2); color: var(--text); }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 13px; }
.btn:hover { border-color: var(--line-strong); text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-accent); }
.btn.green { background: var(--green-soft); border-color: var(--green-edge); color: var(--green); }
.btn.red { background: var(--red-soft); border-color: var(--red-edge); color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; cursor: pointer; user-select: none; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
tbody tr:hover { background: var(--row-hover); }
tfoot td { font-weight: 650; border-top: 2px solid var(--line); border-bottom: 0; }
td.title { max-width: 380px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }

/* status badge */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); background: var(--bg); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.running { color: var(--green); } .badge.running::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.badge.stopped, .badge.failed { color: var(--red); } .badge.stopped::before, .badge.failed::before { background: var(--red); }
.badge.starting, .badge.stopping { color: var(--amber); } .badge.starting::before, .badge.stopping::before { background: var(--amber); }
.badge.offline { color: var(--muted); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 12px; cursor: pointer; font: inherit; }
.tabs button.on { color: var(--text); border-bottom-color: var(--blue); }

/* forms */
form.stack { display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
input[type=color] { padding: 2px; height: 36px; }
textarea { min-height: 80px; resize: vertical; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); border-color: var(--blue); }
details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; background: var(--bg); }
details summary { cursor: pointer; display: flex; align-items: center; gap: 10px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: 12px; }
pre, code { font-family: var(--mono); font-size: 12px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid var(--line); }
.flash.ok { background: var(--green-soft); border-color: var(--green-edge); }
.flash.error { background: var(--red-soft); border-color: var(--red-edge); }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel-2); border: 1px solid var(--line); padding: 10px 14px;
  border-radius: 10px; opacity: 0; transform: translateY(10px); transition: .2s; z-index: 50; max-width: 380px; }
.toast.show { opacity: 1; transform: none; }

.features { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.features dt { color: var(--muted); } .features dd { margin: 0; }
.login-box { max-width: 360px; margin: 10vh auto; }
.err-line { color: var(--red); font-size: 12px; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  main { padding: 16px; }
  .chart-box { height: 260px; }
  .kpi .value { font-size: 18px; }
}

/* company / group tabs on the overview */
.group-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.group-tabs button { background: var(--panel); border: 1px solid var(--line); color: var(--muted); font: inherit; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; cursor: pointer; }
.group-tabs button:hover { color: var(--text); border-color: var(--line-strong); }
.group-tabs button.on { background: var(--blue); border-color: var(--blue); color: var(--on-accent); }

/* ---- modern charts ---- */
.chart-card { background: var(--chart-card-bg); border-color: var(--chart-card-edge); box-shadow: var(--card-shadow); }
.chart-card .card-head { margin-bottom: 4px; }
.chart-card h2 { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.hero { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-height: 40px; margin: 2px 0 10px; }
.hero-val { font-family: var(--mono); font-size: 28px; font-weight: 700; letter-spacing: -.5px; color: var(--text); }
.hero-delta { font-family: var(--mono); font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  background: var(--neutral-soft); color: var(--muted); }
.hero-delta.up { background: var(--green-soft); color: var(--green); }
.hero-delta.down { background: var(--red-soft); color: var(--red); }
.hero-sub { color: var(--muted); font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--chip-bg); border: 1px solid var(--line);
  color: var(--text); font: inherit; font-size: 12px; padding: 5px 10px 5px 8px; border-radius: 99px; cursor: pointer;
  transition: border-color .15s, opacity .15s, background .15s; }
.chip:hover { border-color: var(--line-strong); background: var(--chip-hover); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); }
.chip .nm { color: var(--text-2); }
.chip .v { color: var(--muted); }
.chip.total { border-color: var(--line-strong); font-weight: 600; }
.chip.total .nm { color: var(--text); }
.chip.off { opacity: .4; }
.chip.off .nm { text-decoration: line-through; }
.chart-box { height: 360px; }
.chart-box.small { height: 250px; }
@media (max-width: 640px) { .hero-val { font-size: 22px; } .chart-box { height: 270px; } }

/* light/dark switch */
.theme-toggle { width: 34px; height: 30px; display: inline-grid; place-items: center; padding: 0; font-size: 15px; line-height: 1; }
.card, .kpi { transition: background-color .2s, border-color .2s; }
:root[data-theme="light"] .kpi, :root[data-theme="light"] .card:not(.chart-card) { box-shadow: 0 1px 2px rgba(15,23,42,.04); }
:root[data-theme="light"] .brand .dot { box-shadow: 0 0 8px rgba(37,99,235,.5); }
:root[data-theme="light"] .demo-pill { background: #fbbf24; }

/* ================================================================ login page */
:root {
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9;
  --story-bg:
    radial-gradient(900px 520px at 85% 110%, rgba(79,140,255,.20), transparent 60%),
    radial-gradient(600px 400px at -10% -10%, rgba(144,133,233,.14), transparent 60%),
    #0e1422;
  --story-text: #f1f4fa; --story-muted: #9aa6bd; --story-line: rgba(255,255,255,.07);
  --art-total: #ffffff; --art-glow: rgba(79,140,255,.55);
}
:root[data-theme="light"] {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7;
  --story-bg:
    radial-gradient(900px 520px at 85% 110%, rgba(37,99,235,.14), transparent 60%),
    radial-gradient(600px 400px at -10% -10%, rgba(74,58,167,.08), transparent 60%),
    #eaf0fb;
  --story-text: #0f172a; --story-muted: #475569; --story-line: rgba(15,23,42,.08);
  --art-total: #0f172a; --art-glow: rgba(37,99,235,.30);
}

main.login-main { max-width: none; padding: 0; }
.login-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, 1fr); }

.login-story { position: relative; overflow: hidden; background: var(--story-bg); color: var(--story-text);
  padding: clamp(28px, 5vw, 64px) clamp(24px, 5vw, 72px); display: flex; flex-direction: column; gap: 22px; justify-content: center; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: .1px;
  position: absolute; top: clamp(22px, 3.5vw, 36px); left: clamp(24px, 5vw, 72px); }
.login-mark { width: 30px; height: 30px; }
.login-headline { font-family: "Bricolage Grotesque", Inter, system-ui, sans-serif; font-weight: 700;
  font-size: clamp(36px, 4.6vw, 64px); line-height: 1.02; letter-spacing: -0.03em; margin: 40px 0 0; max-width: 13ch; }
.login-lede { color: var(--story-muted); font-size: 17px; line-height: 1.55; max-width: 46ch; margin: 0; }

.login-art { margin: 6px 0 0; max-width: 620px; }
.login-art svg { width: 100%; height: auto; display: block; overflow: visible; }
.login-art figcaption { color: var(--story-muted); font-size: 13px; margin-top: 10px; }
.art-grid line { stroke: var(--story-line); stroke-width: 1; }
.art-bot { fill: none; stroke: var(--c); stroke-width: 1.6; stroke-linecap: round; opacity: .8; }
.art-total, .art-total-glow { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.art-total { stroke: var(--art-total); stroke-width: 3.4; stroke-dasharray: 1; stroke-dashoffset: 0; }
.art-total-glow { stroke: var(--art-glow); stroke-width: 12; filter: blur(6px); opacity: .9; }
.art-end { fill: var(--art-total); }
.art-end-ring { fill: none; stroke: var(--art-total); stroke-width: 1.5; opacity: .35; }

/* the one moment of motion: the total line draws in, then its end point appears */
@media (prefers-reduced-motion: no-preference) {
  .art-total { animation: art-draw 1.6s cubic-bezier(.65,0,.35,1) .25s both; }
  .art-total-glow { animation: art-fade 1s ease 1.4s both; }
  .art-end, .art-end-ring { animation: art-fade .5s ease 1.75s both; }
}
@keyframes art-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes art-fade { from { opacity: 0; } }

.login-facts { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 12px; max-width: 520px; }
.login-facts li { display: flex; gap: 12px; align-items: flex-start; color: var(--story-muted); font-size: 14px; line-height: 1.45; }
.login-facts b { color: var(--story-text); font-weight: 600; }
.login-facts svg { flex: none; width: 20px; height: 20px; margin-top: 1px; fill: none; stroke: var(--blue); stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 40px clamp(20px, 4vw, 56px); background: var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 30px 28px 26px; box-shadow: var(--card-shadow); }
.login-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.login-card h2 { font-family: "Bricolage Grotesque", Inter, system-ui, sans-serif; font-size: 26px; font-weight: 700;
  letter-spacing: -0.02em; margin: 0 0 4px; }
.login-card-head p { margin: 0; color: var(--muted); font-size: 14px; }
.login-form { display: grid; gap: 6px; }
.login-form label { display: block; color: var(--text-2); font-size: 13px; font-weight: 500; margin-top: 8px; }
.login-form input { width: 100%; height: 44px; font-size: 15px; padding: 0 12px; border-radius: 10px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: var(--panel-2); }
.pw-toggle:focus-visible, .login-submit:focus-visible, .theme-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.login-submit { margin-top: 18px; height: 46px; justify-content: center; font-size: 15px; font-weight: 600; border-radius: 10px; }
.login-submit:hover { filter: brightness(1.08); }
.login-card .flash { margin-bottom: 14px; }
.login-demo { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.login-foot { color: var(--muted); font-size: 12px; margin: 0; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-story { padding-top: 84px; padding-bottom: 32px; gap: 16px; }
  .login-headline { margin-top: 0; font-size: clamp(32px, 9vw, 44px); }
  .login-lede { font-size: 15px; }
  .login-facts { display: none; }
  .login-art { max-width: 100%; }
  .login-panel { padding-top: 28px; padding-bottom: 36px; }
}
