:root {
  --bg: #0b1016;
  --bg-2: #111925;
  --panel: #16202e;
  --panel-2: #1b2736;
  --line: #24344a;
  --line-soft: #1c2937;
  --ink: #e8eef6;
  --ink-2: #9fb0c6;
  --ink-3: #6b7f99;
  --accent: #35c2c8;
  --accent-ink: #06211f;
  --blue: #4d8ff5;
  --amber: #f0b429;
  --red: #f2637a;
  --green: #3ecf8e;
  --violet: #a78bfa;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--ink-3); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 16px; }
.brand-mark { font-size: 20px; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); font-size: 13.5px; border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--panel); color: var(--ink); }
.nav-item.active { background: var(--panel-2); color: var(--ink); font-weight: 550; }
.nav-item .count {
  margin-left: auto; font-size: 11px; background: var(--line); color: var(--ink-2);
  border-radius: 20px; padding: 1px 7px; font-variant-numeric: tabular-nums;
}
.nav-item .count.hot { background: var(--red); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line-soft); }
.user-line { font-size: 13px; font-weight: 550; }
.user-org { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.linkish { background: none; border: 0; color: var(--ink-3); padding: 6px 0 0; font-size: 12px; }
.linkish:hover { color: var(--accent); }

.main { min-width: 0; padding: 22px 26px 60px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 650; letter-spacing: -0.02em; margin: 0; }
.page-sub { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- primitives ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: var(--panel-2); border-color: #2f4664; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #3d2733; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft); font-weight: 600; font-size: 14px;
}
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; }
.stat-n { font-size: 26px; font-weight: 660; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.stat.hot .stat-n { color: var(--red); }
.stat.warn .stat-n { color: var(--amber); }

.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; padding: 2.5px 8px; border-radius: 20px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill.grey   { background: #1e2b3c; color: var(--ink-2); }
.pill.blue   { background: #16294a; color: #8fbaff; }
.pill.teal   { background: #0e3336; color: #6fe0e0; }
.pill.green  { background: #10322a; color: var(--green); }
.pill.amber  { background: #34290d; color: var(--amber); }
.pill.red    { background: #3a1a25; color: var(--red); }
.pill.violet { background: #2a1f45; color: var(--violet); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: var(--panel-2); cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- call cards ---------- */
.calls { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.call-card {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 15px 16px; cursor: pointer; transition: border-color .12s, transform .12s;
}
.call-card:hover { border-color: #2f4664; transform: translateY(-1px); }
.call-card.impacted { border-color: #5a2b3a; box-shadow: inset 3px 0 0 var(--red); }
.cc-top { display: flex; align-items: baseline; gap: 8px; }
.cc-name { font-weight: 640; font-size: 15px; letter-spacing: -0.01em; }
.cc-ref { font-size: 11.5px; color: var(--ink-3); margin-left: auto; font-family: var(--mono); }
.cc-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.cc-times { display: flex; gap: 18px; margin: 12px 0 10px; }
.cc-time-l { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.cc-time-v { font-size: 13.5px; font-weight: 560; font-variant-numeric: tabular-nums; }
.cc-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); flex-wrap: wrap; }

/* ---------- timeline ---------- */
.timeline { position: relative; padding: 4px 0 4px 0; }
.tl-row { display: grid; grid-template-columns: 74px 26px 1fr; align-items: start; gap: 0; }
.tl-time {
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); text-align: right;
  padding: 10px 12px 10px 0; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tl-time .day { display: block; font-size: 10px; color: var(--ink-3); }
.tl-rail { position: relative; }
.tl-rail::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px;
  background: var(--line); transform: translateX(-50%);
}
.tl-row:first-child .tl-rail::before { top: 16px; }
.tl-row:last-child .tl-rail::before { bottom: calc(100% - 16px); }
.tl-dot {
  position: absolute; left: 50%; top: 13px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--line); border: 2px solid var(--bg); transform: translateX(-50%); z-index: 1;
}
.tl-dot.movement { background: var(--blue); width: 11px; height: 11px; top: 12px; }
.tl-dot.actual { background: var(--green); }
.tl-dot.done { background: var(--green); }
.tl-dot.live { background: var(--amber); box-shadow: 0 0 0 4px rgba(240,180,41,.16); }
.tl-body { padding: 8px 0 8px 12px; min-width: 0; }
.tl-row.movement .tl-body { padding-top: 7px; }
.tl-label { font-weight: 560; font-size: 13.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.tl-row.movement .tl-label { color: #a8c8ff; letter-spacing: .02em; text-transform: uppercase; font-size: 12px; }
.tl-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ---------- impact banner ---------- */
.impact {
  border: 1px solid #5a2b3a; background: linear-gradient(180deg, #241520, #1a1119);
  border-radius: var(--radius); margin-bottom: 16px; overflow: hidden;
}
.impact-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid #3a2029; }
.impact-title { font-weight: 640; }
.impact-list { padding: 4px 0; }
.impact-item {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 16px; border-bottom: 1px solid #2a1a22;
}
.impact-item:last-child { border-bottom: 0; }
.impact-item input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); }
.impact-name { font-size: 13.5px; font-weight: 550; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.impact-reason { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.impact-times { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.impact-times .old { color: var(--ink-3); text-decoration: line-through; }
.impact-times .new { color: var(--green); }
.impact-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid #3a2029; align-items: center; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 11.5px; color: var(--ink-2); margin-bottom: 4px; font-weight: 550; }
input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 10px; border-radius: 7px; font: inherit; font-size: 13.5px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(53,194,200,.35); outline-offset: -1px; border-color: var(--accent); }
textarea { min-height: 64px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 11.5px; color: var(--ink-3); margin-top: -8px; margin-bottom: 12px; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(4,8,13,.72); backdrop-filter: blur(3px);
  display: grid; place-items: start center; padding: 40px 20px; z-index: 50; overflow: auto;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  width: min(680px, 100%); box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); }
.modal-title { font-weight: 640; font-size: 15px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line-soft); }
.x { margin-left: auto; background: none; border: 0; color: var(--ink-3); font-size: 20px; line-height: 1; padding: 0 4px; }
.x:hover { color: var(--ink); }

/* ---------- toast ---------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; font-size: 13px; max-width: 340px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: slide .18s ease;
}
.toast.warn { border-left-color: var(--amber); }
.toast.err { border-left-color: var(--red); }
@keyframes slide { from { opacity: 0; transform: translateY(6px); } }

/* ---------- login ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { width: min(400px, 100%); }
.login .brand { justify-content: center; padding-bottom: 20px; }
.login-title { font-size: 16px; font-weight: 640; margin-bottom: 6px; }
.login-links { font-size: 12.5px; text-align: center; margin-top: 12px; }
.btn.block { width: 100%; justify-content: center; }
/* Said in the form, next to the thing that went wrong, not in a toast that leaves. */
.form-error {
  color: var(--red); font-size: 12.5px; margin: 0 0 12px; padding: 8px 10px;
  background: rgba(242, 99, 122, .09); border: 1px solid #3d2733; border-radius: 7px;
}
.form-notice {
  font-size: 13px; margin: 0 0 12px; padding: 9px 11px; color: var(--ink);
  background: rgba(53, 194, 200, .08); border: 1px solid #1d4a4d; border-radius: 7px;
}
/* The attribute has to win over any display rule on the element it hides. */
[hidden] { display: none !important; }

/* ---------- misc ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px; }
.tab {
  background: none; border: 0; color: var(--ink-3); padding: 9px 13px; font-size: 13.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 550; }
.two-col { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 108px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.movement-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 1px; background: var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.ms-cell { background: var(--panel); padding: 11px 13px; }
.ms-l { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.ms-v { font-size: 14px; font-weight: 580; font-variant-numeric: tabular-nums; margin-top: 2px; }
.ms-v.est { color: var(--ink); }
.ms-v.act { color: var(--green); }
.ms-v.none { color: var(--ink-3); font-weight: 400; }
.outbox-msg { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; color: var(--ink-2); background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 11px 13px; margin-top: 8px; }
.crew-row { display: grid; grid-template-columns: 1.3fr .95fr .85fr .7fr 1.25fr .55fr 26px; gap: 7px; margin-bottom: 8px; align-items: center; }
.crew-row input, .crew-row select { padding: 6px 8px; font-size: 12.5px; }
.crew-row input, .crew-row select { margin: 0; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand, .sidebar-foot { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* --- Service detail panel ------------------------------------------------- */
.od-head { cursor: pointer; }
.od-head:hover { background: var(--row-hover, rgba(255,255,255,.03)); }
.od-row > td { padding: 0 14px 16px; background: rgba(0,0,0,.14); }
.od {
  display: grid; gap: 18px; padding: 14px 2px 4px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.od-section { display: grid; gap: 6px; align-content: start; }
.od-title {
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin-bottom: 2px;
}
.od .kv { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.od .kv > .muted { min-width: 108px; flex: 0 0 auto; }
.od table { font-size: 12.5px; width: 100%; }
.od table th { font-size: 10px; }
.hist { display: grid; gap: 5px; }
.hist-row { display: flex; gap: 9px; align-items: baseline; font-size: 12px; flex-wrap: wrap; }

/* --- Operator console ----------------------------------------------------- */
.cand {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px;
  margin-bottom: 8px; background: var(--surface-2, rgba(255,255,255,.02));
}
.row-warn > td { background: rgba(220, 90, 70, .07); }

/* --- Joining -------------------------------------------------------------- */
.join-wrap { max-width: 640px; margin: 0 auto; padding: 42px 20px 60px; }
.join-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px; }
.join-title { font-size: 21px; font-weight: 650; letter-spacing: -.01em; margin-bottom: 6px; }
.join-err { margin-top: 12px; padding: 9px 12px; border-radius: 6px;
  background: rgba(220,90,70,.12); font-size: 13px; }
.type-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
.type-card { text-align: left; padding: 11px 13px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: inherit; font: inherit; }
.type-card.on { border-color: var(--accent, #4a9); background: rgba(80,170,150,.09); }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 7px; }
.svc-pick { display: flex; gap: 7px; align-items: center; font-size: 13px; }

/* --- Principal cost view -------------------------------------------------- */
.cost-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.cost-bar > div { min-width: 3px; }
.cost-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px;
  font-size: 12px; color: var(--muted); }
.cost-key span { display: flex; align-items: center; gap: 6px; }
.cost-key i { width: 10px; height: 10px; border-radius: 3px; display: block; }

/* --- Rate cards and billing (P21) ----------------------------------------- */
/* Utilities the tariff editor and the billing screen needed. Kept small and
   generic rather than page-specific, because the next screen will want them too. */
.row.gap { gap: 8px; }
.row.between { justify-content: space-between; width: 100%; }
.right { text-align: right; }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; line-height: 1.45; }
.pad-t { margin-top: 12px; }
.error { color: var(--red); }
.danger { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* A card whose whole point is that something needs attention. */
.warn-card { border-color: #4a3a18; }
.warn-card .card-head { background: rgba(240, 180, 41, .07); }
/* A rate card that is not live should not look live. */
.card.dim { opacity: .62; }
.card.dim:hover { opacity: 1; }

/* Invoice and quote tables: denser, and the total stands away from the lines. */
table.tight td, table.tight th { padding: 7px 10px; }
tr.total-row > td { border-top: 1px solid var(--line); border-bottom: none; font-weight: 600; }
tr.group-row > td { background: rgba(53, 194, 200, .05); border-bottom-color: var(--line); }

.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { accent-color: var(--accent); }

.preview-out {
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 12px 14px;
}

.btn.small { padding: 5px 10px; font-size: 12.5px; }
.linkish.primary { color: var(--accent); }
.linkish.danger { color: var(--red); }

/* --- The run sheet (P22) -------------------------------------------------- */
/* Held in a hand, on a pier, in the rain. Tap targets are 48px because that is
   what a thumb needs, and the type is larger than anywhere else in the app for
   the same reason. Everything here degrades to one column on a phone. */
.runsheet { max-width: 720px; }
.rs-pick {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}

.rs-job {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.rs-job.done { opacity: .66; }
.rs-job.waiting { border-color: var(--amber); }

.rs-top { display: flex; align-items: flex-start; gap: 14px; }
.rs-when {
  font-family: var(--mono); font-size: 19px; font-weight: 600;
  letter-spacing: -.02em; min-width: 58px; padding-top: 1px;
}
.rs-what { flex: 1; min-width: 0; }
.rs-vessel { font-size: 16px; font-weight: 620; letter-spacing: -.01em; }
.rs-sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }

.rs-facts { color: var(--ink-3); font-size: 12.5px; margin-top: 10px; }
.rs-timer {
  margin-top: 10px; padding: 9px 12px; border-radius: 8px;
  background: rgba(240, 180, 41, .10); color: var(--amber); font-weight: 600; font-size: 13.5px;
}
.rs-earned {
  margin-top: 10px; color: var(--green); font-weight: 650; font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.rs-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.rs-go {
  flex: 1 1 200px; min-height: 48px; border-radius: 10px; border: none;
  background: var(--accent); color: var(--accent-ink);
  font-size: 15.5px; font-weight: 650; letter-spacing: -.01em;
}
.rs-go.amber { background: var(--amber); color: #2a1f05; }
.rs-go.green { background: var(--green); color: #052117; }
.rs-go.blue  { background: var(--blue);  color: #04142e; }
.rs-go:active { transform: translateY(1px); }
.rs-alt {
  min-height: 48px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  font-size: 14.5px; font-weight: 580; display: inline-flex; align-items: center;
}

/* A phone: the sidebar becomes a strip along the top and the sheet fills the rest. */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; overflow-x: auto;
    padding: 10px; gap: 6px; border-right: none; border-bottom: 1px solid var(--line-soft);
    /* A grid item defaults to min-width:auto, which sizes it to its content
       rather than to its track — so without this the nav strip refuses to clip
       and pushes every page sideways instead of scrolling itself. */
    min-width: 0;
  }
  .main { min-width: 0; }
  .brand, .sidebar-foot { display: none; }
  .nav-item { white-space: nowrap; }
  .main { padding: 14px; }
  .rs-when { font-size: 17px; min-width: 50px; }
  .rs-go { flex: 1 1 100%; }
}

/* --- Performance (P23) ----------------------------------------------------- */
/* Single hue throughout: these bars compare SIZE, and identity is already carried
   by the row label beside them. Colour here would be decoration pretending to be
   information. Status colour appears once, on punctuality, always beside a word. */
.stat-sub { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.stat-sub.good { color: var(--green); }
.stat-sub.watch { color: var(--amber); }
.stat-sub.bad { color: var(--red); }

.insight {
  border-color: #1d4a4d; margin-bottom: 14px;
}
.insight .card-body { padding: 13px 16px; font-size: 13.5px; color: var(--ink-2); }
.insight strong { color: var(--accent); }

/* Thin, baseline-anchored, rounded only at the data end. The track stays visible
   on a zero row so "nothing" reads as nothing rather than as a broken render. */
.bar-track {
  height: 10px; background: var(--line-soft); border-radius: 3px; overflow: hidden;
}
.bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 0 4px 4px 0; min-width: 0;
}
tr.dimmed td { opacity: .5; }
.warn { color: var(--amber); }

/* Twelve columns, 2px apart, labelled selectively. */
.months { display: flex; align-items: flex-end; gap: 2px; height: 150px; }
/* Capped, so three months render as marks rather than as slabs. A bar chart that
   fills the panel is a block diagram, and length stops reading as quantity. */
.month {
  flex: 1 1 0; max-width: 64px; display: flex; flex-direction: column;
  height: 100%; min-width: 0;
}
.month-val {
  font-size: 10.5px; color: var(--ink-2); text-align: center; height: 14px;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden;
}
.month-bar-wrap { flex: 1; display: flex; align-items: flex-end; }
.month-bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .55; }
.month-bar.best { opacity: 1; }
.month:hover .month-bar { opacity: .85; }
.month-key {
  font-size: 10px; color: var(--ink-3); text-align: center; padding-top: 5px;
  white-space: nowrap; overflow: hidden;
}

/* A phone cannot carry five columns. The two that go are the bar — which only
   restates the number beside it — and days-to-pay, which nobody checks on a
   phone. Nothing is cut off; it is deliberately not shown. */
/* Shown only where .hide-sm content was dropped, so nothing is actually lost. */
.show-sm { display: none; }
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .show-sm { display: block; }
  /* Three row actions (View / Chase / Mark paid) will not sit on one line at
     phone width; without this they widen the table instead of stacking. */
  td .row { flex-wrap: wrap; row-gap: 4px; }
  /* A dense table that still will not fit scrolls INSIDE its card rather than
     dragging the whole page sideways. Every column survives; the reader swipes
     for the ones off-screen. Applied to the card itself as well as the body,
     because not every table in the app sits inside a .card-body. */
  .card-body, .card > table { overflow-x: auto; }
  .card > table { display: block; }
  /* A header full of actions wraps rather than widening the page. */
  .card-head { flex-wrap: wrap; row-gap: 8px; }
  .card-head .row { flex-wrap: wrap; row-gap: 6px; }
  .stat-n { font-size: 21px; }
  table td, table th { padding: 9px 8px; }
}

/* --- Disbursement accounts and the SOF (P24) ------------------------------- */
.ok-note { color: var(--green); }
/* The signed statement, as plain text, because that is the form it travels in. */
.sof-text {
  font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre;
  overflow-x: auto; background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 14px; margin: 0; color: var(--ink);
}

/* --- Account and team ------------------------------------------------------ */
.narrow { max-width: 640px; }
/* Cards stacked straight on a page (not laid out by a grid) keep their distance. */
:not(.grid):not(.two-col):not(.stats) > .card + .card { margin-top: 14px; }
.tabs + .card, .attention + .card { margin-top: 0; }
.strong { font-weight: 600; }
.break { overflow-wrap: anywhere; }
.row.end { justify-content: flex-end; }
.card-body.flush { padding: 0; overflow-x: auto; }
.card-body.divide { border-top: 1px solid var(--line-soft); }
.inline-select { width: auto; padding: 4px 8px; font-size: 12.5px; }
.copy-row input { flex: 1; min-width: 0; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: baseline; font-size: 13.5px; }
.checklist .tick { color: var(--ink-3); width: 14px; flex: 0 0 auto; }
.checklist li.done .tick { color: var(--green); }
.checklist li.done { color: var(--ink-2); }
/* Needs somebody's decision: said in a banner, not left to a status pill. */
.attention {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  border: 1px solid #4a3a18; background: rgba(240, 180, 41, .07);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px;
}
.attention .spacer { margin-left: auto; }
/* On a phone the sidebar footer (and its Sign out) is gone, so the way to the
   account screen stays pinned to the end of the strip however far it scrolls. */
@media (max-width: 900px) {
  .nav-item { width: auto; white-space: nowrap; flex: 0 0 auto; }
  .nav-item.pinned {
    position: sticky; right: -12px; margin-left: auto; background: var(--bg-2);
    box-shadow: -10px 0 10px -6px var(--bg-2); border-left: 1px solid var(--line-soft); border-radius: 0 8px 8px 0;
  }
  .nav-item.pinned.active { background: var(--panel-2); }
}
@media (max-width: 720px) {
  .nav-item.pinned { right: -10px; }
  .copy-row { flex-wrap: wrap; }
}
/* Seven tabs do not fit a phone: the strip scrolls rather than widening the page. */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 720px) {
  /* The same for a table that sits straight on the page, outside any card. */
  .main table:not(.card table) { display: block; overflow-x: auto; }
}
/* The sidebar's brand is dropped on a phone; the sign-in card's is not. */
.login .brand { display: flex; }
.problems { margin: 0; padding-left: 18px; }
/* A long link or reference in a message wraps instead of widening the page. */
.outbox-msg { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  /* Stacked, the nav strip takes its own height and the page takes the rest —
     otherwise a short page shares the spare height with the strip. */
  .shell { grid-template-rows: auto 1fr; }
  .card-head { flex-wrap: wrap; row-gap: 6px; }
  .card-head .mono { overflow-wrap: anywhere; min-width: 0; }
}
/* A figure, date or reference in a table never breaks mid-value ("SGD" above "2,398.00"). */
td.num, td.mono, td > .mono, td > .num, td.nowrap, td .linkish { white-space: nowrap; }
/* A ticked option is a box beside its words, not a full-width field above them. */
.check input[type=checkbox], .check input[type=radio] { width: auto; flex: none; }
/* A field that cannot be typed in looks it. */
input:disabled, select:disabled, textarea:disabled { opacity: .45; cursor: not-allowed; }
/* A passing message never swallows a click meant for the button underneath it. */
.toast-root { pointer-events: none; }

/* --- Ask (public/js/views/ask.js) — begin ---------------------------------- */
/* The charts reuse the Performance marks above (.bar-track, .months): one series,
   one hue, exact figure on hover, and the table always underneath. */
.ask { max-width: 980px; }
.ask-note {
  border: 1px solid var(--line); border-left: 3px solid var(--amber); background: var(--panel-2);
  border-radius: 8px; padding: 9px 12px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 14px;
}
.ask-thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.ask-q {
  padding: 11px 16px; border-bottom: 1px solid var(--line-soft); font-weight: 600;
  font-family: var(--mono); font-size: 13px; color: var(--accent); overflow-wrap: anywhere;
}
.ask-q::before { content: "> "; color: var(--ink-3); }
.ask-text { font-size: 14.5px; line-height: 1.55; color: var(--ink); max-width: 76ch; }
.ask-figures { margin-top: 14px; }
.ask-figures .stat-n { font-size: 20px; }
.ask-chart { margin-top: 16px; }
.ask-chart .months { height: 130px; }
.ask-sub { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 6px; }
.ask-chart .ask-sub { margin-top: 0; }
.ask-table { margin-top: 14px; overflow-x: auto; }
tr.ask-hl td { background: var(--panel-2); }
tr.ask-hl td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.ask-calc { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.ask-calc summary { cursor: pointer; color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.ask-calc[open] summary { margin-bottom: 8px; }
.ask-calc-row { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 3px 0; }
.ask-calc-k { color: var(--ink-3); }
.ask-sql {
  margin: 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 6px; padding: 8px 10px; color: var(--ink-2);
}
.ask-fb { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.ask-fb .btn.on { border-color: var(--accent); color: var(--accent); }
.ask-form { display: flex; gap: 8px; margin-bottom: 14px; }
.ask-form input { flex: 1; margin: 0; }
.ask-label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 8px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-chip {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-2); border-radius: 999px;
  padding: 6px 12px; font-size: 12.5px; text-align: left; cursor: pointer;
}
.ask-chip:hover:not(:disabled) { border-color: var(--accent); color: var(--ink); }
.ask-chip:disabled { opacity: .5; cursor: default; }
.ask-recent { display: flex; flex-direction: column; gap: 2px; }
.ask-recent-item {
  background: none; border: 0; color: var(--ink-2); text-align: left; padding: 5px 0; font-size: 13px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ask-recent-item:hover { color: var(--accent); }
@media (max-width: 720px) {
  .ask-calc-row { grid-template-columns: 1fr; gap: 0; }
  .ask-form { flex-direction: column; }
}
/* --- Ask — end ------------------------------------------------------------- */

/* ── Messaging: Inbox, drafts, Demo phone (views/inbox.js) ─────────────────── */
.inbox { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 14px; align-items: start; }
.inbox.with-phone { grid-template-columns: minmax(240px, 310px) minmax(0, 1fr) minmax(280px, 340px); }
.inbox-list-card { overflow: hidden; }
.inbox-list { max-height: calc(100vh - 170px); overflow-y: auto; }
.inbox-item {
  display: block; width: 100%; text-align: left; background: transparent; color: inherit; font: inherit; cursor: pointer;
  border: 0; border-bottom: 1px solid var(--line-soft); border-left: 3px solid transparent; padding: 11px 12px;
}
.inbox-item:hover { background: var(--panel-2); }
.inbox-item.active { background: var(--panel-2); border-left-color: var(--accent); }
.inbox-item.unread .inbox-from { font-weight: 650; }
.inbox-item .spacer { margin-left: auto; }
.inbox-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.inbox-snippet { color: var(--ink-2); font-size: 12.5px; margin: 5px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.inbox-tags { flex-wrap: wrap; row-gap: 4px; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 88%; border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 11px; background: var(--bg-2); align-self: flex-start; }
.bubble.out { align-self: flex-end; background: #12303a; border-color: #1d4753; }
.bubble-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-2); margin-bottom: 5px; flex-wrap: wrap; }
.bubble-meta .spacer { margin-left: auto; }
.bubble-subject { font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }
.bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.bubble-media { display: block; margin-top: 8px; color: var(--accent); font-size: 12px; text-decoration: none; }
.bubble-media img { display: block; max-width: 240px; max-height: 200px; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 4px; }
.bubble-note { font-size: 11px; color: var(--ink-3); margin-top: 5px; }
.draft-card { border-color: #3a3212; }
.draft-card > .card-head { background: rgba(240, 180, 41, .06); }
.draft-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.draft-grid .field.wide { grid-column: 1 / -1; }
.draft-grid .field:nth-child(2), .draft-grid .field:nth-child(3), .draft-grid .field:nth-child(8), .draft-grid .field:nth-child(9) { grid-column: span 2; }
.draft-grid input:disabled, .draft-grid select:disabled, .draft-grid textarea:disabled { opacity: 1; color: var(--ink); border-style: dashed; }
.draft-warnings { margin: 0 0 12px; padding: 8px 10px 8px 26px; border-radius: 8px; background: rgba(240, 180, 41, .08); color: var(--amber); font-size: 12.5px; }
.phone .phone-personas { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 12px 0; }
.phone .phone-who { padding: 6px 12px 0; font-size: 11.5px; }
.phone .phone-thread { padding: 10px 12px; max-height: 40vh; overflow-y: auto; flex-direction: column-reverse; }
.phone .phone-thread .bubble { max-width: 94%; }
.phone .phone-compose { padding: 10px 12px 12px; border-top: 1px solid var(--line-soft); }
.phone .phone-compose textarea, .phone .phone-compose select { width: 100%; }
.phone .phone-examples { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 6px; font-size: 11.5px; }
.phone .phone-examples .linkish { text-align: left; }
.phone input[type="file"] { font-size: 11.5px; max-width: 100%; }
@media (max-width: 1250px) { .inbox.with-phone { grid-template-columns: minmax(230px, 300px) minmax(0, 1fr); } .inbox.with-phone .inbox-phone { grid-column: 1 / -1; } }
@media (max-width: 820px) { .inbox, .inbox.with-phone { grid-template-columns: 1fr; } .inbox-list { max-height: 40vh; } .draft-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* ── end of messaging ─────────────────────────────────────────────────────── */
/* Page-head actions written after a spacer sit at the right edge, like .page-actions. */
.page-head > .spacer { flex: 1 1 0; }
.page-head > :last-child:not(:first-child) { margin-left: auto; }
/* A tick box is never a full-width field (the generic input rule made it one). */
input[type=checkbox], input[type=radio] { width: auto; }
/* Inbox: the middle column may shrink, and its headers wrap, instead of sliding under the Demo phone. */
.inbox > * { min-width: 0; }
.inbox .card-head { flex-wrap: wrap; row-gap: 6px; }
.inbox .card-head .btn, .inbox .card-head .pill, .inbox .card-head .mono { white-space: nowrap; }
.inbox.with-phone { grid-template-columns: minmax(220px, 290px) minmax(0, 1fr) minmax(270px, 320px); }
@media (max-width: 1250px) { .inbox.with-phone { grid-template-columns: minmax(230px, 300px) minmax(0, 1fr); } }
@media (max-width: 820px) { .inbox.with-phone { grid-template-columns: 1fr; } }
.inbox-item .mono { white-space: nowrap; flex: none; }
/* The app is dark only: native scrollbars, date pickers and file buttons follow, instead of flashing white. */
:root { color-scheme: dark; }
