/* Painel em coluna larga; cartões por computador; números alinhados; tema claro e escuro. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --fg: #1b2430;
  --muted: #5a6675;
  --line: #dde2e8;
  --accent: #1f5f8b;
  --accent-soft: #e4eef6;
  --work: #2b7a57;
  --unclassified: #6f86a0;
  --neutral: #b6c0cb;
  --personal: #d08a1e;
  --idle: #d9dee4;
  --locked: #eef1f4;
  --bad: #a3322a;
  --bad-bg: #f8e4e2;
  --ok: #1d7a4a;
  --ok-bg: #e3f2e9;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #19212a;
    --fg: #e3e8ee;
    --muted: #98a4b1;
    --line: #2b3541;
    --accent: #7fb4dc;
    --accent-soft: #1c2d3b;
    --work: #5cc28f;
    --unclassified: #8aa2bd;
    --neutral: #55616e;
    --personal: #e6a443;
    --idle: #36414d;
    --locked: #222b35;
    --bad: #ec8a81;
    --bad-bg: #3a1e1c;
    --ok: #6cc596;
    --ok-bg: #16301f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
input, select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 12px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary { color: #0e1720; } }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
button.small { padding: 3px 9px; font-size: 13px; }
button.cat-work { border-color: var(--work); color: var(--work); }
button.cat-personal { border-color: var(--personal); color: var(--personal); }
button.cat-neutral { color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
.error { color: var(--bad); margin: 0; }
.muted { color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; display: flex; flex-direction: column; gap: 8px; }
.login-card h1 { margin-bottom: 12px; }
.login-card button { margin-top: 10px; }

/* Topo */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px max(16px, env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; }
.brand .version { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 4px; }
#nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
#nav a { text-decoration: none; color: var(--muted); padding: 5px 10px; border-radius: 6px; }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.user { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 14px; }

@media (max-width: 640px) {
  .topbar { gap: 6px 12px; }
  #nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
  #nav a { white-space: nowrap; }
  .toolbar h1 { flex-basis: 100%; }
}
.main { max-width: 1180px; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-left, 0px)) 64px; display: flex; flex-direction: column; gap: 20px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar h1 { margin-right: auto; }
.note { font-size: 13px; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.card-head .who { margin-right: auto; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--neutral); }
.dot.on { background: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 21px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.k-active { border-left: 4px solid var(--work); }
.stat.k-idle { border-left: 4px solid var(--idle); }
.stat.k-away { border-left: 4px solid var(--line); }
.stat.k-personal { border-left: 4px solid var(--personal); }

/* Linha do tempo */
.timeline { position: relative; }
.tl-track { position: relative; height: 26px; background: var(--locked); border-radius: 4px; overflow: hidden; }
.tl-window { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--muted); border-right: 2px solid var(--muted); opacity: .35; }
.tl-seg { position: absolute; top: 0; bottom: 0; }
.tl-seg.s-idle { background: repeating-linear-gradient(45deg, var(--idle) 0 4px, transparent 4px 8px); }
.tl-seg.c-work { background: var(--work); }
.tl-seg.c-unclassified { background: var(--unclassified); }
.tl-seg.c-neutral { background: var(--neutral); }
.tl-seg.c-personal { background: var(--personal); }
.tl-axis { position: relative; height: 18px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.tl-axis span { position: absolute; transform: translateX(-50%); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 4px; }

/* Mais usados */
.top { display: flex; flex-direction: column; gap: 6px; }
.top-row { display: grid; grid-template-columns: minmax(120px, 240px) 1fr 70px; gap: 10px; align-items: center; font-size: 14px; }
.top-row .bar { height: 10px; background: var(--accent-soft); border-radius: 3px; overflow: hidden; }
.top-row .bar span { display: block; height: 100%; }
.top-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .top-row { grid-template-columns: 1fr 64px; } .top-row .bar { grid-column: 1 / -1; grid-row: 2; } }

details > summary { cursor: pointer; color: var(--accent); }
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--accent-soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.t { white-space: nowrap; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.title { max-width: 520px; overflow-wrap: anywhere; color: var(--muted); }
tr.total td { font-weight: 700; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; background: var(--accent-soft); color: var(--accent); }
.chip.c-work { background: var(--ok-bg); color: var(--work); }
.chip.c-personal { background: color-mix(in srgb, var(--personal) 18%, transparent); color: var(--personal); }
.chip.c-neutral { background: var(--locked); color: var(--muted); }
.chip.c-unclassified { background: var(--accent-soft); color: var(--unclassified); }

.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.secret { font-family: var(--mono); background: var(--accent-soft); padding: 10px 12px; border-radius: 6px; overflow-wrap: anywhere; user-select: all; }
.callout { background: var(--accent-soft); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.callout.warn { background: var(--bad-bg); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.sched-grid { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 8px 10px; align-items: center; max-width: 420px; }
.toast { position: fixed; bottom: max(16px, env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 20; }
