/* WorkTrace portal - dark navy / slate theme.
   (c) Wynand Goss. All rights reserved. */

:root {
  --bg: #0b1120;
  --bg-raised: #0f172a;
  --card: #111a2e;
  --card-hover: #15203a;
  --line: #1e293b;
  --line-strong: #2a3a55;
  --text: #e2e8f0;
  --text-strong: #f8fafc;
  --muted: #94a3b8;
  --faint: #64748b;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --good: #34d399;
  --good-soft: rgba(52, 211, 153, 0.14);
  --neutral: #a78bfa;
  --neutral-soft: rgba(167, 139, 250, 0.14);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --idle: #475569;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -18px rgba(0, 0, 0, 0.7);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text-strong); margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #1e3a5f, #0c1426);
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 650; font-size: 16px; color: var(--text-strong); letter-spacing: 0.01em; }
.nav-group { margin-top: 12px; padding: 0 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--text-strong); }
.nav a.active .dot { background: var(--accent); }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: none; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: rgba(11, 17, 32, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.org-pill { padding: 5px 11px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.user-chip { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #0891b2);
  display: grid; place-items: center; color: white; font-weight: 600; font-size: 12px; flex: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.view { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Cards and grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { flex: 1; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.wide-narrow { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) {
  .grid.two, .grid.three, .grid.wide-narrow { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav-group, .sidebar-foot { display: none; }
  .view { padding: 18px; }
}

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .value { font-size: 26px; font-weight: 650; color: var(--text-strong); letter-spacing: -0.02em; }
.kpi .hint { font-size: 12.5px; color: var(--faint); }
.kpi .bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.kpi .bar > span { display: block; height: 100%; background: var(--accent); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--faint); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--card-hover); }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 34px 18px; text-align: center; color: var(--faint); }

/* ---------- Badges and status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--line); color: var(--muted); white-space: nowrap;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.neutral { background: var(--neutral-soft); color: var(--neutral); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); display: inline-block; flex: none; }
.status-dot.active { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.status-dot.idle { background: var(--warn); }
.status-dot.break { background: var(--neutral); }
.status-dot.offline { background: var(--idle); }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg-raised);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 11px; min-width: 0; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 140px; }
.form-row > .shrink { flex: none; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.help { font-size: 12px; color: var(--faint); }

button, .btn {
  font: inherit; font-weight: 550; font-size: 13.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card-hover); color: var(--text);
  white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #04111f; }
button.primary:hover { background: var(--accent-strong); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--line-strong); }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12.5px; }
button:disabled { opacity: 0.55; cursor: progress; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { border: none; border-radius: 0; background: transparent; color: var(--muted); }
.segmented button.on { background: var(--accent-soft); color: var(--text-strong); }

/* ---------- Charts ---------- */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; border-radius: 4px 4px 1px 1px; background: linear-gradient(180deg, var(--accent), rgba(56, 189, 248, 0.35)); min-height: 2px; }
.bars .tick { font-size: 10.5px; color: var(--faint); }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 6px 12px; align-items: center; }
.hbar .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: -2px; }
.hbar .fill { height: 100%; border-radius: 3px; }
.fill.productive, .swatch.productive { background: var(--good); }
.fill.neutral, .swatch.neutral { background: var(--neutral); }
.fill.unproductive, .swatch.unproductive { background: var(--bad); }
.fill.idle, .swatch.idle { background: var(--idle); }

/* Day timeline */
.timeline { position: relative; height: 54px; border-radius: 8px; background: var(--bg-raised); border: 1px solid var(--line); overflow: hidden; }
.timeline .seg { position: absolute; top: 8px; bottom: 8px; border-radius: 2px; }
.timeline .seg.productive { background: var(--good); }
.timeline .seg.neutral { background: var(--neutral); }
.timeline .seg.unproductive { background: var(--bad); }
.timeline .seg.idle { background: var(--idle); }
.timeline .band { position: absolute; top: 0; bottom: 0; }
.timeline .band.break { background: repeating-linear-gradient(45deg, rgba(167, 139, 250, 0.16), rgba(167, 139, 250, 0.16) 4px, transparent 4px, transparent 8px); }
.timeline .band.meeting { top: 0; height: 5px; background: var(--warn); }
.timeline .mark { position: absolute; bottom: 0; width: 2px; height: 7px; background: var(--accent); }
.hours { position: relative; height: 18px; font-size: 10.5px; color: var(--faint); }
.hours span { position: absolute; transform: translateX(-50%); }
.tooltip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 340px;
  background: #020617; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; color: var(--text); box-shadow: var(--shadow);
}

/* ---------- People grid ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.person-card { padding: 14px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color 0.15s; }
.person-card:hover { border-color: var(--line-strong); }
.person-card .top { display: flex; align-items: center; gap: 10px; }
.person-card .who { flex: 1; min-width: 0; }
.person-card .who .name { color: var(--text-strong); font-weight: 600; }
.person-card .now { font-size: 12.5px; color: var(--muted); min-height: 19px; }
.mini-split { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); }
.mini-split span { display: block; height: 100%; }
.person-card .stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); }
.person-card .stats b { color: var(--text); font-weight: 600; }

/* ---------- Screen captures ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.shot { overflow: hidden; cursor: zoom-in; }
.shot img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--bg-raised); }
.shot .meta { padding: 9px 12px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.lightbox {
  position: fixed; inset: 0; z-index: 70; background: rgba(2, 6, 23, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px;
}
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 8px; border: 1px solid var(--line-strong); }
.lightbox .caption { color: var(--muted); font-size: 13px; text-align: center; }
.live-frame { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-raised); min-height: 300px; display: block; }

/* ---------- Modal and toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 23, 0.7); display: grid; place-items: center; padding: 20px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; }
.modal .card-body { display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #020617; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: 9px; padding: 10px 14px; max-width: 380px; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--good); }

.callout { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: 13px; border: 1px solid rgba(56, 189, 248, 0.25); }
.callout.warn { background: var(--warn-soft); border-color: rgba(251, 191, 36, 0.25); }
.code-box { font-family: var(--mono); font-size: 13px; background: var(--bg-raised); border: 1px dashed var(--line-strong); border-radius: 8px; padding: 10px 12px; word-break: break-all; }
.insight { white-space: pre-wrap; line-height: 1.65; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; background: transparent; border-radius: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 12px; }
.tabs button.on { color: var(--text-strong); border-bottom-color: var(--accent); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 48px; }

/* ---------- Sign-in page ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(56, 189, 248, 0.12), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(167, 139, 250, 0.10), transparent 60%), var(--bg); }
.auth-card { width: min(400px, 100%); padding: 30px 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card .brand { padding: 0 0 6px; }
.auth-foot { text-align: center; font-size: 11.5px; color: var(--faint); }
.form-error { color: var(--bad); font-size: 13px; min-height: 19px; }
