/* INVA Time Intelligence — calm, low-cognitive-load interface.
   Brand: primary #149EC9 · dark #043442 · secondary #186D87 · accent #501677 · background #E8EAEE
   Text-bearing buttons use #186D87 (AA contrast with white). #149EC9 is reserved for large/bold
   elements (the timer button) and non-text accents, where 3:1 contrast applies. */

:root {
  --brand: #149EC9;
  --brand-dark: #043442;
  --brand-2: #186D87;
  --accent: #501677;
  --ground: #E8EAEE;
  --surface: #FFFFFF;
  --surface-2: #F4F6F8;
  --ink: #14232A;
  --ink-2: #3D525B;
  --muted: #5B6E77;
  --line: #D3D9DF;
  --line-soft: #E4E8EC;
  --ok: #1F7A4D;      --ok-bg: #E3F4EA;
  --warn: #8A5A00;    --warn-bg: #FFF3D6;
  --bad: #A3262E;     --bad-bg: #FBE6E7;
  --info: #0E5E78;    --info-bg: #E1F3F9;
  --violet-bg: #F0E8F6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(4, 52, 66, .06), 0 2px 8px rgba(4, 52, 66, .05);
  --focus: 0 0 0 3px #FFFFFF, 0 0 0 6px var(--accent);
  --sidebar-w: 248px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--ink); background: var(--ground); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; color: var(--brand-dark); }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
a { color: var(--brand-2); text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { box-shadow: var(--focus); }

.skip-link { position: absolute; left: 8px; top: -60px; background: var(--brand-dark); color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 1000; }
.skip-link:focus { top: 8px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--brand-dark); color: #DCEAF0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-weight: 800; letter-spacing: .06em; font-size: 1.1rem; line-height: 1.1; }
.brand-sub { display: block; font-size: .72rem; font-weight: 500; letter-spacing: .02em; color: #9CC6D6; }
.nav { list-style: none; margin: 8px 0; padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 44px; border-radius: 8px; color: #DCEAF0; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a[aria-current="page"] { background: rgba(20, 158, 201, .22); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav svg { width: 20px; height: 20px; flex: none; opacity: .9; }
.nav .count { margin-left: auto; background: var(--brand); color: var(--brand-dark); font-size: .75rem; font-weight: 700; border-radius: 999px; padding: 0 8px; }
.sidebar-foot { margin-top: auto; padding: 16px 20px; font-size: .85rem; color: #9CC6D6; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot strong { color: #fff; display: block; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; min-height: 64px; }
.topbar .page-title { font-size: 1.05rem; font-weight: 650; color: var(--brand-dark); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.btn.menu-btn { display: none; }
.content { padding: 24px 28px 96px; max-width: 1280px; width: 100%; }
.content.narrow { max-width: 920px; }

/* ---------- Persistent timer bar ---------- */
.timerbar { display: flex; align-items: center; gap: 14px; padding: 10px 28px; background: #F0FAFD; border-bottom: 1px solid #BFE3EF; flex-wrap: wrap; }
.timerbar.idle { background: var(--surface); border-bottom-color: var(--line); }
.timerbar.on-break { background: var(--violet-bg); border-bottom-color: #D9C6E8; }
.timerbar .clock { font: 700 1.25rem/1 var(--mono); color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.timerbar .ctx { min-width: 0; flex: 1; font-size: .92rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timerbar .ctx strong { color: var(--ink); }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); flex: none; box-shadow: 0 0 0 4px rgba(20,158,201,.2); }
@media (prefers-reduced-motion: no-preference) { .live-dot { animation: pulse 2s ease-in-out infinite; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(20,158,201,.08); } }

.offline-banner { background: var(--warn-bg); color: var(--warn); padding: 8px 28px; font-size: .9rem; border-bottom: 1px solid #F0D99B; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid transparent; font: 600 .95rem/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--brand-2); color: #fff; }
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--brand-dark); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); border-color: #B9C3CB; color: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--brand-2); border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); color: var(--brand-dark); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #7E1C23; }
.btn.danger-ghost { background: transparent; color: var(--bad); border-color: transparent; }
.btn.danger-ghost:hover { background: var(--bad-bg); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.btn.icon { padding: 0; width: 44px; }
.btn svg { width: 18px; height: 18px; }
.btn.start { background: var(--brand); color: var(--brand-dark); font-size: 1.25rem; font-weight: 800; letter-spacing: .03em; min-height: 64px; padding: 0 36px; border-radius: 14px; box-shadow: 0 4px 14px rgba(20,158,201,.35); }
.btn.start:hover { background: #1BB0DD; color: var(--brand-dark); }
.btn.stop { background: var(--brand-dark); color: #fff; font-size: 1.15rem; font-weight: 800; letter-spacing: .03em; min-height: 60px; padding: 0 32px; border-radius: 14px; }
.btn.stop:hover { background: #021F28; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.section { margin-top: 24px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 0; }
.greeting { font-size: 1.75rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 12px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.stat .label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.55rem; font-weight: 700; color: var(--brand-dark); font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; overflow-wrap: anywhere; }
.stat .value.text { font-size: 1.05rem; font-weight: 650; }
.stat .sub { font-size: .85rem; color: var(--muted); margin-top: 2px; }

/* ---------- Timer hero ---------- */
.timer-hero { background: var(--surface); border-radius: 16px; border: 1px solid var(--line-soft); box-shadow: var(--shadow); padding: 36px 28px; text-align: center; }
.timer-hero.running { border: 2px solid var(--brand); background: linear-gradient(180deg, #F2FBFE 0%, #FFFFFF 60%); }
.timer-hero.on-break { border: 2px solid #B79BCF; background: linear-gradient(180deg, #F7F1FB 0%, #FFFFFF 60%); }
.timer-hero .big-clock { font: 700 clamp(3rem, 9vw, 5.25rem)/1 var(--mono); color: var(--brand-dark); font-variant-numeric: tabular-nums; letter-spacing: .02em; margin: 8px 0 18px; }
.timer-hero .state { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; color: var(--brand-2); }
.working-on { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; text-align: left; max-width: 520px; margin: 0 auto 22px; font-size: .98rem; }
.working-on dt { color: var(--muted); font-weight: 600; }
.working-on dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.timer-hero .hint { color: var(--muted); margin-top: 14px; font-size: .92rem; }
.quick-starts { display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin: 22px auto 0; text-align: left; }
.quick-start { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; min-height: 52px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer; text-align: left; font: inherit; color: var(--ink); }
.quick-start:hover { border-color: var(--brand); background: #F2FBFE; }
.quick-start .play { width: 32px; height: 32px; border-radius: 50%; background: var(--info-bg); color: var(--brand-2); display: grid; place-items: center; flex: none; }
.quick-start .play svg { width: 16px; height: 16px; }
.quick-start .qs-text { min-width: 0; }
.quick-start .qs-text span { display: block; font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: .92rem; color: var(--ink-2); }
.field .help { font-size: .84rem; color: var(--muted); }
.field .error-text { font-size: .86rem; color: var(--bad); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #AEB9C2; border-radius: 8px; padding: 9px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: #8D9AA5; }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--brand-2); flex: none; }
.toggle-group { display: inline-flex; border: 1px solid #AEB9C2; border-radius: 8px; overflow: hidden; }
.toggle-group label { position: relative; }
.toggle-group input { position: absolute; opacity: 0; inset: 0; }
.toggle-group span { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 14px; cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--ink-2); }
.toggle-group input:checked + span { background: var(--brand-2); color: #fff; }
.toggle-group input:focus-visible + span { box-shadow: inset 0 0 0 3px var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; inset: 0; }
.chip-check span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .88rem; cursor: pointer; background: var(--surface); }
.chip-check input:checked + span { background: var(--info-bg); border-color: var(--brand-2); color: var(--brand-dark); font-weight: 600; }
.chip-check input:checked + span::before { content: "✓"; margin-right: 6px; }
.chip-check input:focus-visible + span { box-shadow: var(--focus); }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 600; font-size: .92rem; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.form-error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 14px; font-weight: 600; margin-bottom: 14px; }
.form-warn { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.form-warn strong, .form-error strong { display: block; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 150px; flex: 1 1 150px; }
.filters .field.wide { flex: 2 1 220px; }
.filters .field label { font-size: .82rem; }
.filters .btn-row { flex: 0 0 auto; }
.active-filters { font-size: .88rem; color: var(--muted); margin: -6px 0 14px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: #F8FAFB; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.desc { min-width: 220px; max-width: 420px; }
tfoot td { font-weight: 700; background: var(--surface-2); }
.day-group th { background: #EEF3F6; color: var(--brand-dark); font-size: .86rem; text-transform: none; letter-spacing: 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.cell-sub { display: block; font-size: .84rem; color: var(--muted); }
.actions { white-space: nowrap; text-align: right; }

/* Timesheet grid */
.ts-grid td.day, .ts-grid th.day { text-align: center; min-width: 74px; font-variant-numeric: tabular-nums; }
.ts-grid td.day.zero { color: #A3AEB6; }
.ts-grid th.day.today { color: var(--brand-2); }
.ts-grid .rowname { min-width: 200px; }

/* Calendar */
.cal { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow-x: auto; }
.cal-head, .cal-body { display: grid; grid-template-columns: 56px repeat(7, minmax(110px, 1fr)); min-width: 840px; }
.cal-head > div { padding: 10px 8px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line-soft); font-size: .86rem; }
.cal-head > div span { display: block; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-head > div.today strong { color: var(--brand-2); }
.cal-hours > div { height: var(--hour); font-size: .75rem; color: var(--muted); text-align: right; padding: 0 6px; transform: translateY(-.6em); }
.cal-day { position: relative; border-left: 1px solid var(--line-soft); background-image: repeating-linear-gradient(to bottom, var(--line-soft) 0 1px, transparent 1px var(--hour)); }
.cal-entry { position: absolute; left: 4px; right: 4px; overflow: hidden; text-align: left; border: 0; border-left: 4px solid var(--c); border-radius: 6px; background: #EAF6FB; color: var(--ink); padding: 3px 6px; font: .76rem/1.25 var(--font); cursor: pointer; }
.cal-entry:hover, .cal-entry:focus-visible { background: #D8EFF8; z-index: 2; }
.cal-entry strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-entry span { display: block; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-entry .cal-desc { white-space: normal; color: var(--muted); }
.cal-entry.is-break { background: var(--violet-bg); border-left-color: var(--accent); }
.cal-entry.is-running { box-shadow: inset 0 0 0 2px var(--brand); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.badge::before { font-size: .75em; }
.badge.draft { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.badge.draft::before { content: "○"; }
.badge.running { background: var(--info-bg); color: var(--info); }
.badge.running::before { content: "●"; }
.badge.submitted { background: #E8EEFB; color: #2D4C8A; }
.badge.submitted::before { content: "↑"; }
.badge.approved { background: var(--ok-bg); color: var(--ok); }
.badge.approved::before { content: "✓"; }
.badge.rejected { background: var(--bad-bg); color: var(--bad); }
.badge.rejected::before { content: "!"; font-weight: 900; }
.badge.locked { background: #EEE9F2; color: var(--accent); }
.badge.locked::before { content: "🔒"; font-size: .7em; }
.badge.billable { background: var(--info-bg); color: var(--info); }
.badge.billable::before { content: "$"; }
.badge.nonbillable { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.badge.nonbillable::before { content: "–"; }
.badge.neutral { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.warn::before { content: "▲"; }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.bad::before { content: "■"; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.ok::before { content: "✓"; }
.badge.break { background: var(--violet-bg); color: var(--accent); }
.badge.break::before { content: "☕"; font-size: .8em; }

/* ---------- Progress / allocation ---------- */
.progress { height: 14px; border-radius: 999px; background: #DCE3E8; overflow: hidden; position: relative; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.progress.warn > span { background: #C98A00; }
.progress.over > span { background: var(--accent); }
.progress .marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: rgba(4,52,66,.35); }
.alloc { display: flex; flex-direction: column; gap: 8px; }
.alloc-figures { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .92rem; }
.alloc-figures strong { font-variant-numeric: tabular-nums; }

/* ---------- Bars (single-series, one hue) ---------- */
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bars li { display: grid; grid-template-columns: minmax(120px, 34%) 1fr auto; align-items: center; gap: 12px; font-size: .93rem; }
.bars .bar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar-track { height: 12px; position: relative; }
.bars .bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brand); border-radius: 0 4px 4px 0; min-width: 3px; }
.bars .bar-value { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.bars .bar-value .pct { font-weight: 500; color: var(--muted); margin-left: 6px; }
.bars li:hover .bar-fill { background: var(--brand-2); }

.colchart { position: relative; }
.colchart svg { display: block; width: 100%; height: 180px; overflow: visible; }
.colchart .col { fill: var(--brand); }
.colchart .col:hover, .colchart .col:focus { fill: var(--brand-2); outline: none; }
.colchart .axis { stroke: var(--line); stroke-width: 1; }
.colchart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.colchart text { font: 11px var(--font); fill: var(--muted); }
.chart-tip { position: absolute; pointer-events: none; background: var(--brand-dark); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: .85rem; white-space: nowrap; transform: translate(-50%, -110%); z-index: 5; }
.chart-tip strong { display: block; }
details.table-view { margin-top: 10px; font-size: .9rem; }
details.table-view summary { cursor: pointer; color: var(--brand-2); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .empty-icon { width: 48px; height: 48px; margin: 0 auto 10px; color: #9DB3BD; }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 300; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--brand-dark); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.toast.error { background: var(--bad); }
.toast.warn { background: #6E4700; }
.toast button { margin-left: auto; background: transparent; color: #fff; border: 0; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 2px 4px; }

/* ---------- Dialogs ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(4,52,66,.3); color: var(--ink); }
dialog.wide { width: min(860px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(4, 52, 66, .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 10px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 8px 22px 6px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line-soft); }

/* ---------- Popovers (notifications, search) ---------- */
.popover-wrap { position: relative; }
.popover { position: absolute; right: 0; top: calc(100% + 8px); width: min(400px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 36px rgba(4,52,66,.18); z-index: 50; max-height: 70vh; overflow-y: auto; }
.popover-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.notif { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: #F2FBFE; }
.notif.unread strong::before { content: "● "; color: var(--brand-2); }
.notif small { color: var(--muted); display: block; }
.bell-count { background: var(--bad); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 6px; font-weight: 700; }
.search-box { position: relative; width: min(360px, 40vw); }
.search-results { left: 0; right: auto; width: 100%; min-width: 320px; }
.search-group { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.search-group h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 16px; }
.search-group a { display: block; padding: 8px 16px; text-decoration: none; color: var(--ink); }
.search-group a:hover, .search-group a:focus { background: var(--surface-2); }
.search-group a small { display: block; color: var(--muted); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button, .tabs a { background: none; border: 0; padding: 10px 14px; min-height: 44px; font: 600 .95rem var(--font); color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* ---------- Login & public pages ---------- */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--brand-dark) 0%, #0A4C5F 55%, var(--brand-2) 100%); }
.login-card { width: min(420px, 100%); background: var(--surface); border-radius: 16px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card .brand { color: var(--brand-dark); padding: 0 0 18px; }
.login-card .brand-sub { color: var(--muted); }

.public { min-height: 100vh; }
.public-head { background: var(--brand-dark); color: #fff; }
.public-head .inner { max-width: 1100px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.public-head .brand { padding: 0; }
.public-main { max-width: 1100px; margin: 0 auto; padding: 24px 24px 64px; }
.three-q { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.three-q .q { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.hero-num { font-size: 2.2rem; font-weight: 800; color: var(--brand-dark); font-variant-numeric: tabular-nums; line-height: 1.15; }
.public-foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 200; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(4,52,66,.45); z-index: 150; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 14px; }
  .content { padding: 18px 14px 140px; }
  .timerbar { padding: 10px 14px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; border-top: 1px solid #BFE3EF; border-bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -4px 16px rgba(4,52,66,.12); }
  .timerbar .ctx { flex-basis: 100%; order: 3; white-space: normal; }
  .timerbar .btn { flex: 1; min-height: 48px; font-size: 1rem; border-radius: 10px; padding: 0 16px; }
  .offline-banner { padding: 8px 14px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .three-q { grid-template-columns: 1fr; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .search-box { width: auto; flex: 1; }
  .search-results { min-width: 0; width: calc(100vw - 28px); }
  .bars li { grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; }
  .hide-mobile { display: none !important; }
  .timer-hero { padding: 26px 16px; }
  .btn.start, .btn.stop { width: 100%; }
  .greeting { font-size: 1.4rem; }
  .dialog-foot .btn { flex: 1; }
}
@media (min-width: 861px) { .show-mobile { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .sidebar, .topbar, .timerbar, .filters, .btn, .no-print, .toasts, .public-head .btn { display: none !important; }
  body, .public, .main { background: #fff; }
  .shell { display: block; }
  .card, .stat { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .content, .public-main { padding: 0; max-width: none; }
  .table-wrap { overflow: visible; border: 0; }
  th { position: static; }
}

/* Team hours: keep names visible while scrolling across many day columns */
.team-grid .rowname { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line-soft); }
.team-grid thead .rowname { background: var(--surface-2); z-index: 2; }
.team-grid tfoot .rowname { background: var(--surface-2); }
.team-grid tbody tr:hover .rowname { background: #F8FAFB; }
