/* Wave Ops — layout: right-hand rail nav, dense tables, numbers in mono so columns line up. */
:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --ink: #141a22;
  --muted: #5d6774;
  --line: #dde3e9;
  --accent: #1d6b59;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ec;
  --bad: #b8392a;
  --bad-soft: #fbe9e6;
  --warn: #a8670f;
  --warn-soft: #fbf0dc;
  --info: #2f62a8;
  --info-soft: #e5eef9;
  --ok: #2c7a4b;
  --ok-soft: #e3f3e9;
  --rail: #121820;
  --rail-ink: #c9d1da;
  --font: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1217;
    --surface: #161b22;
    --surface-2: #1b2129;
    --ink: #e5e9ee;
    --muted: #96a0ac;
    --line: #29313b;
    --accent: #4bb394;
    --accent-ink: #08130f;
    --accent-soft: #15302a;
    --bad: #ef7d6c;
    --bad-soft: #3a1c18;
    --warn: #e2a74b;
    --warn-soft: #36280f;
    --info: #78a6e6;
    --info-soft: #172a42;
    --ok: #6fcb93;
    --ok-soft: #14301f;
    --rail: #0a0d11;
    --rail-ink: #b3bdc8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 700; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; letter-spacing: .01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-family: var(--mono); font-size: 13px; }
.rail a.nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--rail-ink);
}
.rail a.nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.rail a.nav.on { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.rail .count { font-family: var(--mono); font-size: .75rem; background: var(--bad); color: #fff; border-radius: 99px; padding: 0 7px; }
.rail-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; display: grid; gap: 6px; }
.rail-foot button { background: none; border: 0; color: var(--rail-ink); padding: 0; font: inherit; cursor: pointer; text-align: start; text-decoration: underline; }

.main {
  padding-block: 28px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  min-width: 0;
}
.page { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between; }
.page-head p { margin: 4px 0 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .brand { padding: 0 6px 0 10px; }
  .rail-foot { margin: 0; margin-inline-start: auto; border: 0; padding: 0; display: flex; gap: 12px; }
  .rail-foot .who { display: none; }
}

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-body { padding: 16px 18px; }
.flash { padding: 10px 14px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.errors { padding: 10px 14px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); }
.errors ul { margin: 0; padding-inline-start: 18px; }

/* KPI strip: one bordered band, cells divided by hairlines */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi { padding: 16px 18px; border-inline-start: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-inline-start: 0; }
.kpi .label { color: var(--muted); font-size: .82rem; }
.kpi .value { font-family: var(--mono); font-size: 1.55rem; font-weight: 600; direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: .8rem; }
.kpi.accent .value { color: var(--accent); }
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-inline-start: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
}

.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th { text-align: start; font-weight: 600; color: var(--muted); font-size: .78rem; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.n, table.grid th.n { text-align: left; }
table.grid tbody tr.link { cursor: pointer; }
table.grid tbody tr.link:hover td { background: var(--surface-2); }
table.grid tr.dim td { color: var(--muted); }
table.grid tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.cell-name a { text-decoration: none; font-weight: 500; }
.cell-name a:hover { text-decoration: underline; }
.cell-name .domain { font-family: var(--mono); font-size: .86rem; direction: ltr; unicode-bidi: isolate; }
.group-title { display: flex; align-items: baseline; gap: 10px; }
.group-title .meta { font-size: .8rem; color: var(--muted); font-weight: 400; }

/* ---------- state marks ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; padding: 2px 9px; border-radius: 99px; white-space: nowrap; font-weight: 500; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.delay { background: var(--warn-soft); color: var(--warn); }
.pill.suspended { background: var(--bad-soft); color: var(--bad); }
.pill.deleted { background: var(--surface-2); color: var(--muted); }

.due { display: inline-flex; flex-direction: column; line-height: 1.25; }
.due .d { font-family: var(--mono); font-size: .86rem; direction: ltr; text-align: right; }
.due .rel { font-size: .74rem; font-weight: 600; }
.due.overdue .rel { color: var(--bad); }
.due.soon .rel { color: var(--warn); }
.due.upcoming .rel { color: var(--info); }
.due.ok .rel, .due.unknown .rel { color: var(--muted); font-weight: 400; }
.est { color: var(--muted); font-size: .72rem; }

.kind { font-size: .76rem; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }

/* ---------- attention list ---------- */
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.attn li:last-child { border-bottom: 0; }
.attn .bar { width: 4px; height: 34px; border-radius: 2px; background: var(--warn); }
.attn li.overdue .bar { background: var(--bad); }
.attn .what { min-width: 0; }
.attn .what a { font-weight: 500; text-decoration: none; }
.attn .what .sub { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn form { margin: 0; }
.empty { padding: 26px 18px; color: var(--muted); text-align: center; }

/* ---------- forecast ---------- */
.forecast { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 190px; padding: 18px 18px 0; }
.forecast .col { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; gap: 2px; position: relative; }
.forecast .in { background: var(--accent); border-radius: 4px 4px 0 0; height: var(--h); min-height: 2px; }
.forecast .out { background: var(--bad); opacity: .55; border-radius: 0 0 2px 2px; height: var(--h); }
.forecast .amt { font-family: var(--mono); font-size: .66rem; color: var(--muted); text-align: center; direction: ltr; white-space: nowrap; overflow: hidden; }
.forecast-axis { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; padding: 6px 18px 14px; font-size: .72rem; color: var(--muted); text-align: center; }
.legend { display: flex; gap: 14px; font-size: .78rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 5px; vertical-align: -1px; }

/* ---------- filters & forms ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=search] { min-width: 220px; flex: 1 1 220px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-width: 0; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.ltr { direction: ltr; text-align: right; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips a { text-decoration: none; font-size: .82rem; padding: 4px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.chips a.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 5px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field .hint { font-size: .76rem; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.check input { width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: .88rem; font-weight: 600; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; 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.07); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.sm { padding: 4px 10px; font-size: .8rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.money-preview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.money-preview div { padding: 10px 12px; border-inline-start: 1px solid var(--line); }
.money-preview div:first-child { border-inline-start: 0; }
.money-preview span { display: block; font-size: .74rem; color: var(--muted); }
.money-preview b { font-family: var(--mono); direction: ltr; display: block; text-align: right; }

.timeline { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); display: grid; gap: 2px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .75rem; }

.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.auth .card { width: min(400px, 100%); padding: 28px; display: grid; gap: 16px; }
.auth .brand { color: var(--ink); padding: 0; }

/* ---------- hours ---------- */
.timer-card.is-running { border-color: var(--accent); }
.timer-now { display: grid; gap: 4px; }
.timer-clock { font-size: 2.4rem; font-weight: 600; color: var(--accent); text-align: right; }
.day-head { display: flex; justify-content: space-between; padding: 10px 18px 6px; font-size: .82rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }

/* ---------- projects ---------- */
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; width: var(--w); background: var(--accent); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }
.pill.quote { background: var(--info-soft); color: var(--info); }
.pill.won, .pill.in_progress { background: var(--accent-soft); color: var(--accent); }
.pill.waiting { background: var(--warn-soft); color: var(--warn); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.paid { background: var(--surface-2); color: var(--ok); }
.pill.lost { background: var(--surface-2); color: var(--muted); }
.neg { color: var(--bad); }
.list-rows { list-style: none; margin: 0; padding: 0; }
.list-rows li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 9px 18px; border-bottom: 1px solid var(--line); font-size: .9rem; }
.list-rows li.done .what { color: var(--muted); text-decoration: line-through; }
.list-rows form { margin: 0; }
.list-rows .tick { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: .8rem; color: var(--accent-ink); padding: 0; }
.list-rows li.done .tick { background: var(--accent); border-color: var(--accent); }
.inline-add { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; background: var(--surface-2); border-top: 1px solid var(--line); }
.inline-add input { flex: 1 1 120px; }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 2px 6px; }
.x:hover { color: var(--bad); }
