/* Self-hosted so the page loads nothing from third parties (latin subsets). */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap; src: url(/fonts/ibm-plex-sans.woff2) format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 500 700; font-stretch: 100%; font-display: swap; src: url(/fonts/bricolage-grotesque-500-700.woff2) format("woff2"); }

/* Layout: sticky top bar; below it a fluid calendar canvas on the left and a 340px planning ledger
   (time off, month totals, data) on the right, which stacks underneath on narrow screens. */
:root {
  --bg: #EEF1F5;
  --surface: #FFFFFF;
  --surface-2: #F5F7FA;
  --fg: #16202B;
  --muted: #5F6B7A;
  --line: #D6DCE4;
  --accent: #1E5A8A;
  --on-accent: #FFFFFF;
  --danger: #B42318;
  --today: #D9480F;
  --holiday: #8A5A0B;  --holiday-soft: #F8E7BF;
  --trip: #6B2FA0;     --trip-soft: #EADAF7;
  --other: #4B5563;    --other-soft: #E3E7EC;
  --h0: #E8F0F8; --h1: #CFE0EF; --h2: #B3CDE3; --h3: #8FB3D2; --h4: #4A7BAA; --h5: #2F6391; --h6: #1B4A72;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(22,32,43,.06), 0 12px 32px rgba(22,32,43,.14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F151C; --surface: #171F29; --surface-2: #1D2733; --fg: #E7ECF2; --muted: #93A0AF; --line: #2A3542;
    --accent: #6DA9DF; --on-accent: #0F151C; --danger: #F97066; --today: #FF8A4C;
    --holiday: #E8B04A; --holiday-soft: #3A2E14; --trip: #C49AE6; --trip-soft: #2F1F3B; --other: #AAB3BE; --other-soft: #2A313A;
    --h0: #1F2E3D; --h1: #27405A; --h2: #2F5478; --h3: #3A6A97; --h4: #4F86B8; --h5: #7AA8D4; --h6: #A9CBEA;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F151C; --surface: #171F29; --surface-2: #1D2733; --fg: #E7ECF2; --muted: #93A0AF; --line: #2A3542;
  --accent: #6DA9DF; --on-accent: #0F151C; --danger: #F97066; --today: #FF8A4C;
  --holiday: #E8B04A; --holiday-soft: #3A2E14; --trip: #C49AE6; --trip-soft: #2F1F3B; --other: #AAB3BE; --other-soft: #2A313A;
  --h0: #1F2E3D; --h1: #27405A; --h2: #2F5478; --h3: #3A6A97; --h4: #4F86B8; --h5: #7AA8D4; --h6: #A9CBEA;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font-body); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--line); padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-inline: auto; }
.nav-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin: 0; min-width: 190px; text-align: center; font-variant-numeric: tabular-nums; }
.topbar-right { display: flex; gap: 8px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg-btn { border: 0; background: var(--surface); padding: 6px 13px; font-weight: 500; color: var(--muted); }
.seg-btn[aria-selected="true"] { background: var(--fg); color: var(--bg); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 6px 12px; font-weight: 500; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn.armed { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.icon-btn { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; font-size: 20px; line-height: 1; }
.btn-sm { padding: 3px 9px; font-size: 12.5px; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; max-width: 1640px; margin: 0 auto; padding-block: 20px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.main { min-width: 0; }
.aside { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; }
.panel h2 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 12.5px; }
.pill { font-size: 11px; font-weight: 600; letter-spacing: .02em; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }

/* ---------- year view ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: 12.5px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.ramp { display: inline-flex; gap: 2px; }
.ramp i, .sw { display: inline-block; width: 16px; height: 13px; border-radius: 2px; }
.sw.today-sw { box-shadow: inset 0 0 0 2px var(--today); }
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.mini { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.mini-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mini-title { border: 0; background: none; padding: 0; font-family: var(--font-display); font-weight: 600; font-size: 16px; text-align: left; }
.mini-title:hover { color: var(--accent); }
.mini-title span { color: var(--muted); font-weight: 500; }
.mini-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.wd { font-size: 10.5px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.blank { background: transparent; }
.day { position: relative; border: 0; border-radius: 3px; background: var(--surface-2); color: var(--fg); font-variant-numeric: tabular-nums; }
.mini-day { aspect-ratio: 1; display: grid; place-items: center; font-size: 11.5px; padding: 0; }
.mini-foot { margin-top: auto; display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); padding-top: 8px; }
.mini-foot b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }

.h0 { background: var(--h0); } .h1 { background: var(--h1); } .h2 { background: var(--h2); } .h3 { background: var(--h3); }
.h4 { background: var(--h4); color: var(--on-accent); } .h5 { background: var(--h5); color: var(--on-accent); } .h6 { background: var(--h6); color: var(--on-accent); }
.off-holiday { background: var(--holiday-soft); color: var(--holiday); }
.off-trip { background: var(--trip-soft); color: var(--trip); }
.off-other { background: var(--other-soft); color: var(--other); }
.off-weekend { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.day.past { opacity: .5; }
.day.today { box-shadow: inset 0 0 0 2px var(--today); }
.day.sel { outline: 2px solid var(--fg); outline-offset: -1px; z-index: 1; }
.day:hover { filter: brightness(.96); }

/* ---------- month view ---------- */
.month { display: flex; flex-direction: column; gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.actions { display: flex; gap: 8px 10px; flex-wrap: wrap; align-items: center; }
.dist { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px 2px 6px; background: var(--surface); color: var(--fg); font-variant-numeric: tabular-nums; }
.chip i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.chip b { font-weight: 600; color: var(--muted); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.month-grid .wd { font-size: 12px; padding: 4px 0 2px; }
.big-day { min-height: 86px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line); padding: 6px 8px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-width: 0; }
.big-day.h0, .big-day.h1, .big-day.h2, .big-day.h3, .big-day.h4, .big-day.h5, .big-day.h6, .big-day.off-holiday, .big-day.off-trip, .big-day.off-other { box-shadow: none; }
.big-day.today { box-shadow: inset 0 0 0 2px var(--today); }
.big-day .dnum { font-size: 12px; opacity: .8; }
.big-day .hrs { font-family: var(--font-display); font-size: 23px; font-weight: 600; margin-top: auto; line-height: 1.1; }
.big-day .tag { position: absolute; top: 6px; right: 8px; font-size: 10.5px; opacity: .85; }
.big-day .off-label { font-weight: 600; margin-top: auto; font-size: 13px; line-height: 1.2; overflow-wrap: anywhere; }
.big-day .kind { font-size: 11px; opacity: .85; }
@media (max-width: 640px) {
  .big-day { min-height: 60px; padding: 4px 5px; }
  .big-day .hrs { font-size: 15px; }
  .big-day .off-label { font-size: 10.5px; }
  .big-day .kind, .big-day .tag { display: none; }
  .big-day .off-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .topbar { gap: 10px 12px; }
  .topbar-right { order: 1; margin-left: auto; }
  .nav { order: 2; flex-basis: 100%; flex-wrap: nowrap; justify-content: center; margin-inline: 0; }
  .nav-title { min-width: 0; flex: 1 1 auto; font-size: 15px; }
  .btn-ghost { padding: 6px 8px; }
}

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; background: var(--surface); color: var(--fg); min-width: 0; width: 100%; }
.field input[type="number"] { font-variant-numeric: tabular-nums; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--fg); }
.check input { width: 16px; height: 16px; margin: 0; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.4; white-space: pre; resize: vertical; }

.blocks { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.block { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); cursor: pointer; text-align: left; width: 100%; }
.block:hover { border-color: var(--accent); }
.block .sw { flex: none; width: 10px; height: 10px; }
.block .bl { font-weight: 600; }
.block .bd { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0 0; }

.sum { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.sum th, .sum td { padding: 5px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.sum th { color: var(--muted); font-weight: 500; font-size: 12px; }
.sum th:first-child, .sum td:first-child { text-align: left; }
.sum tbody tr { cursor: pointer; }
.sum tbody tr:hover td { background: var(--surface-2); }
.sum tbody tr.current td:first-child { font-weight: 600; color: var(--accent); }
.sum tfoot td { font-weight: 600; border-bottom: 0; padding-top: 8px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(10, 16, 24, .45); display: flex; align-items: center; justify-content: center; z-index: 50;
  padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100% - 32px); overflow: auto; padding: 18px 20px 20px; }
.modal h3 { font-family: var(--font-display); margin: 0 0 4px; font-size: 19px; font-weight: 600; }
.modal .sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 18px; }
.modal-actions .left { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.weights { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; }
.wcol { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wcol .bar { width: 100%; height: 48px; display: flex; align-items: flex-end; }
.wcol .bar i { display: block; width: 100%; border-radius: 2px 2px 0 0; min-height: 2px; }
.wcol input { width: 100%; text-align: center; padding: 4px 2px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.wcol .val { font-weight: 600; color: var(--fg); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

/* ---------- saved-state note, sign-in and account pages ---------- */
.mt { margin: 10px 0 0; }
.check-end { align-self: end; padding-bottom: 6px; }
.inline { display: inline; margin: 0; }
.topbar-right { flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.store-note { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.store-note.store-warn { color: var(--danger); }
body.signin { display: grid; place-items: center; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.book { width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 18px; padding-block: 32px; }
.monogram { font-family: var(--font-display); font-size: 44px; font-weight: 700; margin: 0; color: var(--accent); line-height: 1; }
.book .panel { width: 100%; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.wide { width: 100%; }
.err { color: var(--danger); font-size: 13.5px; margin: 0 0 10px; }
.flash { color: var(--accent); font-size: 13.5px; margin: 0 0 10px; }
.narrow { max-width: 560px; margin: 24px auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.h { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin: 0 0 6px; }
