:root {
  --bg: #f6f5f8;
  --surface: #ffffff;
  --surface-2: #f1eff5;
  --border: #e4e0ea;
  --text: #1d1726;
  --muted: #6d6579;
  --brand: #3b1f5c;
  --brand-2: #5b3590;
  --brand-ink: #ffffff;
  --accent: #7c4dcc;
  --prod: #1f9d6b;
  --neutral: #a3a0ab;
  --unprod: #d6493f;
  --idle: #e1a521;
  --break: #5a8dee;
  --shadow: 0 1px 2px rgba(30, 20, 50, .05), 0 4px 16px rgba(30, 20, 50, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #120d19; --surface: #1c1526; --surface-2: #251c32; --border: #342a44;
    --text: #efeaf6; --muted: #a79eb5; --brand: #2c1846; --brand-2: #8f63d6; --accent: #a987ec;
    --neutral: #7c7888; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #e9e0f7; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: #fff; padding: 0 8px 18px; }
.side .logo img { width: 30px; height: 30px; }
.side a { color: #d6c9ea; padding: 9px 12px; border-radius: 10px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side a.on { background: rgba(255,255,255,.14); color: #fff; }
.side a svg { width: 18px; height: 18px; flex: none; }
.side .grow { flex: 1; }
.side a .s, .mtop, .mcards, .mobile-only { display: none; }
.side .who { font-size: 12px; color: #bfb1d6; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.1); }
.main { padding: 26px 30px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: 1fr 1fr; }
.g21 { grid-template-columns: 2fr 1fr; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.dark { background: linear-gradient(135deg, #2b1840, #1b1027); color: #fff; border: 0; }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.card.dark .label, .card.dark .hint { color: #c9b8e3; }

/* buttons & inputs */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--unprod); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
label.f { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
label.f span.h { font-weight: 400; color: var(--muted); font-size: 12px; }
.form { display: grid; gap: 14px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }

/* clickable numbers & bars that open the breakdown */
.bd, [data-bd] { cursor: pointer; }
td.bd:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
td.bd:hover .bar, .bd:hover > .bar { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.card.bd:hover { filter: brightness(1.08); }
.bdhint { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 8px; }
.bigbar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.bigbar i { display: block; height: 100%; }
.bditem { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(60px, 1fr) 64px; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); }
.bdname { display: flex; flex-direction: column; min-width: 0; }
.bdname .kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.bdbar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bdbar i { display: block; height: 100%; border-radius: 99px; }
.bdmin { text-align: right; font-weight: 700; }

/* status */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); flex: none; }
.st-working .dot { background: var(--prod); box-shadow: 0 0 0 3px color-mix(in srgb, var(--prod) 25%, transparent); }
.st-working { color: var(--prod); }
.st-idle .dot { background: var(--idle); } .st-idle { color: #a87600; }
.st-break .dot { background: var(--break); } .st-break { color: var(--break); }
.st-offline .dot, .st-clocked_out .dot { background: var(--neutral); }
.st-not_installed .dot { background: transparent; border: 1.5px dashed var(--neutral); }
.st-disabled { text-decoration: line-through; }
.cat { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.c-productive { background: var(--prod); } .c-neutral { background: var(--neutral); } .c-unproductive { background: var(--unprod); } .c-idle { background: var(--idle); }

.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; min-width: 80px; }
.bar > i { display: block; height: 100%; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; flex: none; }
.person { display: flex; gap: 10px; align-items: center; min-width: 0; }
.person .n { font-weight: 600; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; display: inline-block; vertical-align: bottom; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.list-item { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.list-item:last-child { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.banner { background: color-mix(in srgb, var(--idle) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--idle) 40%, transparent); padding: 10px 14px; border-radius: 12px; margin-bottom: 16px; }
.code { font: 700 26px/1 ui-monospace, "Cascadia Mono", Menlo, monospace; letter-spacing: .12em; background: var(--surface-2); padding: 14px; border-radius: 12px; text-align: center; }
.mono { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: 12px; word-break: break-all; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .hero { background: radial-gradient(circle at 20% 20%, #5b3590, #231233 70%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .hero h1 { font-size: 38px; line-height: 1.15; max-width: 480px; letter-spacing: -.02em; }
.auth .hero ul { padding: 0; list-style: none; display: grid; gap: 12px; color: #dccdf2; }
.auth .hero li::before { content: "✓"; color: #7ee0b0; margin-right: 10px; font-weight: 700; }
.auth .pane { display: grid; place-items: center; padding: 30px; }
.auth .box { width: 100%; max-width: 380px; }
.err { color: var(--unprod); font-size: 13px; min-height: 18px; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 8, 25, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal h2 { font-size: 18px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #231233; color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; }
#toast.show { opacity: 1; }

svg text { fill: var(--muted); font-size: 11px; }
.timeline-wrap { position: relative; }
.log { max-height: 420px; overflow: auto; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g21 { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  /* phone: bottom tab bar like a native app */
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 40; flex-direction: row; justify-content: space-around; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 20px rgba(20, 10, 35, .25); }
  .side .logo, .side .grow, .side .who, .side #logout, .side .nav-platform { display: none; }
  .side a { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; font-weight: 600; justify-content: center; }
  .side a .l { display: none; } .side a .s { display: block; }
  .side a svg { width: 22px; height: 22px; }
  .mtop { display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; }
  .mtop img { width: 28px; height: 28px; } .mtop span { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }
  .main { padding: 16px 14px 100px; }
  .topbar { margin-bottom: 14px; } h1 { font-size: 20px; }
  .kpi .value { font-size: 22px; } .card { padding: 14px; }
  .g2 { grid-template-columns: 1fr; }
  .grid { gap: 10px; }
  .mcards { display: grid; gap: 10px; }
  .mcard { display: block; color: inherit; border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: var(--surface); }
  .mstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 8px; }
  .mstats span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
  .mstats b { font-variant-numeric: tabular-nums; }
  .team-table { display: none; }
  .bditem { grid-template-columns: minmax(0, 1fr) 70px; } .bdbar { grid-column: 1 / -1; order: 3; }
  #rng { width: 100%; } #rng button { flex: 1; white-space: nowrap; padding: 6px 4px; }
  .mobile-only { display: block; }
  .auth { grid-template-columns: 1fr; } .auth .hero { padding: 30px; }
  .hide-sm { display: none; }
  #toast { bottom: 90px; }
}
input[type=checkbox] { width: 16px; height: 16px; min-width: 16px; padding: 0; accent-color: var(--brand-2); }
