:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #16191f;
  --text-2: #4a5160;
  --muted: #6f7787;
  --accent: #1f5fd1;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --warn: #b45309;
  --warn-soft: #fdf0dc;
  --ok: #0f8a4f;
  --bad: #b91c1c;
  --today: #fff8e1;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-lg: 0 12px 40px rgb(16 24 40 / 22%);
  --proj-l: 58%;
  --proj-c: 0.15;
  --radius: 10px;
  --sidebar-w: 320px;
  --topbar-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --border: #2a3039;
    --border-strong: #3a424e;
    --text: #e8ebf0;
    --text-2: #b6bdc9;
    --muted: #8c95a4;
    --accent: #6ea1ff;
    --accent-ink: #0b1220;
    --accent-soft: #1b2a45;
    --warn: #f0a648;
    --warn-soft: #3a2a12;
    --ok: #3ccf8a;
    --bad: #f87171;
    --today: #262214;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-lg: 0 12px 40px rgb(0 0 0 / 60%);
    --proj-l: 72%;
    --proj-c: 0.13;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
mark { background: color-mix(in oklch, var(--accent) 25%, transparent); color: inherit; border-radius: 2px; }

/* project color: set --h (hue) inline */
.dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: oklch(var(--proj-l) var(--proj-c) var(--h, 250));
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; text-decoration: none; color: var(--text); font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.icon { width: 36px; padding: 0; font-size: 22px; line-height: 1; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn svg.icon-stroke { fill: none; stroke: currentColor; stroke-width: 1.5; }
.btn:focus-visible, .pill:focus-visible, .mday:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.linkish:hover { text-decoration: underline; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */
.field { display: grid; gap: 4px; margin-bottom: 12px; font-size: 13px; color: var(--text-2); font-weight: 550; }
.field input, .field select, .field textarea, .input {
  height: 38px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); font-size: 15px; font-weight: 400; color: var(--text); width: 100%;
}
.field textarea { height: auto; padding: 8px 10px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field small { font-weight: 400; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); cursor: pointer; margin-bottom: 12px; }
.form-error { color: var(--bad); font-size: 14px; margin: 0 0 12px; }
.form-error:empty { display: none; }
.form-ok { color: var(--ok); font-size: 14px; margin: 0 0 12px; }
.form-ok:empty { display: none; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.form-actions .left { margin-right: auto; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 60px;
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
/* Sized so the search box lines up with the main column: padding + toggle + 2 gaps. */
.brand { display: flex; align-items: center; gap: 10px; width: calc(var(--sidebar-w) - 84px); flex: none; }
.org-btn { gap: 6px; }
.org-btn h1 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-btn .caret { flex: none; color: var(--muted); font-size: 12px; }
.brand h1 { margin: 0; font-size: 16px; letter-spacing: -0.01em; line-height: 1.1; }
.brand .sub { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-btn { border: 0; background: transparent; padding: 4px 8px 4px 4px; margin-left: -4px; border-radius: 8px; cursor: pointer; text-align: left; min-width: 0; }
.org-btn:hover { background: var(--surface-2); }
.org-btn > div { min-width: 0; }
.org-btn .sub { color: var(--text-2); }
.menu {
  position: fixed; z-index: 60; min-width: 260px; max-width: calc(100vw - 16px); padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg);
}
.menu button {
  display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px;
  background: transparent; text-align: left; cursor: pointer; font-weight: 500;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu small { color: var(--muted); font-size: 12px; font-weight: 400; }
.menu .check { flex: none; width: 14px; color: var(--accent); font-weight: 700; }
.menu button[aria-checked="true"] .name { font-weight: 650; }
.menu-label { padding: 4px 10px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; }
.menu-sep { height: 1px; margin: 6px 0; background: var(--border); }
.search { flex: 1; max-width: 420px; position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; width: 18px; height: 18px; fill: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 36px;
  border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface-2);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.views {
  display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px;
}
.views button {
  border: 0; background: transparent; padding: 0 14px; height: 30px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--text-2);
}
.views button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.top-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.filters-toggle { display: none; }
.sidebar-toggle { position: relative; flex: none; }
.sidebar-toggle .pill-count { display: none; position: absolute; top: 0; right: -4px; }
.pill-count:not(:empty) {
  background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; padding: 0 6px; line-height: 18px;
}
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.me-btn { padding: 0 8px 0 4px; }
.me-btn .who { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border); padding: 8px 16px 16px;
  display: flex; flex-direction: column; /* so the footer sits at the bottom */
}
.sidebar > * { flex-shrink: 0; }
.sidebar-head { display: none; }
.scrim { display: none; }
.sidebar-clear { display: flex; justify-content: flex-end; padding: 8px 0 0; }
.panel { padding: 12px 0; border-bottom: 1px solid var(--border); }
.panel:last-of-type { border-bottom: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel h3 {
  margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650;
  display: inline-block;
}
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.mini-search {
  width: 100%; height: 32px; padding: 0 10px; margin-bottom: 8px;
  border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface-2); font-size: 14px;
}
.mini-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  cursor: pointer; font-size: 14px; color: var(--text-2);
}
.pill:hover { background: var(--surface-2); }
.pill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 550; }
.custom-range { display: flex; gap: 8px; margin-top: 10px; }
.custom-range label { flex: 1; font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.custom-range input { height: 32px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface-2); padding: 0 6px; }

/* my chargeables */
.my-list { display: flex; flex-direction: column; gap: 6px; }
.chip {
  display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  border-left: 4px solid oklch(var(--proj-l) var(--proj-c) var(--h));
}
.chip.on { border-color: var(--accent); border-left-color: oklch(var(--proj-l) var(--proj-c) var(--h)); background: var(--accent-soft); }
.chip button:first-child {
  flex: 1; text-align: left; border: 0; background: transparent; padding: 6px 10px; cursor: pointer; display: grid; line-height: 1.25; min-width: 0;
}
.chip button:first-child:hover { background: var(--surface-2); }
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .hrs { align-self: center; padding: 0 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip .unstar { border: 0; background: transparent; width: 32px; cursor: pointer; color: var(--muted); font-size: 18px; }
.chip .unstar:hover { color: var(--text); background: var(--surface-2); }

/* project / chargeable tree */
.tree ul { list-style: none; margin: 0; padding: 0; }
.proj-line, .charge-row { display: flex; align-items: center; }
.caret {
  width: 22px; height: 28px; border: 0; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 12px; flex: none; transition: transform 0.12s;
}
.proj-row.open > .proj-line .caret { transform: rotate(90deg); }
.tree label, .checklist label {
  flex: 1; display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 2px 6px; border-radius: 6px; cursor: pointer; min-width: 0;
}
.tree label:hover, .checklist label:hover { background: var(--surface-2); }
.tree .name, .checklist .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.tree .client { color: var(--muted); font-size: 12px; }
.tree .n, .checklist .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tree .archived .name { color: var(--muted); text-decoration: line-through; }
.charges { display: none; padding-left: 22px !important; }
.proj-row.open .charges { display: block; }
.charge-row.implied label { opacity: 0.7; }
.charges .add { padding: 2px 6px 6px; }
.star, .more-btn {
  border: 0; background: transparent; cursor: pointer; width: 28px; height: 28px; font-size: 16px; color: var(--muted); flex: none; border-radius: 6px;
}
.star:hover, .more-btn:hover { background: var(--surface-2); color: var(--text); }
.star.on { color: #e3a008; }
.more-btn { opacity: 0; font-size: 14px; letter-spacing: 1px; }
.proj-line:hover .more-btn, .charge-row:hover .more-btn, .more-btn:focus-visible { opacity: 1; }
@media (hover: none) { .more-btn { opacity: 1; } }
.checklist { max-height: 320px; overflow-y: auto; }

.sidebar-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: auto; padding-top: 14px; font-size: 13px; color: var(--muted); }
.app-name { flex-basis: 100%; display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; opacity: 0.75; }

/* ---------- main ---------- */
.main { min-width: 0; padding: 0 24px 48px; }
.toolbar {
  position: sticky; top: var(--topbar-h); z-index: 10; background: var(--bg);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 0 10px;
}
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav h2 { margin: 0 0 0 8px; font-size: 20px; letter-spacing: -0.01em; white-space: nowrap; }
.toolbar-actions { display: flex; gap: 6px; }
.result-count { color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; }
.result-count b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.banner { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.banner.editing-other { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text); }
.banner.editing-other .btn { margin-left: auto; }
.as-picker { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.as-picker select { width: auto; max-width: 220px; height: 36px; font-weight: 550; }
.as-picker.other select { border-color: var(--warn); background: var(--warn-soft); }

.loading, .empty-state { text-align: center; padding: 80px 20px; color: var(--text-2); }
.empty-state .big { font-size: 44px; }
.empty-state .row { justify-content: center; margin-top: 12px; }
.spinner {
  width: 28px; height: 28px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- entry rows (Day and List) ---------- */
.day { margin-bottom: 18px; scroll-margin-top: calc(var(--topbar-h) + var(--toolbar-h, 58px)); }
.day-head {
  position: sticky; top: calc(var(--topbar-h) + var(--toolbar-h, 58px)); z-index: 5;
  display: flex; align-items: baseline; gap: 10px; margin: 0; padding: 8px 2px 6px;
  font-size: 15px; background: var(--bg);
}
.day-head a { color: inherit; text-decoration: none; }
.day-head a:hover { color: var(--accent); }
.day-head .rel { font-size: 12px; font-weight: 650; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.day-head .n { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.entries { display: grid; gap: 6px; }

.entry {
  display: grid; grid-template-columns: minmax(150px, 230px) 76px 1fr 22px; gap: 12px; align-items: start;
  padding: 8px 10px 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  border-left: 5px solid oklch(var(--proj-l) var(--proj-c) var(--h)); box-shadow: var(--shadow);
}
.entry:focus-within { border-color: var(--border-strong); border-left-color: oklch(var(--proj-l) var(--proj-c) var(--h)); }
.entry.blank { background: color-mix(in srgb, var(--surface) 70%, var(--bg)); box-shadow: none; }
.entry-what { display: grid; line-height: 1.25; padding-top: 6px; min-width: 0; }
.entry-what b { font-weight: 600; overflow-wrap: anywhere; }
.entry-what small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-what small.edited, .memo-bar .edited { color: var(--warn); }
.hours, .memo {
  border: 1px solid transparent; border-radius: 7px; background: var(--surface-2); color: var(--text);
}
.hours {
  width: 100%; height: 36px; padding: 0 8px; text-align: right; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.memo { width: 100%; min-height: 36px; padding: 7px 10px; resize: none; overflow: hidden; line-height: 1.4; font-size: 14.5px; }
.hours:hover, .memo:hover { border-color: var(--border-strong); }
.hours:focus, .memo:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.hours::placeholder, .memo::placeholder { color: var(--muted); font-weight: 400; }
.invalid, .invalid:focus { outline: 2px solid var(--bad) !important; outline-offset: -1px; }
.save-state { width: 22px; height: 36px; display: grid; place-items: center; font-size: 13px; color: var(--muted); }
.save-state.saving::after { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.save-state.saved::after { content: "✓"; color: var(--ok); font-weight: 700; }
.save-state.error::after { content: "!"; color: #fff; background: var(--bad); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.save-error { grid-column: 2 / -1; color: var(--bad); font-size: 13px; margin-top: -4px; }
.save-error:empty { display: none; }

.adder {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 10px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.adder input { flex: 1; min-width: 200px; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); }
.adder input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.day-total {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 10px; padding: 12px 4px 0; color: var(--text-2);
}
.day-total b { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--text); }
.kbd-hint { font-size: 12px; color: var(--muted); margin-top: 10px; }
kbd { font: 11px/1 ui-monospace, monospace; padding: 2px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); }

/* ---------- week: timesheet grid ---------- */
.sheet-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.sheet { width: 100%; border-collapse: collapse; min-width: 640px; }
.sheet th, .sheet td { border-bottom: 1px solid var(--border); padding: 0; }
.sheet thead th {
  padding: 8px 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--surface-2); text-align: center; white-space: nowrap;
}
.sheet thead th a { color: inherit; text-decoration: none; display: grid; line-height: 1.15; }
.sheet thead th a:hover { color: var(--accent); }
.sheet thead th .num { font-size: 17px; color: var(--text); letter-spacing: 0; }
.sheet thead th.is-today { background: var(--accent); color: var(--accent-ink); }
.sheet thead th.is-today .num { color: var(--accent-ink); }
.sheet thead th:first-child { text-align: left; padding-left: 14px; }
.sheet .what {
  text-align: left; padding: 6px 10px 6px 12px; font-weight: 400; min-width: 150px; max-width: 260px;
  border-left: 5px solid oklch(var(--proj-l) var(--proj-c) var(--h));
}
.sheet .what b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .what small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet td.cell { position: relative; width: 11%; border-left: 1px solid var(--border); }
.sheet td.weekend { background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); }
.sheet td.today-col { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.sheet .cell input {
  width: 100%; height: 44px; border: 0; background: transparent; text-align: center;
  font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text);
}
.sheet .cell input::placeholder { color: color-mix(in oklch, var(--muted) 45%, transparent); font-weight: 400; }
.sheet .cell input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
.sheet .cell.active input { outline: 2px solid var(--accent); outline-offset: -2px; }
.sheet .cell .memo-dot {
  position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); pointer-events: none;
}
.sheet .cell .save-state { position: absolute; bottom: 2px; right: 2px; width: 14px; height: 14px; font-size: 10px; }
.sheet .cell .save-state.saved::after { font-size: 10px; }
.sheet .cell .save-state.saving::after { width: 8px; height: 8px; }
.sheet .cell .save-state.error::after { width: 12px; height: 12px; font-size: 9px; }
.sheet .tot { text-align: right; padding: 0 12px; font-weight: 650; font-variant-numeric: tabular-nums; border-left: 1px solid var(--border); white-space: nowrap; }
.sheet tfoot td, .sheet tfoot th { border-bottom: 0; background: var(--surface-2); padding: 10px 6px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.sheet tfoot th { text-align: left; padding-left: 17px; }
.sheet tfoot .tot { text-align: right; padding: 10px 12px; font-size: 17px; }
.sheet tr.empty-row td { padding: 24px; text-align: center; color: var(--muted); }

.memo-bar {
  position: sticky; bottom: 0; z-index: 6; margin-top: 10px; padding: 10px 12px 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  border-left: 5px solid oklch(var(--proj-l) var(--proj-c) var(--h, 250));
}
.memo-bar .label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 6px; font-size: 13px; color: var(--text-2); }
.memo-bar .label b { color: var(--text); }
.memo-bar .label .save-state { width: auto; height: auto; margin-left: auto; }
.memo-bar .memo { min-height: 56px; background: var(--surface-2); }
.memo-bar.idle { opacity: 0.6; }

/* ---------- month ---------- */
.month { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.mhead, .mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 72px; }
.mhead { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.mhead div { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mhead div:last-child, .mweek { text-align: right; }
.mday {
  min-height: 112px; padding: 4px 5px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; text-align: left; background: transparent;
  border-top: 0; border-left: 0; font: inherit; color: inherit;
}
.mday:hover { background: var(--surface-2); }
.mday.out { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.mday.out .mnum { color: var(--muted); }
.mday.weekend:not(.out) { background: color-mix(in srgb, var(--surface-2) 35%, var(--surface)); }
.mday.is-today { background: var(--today); }
.mday.is-today .mnum span:first-child { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; }
.mnum { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; padding: 1px 2px 3px; }
.mnum .n { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mev {
  font-size: 11.5px; line-height: 1.3; padding: 1px 5px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid oklch(var(--proj-l) var(--proj-c) var(--h));
  background: color-mix(in oklch, oklch(var(--proj-l) var(--proj-c) var(--h)) 14%, transparent);
}
.mev .t { font-weight: 650; font-variant-numeric: tabular-nums; }
.more { font-size: 11.5px; color: var(--accent); padding: 0 5px; font-weight: 550; }
.mweek {
  padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px;
}
.mweek small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }

/* ---------- reports ---------- */
.report {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 26px 26px; margin-bottom: 18px; border-top: 5px solid oklch(var(--proj-l) var(--proj-c) var(--h));
}
.report header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 24px; margin-bottom: 16px; }
.report h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.report .meta { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.report .grand { text-align: right; }
.report .grand b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.report .grand span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.report h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.report h4 { display: flex; justify-content: space-between; margin: 16px 0 6px; font-size: 15px; }
.report h4 span { font-variant-numeric: tabular-nums; }
.summaries { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 28px; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th, .rtable td { padding: 5px 8px 5px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.rtable th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; }
.rtable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 0; }
.rtable .date { white-space: nowrap; color: var(--text-2); width: 92px; }
.rtable .charge { width: 24%; }
.rtable .memo-text { white-space: pre-wrap; color: var(--text-2); }
.rtable .num + td, .rtable .num + th { padding-left: 18px; }
.rtable tfoot td { font-weight: 700; border-bottom: 0; }
.report h4 small { font-weight: 400; color: var(--muted); font-size: 13px; }
.rgroup { margin-top: 6px; }
.rgroup h4 { padding-top: 10px; border-top: 2px solid oklch(var(--proj-l) var(--proj-c) var(--h)); }
.rtable .charge .dot { width: 8px; height: 8px; margin-right: 2px; }
.open-report { margin-left: 8px; font-size: 13px; text-decoration: none; white-space: nowrap; }
.open-report:hover { text-decoration: underline; }
.print-only { display: none; }
.bar { height: 6px; border-radius: 3px; background: oklch(var(--proj-l) var(--proj-c) var(--h)); margin-top: 3px; }

/* ---------- dialog ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog.wide { width: min(820px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(10 14 20 / 45%); }
#dialog-body { padding: 14px 20px 20px; }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.dialog-top h2 { margin: 0; font-size: 18px; }
.dialog section { padding: 14px 0; border-top: 1px solid var(--border); }
.dialog section:first-of-type { border-top: 0; padding-top: 0; }
.dialog section h3 { margin: 0 0 10px; font-size: 15px; }
.toolbar-actions { flex-wrap: wrap; align-items: center; }
.report-project { width: auto; max-width: 260px; height: 36px; font-weight: 550; }
.seg .lbl { align-self: center; padding: 0 6px 0 8px; font-size: 12px; color: var(--muted); }
.seg button:disabled { opacity: 0.4; cursor: default; }
.setting-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; font-size: 14px; }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 14px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--text-2); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.copy { display: flex; gap: 6px; margin-top: 8px; }
.copy input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.key-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 10px; }
.key-form .form-error { grid-column: 1 / -1; margin: 0; }
.keys td { vertical-align: middle; }
.keys .muted { font-size: 12px; }
code { font: 12.5px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; }
.new-key-note { margin: 14px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); font-size: 14px; }
@media (max-width: 480px) { .key-form { grid-template-columns: 1fr 1fr; } .key-form .input:first-child { grid-column: 1 / -1; } }
.people { width: 100%; border-collapse: collapse; font-size: 14px; }
.people th, .people td { padding: 7px 8px 7px 0; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.people th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; }
.people td small { display: block; color: var(--muted); font-size: 12px; }
.people select { height: 30px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); padding: 0 4px; }
.people tr.off td:not(:last-child) { opacity: 0.55; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 14px;
}
.toast.error { background: var(--bad); color: #fff; }

/* ---------- sign-in page ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 26px 26px 22px;
}
.auth-card .brand { width: auto; margin-bottom: 18px; }
.auth-card .brand h1 { font-size: 20px; }
.auth-card h2 { margin: 0 0 4px; font-size: 18px; }
.auth-card .lead { margin: 0 0 18px; color: var(--text-2); font-size: 14px; }
.auth-card .btn.primary { width: 100%; height: 40px; margin-top: 4px; }
.auth-foot { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- responsive ---------- */
@media (min-width: 861px) {
  .sidebar-collapsed .layout { grid-template-columns: 1fr; }
  .sidebar-collapsed .sidebar { display: none; }
  .sidebar-collapsed .sidebar-toggle .pill-count { display: inline-block; }
}

@media (max-width: 1100px) {
  :root { --sidebar-w: 290px; }
  .brand { width: auto; }
  .me-btn .who { display: none; }
}

@media (max-width: 860px) {
  :root { --topbar-h: 108px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px 10px; }
  .brand { order: 1; }
  .top-actions { order: 2; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .filters-toggle { display: inline-flex; }
  .sidebar-toggle { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; height: 100%; width: min(360px, 88vw);
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
  .sidebar-head h2 { margin: 0; font-size: 18px; }
  .filters-open .sidebar { transform: none; }
  .filters-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(10 14 20 / 45%); }
  .main { padding: 0 12px 88px; }
  .toolbar { padding-top: 10px; }
  .entry { grid-template-columns: 1fr 76px 22px; gap: 6px 10px; }
  .entry .memo { grid-column: 1 / -1; grid-row: 2; }
  .entry .save-error { grid-column: 1 / -1; }
  .mday { min-height: 64px; padding: 3px; }
  .mev, .more { display: none; }
  .mhead, .mgrid { grid-template-columns: repeat(7, minmax(0, 1fr)) 48px; }
  .cal-nav { min-width: 0; }
  .cal-nav h2 { font-size: 17px; white-space: normal; line-height: 1.2; }
  .report { padding: 16px; }
  /* view switcher becomes a floating tab bar at the bottom */
  .views {
    display: flex; order: 4; position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 25;
    box-shadow: var(--shadow-lg); background: var(--surface); padding: 4px;
  }
  .views button { height: 38px; padding: 0 11px; white-space: nowrap; }
  .views button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
  .memo-bar { bottom: 72px; }
}

@media (max-width: 480px) {
  .top-actions .btn { padding: 0 10px; }
  .result-count { width: 100%; margin-left: 0; order: 3; }
  .views button { padding: 0 8px; font-size: 14px; }
}

/* ---------- print: reports only ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --shadow: none; --text: #000; --text-2: #222; --muted: #555; --border: #ccc; color-scheme: light; }
  .topbar, .sidebar, .scrim, .toolbar, .views, .dialog, .banner, .no-print { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  body { font-size: 11.5px; }
  .report { border: 0; border-top: 4px solid oklch(58% 0.15 var(--h)); box-shadow: none; padding: 12px 0 0; margin: 0; }
  .rgroup.page { break-before: page; }
  .print-only { display: inline; }
  .rtable tr { break-inside: avoid; }
}
