:root {
  --ink: #1f2328; --ink-2: #57606a; --muted: #8b949e;
  --line: #e5e7eb; --line-2: #f1f2f4; --bg: #f7f7f8; --surface: #fff;
  --side: #3c3f45; --side-ink: #e8e9eb;
  --accent: #2a78d6; --accent-ink: #fff;
  --ok: #16a37a; --ok-bg: #e3f6ef;
  --pend: #b7791f; --pend-bg: #fdf3e1;
  --mine: #2a78d6; --mine-bg: #e6f0fc;
  --danger: #c93a3a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink); font-size: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
.muted { color: var(--muted); font-weight: normal; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 210px; flex: none; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 16px 10px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 18px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: var(--side-ink); text-decoration: none; padding: 8px 10px; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; }
.side nav a:hover { background: rgba(255,255,255,.07); }
.side nav a.on { background: rgba(255,255,255,.14); }
.badge { background: #f0b429; color: #222; border-radius: 9px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.me { margin-top: auto; padding: 10px; font-size: 13px; line-height: 1.6; }
.me a { color: #b9c7d8; }
.main { flex: 1; min-width: 0; padding: 18px 22px; }
.flash { background: var(--ok-bg); border: 1px solid #b7e4d3; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }

/* controls */
.btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: #c9ced6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.icon { padding: 7px 11px; font-size: 16px; line-height: 1; }
.btn:disabled { opacity: .6; cursor: default; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #fff; color: var(--ink); width: 100%; }
label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 0; }
label input, label select, label textarea { margin-top: 4px; font-weight: normal; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar h2 { font-size: 16px; margin: 0 6px; font-weight: 600; }
.toolbar input[type=date], .toolbar select { width: auto; }
.grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.seg a { padding: 7px 12px; color: var(--ink); text-decoration: none; }
.seg a.on { background: var(--ink); color: #fff; }
.legend { color: var(--ink-2); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 6px; }
.sw.approved { background: var(--ok); } .sw.pending { background: var(--pend); } .sw.mine { background: var(--mine); }

/* calendar grid */
.grid-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: calc(100vh - 110px); }
.grid { display: grid; position: relative; min-width: max-content; }
.corner, .colhead { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); }
.corner { left: 0; z-index: 4; }
.colhead { padding: 8px 6px; text-align: center; border-left: 1px solid var(--line); font-size: 13px; line-height: 1.25; display: flex; flex-direction: column; justify-content: center; }
.colhead small { color: var(--muted); font-size: 11px; }
.colhead.today b { color: var(--accent); }
.gutter { position: sticky; left: 0; z-index: 2; background: var(--surface); }
.gutter div { font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); }
.col { position: relative; border-left: 1px solid var(--line); cursor: cell; touch-action: pan-y;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--row) - 1px), var(--line-2) calc(var(--row) - 1px), var(--line-2) var(--row)); }
.past { position: absolute; left: 0; right: 0; top: 0; background: rgba(0,0,0,.025); pointer-events: none; }
.sel { position: absolute; left: 2px; right: 2px; background: rgba(42,120,214,.15); border: 2px solid var(--accent); border-radius: 6px; pointer-events: none; }
.bk { position: absolute; left: 3px; right: 3px; border: 0; border-left: 4px solid var(--ok); background: var(--ok-bg); border-radius: 6px; padding: 3px 6px; text-align: left; font: inherit; font-size: 12px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; gap: 1px; color: var(--ink); }
.bk b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk span { color: var(--ink-2); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk.pending { border-left-color: var(--pend); background: var(--pend-bg); background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(183,121,31,.08) 6px 12px); }
.bk.mine { border-left-color: var(--mine); background-color: var(--mine-bg); }
.bk:hover { filter: brightness(.97); }

/* dialogs */
.dlg { border: 0; border-radius: 12px; padding: 20px 22px; width: min(480px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(20,22,26,.35); }
.dlg h3 { margin: 0 0 6px; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.err { color: var(--danger); min-height: 0; margin: 8px 0 0; }
.note { background: var(--pend-bg); padding: 8px 10px; border-radius: 7px; font-size: 13px; }
dl { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; margin: 10px 0 0; }
dt { color: var(--muted); } dd { margin: 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.pill.approved { background: var(--ok-bg); color: #0d7a5a; } .pill.pending { background: var(--pend-bg); color: #8a5a12; }
.pill.declined, .pill.cancelled { background: #f3f3f3; color: #666; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; }
.toast.bad { background: var(--danger); }

/* pages */
h1.page { font-size: 20px; margin: 4px 0 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list th, table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
table.list th { background: #fafafa; font-size: 12px; color: var(--ink-2); font-weight: 600; }
table.list tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.inline-form { display: inline; }
.inline-form input, .inline-form select { width: auto; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

/* insights */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.tile .k { color: var(--ink-2); font-size: 12px; }
.tile .v { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--muted); font-size: 12px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.chart h3 { font-size: 14px; margin: 0 0 2px; } .chart p.sub { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.bars { display: grid; grid-template-columns: minmax(90px, max-content) 1fr 56px; gap: 6px 10px; align-items: center; font-size: 13px; }
.bars .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars .track { height: 14px; position: relative; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.bars .hit { display: contents; }
.bars .hit:hover .fill { filter: brightness(.88); }
.filters { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.filters label { margin: 0; } .filters input, .filters select { width: auto; }

/* login */
body.center { display: grid; place-items: center; min-height: 100vh; }
.card.login { width: min(380px, 92vw); text-align: center; padding: 28px; }
.card.login h1 { font-size: 20px; margin: 0 0 10px; }

@media (max-width: 760px) {
  .side { display: none; }
  .main { padding: 10px; }
  .legend { display: none; }
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #e6e6e3; --ink-2: #b4b4ae; --muted: #8b8b85; --line: #34342f; --line-2: #2a2a26; --bg: #121211; --surface: #1a1a19;
    --accent: #3987e5; --ok-bg: #173a2f; --pend-bg: #3a2e17; --mine-bg: #1b3150; }
  input, select, textarea { background: #222220; }
  table.list th { background: #222220; }
  .seg a.on { background: #e6e6e3; color: #121211; }
  .toast { background: #e6e6e3; color: #121211; }
}
