/* ==========================================================================
   Timetrack — design system (see DESIGN.md). Calm, focused, precise.
   Colors in OKLCH. Light is default; [data-theme="dark"] is a first-class peer.
   ========================================================================== */

:root {
  --bg:            oklch(1.000 0.000 0);
  --surface:       oklch(0.986 0.003 245);
  --surface-2:     oklch(0.968 0.004 245);
  --border:        oklch(0.922 0.005 245);
  --border-strong: oklch(0.870 0.006 245);

  --ink:           oklch(0.235 0.020 250);
  --ink-muted:     oklch(0.455 0.018 250);  /* ≥4.5:1 on white & tinted surfaces */
  --ink-faint:     oklch(0.545 0.016 250);  /* placeholders/hints, ~4.5:1 on white */

  --primary:       oklch(0.530 0.130 232);
  --primary-hover: oklch(0.470 0.135 232);
  --primary-press: oklch(0.420 0.135 232);
  --primary-weak:  oklch(0.950 0.030 232);
  --primary-ring:  oklch(0.620 0.130 232 / 0.45);
  --on-primary:    oklch(0.990 0.005 232);

  --accent:        oklch(0.700 0.170 50);
  --accent-weak:   oklch(0.960 0.040 60);
  --on-accent:     oklch(0.990 0.010 50);

  --success:       oklch(0.580 0.130 150);
  --success-weak:  oklch(0.950 0.040 150);
  --warning:       oklch(0.720 0.140 80);
  --warning-weak:  oklch(0.960 0.050 85);
  --danger:        oklch(0.550 0.200 25);
  --danger-weak:   oklch(0.960 0.040 25);
  --on-status:     oklch(0.990 0.005 250);

  --shadow-sm: 0 1px 2px oklch(0.235 0.02 250 / 0.06), 0 1px 1px oklch(0.235 0.02 250 / 0.04);
  --shadow-md: 0 4px 12px oklch(0.235 0.02 250 / 0.08), 0 1px 3px oklch(0.235 0.02 250 / 0.05);
  --shadow-lg: 0 12px 32px oklch(0.235 0.02 250 / 0.12), 0 2px 8px oklch(0.235 0.02 250 / 0.06);

  --font-ui:   "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", monospace;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px; --space-12: 48px; --space-16: 64px;

  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-full: 999px;

  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --dur-fast: 120ms; --dur: 160ms; --dur-slow: 220ms;

  --z-dropdown: 1000; --z-sticky: 1100; --z-backdrop: 1200;
  --z-modal: 1300; --z-toast: 1400; --z-tooltip: 1500;

  --sidebar-w: 230px;
  --topbar-h: 56px;
  --player-h: 72px;
}

[data-theme="dark"] {
  --bg:            oklch(0.165 0.010 250);
  --surface:       oklch(0.205 0.012 250);
  --surface-2:     oklch(0.245 0.013 250);
  --border:        oklch(0.290 0.012 250);
  --border-strong: oklch(0.360 0.013 250);

  --ink:           oklch(0.960 0.005 250);
  --ink-muted:     oklch(0.720 0.012 250);
  --ink-faint:     oklch(0.580 0.012 250);

  --primary:       oklch(0.640 0.140 235);
  --primary-hover: oklch(0.700 0.140 235);
  --primary-press: oklch(0.740 0.135 235);
  --primary-weak:  oklch(0.300 0.060 235);
  --primary-ring:  oklch(0.700 0.140 235 / 0.55);
  --on-primary:    oklch(0.150 0.020 235);

  --accent:        oklch(0.740 0.160 52);
  --accent-weak:   oklch(0.320 0.070 52);
  --on-accent:     oklch(0.980 0.010 52);

  --success:       oklch(0.680 0.140 150);
  --success-weak:  oklch(0.300 0.060 150);
  --warning:       oklch(0.780 0.140 82);
  --warning-weak:  oklch(0.320 0.060 82);
  --danger:        oklch(0.650 0.190 25);
  --danger-weak:   oklch(0.320 0.080 25);
  --on-status:     oklch(0.980 0.010 250);

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.40);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.45);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.55);
}

/* --- reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { line-height: 1.2; font-weight: 650; text-wrap: balance; letter-spacing: -0.01em; }
p { text-wrap: pretty; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }

/* --- layout: app shell ------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: calc(100vh - var(--player-h));
}
.brand {
  display: flex; align-items: center; gap: var(--space-2);
  height: var(--topbar-h); padding: 0 var(--space-4);
  font-weight: 700; letter-spacing: -0.02em; font-size: 16px;
  border-bottom: 1px solid var(--border);
}
.brand .dot { width: 11px; height: 11px; border-radius: var(--radius-full); background: var(--primary); }
.nav { padding: var(--space-3); display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  color: var(--ink-muted); font-weight: 500; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--primary-weak); color: var(--primary); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav .nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); padding: var(--space-4) var(--space-3) var(--space-1); }

.sidebar-foot { padding: var(--space-3); border-top: 1px solid var(--border); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-6);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: var(--z-sticky);
}
.topbar .spacer { flex: 1; }

.content { padding: var(--space-8) var(--space-6); max-width: none; width: 100%; padding-bottom: calc(var(--player-h) + var(--space-8) + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--ink-muted); margin-top: 2px; }

/* --- buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 36px; padding: 0 var(--space-4); border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-2); color: var(--ink);
  font-weight: 550; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 16px; height: 16px; }
.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: 13px; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-press); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--ink); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger-weak); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: none; background: transparent; color: var(--ink-muted); border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* --- forms ------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.field label { font-size: 13px; font-weight: 550; color: var(--ink-muted); }
.field .req { color: var(--danger); }
.field .lbl-hint {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  padding: 1px 6px; border-radius: 999px; margin-left: 4px; vertical-align: 1px;
}
.input, .select, textarea.input {
  height: 36px; padding: 0 var(--space-3); width: 100%;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea.input { height: auto; padding: var(--space-2) var(--space-3); resize: vertical; min-height: 64px; }
.input::placeholder { color: var(--ink-faint); }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.field .hint { font-size: 12px; color: var(--ink-faint); }
.input-group { display: flex; gap: var(--space-2); }

/* --- cards & panels ---------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--space-6); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }

.stat { padding: var(--space-5, 20px) var(--space-6); }
.stat .label { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 600; margin-top: var(--space-2); letter-spacing: -0.02em; }
.stat .meta { font-size: 13px; color: var(--ink-faint); margin-top: var(--space-1); }

/* --- tables ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data thead th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-muted); background: var(--surface-2);
  padding: var(--space-3) var(--space-4); position: sticky; top: 0; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.data tbody td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface); }
table.data .num, table.data .right { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }

/* Stacked cards: each row becomes a labelled card on phones. */
@media (max-width: 640px) {
  .table-wrap { overflow-x: visible; }
  table.data, table.data tbody, table.data tbody tr, table.data tbody td, table.data tfoot, table.data tfoot tr { display: block; width: auto; }
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.data tbody tr {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); background: var(--surface-1);
  }
  table.data tbody tr:hover { background: var(--surface-1); }
  table.data tbody td {
    border: none; padding: var(--space-2) 0; min-height: 0;
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); text-align: right;
  }
  table.data tbody td + td { border-top: 1px solid var(--border); }
  table.data tbody td[data-label]::before {
    content: attr(data-label); flex: none; text-align: left;
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted);
  }
  table.data tbody td.td-primary { justify-content: flex-start; font-size: 15px; }
  table.data tbody td.td-primary::before { content: none; }
  table.data tbody td.td-actions { justify-content: flex-end; }
  table.data tbody td.td-bar { display: none; }
  table.data tfoot tr { border: 1px dashed var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); background: var(--surface-2); }
  table.data tfoot td { display: flex; justify-content: space-between; padding: var(--space-1) 0; }
  table.data tfoot td:empty { display: none; }
  table.data tfoot td[data-label]::before {
    content: attr(data-label); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted);
  }
  .report-filters .row { flex-direction: column; align-items: stretch; }
  .report-filters .field { width: 100%; }
  .report-filters .btn { width: 100%; }
}

/* --- badges & pills ---------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--space-2); border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; }
.badge .dot { width: 8px; height: 8px; border-radius: var(--radius-full); }
.badge-billable { background: var(--success-weak); color: var(--success); }
.badge-nonbillable { background: var(--surface-2); color: var(--ink-muted); }
.badge-muted { background: var(--surface-2); color: var(--ink-muted); }
.badge-warn { background: var(--warning-weak); color: var(--warning); }
.pill-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-muted); }
.proj-dot { width: 10px; height: 10px; border-radius: var(--radius-full); flex: none; display: inline-block; }

/* --- flash messages ---------------------------------------------------- */
.flashes { position: fixed; top: var(--space-4); right: var(--space-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); max-width: 360px; }
.flash { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); box-shadow: var(--shadow-md); background: var(--surface); border: 1px solid var(--border); font-size: 14px; animation: slidein var(--dur-slow) var(--ease); }
.flash-success { border-left: 3px solid var(--success); }
.flash-error { border-left: 3px solid var(--danger); }
.flash-info { border-left: 3px solid var(--primary); }
@keyframes slidein { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* --- dropdown menu ----------------------------------------------------- */
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: var(--space-2); z-index: var(--z-dropdown);
  display: none;
}
.menu.open .menu-panel { display: block; animation: pop var(--dur-fast) var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-panel a, .menu-panel button { display: flex; align-items: center; gap: var(--space-2); width: 100%; text-align: left; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--ink); background: none; border: none; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-divider { height: 1px; background: var(--border); margin: var(--space-2) 0; }

/* --- modal ------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: oklch(0.2 0.02 250 / 0.45);
  z-index: var(--z-backdrop); display: none; align-items: flex-start; justify-content: center; padding: 10vh var(--space-4) var(--space-4);
}
.modal-backdrop.open { display: flex; animation: fade var(--dur) var(--ease); }
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; z-index: var(--z-modal);
  animation: rise var(--dur-slow) var(--ease);
}
.modal.modal-lg { max-width: 620px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: var(--space-6); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- empty state ------------------------------------------------------- */
.empty { text-align: center; padding: var(--space-12) var(--space-4); color: var(--ink-muted); }
.empty h3 { color: var(--ink); font-size: 16px; margin-bottom: var(--space-2); }
.empty p { margin-bottom: var(--space-4); }

/* --- timer player (fixed bottom bar, Spotify-style) ------------------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--player-h) + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-4);
  padding: 0 max(var(--space-6), env(safe-area-inset-left)) env(safe-area-inset-bottom) max(var(--space-6), env(safe-area-inset-right));
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: var(--z-sticky);
}
.player.is-running {
  background: color-mix(in oklab, var(--accent) 10%, var(--surface));
}

/* Daily-progress bar across the top edge — segments = projects worked today. */
.player-progress {
  position: absolute; top: 0; left: 0; right: 0; height: 5px;
  display: flex; gap: 1px; overflow: hidden;
  background: var(--surface-2);
}
.player-progress:empty { display: none; }
.player-seg { height: 100%; min-width: 0; }

.player-now { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.timer-active { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.timer-id { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
.timer-id-name, .timer-id-task { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.timer-id-name { font-weight: 600; font-size: 16px; color: var(--ink); flex: 0 1 auto; }
.timer-id-task { font-size: 15px; color: var(--ink-muted); flex: 1 1 auto; }
.timer-id-task::before { content: "·"; margin-right: var(--space-2); color: var(--ink-faint); }
.timer-id-task:empty { display: none; }

.timer-form { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.timer-select { height: 36px; min-width: 180px; max-width: 240px; }
.timer-note { height: 36px; flex: 1 1 160px; min-width: 0; max-width: 340px; }

.player-transport { display: flex; align-items: center; gap: var(--space-4); }
.timer-readout {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 26px; font-weight: 600; letter-spacing: -0.01em; min-width: 116px; text-align: right;
  color: var(--ink);
}
.is-running .timer-readout { color: var(--accent); }
.timer-btn {
  height: 48px; width: 48px; border-radius: var(--radius-full); border: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: var(--on-primary);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.timer-btn:hover { background: var(--primary-hover); }
.timer-btn:active { transform: scale(0.95); }
.is-running .timer-btn { background: var(--accent); color: var(--on-accent); }

.player-meta { justify-self: end; text-align: right; line-height: 1.2; }
.player-meta-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); }
.player-meta-val { font-size: 15px; font-weight: 600; color: var(--ink-muted); }

.rec-dot { width: 9px; height: 9px; border-radius: var(--radius-full); background: var(--accent); flex: none; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- theme toggle ------------------------------------------------------ */
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-muted); }
.theme-toggle:hover { background: var(--surface-2); color: var(--ink); }

.avatar { width: 30px; height: 30px; border-radius: var(--radius-full); background: var(--primary); color: var(--on-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: 13px; }

/* --- timesheet grid ---------------------------------------------------- */
.ts-toolbar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.ts-grid { width: 100%; border-collapse: collapse; }
.ts-grid th, .ts-grid td { border: 1px solid var(--border); }
.ts-grid thead th { background: var(--surface-2); padding: var(--space-2) var(--space-3); font-size: 12px; font-weight: 600; color: var(--ink-muted); text-align: center; }
.ts-grid thead th.proj-col { text-align: left; width: 280px; }
.ts-grid thead th.today { color: var(--primary); background: var(--primary-weak); }
.ts-grid thead th .dow { display: block; text-transform: uppercase; letter-spacing: 0.04em; }
.ts-grid thead th .dom { display: block; font-family: var(--font-mono); font-size: 14px; color: var(--ink); font-weight: 600; }
.ts-grid tbody td.proj-cell { padding: var(--space-2) var(--space-3); }
.ts-grid tbody td.proj-cell .name { font-weight: 550; }
.ts-grid tbody td.proj-cell .task { font-size: 12px; color: var(--ink-muted); }
.ts-cell { padding: 0; height: 44px; position: relative; }
.ts-cell.today { background: color-mix(in oklab, var(--primary-weak) 50%, var(--bg)); }
.ts-cell input {
  width: 100%; height: 100%; border: 0; background: transparent; text-align: center;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink);
}
.ts-cell input:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--bg); }
.ts-cell input::placeholder { color: transparent; }
.ts-cell:hover input::placeholder { color: var(--ink-faint); }
.ts-grid tfoot td, .ts-grid .total-col { background: var(--surface-2); font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: center; font-weight: 650; padding: var(--space-2); }
.ts-grid tfoot td.proj-cell { text-align: left; color: var(--ink-muted); text-transform: uppercase; font-size: 12px; letter-spacing: 0.04em; }

/* --- utilities --------------------------------------------------------- */
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.right { text-align: right; }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.gap-2 { gap: var(--space-2); }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.hidden { display: none !important; }
[hidden] { display: none !important; } /* class selectors (.btn) otherwise win over the UA rule */
.text-sm { font-size: 13px; } .text-xs { font-size: 12px; }
.w-full { width: 100%; }
.color-swatch { width: 16px; height: 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* --- responsive -------------------------------------------------------- */
@media (max-width: 980px) {
  :root { --sidebar-w: 60px; }
  .brand span, .nav a span, .nav .nav-section, .sidebar-foot .ws-name { display: none; }
  .nav a { justify-content: center; }
  .timer-note { display: none; }
}
.scrim { display: none; }
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; height: 100dvh; z-index: var(--z-modal); transform: translateX(-100%); transition: transform var(--dur) var(--ease); --sidebar-w: 264px; width: 264px; padding-top: env(safe-area-inset-top); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: var(--z-backdrop); background: oklch(0.2 0.02 250 / 0.5); opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease); }
  .scrim.open { opacity: 1; visibility: visible; }
  .brand span, .nav a span, .nav .nav-section, .sidebar-foot .ws-name { display: inline; }
  .nav a { justify-content: flex-start; }
  .content { padding: var(--space-6) var(--space-4); padding-bottom: calc(var(--player-h) + var(--space-6) + env(safe-area-inset-bottom)); padding-left: max(var(--space-4), env(safe-area-inset-left)); padding-right: max(var(--space-4), env(safe-area-inset-right)); }

  /* Player → thumb-friendly. Idle: project + task pickers share the bar and the
     0:00:00 readout is hidden (it's meaningless before starting), freeing room.
     Running: the form collapses to the active id and the live readout shows. */
  .player { grid-template-columns: 1fr auto; gap: var(--space-3); }
  .player-meta { display: none; }
  .player-now { min-width: 0; }
  .timer-form { flex: 1; min-width: 0; gap: var(--space-2); }
  .timer-form .cbx { flex: 1 1 0; min-width: 0; width: auto; }
  .player:not(.is-running) .timer-readout { display: none; }
  .timer-readout { font-size: 22px; min-width: 0; }
  .player-transport { gap: var(--space-2); }

  /* Page header stacks; actions drop below the title. */
  .page-head { flex-direction: column; align-items: stretch; gap: var(--space-3); }
  .page-head > .row { flex-wrap: wrap; }

  /* Dashboard split → single column. */
  .row-2 { grid-template-columns: 1fr; }

  /* Modals → bottom sheets that slide up, with a sticky footer. */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none; width: 100%; max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: none;
    display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
    animation: sheet var(--dur-slow) var(--ease);
  }
  .modal-head { padding: var(--space-4); }
  .modal-body { padding: var(--space-4); overflow-y: auto; flex: 1; }
  .modal-foot { padding: var(--space-4); position: sticky; bottom: 0; background: var(--bg); }
}
@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { @keyframes sheet { from { transform: none; } to { transform: none; } } }

/* Touch devices: kill iOS focus-zoom (<16px inputs) and grow tap targets. */
@media (pointer: coarse) {
  .input, .select, textarea.input, .cbx-toggle, .cbx-search,
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="time"], input[type="date"], input[type="search"] {
    font-size: 16px;
  }
  .input, .select, .cbx-toggle { height: 44px; }
  .btn { min-height: 44px; }
  .btn-icon, .theme-toggle { min-width: 44px; min-height: 44px; }
  .nav a { min-height: 44px; }
  .modal-head .btn-icon { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .rec-dot { animation: none; }
}

/* ===== Week calendar (timesheet) ===================================== */
.gap-3 { gap: var(--space-3); }
.mt-3 { margin-top: var(--space-3); }
.spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

.cal { padding: 0; overflow: hidden; }
.cal-scroll { max-height: calc(100vh - 240px); overflow: auto; scrollbar-gutter: stable; }

/* Mobile single-day switcher (revealed under 720px; hidden here so a viewport
   change can't strand it visible on desktop — visibility is pure CSS). */
.cal-daynav { display: none; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.cal-daynav .btn-icon { border: 1px solid var(--border-strong); height: 40px; width: 40px; flex: none; }
.cal-daynav-label { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: var(--space-2); }
.cal-daynav-label .dn-dow { font-weight: 600; }
.cal-daynav-label .dn-date { color: var(--ink-muted); }
.cal-daynav-label .dn-total { margin-left: var(--space-2); color: var(--primary); font-weight: 600; }
.cal-hint-mobile { display: none; }
.cal-grid {
  display: grid;
  grid-template-columns: 56px repeat(7, minmax(0, 1fr));
  grid-template-rows: auto var(--bodyh);
}
.cal-corner {
  position: sticky; top: 0; z-index: 4; grid-column: 1; grid-row: 1;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.cal-dayhead {
  position: sticky; top: 0; z-index: 3; grid-row: 1;
  background: var(--surface);
  border-bottom: 1px solid var(--border); border-left: 1px solid var(--border);
  padding: var(--space-2); text-align: center;
  display: flex; flex-direction: column; gap: 1px;
}
.cal-dayhead .dow { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.cal-dayhead .dom { font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--ink); line-height: 1.05; }
.cal-dayhead .dtotal { font-size: 12px; color: var(--ink-muted); }
.cal-dayhead.today { background: var(--primary-weak); }
.cal-dayhead.today .dom, .cal-dayhead.today .dtotal { color: var(--primary); }

.cal-gutter { grid-column: 1; grid-row: 2; }
.cal-hr { height: var(--hourh); position: relative; }
.cal-hr span {
  position: absolute; top: -7px; right: 6px; font-size: 11px;
  color: var(--ink-faint); font-family: var(--font-mono);
  background: var(--surface); padding: 0 2px;
}
.cal-hr:first-child span { top: 2px; }

.cal-col {
  grid-row: 2; position: relative; border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom,
    transparent 0, transparent calc(var(--hourh) - 1px),
    var(--border) calc(var(--hourh) - 1px), var(--border) var(--hourh));
}
.cal-col.today { background-color: color-mix(in oklab, var(--primary-weak) 35%, transparent); }

.cal-block {
  position: absolute; left: 2px; right: 2px; min-height: 14px;
  border-radius: var(--radius-sm); padding: 3px 6px; overflow: hidden;
  background: color-mix(in oklab, var(--c) 14%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--c) 35%, var(--border));
  border-left: 3px solid var(--c);
  box-shadow: var(--shadow-sm); cursor: grab; user-select: none;
  font-size: 12px; line-height: 1.25;
  transition: box-shadow var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.cal-block:hover { box-shadow: var(--shadow-md); z-index: 5; }
.cal-block.dragging { cursor: grabbing; opacity: .92; z-index: 20; box-shadow: var(--shadow-lg); }
.cal-block .cb-title { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-block .cb-sub { color: var(--c); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-block .cb-dur { font-family: var(--font-mono); color: var(--ink-muted); font-size: 11px; }
.cal-block.compact { padding: 1px 6px; }
.cal-block.compact .cb-sub, .cal-block.compact .cb-dur { display: none; }
.cal-block .cb-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.cal-block.running { background: color-mix(in oklab, var(--accent) 18%, var(--surface)); border-color: var(--accent); border-left-color: var(--accent); cursor: default; }
.cal-block.running .cb-sub { color: var(--accent); }

.cal-ghost {
  position: absolute; left: 2px; right: 2px; border-radius: var(--radius-sm);
  background: var(--primary-weak); border: 1px dashed var(--primary);
  z-index: 15; pointer-events: none;
}
.cal-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--accent); z-index: 6; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* Phones: collapse the week grid to a single day driven by the day switcher.
   Placed after the base .cal-* rules so it wins without needing extra specificity. */
@media (max-width: 720px) {
  .cal-daynav { display: flex; }
  .cal-grid { grid-template-columns: 56px 1fr; }
  .cal-dayhead:not(.is-active), .cal-col:not(.is-active) { display: none; }
  .cal-dayhead.is-active, .cal-col.is-active { grid-column: 2; }
  .cal-scroll { max-height: calc(100dvh - 320px); }
  .cal-hint-desktop { display: none; }
  .cal-hint-mobile { display: block; }
}

/* ===== Searchable select (select2-style combobox) ==================== */
.cbx { position: relative; display: inline-block; width: 100%; }
.cbx-native { display: none !important; }
.cbx-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  height: 36px; padding: 0 var(--space-3); width: 100%;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; cursor: pointer; text-align: left;
}
.cbx-toggle:hover { border-color: var(--ink-faint); }
.cbx.open .cbx-toggle { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.cbx-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbx-label.placeholder { color: var(--ink-faint); }
.cbx-toggle svg { flex: none; color: var(--ink-faint); }
.cbx-pop {
  display: none; position: absolute; z-index: var(--z-dropdown);
  top: calc(100% + 4px); left: 0; right: 0; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px;
}
.cbx.open .cbx-pop { display: block; }
/* In the fixed bottom player bar there's no room below — open upward. */
.player .cbx-pop { top: auto; bottom: calc(100% + 4px); }
.player .cbx-list { max-height: 50vh; }
.cbx-search {
  width: 100%; height: 34px; padding: 0 var(--space-3); margin-bottom: 6px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.cbx-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.cbx-list { max-height: 280px; overflow: auto; }
.cbx-opt {
  padding: 7px var(--space-3); border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cbx-opt:hover, .cbx-opt.active { background: var(--surface-2); }
.cbx-opt.sel { color: var(--primary); font-weight: 600; }
.cbx-empty { padding: 8px var(--space-3); color: var(--ink-faint); font-size: 13px; }
.cbx-create {
  display: flex; align-items: center; gap: 7px;
  padding: 7px var(--space-3); border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; color: var(--primary); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
  border-top: 1px solid var(--border);
}
.cbx-create:hover { background: var(--primary-weak); }
.cbx-create b { font-weight: 600; }
.cbx-create-plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; flex: none; border-radius: var(--radius-full);
  background: var(--primary); color: #fff; font-size: 13px; line-height: 1;
}
.cbx.creating .cbx-toggle { opacity: 0.6; pointer-events: none; }
.player .cbx { width: 230px; }

/* quick "new project" modal must stack above the timesheet entry modal */
#quickProjectModal { z-index: 1450; }

/* active/inactive toggle switch (clients) */
.switch-form { display: inline-flex; }
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px; height: 22px; border-radius: var(--radius-full); flex: none;
  background: var(--border-strong); transition: background var(--dur) var(--ease);
}
.switch .thumb {
  position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track + .thumb { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch .switch-label { margin-left: 9px; font-size: 13px; color: var(--ink-muted); min-width: 54px; }
.data tr.is-inactive td:first-child span, .data tr.is-inactive td.num { color: var(--ink-faint); }

/* recent-entry quick-start button */
.row-start { width: 1%; padding-right: var(--space-2); }
.row-start .btn-play { width: 28px; height: 28px; opacity: 0.45; color: var(--primary); border-radius: var(--radius-full); transition: opacity var(--dur) var(--ease), background var(--dur-fast) var(--ease); }
.row-start .btn-play svg { width: 14px; height: 14px; }
tr:hover .row-start .btn-play { opacity: 1; }
.btn-play:hover { background: var(--primary-weak); }
