:root {
  color-scheme: light;
  --page: #f7faff;
  --bg-strong: #eef5ff;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --text-primary: #0b163f;
  --text-secondary: #34446b;
  --text-muted: #7583a3;
  --border: #dce6f4;
  --gridline: #e3ecf9;
  --baseline: #b9c8e6;

  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --primary-soft: #eaf2ff;
  --orange: #eb6834;
  --aqua: #1baf7a;
  --yellow: #f59e0b;
  --red: #ef4444;

  --series-1: #2563eb;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #f59e0b;
  --series-5: #e87ba4;
  --series-6: #147a3d;
  --series-7: #6d4ad1;
  --series-8: #ef4444;

  --good: #22c55e;
  --good-text: #15803d;
  --good-soft: #e9f9ef;
  --warning: #f59e0b;
  --warning-soft: #fff7e6;
  --critical: #ef4444;
  --critical-soft: #fff0f0;

  /* Sequential blue ramp - light to dark, used for level/score visuals */
  --blue-100: #dbe8ff;
  --blue-200: #b6d0ff;
  --blue-300: #8fb4fb;
  --blue-400: #5b8ff2;
  --blue-500: #2563eb;
  --blue-600: #1d4fc0;
  --blue-700: #163a8f;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 10px 30px rgba(37, 99, 235, 0.08);
  --shadow-strong: 0 18px 48px rgba(24, 65, 125, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0a0f1f;
    --bg-strong: #0f1830;
    --surface: #121a2e;
    --surface-2: #17213a;
    --text-primary: #eef3ff;
    --text-secondary: #aab8dd;
    --text-muted: #7f8cb3;
    --border: rgba(219, 232, 255, 0.14);
    --gridline: rgba(219, 232, 255, 0.10);
    --baseline: #3a466e;

    --blue: #5b8ff2;
    --blue-strong: #8fb4fb;
    --primary-soft: rgba(91, 143, 242, 0.16);
    --orange: #e07a44;
    --aqua: #33c48c;
    --yellow: #f5a940;
    --red: #f16565;

    --series-1: #5b8ff2;
    --series-2: #e07a44;
    --series-3: #33c48c;
    --series-4: #f5a940;
    --series-5: #e792b3;
    --series-6: #3ba565;
    --series-7: #9483e6;
    --series-8: #f16565;

    --good: #33c48c;
    --good-text: #33c48c;
    --good-soft: rgba(51, 196, 140, 0.14);
    --warning: #f5a940;
    --warning-soft: rgba(245, 169, 64, 0.14);
    --critical: #f16565;
    --critical-soft: rgba(241, 101, 101, 0.14);

    --blue-100: #17213a;
    --blue-200: #1d2c4d;
    --blue-300: #2c447a;
    --blue-400: #3d5fa3;
    --blue-500: #5b8ff2;
    --blue-600: #8fb4fb;
    --blue-700: #b6d0ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { min-height: 100vh; }

h1, h2, h3 { font-weight: 700; margin: 0 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 14px; color: var(--text-secondary); font-weight: 650; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
  padding: 14px 24px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
@media (prefers-color-scheme: dark) {
  .topbar { background: rgba(18,26,46,0.92); }
}
.topbar h1 { font-size: 16px; margin: 0; white-space: nowrap; font-weight: 800; }

.tabs { display: flex; gap: 4px; }
.tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
}
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--blue); color: #fff; }

.account-box { display: flex; align-items: center; gap: 10px; }
.account-email { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Dashboard ---------- */
.mono-label {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--blue-500);
}

.dash-greeting { margin-bottom: 20px; }
.dash-hello { font-size: 32px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.02em; }

.dash-level-card {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 28px 32px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-strong) 220%);
  box-shadow: var(--shadow-strong);
}

.dash-level-ring {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-500);
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.28);
  transition: background 0.3s ease;
}
.dash-level-ring-inner {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.dash-level-number { font-size: 34px; font-weight: 800; line-height: 1; color: var(--text-primary); }
.dash-level-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: var(--text-muted); margin-top: 2px; }

.dash-level-info { flex: 1 1 auto; min-width: 0; }
.dash-level-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }
.dash-level-name { font-size: 24px; font-weight: 800; margin: 0; }
.dash-level-info .hint { margin: 0 0 14px; max-width: 480px; }

.dash-delta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
  background: var(--good-soft);
  color: var(--good-text);
}
.dash-delta-chip.is-down { background: var(--critical-soft); color: var(--critical); }
.dash-delta-chip.is-empty { background: var(--surface-2); color: var(--text-muted); font-weight: 600; }

.dash-score-bar-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
  max-width: 420px;
}
.dash-score-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--blue-300), var(--blue-600));
  transition: width 0.4s ease;
}
.dash-score-text { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

.dash-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 20px 0 24px;
}
.dash-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.dash-stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.dash-stat-icon svg { width: 18px; height: 18px; }
.dash-stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.dash-stat-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dash-stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }

.dash-cta { width: 100%; padding: 16px; font-size: 15.5px; border-radius: var(--radius-sm); }

@media (max-width: 600px) {
  .dash-level-card { flex-direction: column; text-align: center; gap: 18px; padding: 26px 20px; }
  .dash-level-info .hint { max-width: none; }
  .dash-score-bar-track { max-width: none; }
  .dash-level-name-row { justify-content: center; }
}

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 85% 0%, var(--bg-strong), transparent 60%),
    radial-gradient(50% 40% at 0% 100%, var(--bg-strong), transparent 60%),
    var(--page);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  padding: 36px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.auth-card h1 { font-size: 21px; margin: 0 0 10px; }
.auth-card .btn { width: 100%; margin-top: 14px; padding: 12px 14px; font-size: 14.5px; }
.auth-error { color: var(--critical); margin-top: 12px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 24px 60px; }

.view { display: none; }
.view.active { display: block; }

.stale-banner {
  border-color: var(--yellow);
  background: var(--warning-soft);
}
.stale-banner h2 { color: var(--text-primary); }
.stale-banner-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stale-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  padding: 4px 0;
}
.stale-days { color: var(--text-muted); font-size: 12px; }
.stale-banner-total { margin: 8px 0 0; font-weight: 600; }

.date-nav-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
}
.date-nav-label { font-size: 14.5px; font-weight: 700; min-width: 220px; text-align: center; }

.today-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.main-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.side-col { position: sticky; top: 76px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card:last-child { margin-bottom: 0; }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.hint { color: var(--text-muted); font-size: 12.5px; }

.count-badge {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* Form */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.form-row:last-child { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); flex: 1 1 160px; }
.field-wide { flex: 1 1 100%; }
.field-narrow { flex: 0 1 110px; }
.field-btn { flex: 0 0 auto; justify-content: flex-end; }
.field input, .field select {
  font: inherit;
  font-size: 14px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
}
.field input:focus, .field select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

.btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s ease, background 0.12s ease;
}
.btn:hover { filter: brightness(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-strong); filter: none; }
.btn-start { background: var(--good); border-color: var(--good); color: #fff; }
.btn-stop { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-pause { background: var(--yellow); border-color: var(--yellow); color: #1a1a19; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-sm { min-height: 32px; padding: 6px 12px; font-size: 12.5px; }

/* Task list */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--gridline);
}
.task-item:last-child { border-bottom: none; }
.task-item.dragging { opacity: 0.4; }
.task-item.active-task { background: var(--good-soft); }
.task-item.paused-task { background: var(--warning-soft); }
.chip-paused { background: var(--yellow); color: #1a1a19; font-weight: 700; }

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0 2px;
  user-select: none;
}

.task-body { flex: 1 1 auto; min-width: 0; }
.task-title { font-size: 14.5px; font-weight: 650; margin-bottom: 3px; word-break: break-word; }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-secondary);
  white-space: nowrap;
}
.chip-est { color: var(--text-muted); }

.task-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.task-actions .btn { min-width: 88px; text-align: center; }

.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 700;
  color: var(--good-text);
  min-width: 64px;
  text-align: right;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
}
.timer-display:hover { background: color-mix(in srgb, var(--good) 12%, transparent); }
.timer-display.timer-paused { color: var(--text-secondary); }
.timer-display.timer-paused:hover { background: var(--surface-2); }

.delta-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}
.delta-over { background: var(--critical-soft); color: var(--critical); }
.delta-under { background: var(--good-soft); color: var(--good-text); }
.delta-onpar { background: var(--surface-2); color: var(--text-secondary); }
.delta-notcompleted { background: var(--warning-soft); color: var(--text-primary); }

.done-list .task-title { color: var(--text-secondary); }

.done-item { align-items: stretch; border-bottom: none; padding: 0 8px; }
.done-time-col { display: flex; flex-direction: column; align-items: center; width: 44px; flex-shrink: 0; padding-top: 12px; }
.done-time { font-size: 11.5px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.done-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.done-line { flex: 1; width: 2px; background: var(--gridline); margin-top: 4px; min-height: 12px; }
.done-item .task-body { padding: 12px 0 16px; }
.done-intervals { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.done-item .task-actions { padding-top: 12px; }

.done-summary {
  border-top: 1px solid var(--gridline);
  margin-top: 10px;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.done-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.done-summary-row strong { font-variant-numeric: tabular-nums; color: var(--text-primary); }

.empty-hint { color: var(--text-muted); font-size: 13px; padding: 6px 2px; }

/* Edit form inline */
.edit-form { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; }
.edit-form .form-row { margin-bottom: 0; }

/* Postpone (ikke rukket) form inline */
.postpone-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.postpone-form .form-row { margin-bottom: 0; align-items: flex-end; }
.postpone-hint { margin: 0; }

/* Edit actual start/end time inline (done tasks) */
.edit-time-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.edit-time-form .form-row { margin-bottom: 0; }
.edit-time-form .hint { margin: 0; }
.edit-time-form input[type="datetime-local"] { min-width: 190px; }
.edit-time-rows { display: flex; flex-direction: column; gap: 8px; }
.edit-time-row { display: flex; gap: 12px; align-items: flex-end; }
.edit-time-row .btn-icon { flex-shrink: 0; margin-bottom: 1px; }

/* Day plan */
.capacity-block { margin-bottom: 10px; }

.segbar-label { font-size: 11px; color: var(--text-muted); margin: 0 0 3px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.segbar-track {
  height: 16px;
  border-radius: 6px;
  background: var(--surface-2);
  overflow: visible;
  position: relative;
  display: flex;
  margin-bottom: 10px;
}
.segbar-track:last-of-type { margin-bottom: 0; }
.segbar-segment {
  height: 100%;
  min-width: 2px;
  box-sizing: border-box;
  border-right: 2px solid var(--surface);
}
.segbar-segment:last-child { border-right: none; }
.segbar-segment:first-child { border-radius: 6px 0 0 6px; }
.segbar-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 0;
  border-left: 2px dashed var(--critical);
}
.segbar-marker-label {
  position: absolute;
  top: -16px;
  font-size: 10px;
  color: var(--critical);
  white-space: nowrap;
  transform: translateX(-100%);
  padding-right: 3px;
}

.capacity-text { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0 0; font-variant-numeric: tabular-nums; }

.capacity-warning {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--critical);
  background: var(--critical-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 8px 0 0;
}

.day-start-text { font-size: 12.5px; color: var(--text-muted); margin: 0 0 8px; }

.today-delta-text { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 14px; font-variant-numeric: tabular-nums; }
.today-delta-text .over { color: var(--critical); font-weight: 700; }
.today-delta-text .under { color: var(--good-text); font-weight: 700; }

.task-color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
}

.timeline-heading { margin: 0 0 8px; }
.timeline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 480px; overflow-y: auto; }
.timeline-item { display: flex; gap: 10px; font-size: 12.5px; padding-bottom: 8px; border-bottom: 1px dashed var(--gridline); }
.timeline-item:last-child { border-bottom: none; }
.timeline-time { flex: 0 0 78px; color: var(--text-muted); font-variant-numeric: tabular-nums; line-height: 1.4; }
.timeline-body { flex: 1 1 auto; min-width: 0; }
.timeline-title { font-weight: 600; margin-bottom: 2px; word-break: break-word; }
.timeline-title.is-done { color: var(--text-muted); text-decoration: line-through; }
.timeline-title.is-active { color: var(--good-text); }
.timeline-title.is-overtime { color: var(--critical); }

.timeline-item.timeline-gap { opacity: 0.7; }
.timeline-title.is-gap { font-weight: 400; font-style: italic; color: var(--text-muted); }

.timeline-item-overtime { background: var(--critical-soft); border-radius: var(--radius-sm); margin: 0 -6px; padding: 0 6px 8px; }

.timeline-overtime-marker {
  list-style: none;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--critical);
  border-top: 1px dashed var(--critical);
  padding-top: 6px;
  margin-top: -2px;
}
.timeline-actual { color: var(--text-muted); }

/* ---------- Persistent active-timer sidebar card ---------- */
.active-timer-card { text-align: center; }
.active-timer-title { font-size: 15px; font-weight: 700; margin: 6px 0 14px; color: var(--text-primary); word-break: break-word; }
.active-timer-ring-wrap { position: relative; width: 150px; height: 150px; margin: 0 auto 14px; }
.active-timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.active-timer-ring-track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.active-timer-ring-fill {
  fill: none; stroke: var(--blue); stroke-width: 10; stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease, stroke 0.3s ease;
}
.active-timer-ring-fill.is-warning { stroke: var(--yellow); }
.active-timer-ring-fill.is-critical { stroke: var(--critical); }
.active-timer-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.active-timer-time { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.active-timer-estimate { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.active-timer-over { font-size: 12px; font-weight: 700; color: var(--critical); margin-bottom: 12px; }
.active-timer-controls { display: flex; gap: 8px; }
.active-timer-controls .btn { flex: 1 1 0; }

@media (max-width: 860px) {
  .active-timer-card { display: none !important; }
}

/* ---------- Mobile sticky active-task bar ---------- */
.mobile-active-bar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 14px; align-items: center; gap: 10px;
  box-shadow: 0 -6px 20px rgba(11,22,63,0.14);
}
@media (max-width: 860px) {
  .mobile-active-bar:not([hidden]) { display: flex; }
  body:has(.mobile-active-bar:not([hidden])) main { padding-bottom: 88px; }
}
.mobile-active-info { flex: 1 1 auto; min-width: 0; cursor: pointer; }
.mobile-active-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-active-time { font-size: 12.5px; color: var(--good-text); font-variant-numeric: tabular-nums; }

/* ---------- Compact + expandable timer ---------- */
.timer-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 22, 63, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.timer-modal {
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-strong);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  position: relative;
}
.timer-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-modal-title { font-size: 16px; font-weight: 700; margin: 4px 0 4px; padding-right: 24px; }
.timer-modal-meta { font-size: 12.5px; color: var(--text-muted); margin-bottom: 18px; }
.timer-modal-ring-wrap { position: relative; width: 220px; height: 220px; margin: 0 auto 22px; }
.timer-modal-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-modal-ring-track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.timer-modal-ring-fill {
  fill: none;
  stroke: var(--blue);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease, stroke 0.3s ease;
}
.timer-modal-ring-fill.is-warning { stroke: var(--yellow); }
.timer-modal-ring-fill.is-critical { stroke: var(--critical); }
.timer-modal-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.timer-modal-time { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.timer-modal-estimate { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.timer-modal-controls { display: flex; gap: 10px; }
.timer-modal-controls .btn { flex: 1 1 0; min-height: 46px; }

/* Stats */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-tile .stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.stat-tile .stat-value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-tile .stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.stats-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--gridline); font-variant-numeric: tabular-nums; }
th { color: var(--text-muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
td:first-child, th:first-child { font-variant-numeric: normal; }

.chart-wrap { overflow-x: auto; }
.chart-wrap svg { display: block; }
.bar-value-label { font-size: 10px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.bar-axis-label { font-size: 10.5px; fill: var(--text-muted); }
.trend-bar { fill: var(--blue); }
.trend-baseline { stroke: var(--baseline); stroke-width: 1; }

.reorder-btns { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.btn-icon {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  width: 24px; height: 20px;
  border-radius: 6px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.btn-icon:hover { filter: brightness(0.95); }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Settings ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}
.settings-grid .card { margin-bottom: 0; }
.settings-grid .card-wide { grid-column: 1 / -1; }

.profile-row { display: flex; align-items: center; gap: 14px; }
.profile-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; flex-shrink: 0;
}
.profile-name { font-size: 15px; font-weight: 700; }
.profile-email { font-size: 13px; color: var(--text-muted); }

.danger-zone {
  border-color: var(--critical);
  background: var(--critical-soft);
}
.danger-zone h2 { color: var(--critical); }

.tag-manage-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.tag-manage-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 4px 6px 4px 12px;
  font-size: 13px;
  font-weight: 600;
}
.tag-remove {
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 13px; width: 20px; height: 20px; border-radius: var(--radius-pill);
  display: flex; align-items: center; justify-content: center;
}
.tag-remove:hover { background: var(--border); color: var(--critical); }

@media (max-width: 860px) {
  .today-grid { grid-template-columns: 1fr; }
  .side-col { position: static; }
  .stats-tables { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  main { padding: 12px 12px 40px; }
  .card { padding: 16px 16px; }

  .topbar { padding: 10px 12px; }
  .topbar h1 { font-size: 13.5px; white-space: normal; line-height: 1.25; flex: 1 1 auto; }
  .account-email { display: none; }
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .tab { flex: 1 1 auto; padding: 8px 6px; font-size: 12.5px; text-align: center; }

  .date-nav-card { padding: 8px 10px; gap: 8px; }
  .date-nav-label { min-width: 0; flex: 1 1 auto; font-size: 12.5px; }

  .task-item { flex-wrap: wrap; row-gap: 8px; }
  .task-body { flex-basis: 100%; order: 1; }
  .reorder-btns { order: 0; }
  .drag-handle { order: 0; }
  .task-actions { order: 2; flex-basis: 100%; flex-wrap: wrap; }
  .task-actions .btn { min-width: 0; flex: 1 1 auto; }
  .timer-display { flex: 0 0 auto; }

  .edit-time-row { flex-wrap: wrap; }
  .edit-time-form input[type="datetime-local"] { min-width: 0; width: 100%; }

  /* Done timeline keeps its single-row layout (time rail + content) on
     mobile too - wrapping it would break the connecting line. */
  .done-item { flex-wrap: nowrap; gap: 8px; }
  .done-time-col { width: 36px; }
  .done-item .task-actions { flex-direction: column; align-items: stretch; flex-basis: auto; }
  .done-item .task-actions .btn { width: 100%; }

  .form-row { gap: 8px; }
  .field-narrow { flex-basis: 90px; }

  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
  .auth-card { padding: 28px 22px; }

  .timer-modal-ring-wrap { width: 180px; height: 180px; }
  .timer-modal-time { font-size: 28px; }
}
