:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde2e8;
  --text: #1c2430;
  --muted: #667085;
  --accent: #16805c;
  --accent-ink: #ffffff;
  --productive: #1f9d6a;
  --unproductive: #d64545;
  --neutral: #8a94a6;
  --idle: #f0b429;
  --locked: #3b4252;
  --offline: #b0b8c4;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --surface: #1a2028; --surface-2: #222a34; --border: #2e3844;
    --text: #e6eaf0; --muted: #98a2b3; --accent: #2fb383; --neutral: #7d8799;
    --locked: #59647a; --offline: #4a5260; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }
.ok { color: var(--productive); }

/* topo */
.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 24px; justify-content: center; margin-bottom: 16px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 15px; }
.big .logo { width: 38px; height: 38px; font-size: 20px; }
nav { display: flex; gap: 4px; flex: 1; }
nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav a:hover { background: var(--surface-2); text-decoration: none; }
nav a.active { color: var(--text); background: var(--surface-2); }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); }
main { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; }
textarea { width: 100%; min-height: 120px; resize: vertical; }
label { display: grid; gap: 4px; font-weight: 500; }
label small { font-weight: 400; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* tabelas */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.ellipsis { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* status */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--offline); }
.dot.active { background: var(--productive); }
.dot.idle { background: var(--idle); }
.dot.locked { background: var(--locked); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); }
.pill.productive { background: color-mix(in srgb, var(--productive) 16%, transparent); color: var(--productive); }
.pill.unproductive { background: color-mix(in srgb, var(--unproductive) 16%, transparent); color: var(--unproductive); }

.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); min-width: 120px; }
.bar span { display: block; height: 100%; }
.bg-productive { background: var(--productive); }
.bg-unproductive { background: var(--unproductive); }
.bg-neutral { background: var(--neutral); }
.bg-idle { background: var(--idle); }
.bg-locked { background: var(--locked); }

.thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* timeline */
.timeline { position: relative; height: 38px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.timeline .seg { position: absolute; top: 0; bottom: 0; min-width: 1px; }
.timeline-axis { position: relative; height: 18px; font-size: 11px; color: var(--muted); }
.timeline-axis span { position: absolute; transform: translateX(-50%); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--text); color: var(--bg);
  padding: 6px 9px; border-radius: 6px; font-size: 12px; max-width: 420px; }

/* abas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 22px 0 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font: inherit;
  font-weight: 500; color: var(--muted); cursor: pointer; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* capturas */
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.shot { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: zoom-in; }
.shot img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--surface-2); }
.shot div { padding: 7px 9px; font-size: 12px; }
.shot .t { font-weight: 600; }
.shot .a { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 30; display: flex; align-items: center; justify-content: center; }
.lightbox figure { margin: 0; max-width: 92vw; max-height: 92vh; text-align: center; }
.lightbox img { max-width: 92vw; max-height: 84vh; border-radius: 6px; }
.lightbox figcaption { color: #ddd; margin-top: 8px; font-size: 13px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%;
  width: 44px; height: 44px; font-size: 22px; cursor: pointer; }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 18px; top: 50%; }
.lb-next { right: 18px; top: 50%; }

/* texto digitado */
.notice { background: color-mix(in srgb, var(--idle) 14%, transparent); border: 1px solid color-mix(in srgb, var(--idle) 45%, transparent);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.keylog { border-left: 3px solid var(--border); padding: 4px 0 4px 12px; margin-bottom: 14px; }
.keylog .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.keylog pre { white-space: pre-wrap; word-break: break-word; margin: 0; font: 13px/1.5 Consolas, "Cascadia Mono", monospace;
  background: var(--surface-2); padding: 8px 10px; border-radius: 6px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; padding: 28px; }
.token { font-family: Consolas, monospace; background: var(--surface-2); padding: 6px 10px; border-radius: 6px; user-select: all; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 700px) {
  .topbar { padding: 0 12px; gap: 10px; height: auto; flex-wrap: wrap; padding-block: 8px; }
  main { padding: 16px; }
  .userbox #whoami { display: none; }
}
