:root {
  color-scheme: light;
  --brand: #420e35;
  --bg: #f7f4f6;
  --surface: #ffffff;
  --surface-2: #f4eef2;
  --border: #e8dfe5;
  --text: #1d0a18;
  --text-2: #5a4a55;
  --muted: #84737e;
  --accent: #6b2059;
  --accent-soft: #f3e6ef;
  --track: #eee5eb;
  --good: #1f7a3a;
  --warn-bg: #fff6e0;
  --warn-text: #6b4a00;
  --grid: #eee5eb;
  --critical: #b42318;
  --critical-soft: #fdecea;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #420e35;
    --bg: #140910;
    --surface: #1e1019;
    --surface-2: #2a1723;
    --border: #36202e;
    --text: #f5eef2;
    --text-2: #cdbcc6;
    --muted: #9a8692;
    --accent: #d08ac0;
    --accent-soft: #3a1932;
    --track: #2f1a28;
    --good: #4cc274;
    --warn-bg: #3a2f12;
    --warn-text: #f3d48a;
    --grid: #2f1a28;
  --critical: #f97066;
  --critical-soft: #3d1715;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #420e35;
  --bg: #140910;
  --surface: #1e1019;
  --surface-2: #2a1723;
  --border: #36202e;
  --text: #f5eef2;
  --text-2: #cdbcc6;
  --muted: #9a8692;
  --accent: #d08ac0;
  --accent-soft: #3a1932;
  --track: #2f1a28;
  --good: #4cc274;
  --warn-bg: #3a2f12;
  --warn-text: #f3d48a;
  --grid: #2f1a28;
  --critical: #f97066;
  --critical-soft: #3d1715;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-family: Kanit, Inter, system-ui, sans-serif; font-size: 34px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.01em; line-height: 1.05; }
h2 { font-family: Kanit, Inter, system-ui, sans-serif; font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
section { margin-top: 20px; }

.top { background: var(--brand); color: #fff; }
.logo { display: block; height: 30px; width: auto; margin-bottom: 18px; }
.top-inner { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding-top: 28px; padding-bottom: 22px; flex-wrap: wrap; }
.byline { color: rgba(255,255,255,0.78); font-size: 15px; margin-top: 4px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,0.6); padding: 6px 12px; border-radius: 999px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.5); }
.live.ok .dot { background: #7be39b; box-shadow: 0 0 0 0 var(--good); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 50%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.notice { margin-top: 20px; background: var(--warn-bg); color: var(--warn-text); border-radius: 10px; padding: 10px 14px; font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.card-head, .section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.goal { border-left: 4px solid var(--accent); padding: 24px; }
.goal-headline { font-size: 22px; font-weight: 600; line-height: 1.35; margin: 8px 0 0; text-wrap: balance; }
.goal-detail { color: var(--text-2); margin: 8px 0 0; max-width: 70ch; }
.goal-detail:empty { display: none; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.tile .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.tile .value .unit { font-size: 15px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.tile .sub { font-size: 13px; color: var(--text-2); }
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

.weekly svg { display: block; width: 100%; height: 200px; overflow: visible; }
.weekly .axis-text { fill: var(--muted); font-size: 11px; }
.weekly .gridline { stroke: var(--grid); stroke-width: 1; }
.weekly .bar { fill: var(--accent); }
.weekly .bar.dim { opacity: 0.45; }
.weekly .hit { fill: transparent; cursor: default; }

.table-view { margin-top: 10px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--text-2); }
.table-view table { margin-top: 8px; border-collapse: collapse; }
.table-view td, .table-view th { padding: 3px 14px 3px 0; text-align: left; font-variant-numeric: tabular-nums; }

.projects { display: grid; gap: 14px; }
.project { padding: 0; overflow: hidden; }
.project-top { display: flex; align-items: stretch; }
.project-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; text-align: left; background: none; border: 0; color: inherit; font: inherit; padding: 18px 20px; cursor: pointer; }
.project-toggle:hover { background: var(--surface-2); }
.project-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.prio { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.project-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.project-name { font-size: 17px; font-weight: 600; }
.project-desc { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.project-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.project-hours { flex: none; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.project-hours strong { font-size: 22px; color: var(--text); }
.chev { flex: none; color: var(--muted); transition: transform 0.15s ease; }
.project.open .chev { transform: rotate(90deg); }
.project .budget { margin: 0 20px 16px 62px; }
.project-body { padding: 4px 20px 18px 62px; border-top: 1px solid var(--border); }
.sub-head { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 0 4px; }
.reorder { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding-left: 12px; }
.icon-btn { width: 28px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 14px; line-height: 1; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.edit-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.btn { border: 1px solid var(--accent); background: transparent; color: var(--accent); font: inherit; font-weight: 600; border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.link-btn { background: none; border: 0; padding: 8px 0 0; color: var(--accent); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.activity li:last-child { border-bottom: 0; }
.a-date { color: var(--text-2); white-space: nowrap; }
.a-main { display: flex; flex-direction: column; min-width: 0; }
.a-task { font-weight: 500; }
.a-notes { color: var(--text-2); font-size: 13px; }
.a-hours { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 560px) {
  .project-toggle { padding: 16px; gap: 10px; }
  .project .budget { margin: 0 16px 14px; }
  .project-body { padding: 4px 16px 16px; }
}
.pill { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); margin-left: 8px; vertical-align: middle; }
.budget { margin-top: 14px; }
.budget-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.track { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; background: var(--accent); border-radius: 4px; }

.running { color: var(--good); font-weight: 600; font-size: 12px; }
.empty { color: var(--muted); padding: 12px 0; }

.tooltip { position: fixed; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 6px; white-space: nowrap; z-index: 10; transform: translate(-50%, calc(-100% - 10px)); }

main { padding-bottom: 40px; }

/* to-dos & upcoming */
.sub-head-row { display: flex; justify-content: space-between; align-items: baseline; }
.sub-head-row .link-btn { padding: 0; }
.todos { list-style: none; margin: 0; padding: 0; }
.todo { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.todos .todo:last-child { border-bottom: 0; }
.todo-check { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; cursor: pointer; }
.todo-status { flex: none; width: 14px; height: 14px; margin-top: 3px; border: 1.5px solid var(--muted); border-radius: 4px; }
.todo-status.done { background: var(--accent); border-color: var(--accent); }
.todo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.todo-title { font-weight: 500; text-align: left; }
.as-link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.as-link:hover { text-decoration: underline; }
.todo-sub { color: var(--muted); font-size: 13px; }
.todo-notes { color: var(--text-2); font-size: 13px; }
.is-done .todo-title { text-decoration: line-through; color: var(--muted); }
.due { flex: none; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 2px 9px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.due.overdue { color: var(--critical); background: var(--critical-soft); }
.due.today { color: var(--accent); background: var(--accent-soft); }
.up-group + .up-group { margin-top: 6px; }
.up-group .sub-head { margin-top: 8px; }

.dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 22px; width: min(520px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(20, 9, 16, 0.55); }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); flex: 1; }
.dialog input:not([type=checkbox]), .dialog select, .dialog textarea { font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.dialog input:focus, .dialog select:focus, .dialog textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field-row { display: flex; gap: 12px; }
@media (max-width: 480px) { .field-row { flex-direction: column; } }
.check-row { flex-direction: row !important; align-items: center; gap: 8px !important; }
.form-error { color: var(--critical); font-size: 13px; min-height: 1em; }
.dialog-actions { display: flex; gap: 8px; align-items: center; }
.dialog-actions .spacer { flex: 1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.ghost { border-color: var(--border); color: var(--text); }
.btn.danger { border-color: transparent; color: var(--critical); padding-left: 0; }
