/* =========================================================================
 * notebook.css — the Engineer's Notebook design system
 *
 * Fraunces display / DM Sans UI / JetBrains Mono data, warm paper with a rust
 * accent. The :root block below is shared byte-for-byte with doka-platform-
 * manager, Doka Pocket CRM and TiplistToGo — never retune it per app. Add
 * app-local tokens below it, clearly marked.
 *
 * Copy to css/app.css and delete what this app does not use. Full rulebook:
 * ../engineers-notebook-style/DESIGN-SYSTEM.md
 * ========================================================================= */

:root {
  --paper: #F6F2E9;
  --card: #FFFDF7;
  --ink: #2B2A26;
  --ink-soft: #6B675C;
  --line: #DDD5C4;
  --line-soft: #EAE3D4;
  --rust: #B3502D;
  --rust-deep: #8F3E21;
  --amber: #E0A41B;
  --teal: #1F6F9C;
  --green: #4A7A43;
  --purple: #6E4FA3;
  --warn-bg: #F6E3DC;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --nav-h: 58px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(43, 42, 38, .10), 0 4px 14px rgba(43, 42, 38, .06);
}

* { box-sizing: border-box; }

/* Load-bearing. View switching uses the hidden attribute; an author
 * display:flex on a hidden pane paints an empty overlay over the whole app. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--teal); }

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 640; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

.mono, code, kbd, pre, .kv dt, .kv dd { font-family: var(--font-mono); }
.muted { color: var(--ink-soft); }
.pad { padding: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* The signature small-caps label: field labels, section heads, KPI captions. */
.label, .ctl-label, .panel-sub {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft);
}

.hint { font-size: 12.5px; color: var(--ink-soft); margin: 6px 0 0; }
.hint-warn { color: var(--rust-deep); }

/* ------------------------------------------------------------ buttons ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--rust); border-color: var(--rust-deep); color: #fff; font-weight: 600; }
.btn-primary:hover, .btn-primary:active { background: var(--rust-deep); }
.btn-ghost { border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { color: var(--ink); background: var(--paper); border-color: var(--line); }
.btn-ghost.danger { color: var(--rust-deep); border-color: var(--rust); }
.btn-link { border-color: var(--teal); color: var(--teal); text-decoration: none; }
.btn-tiny { font-size: 12px; padding: 3px 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  color: var(--ink-soft); font-size: 14px; line-height: 1;
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.icon-btn.danger:hover { color: var(--rust-deep); }

/* Touch targets. Apply to the whole app on a mobile-first build. */
.touch .btn { min-height: 42px; padding: 10px 16px; border-width: 1.5px; }
.touch .icon-btn { width: 40px; height: 40px; border-radius: 50%; font-size: 20px; }

/* ------------------------------------------------------------- inputs ---- */

.text-input, input[type=text], input[type=search], input[type=number],
input[type=email], select, textarea {
  width: 100%;
  font-family: var(--font-body); font-size: 13px;
  padding: 6px 9px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); color: var(--ink);
}
input[type=text], input[type=number], input[type=email], select { height: 36px; }
textarea { resize: vertical; min-height: 52px; line-height: 1.5; }
.text-input:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal);
}
.touch .text-input, .touch input, .touch select, .touch textarea {
  font: inherit; padding: 10px 12px; border-width: 1.5px; border-radius: var(--radius);
}
.touch .text-input:focus, .touch input:focus { outline: none; border-color: var(--rust); }

.search-input {
  flex: 1; min-width: 0; font: inherit;
  padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 22px;
  background: var(--card);
}
.search-input:focus { border-color: var(--rust); outline: none; }

/* Labelled control in a toolbar row. */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ctl { display: flex; flex-direction: column; gap: 3px; flex: 1 1 150px; }
.ctl-narrow { flex: 0 0 84px; }
.ctl-wide { flex: 2 1 320px; }
.ctl-actions { display: flex; gap: 7px; }
.controls.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 12px; align-items: end;
}
.controls.form-grid .ctl, .controls.form-grid .ctl-narrow { flex: none; min-width: 0; }
.controls.form-grid .ctl-wide { flex: none; grid-column: 1 / -1; }

/* -------------------------------------------------- chips & segments ---- */

.chip-row {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1.5px solid var(--line); border-radius: 16px;
  background: var(--card);
  font-size: 13px; font-weight: 500; color: var(--ink-soft);
  white-space: nowrap;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.st-a.on { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.chip.st-b.on { background: var(--teal); border-color: var(--teal); color: #FFF8F0; }
.chip.st-c.on { background: var(--green); border-color: var(--green); color: #FFF8F0; }

.status-badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding: 2px 7px; border-radius: 4px;
  background: var(--ink-soft); color: #FFFDF7;
}
.status-badge.st-a { background: var(--amber); color: var(--ink); }
.status-badge.st-b { background: var(--teal); }
.status-badge.st-c { background: var(--green); }

.pill {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  border: 1px solid var(--teal); color: var(--teal);
  border-radius: 999px; padding: 1px 8px;
}
.pill-warn { border-color: var(--rust); color: var(--rust-deep); background: var(--warn-bg); }

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.segmented button {
  padding: 6px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.segmented button.active { background: var(--ink); color: var(--paper); }

.env-chip {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
  cursor: pointer; flex-shrink: 0;
}
.env-chip.is-dev { background: var(--amber); border-color: var(--amber); color: var(--ink); }

/* ------------------------------------------------- cards & the spine ---- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px; margin-bottom: 14px;
}
.card-title { font-family: var(--font-display); font-size: 17px; font-weight: 640; margin: 0 0 8px; }
.card-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* The record card: a filed ticket stub with a colored spine. */
.record-list { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 0; }
.record-card {
  position: relative; display: flex; overflow: hidden; cursor: pointer;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-spine { flex: 0 0 5px; background: var(--ink-soft); }
.record-card.st-a .card-spine { background: var(--amber); }
.record-card.st-b .card-spine { background: var(--teal); }
.record-card.st-c .card-spine { background: var(--green); }
.card-body { flex: 1; min-width: 0; padding: 10px 44px 10px 12px; }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-num { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); letter-spacing: .04em; }
.card-name {
  font-size: 16.5px; line-height: 1.2; margin: 4px 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--ink-soft); }
.card-flag {
  font-size: 10.5px; font-weight: 700;
  background: var(--warn-bg); color: var(--rust-deep);
  border: 1px solid var(--rust); border-radius: 9px; padding: 1px 7px; white-space: nowrap;
}

/* The figure block: mono value over a small-caps caption. Used everywhere. */
.card-figures, .kpi-strip { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 7px; }
.kpi-strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 14px; }
.kpi-strip::-webkit-scrollbar { display: none; }
.fig, .kpi { display: flex; flex-direction: column; line-height: 1.1; flex: 0 0 auto; }
.fig, .kpi-value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.fig i, .kpi-label {
  font-style: normal; font-family: var(--font-body); font-weight: 400;
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft);
}
.fig.warn, .kpi.warn .kpi-value { color: var(--rust-deep); }

/* ------------------------------------------------------ key/value rows ---- */

.dgroup { margin-bottom: 20px; }
.dgroup h3 {
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--rust);
  border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 2px;
}
.dgroup-rows {
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); overflow: hidden;
}
.drow {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
}
.drow:last-child { border-bottom: 0; }
.drow.editable { cursor: pointer; }
.drow.editable:active, .drow.editable:hover { background: var(--paper); }
.drow-label { font-size: 13px; color: var(--ink-soft); flex: 0 1 46%; }
.drow-value {
  font-family: var(--font-mono); font-size: 13.5px; font-weight: 500;
  text-align: right; flex: 1; min-width: 0; overflow-wrap: anywhere;
}
.drow-value.warn { color: var(--rust-deep); }
.drow.has-pending { background: #FBF4E4; }
.q-old { font-family: var(--font-mono); text-decoration: line-through; color: var(--ink-soft); }
.q-arrow { color: var(--rust); }
.q-new { font-family: var(--font-mono); font-weight: 600; color: var(--rust-deep); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--ink-soft); font-size: 11.5px; white-space: nowrap; }
.kv dd { margin: 0; word-break: break-all; }
.kv dd.is-null { color: var(--ink-soft); font-style: italic; }

/* -------------------------------------------------------- data tables ---- */

.tablewrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 7px; margin-top: 10px; }
table.data { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 12px; }
table.data th, table.data td {
  padding: 5px 9px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap;
}
table.data th {
  position: sticky; top: 0; background: var(--paper); cursor: pointer; user-select: none;
  font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-soft); border-bottom: 1px solid var(--line);
}
table.data th:hover { color: var(--rust); }
table.data th.is-sorted { color: var(--rust-deep); }
table.data tbody tr:nth-child(even) { background: #FBF7EE; }
table.data td.is-null { color: var(--ink-soft); font-style: italic; }
table.data td.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-clip { display: inline-block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

/* ----------------------------------------------------- result / tone ---- */

.result { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 14px; overflow: hidden; }
.result-head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--line-soft); }
.result-body { padding: 12px 15px; }
.result-headline { font-size: 14.5px; font-weight: 700; margin: 0 0 3px; }
.result-plain { font-size: 13px; margin: 0; }
.result-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); margin-top: 8px; }

/* Tone drives every colour here. Nothing else sets them. */
.tone-ok     { border-left: 5px solid var(--green); }
.tone-empty  { border-left: 5px solid var(--teal); }
.tone-denied { border-left: 5px solid var(--rust); }
.tone-broken { border-left: 5px solid var(--amber); }
.tone-fatal  { border-left: 5px solid var(--rust-deep); }
.tone-denied .result-head, .tone-fatal .result-head { background: var(--warn-bg); }

.status-chip {
  font-family: var(--font-mono); font-size: 15px; font-weight: 600;
  padding: 3px 10px; border-radius: 6px; color: #fff; white-space: nowrap;
  background: var(--ink-soft);
}
.tone-ok .status-chip { background: var(--green); }
.tone-empty .status-chip { background: var(--teal); }
.tone-denied .status-chip, .tone-fatal .status-chip { background: var(--rust-deep); }
.tone-broken .status-chip { background: var(--amber); color: var(--ink); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-ok { background: var(--green); }
.dot-empty { background: var(--teal); }
.dot-denied { background: var(--rust); }
.dot-broken { background: var(--amber); }
.dot-fatal { background: var(--rust-deep); }

.raw {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.45; margin: 0;
  background: #FBF7EE; border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.cmd {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  background: var(--ink); color: #F1EADC; border-radius: 7px;
  padding: 10px 12px; margin: 8px 0 4px; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
details.raw-wrap { margin-top: 10px; }
details.raw-wrap > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft); padding: 4px 0; }
details.raw-wrap > summary:hover { color: var(--ink); }

/* --------------------------------------------- empty / loading / boot ---- */

.empty-state { text-align: center; padding: 56px 28px; color: var(--ink-soft); }
.empty-mark { font-size: 34px; color: var(--line); margin-bottom: 10px; }
.empty-state h2 { color: var(--ink); font-size: 21px; margin-bottom: 6px; }

.spinner {
  width: 22px; height: 22px; margin: 0 auto 10px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--rust);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.view { min-height: 100%; }
.view-center { display: flex; justify-content: center; padding: 32px 20px; }
.boot-card { text-align: center; color: var(--ink-soft); font-size: 13px; margin: auto; }
.fatal-card {
  max-width: 760px; margin: auto;
  background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--rust-deep); border-radius: var(--radius);
  padding: 24px 28px; box-shadow: var(--shadow);
}
.fatal-title { font-family: var(--font-display); font-size: 24px; margin: 0 0 10px; color: var(--rust-deep); }

/* ---------------------------------------------------------- topbar ------ */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  height: var(--nav-h); padding: 0 18px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; flex-direction: column; line-height: 1.15; flex-shrink: 0; }
.topbar-name { font-family: var(--font-mono); font-size: 14px; font-weight: 600; margin: 0; }
.topbar-sub { font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--rust); }
.topbar-nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; min-width: 0; }
.topbar-right { margin-left: 10px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tabnav-btn {
  font-size: 13px; font-weight: 500; padding: 7px 13px;
  border: 1px solid transparent; border-radius: 7px; color: var(--ink-soft);
}
.tabnav-btn:hover { color: var(--ink); background: var(--paper); }
.tabnav-btn.is-active { color: var(--rust-deep); background: var(--paper); border-color: var(--line); font-weight: 700; }

.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 200px; display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px;
}

/* Mobile search/filter header (sticky, above the list). */
.mobile-topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 10px 12px 8px;
}

/* ------------------------------------------------------ bottom nav ------ */

.tab { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
  display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 11px; font-weight: 500; color: var(--ink-soft);
}
.nav-btn .nav-ico { font-size: 18px; line-height: 1; }
.nav-btn.active { color: var(--rust); }
.nav-btn.active::after {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%;
  height: 2.5px; background: var(--rust); border-radius: 0 0 3px 3px;
}
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 26px);
  min-width: 17px; height: 17px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  background: var(--rust); color: #FFF8F0; border-radius: 9px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
}

/* ------------------------------------------------ overlays & toast ------
 * z-index ladder — keep every overlay inside it:
 *   map / canvas internals  <= 1000
 *   bottom nav                 1500
 *   full-screen detail         2000
 *   sheet / modal              2100
 *   toast                      2200
 */

.overlay { position: fixed; inset: 0; z-index: 2100; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(43, 42, 38, .42); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 86dvh;
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: 16px 16px 0 0;
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 38px; height: 4px; background: var(--line); border-radius: 2px; margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 4px; }
.sheet-scroll { overflow-y: auto; padding: 4px 16px 12px; }
.sheet-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-foot .btn { width: 100%; }

.modal-panel {
  position: absolute; left: 14px; right: 14px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 12px;
  max-width: 640px; margin: 0 auto; max-height: 80dvh; overflow-y: auto;
  background: var(--paper); border-radius: 14px; padding: 20px 16px;
  box-shadow: 0 12px 40px rgba(43, 42, 38, .3);
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.detail-view { position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; background: var(--paper); }
.detail-head {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 10px 12px;
  background: var(--card); border-bottom: 4px solid var(--ink-soft);
}
.detail-head.st-a { border-bottom-color: var(--amber); }
.detail-head.st-b { border-bottom-color: var(--teal); }
.detail-head.st-c { border-bottom-color: var(--green); }
.detail-scroll { flex: 1; overflow-y: auto; padding: 12px 14px; }

.toast {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
  z-index: 2200;
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius); padding: 11px 14px; font-size: 13.5px;
  box-shadow: 0 6px 22px rgba(43, 42, 38, .32);
  opacity: 0; transform: translateY(8px);
  transition: opacity .22s, transform .22s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* ------------------------------------------------ desktop tool layout ---- */

.workspace {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  gap: 16px; padding: 16px;
}
.panel {
  min-height: 0; overflow: auto;
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
}
.panel-scroll { flex: 1; min-height: 0; overflow: auto; }
.page { padding: 18px; max-width: 1400px; margin: 0 auto; }

/* ------------------------------------------------------- credit tag ------
 * The maker's mark. Identical in every app in the family — do not reword it.
 * <a class="credit" href="https://josiahmdavidson.com" target="_blank"
 *    rel="noopener">Built by Claude + Josiah in Illinois 🌽</a>
 * Mobile: bottom of the More tab. Desktop: footer strip or the welcome state. */

.credit {
  display: block; text-align: center; margin-top: 14px; padding-bottom: 20px;
  font-family: var(--font-body); font-size: 11.5px; font-weight: 600;
  color: var(--ink-soft); opacity: .6; text-decoration: none;
}
.credit:hover, .credit:active { opacity: .85; }

/* -------------------------------------------------------- a11y & motion -- */

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
.tabnav-btn:focus-visible, .btn:focus-visible { outline-offset: 1px; }
table.data th:focus-visible { outline-offset: -2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none; border-top-color: var(--line); }
}

/* ------------------------------------------------------------ widths ----- */

/* Centre the reading column once there's room, with paper edges. */
@media (min-width: 740px) {
  .record-list, .mobile-topbar { max-width: 720px; margin-left: auto; margin-right: auto; }
  .mobile-topbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .topbar { padding: 0 10px; gap: 8px; }
  .page { padding: 12px; }
  .cell-clip { max-width: 180px; }
}

@media (max-width: 600px) {
  .page { padding: 10px; }
  .card { padding: 12px; }
  .controls { gap: 8px; }
  .controls.form-grid { grid-template-columns: 1fr; }
  .ctl, .ctl-narrow, .ctl-wide { flex: 1 1 100%; }
  .ctl-actions, .ctl-actions .btn, .card-foot .btn { flex: 1 1 auto; width: 100%; }
  .result-head { flex-direction: column; gap: 8px; }
  .status-chip { align-self: flex-start; }
  .kv { grid-template-columns: 1fr; gap: 1px 0; }
  .kv dt { margin-top: 8px; }
}

/* =========================================================================
 * App-local — Doka Team Travel Hub
 *
 * One local rule: the status → color map is defined ONCE here (.st-*) and
 * picked up by chips, card spines, calendar bars, detail rules and map pins
 * through descendant selectors. Team is a second dimension (.team-*), never
 * a status.
 * ========================================================================= */

:root {
  --st-planned:   #6B675C;   /* ink-soft */
  --st-traveling: #E0A41B;   /* amber */
  --st-on_site:   #1F6F9C;   /* teal */
  --st-done:      #4A7A43;   /* green */
  --st-cancelled: #DDD5C4;   /* line */
  --team-fs:      #B3502D;   /* field service = rust */
  --team-ops:     #6E4FA3;   /* operations = purple */
  --cal-col:      120px;     /* week column min width; month view narrows it */
  --cal-lane:     28px;      /* one bar lane */
}

.st-planned   { --st: var(--st-planned); }
.st-traveling { --st: var(--st-traveling); }
.st-on_site   { --st: var(--st-on_site); }
.st-done      { --st: var(--st-done); }
.st-cancelled { --st: var(--st-cancelled); }
.team-field_service { --team: var(--team-fs); }
.team-operations    { --team: var(--team-ops); }

.status-badge[class*="st-"] { background: var(--st); color: #FFF8F0; }
.status-badge.st-cancelled { color: var(--ink-soft); }
.record-card[class*="st-"] .card-spine { background: var(--st); }
.detail-head[class*="st-"] { border-bottom-color: var(--st); }
.team-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--team); color: var(--team);
}

/* ---- gate (welcome / sign-in / loading / not provisioned / error) ------- */

.setup {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 18px;
}
.setup-card { width: 100%; max-width: 420px; text-align: center; }
.brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--rust); margin-bottom: 18px;
}
.brand-rule { flex: 0 0 34px; height: 1px; background: var(--rust); opacity: .5; }
.setup-card h1 { font-size: 34px; line-height: 1.1; margin-bottom: 12px; }
.setup-sub { color: var(--ink-soft); margin: 0 0 22px; }
.setup-status { margin-top: 16px; min-height: 24px; font-family: var(--font-mono); font-size: 13px; }
.setup-status .spinner { display: inline-block; width: 14px; height: 14px; margin: 0 8px -2px 0; }
.setup-error { color: var(--rust-deep); }
.setup-choice { width: 100%; margin-top: 8px; }
/* Clerk's prebuilt sign-in mounts here. min-height reserves the space so the
 * card doesn't jump when the widget (and then the MFA step) renders. */
.clerk-mount { display: flex; justify-content: center; margin: 6px 0 14px; min-height: 320px; }

/* ---- shell --------------------------------------------------------------- */

.app { min-height: 100dvh; display: flex; flex-direction: column; }
.app > .view { flex: 1; min-height: 0; }
.topbar-right { position: relative; }
.me-card { font-size: 12.5px; color: var(--ink-soft); padding: 2px 4px 6px; border-bottom: 1px solid var(--line-soft); }
.me-card .mono { display: block; font-size: 11px; }
.me-card b { color: var(--ink); display: block; }
.me-prefs { display: flex; flex-direction: column; gap: 4px; padding: 6px 4px 8px; border-bottom: 1px solid var(--line-soft); }
.me-prefs .ctl-label { margin-top: 4px; }
.me-pref-row { display: flex; align-items: center; gap: 8px; }
.me-pref-row .text-input { width: 72px; }
.me-prefs .hint { margin: 0; font-size: 11.5px; }
.menu .btn-ghost { text-align: left; padding: 6px 8px; }
.banner {
  margin: 12px 18px 0; padding: 10px 14px;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--teal);
  border-radius: var(--radius); font-size: 13.5px; color: var(--ink-soft);
}
.banner.warn { border-left-color: var(--rust); background: var(--warn-bg); color: var(--rust-deep); }
.foot { padding: 0 18px; }
.view-loading { padding: 56px 28px; text-align: center; color: var(--ink-soft); font-size: 13px; }
@media (max-width: 600px) {
  .topbar { padding: 0 10px; gap: 10px; }
  .topbar-sub { display: none; }
  .foot .credit { display: none; }
}

/* ---- calendar ---------------------------------------------------------------
 * The header and every row are the same CSS grid columns, so bars placed by
 * percentage inside .cal-cells line up with the day headers without any
 * measuring. Sticky first column + sticky header make the month view
 * scroll like a spreadsheet. */

.view-cal { padding: 14px 18px 8px; display: flex; flex-direction: column; gap: 10px; }
.cal-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-range { font-size: 13px; margin-left: 8px; color: var(--ink); }
.cal-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.cal-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.cal-filters { align-items: center; padding-bottom: 4px; }
.chip-gap { flex: 0 0 8px; }
.chip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--st); margin-right: 6px; vertical-align: 0; }
.chip[class*="st-"].on { background: var(--st); border-color: var(--st); color: #FFF8F0; }
.chip.st-cancelled.on { color: var(--ink); }
.chip.on .chip-dot { background: #FFF8F0; }
.cal-select { height: 32px; font-size: 13px; padding: 0 8px; width: auto; }

.cal-body { flex: 1; min-height: 0; }
.cal-grid {
  display: grid; grid-template-columns: 180px repeat(var(--cal-n), minmax(var(--cal-col), 1fr));
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: auto; max-height: calc(100dvh - var(--nav-h) - 150px);
  font-size: 12.5px;
}
.cal-grid.cal-month { --cal-col: 34px; }
.cal-head { display: contents; }
.cal-corner, .cal-day {
  position: sticky; top: 0; z-index: 3; background: var(--paper);
  border-bottom: 1px solid var(--line); padding: 6px 8px; min-height: 44px;
}
.cal-corner { left: 0; z-index: 4; border-right: 1px solid var(--line); display: flex; align-items: flex-end; }
.cal-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.15; border-left: 1px solid var(--line-soft); }
.cal-dow { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.cal-dom { font-size: 14px; font-weight: 600; }
.cal-month .cal-dow { font-size: 9px; letter-spacing: .04em; }
.cal-month .cal-dom { font-size: 12px; }
.cal-day.is-weekend { background: #F0EBE0; }
.cal-day.is-today .cal-dom { color: var(--rust); }
.cal-day.is-today { box-shadow: inset 0 -2.5px 0 var(--rust); }

.cal-row { display: contents; }
.cal-person {
  position: sticky; left: 0; z-index: 2; background: var(--card);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-soft);
  padding: 6px 8px; display: flex; align-items: center; gap: 8px; min-width: 0;
}
.cal-person-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.cal-cells {
  grid-column: 2 / -1; position: relative; border-bottom: 1px solid var(--line-soft); min-height: 36px;
}
.cal-cell { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line-soft); }
.cal-cell.is-today { background: rgba(179, 80, 45, .05); }
.cal-cells.can-book .cal-cell { cursor: copy; }
.cal-cells.can-book .cal-cell:hover { background: rgba(31, 111, 156, .06); }

.cal-bar {
  position: absolute; height: 24px; padding: 0 8px; margin: 0 1px;
  display: flex; align-items: center; overflow: hidden; white-space: nowrap;
  border-radius: 6px; background: var(--st); color: #FFF8F0; font-size: 12px; font-weight: 500;
  box-shadow: 0 1px 2px rgba(43, 42, 38, .18); text-align: left; min-width: 6px;
  transition: filter .12s ease;
}
.cal-bar span { overflow: hidden; text-overflow: ellipsis; font-family: var(--font-body); }
.cal-bar.is-timed span::first-line { font-family: var(--font-mono); }
.cal-bar:hover { filter: brightness(.92); }
.cal-bar.st-planned { background: var(--card); color: var(--ink); border: 1.5px solid var(--st-planned); }
.cal-bar.st-cancelled { background: var(--paper); color: var(--ink-soft); border: 1px dashed var(--line); text-decoration: line-through; box-shadow: none; }
.cal-bar.clip-start { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 0; }
.cal-bar.clip-end { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-month .cal-bar { padding: 0 4px; font-size: 11px; }
.cal-bar.dragging { opacity: .55; cursor: grabbing; }
.cal-bar.can-drag { cursor: grab; }

@media (max-width: 900px) {
  .view-cal { padding: 10px 10px 6px; }
  .cal-grid { grid-template-columns: 120px repeat(var(--cal-n), minmax(var(--cal-col), 1fr)); --cal-col: 92px; }
  .cal-tools { margin-left: 0; }
}

/* ---- trip page ------------------------------------------------------------ */

.trip { max-width: 1100px; }
.trip-crumbs { margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.trip-head { margin-bottom: 14px; }
.trip-head .card-name { white-space: normal; display: flex; align-items: center; gap: 10px; font-size: 21px; }
.trip-task { margin: 8px 0 0; font-size: 15px; }
.trip-grid { align-items: start; }
.trip-status { display: inline-flex; margin-bottom: 4px; }
.trip-status button { padding: 7px 12px; font-size: 13px; }
.trip-status button:disabled { opacity: .5; cursor: not-allowed; }
.trip-notes { width: 100%; min-height: 150px; resize: vertical; font-family: var(--font-body); font-size: 14px; line-height: 1.45; padding: 10px 12px; }
.trip-notes-ro { white-space: pre-wrap; font-size: 14px; line-height: 1.45; padding: 10px 12px; background: #FBF7EE; border-radius: 7px; border: 1px solid var(--line-soft); }
.trip-check { list-style: none; margin: 0; padding: 0; }
.trip-check li { border-bottom: 1px solid var(--line-soft); }
.trip-check label { display: flex; align-items: center; gap: 10px; padding: 8px 4px; cursor: pointer; font-size: 14px; }
.trip-check .is-done { color: var(--ink-soft); text-decoration: line-through; }
.trip-add { display: flex; gap: 8px; margin-top: 10px; }
.trip-add .text-input { flex: 1; }
.trip-ev { text-align: right; font-family: var(--font-body); font-size: 13px; }
.trip-danger { border-top: 1px dashed var(--line); padding-top: 12px; }
.dgroup h3 .pill { margin-left: 8px; vertical-align: 2px; }

/* ---- booking ------------------------------------------------------------------ */

.book { max-width: 1180px; }
.book-head { margin-bottom: 12px; }
.book-head .hint { margin: 2px 0 0; }
.book-grid { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(320px, 440px); gap: 16px; align-items: start; }
.book-panel { gap: 14px; }
.book-panel .ctl { width: 100%; }
.book-dates { margin-top: 4px; }
.typeahead { position: relative; }
.typeahead .text-input { width: 100%; }
.typeahead-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow);
  max-height: 300px; overflow-y: auto; padding: 4px;
}
.typeahead-item {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%;
  padding: 7px 10px; border-radius: 6px; text-align: left; font-size: 14px;
}
.typeahead-item:hover, .typeahead-item:focus-visible { background: var(--paper); }
.typeahead-meta { font-size: 12px; color: var(--ink-soft); }
.typeahead-new { color: var(--teal); font-weight: 500; border-top: 1px dashed var(--line); border-radius: 0; margin-top: 4px; padding-top: 9px; }
.book-newloc { border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 12px; background: #FBF7EE; }
.book-newloc .hint { margin: 0 0 6px; }
.book-people-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.book-people { display: flex; flex-direction: column; gap: 6px; max-height: 50dvh; overflow-y: auto; }
.book-person {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px;
  align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  background: var(--card);
}
.book-person input { grid-row: 1 / 3; margin: 0; }
.book-person.on { border-color: var(--rust); box-shadow: 0 0 0 2px rgba(179, 80, 45, .15); }
.book-person.is-unavail { background: var(--paper); }
.book-person-name { font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.book-person-meta { font-size: 12.5px; color: var(--ink-soft); }
.book-empty { padding: 24px 12px; }
.book-unavail summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); padding: 6px 2px; }
.book-unavail .book-person { margin-top: 6px; }
.book-warnings { display: flex; flex-direction: column; gap: 8px; }
.book-warnings .result { margin: 0; }
.book-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
@media (max-width: 900px) {
  .book-grid { grid-template-columns: 1fr; }
  .book-people { max-height: none; }
}
/* .ctl carries flex: 1 1 150px for toolbar rows; inside a column panel that
 * basis becomes HEIGHT and leaves a 150px hole under the field. */
.book-panel > .ctl { flex: none; }

/* ---- map ----------------------------------------------------------------------- */

.view-map { padding: 14px 18px 8px; display: flex; flex-direction: column; gap: 10px; }
.map-toolbar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.map-ctl { flex: none; }
.map-scrub { min-width: 240px; flex: 1 1 260px; }
.map-scrub input[type=range] { width: 100%; accent-color: var(--rust); margin: 8px 0 6px; }
.map-chips { flex: 0 1 auto; align-items: center; padding-bottom: 4px; }
.map-homes { padding-bottom: 8px; }
.map-layout {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 1fr; gap: 12px;
  height: calc(100dvh - var(--nav-h) - 120px); min-height: 380px;
}
.map-side { padding: 10px; gap: 8px; }
.map-side-head { padding: 2px 4px 6px; border-bottom: 1px dashed var(--line); }
.map-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.map-row {
  display: flex; align-items: stretch; text-align: left; gap: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.map-row.on { border-color: var(--rust); box-shadow: 0 0 0 2px rgba(179, 80, 45, .15); }
.map-row-spine { flex: 0 0 4px; background: var(--st, var(--line)); }
.map-row.st-home .map-row-spine { background: var(--line); }
.map-row-body { display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; min-width: 0; }
.map-row-name { font-weight: 500; display: flex; align-items: center; gap: 6px; }
.map-row-loc { font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-row-meta { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.map-empty { padding: 32px 12px; }
.map-stage { position: relative; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.map-canvas { position: absolute; inset: 0; background: #E8E4D8; }
.map-hint {
  position: absolute; left: 10px; bottom: 10px; z-index: 900;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 9px; font-size: 12px; color: var(--ink-soft); box-shadow: var(--shadow);
}
.pin-wrap { background: none; border: 0; }
.pin {
  display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--st); color: #FFF8F0; font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  border: 2.5px solid var(--team, var(--card)); box-shadow: 0 1px 4px rgba(43, 42, 38, .35);
}
.pin.st-planned { background: var(--card); color: var(--ink); }
.pin.is-home { background: var(--paper); color: var(--ink-soft); border-style: dashed; box-shadow: none; }
.pin-cluster {
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: var(--ink); color: var(--paper); font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  border: 2px solid var(--card); box-shadow: 0 1px 4px rgba(43, 42, 38, .35);
}
.map-pop { font-family: var(--font-body); }
.map-pop-name { font-weight: 700; font-size: 14px; }
.map-pop-loc { font-size: 12.5px; color: var(--ink-soft); }
.map-pop-fig { font-family: var(--font-mono); font-size: 11.5px; margin: 6px 0 8px; }
.map-pop .btn { display: block; text-align: center; text-decoration: none; }
.leaflet-container { font-family: var(--font-body); background: #E8E4D8; }
.leaflet-popup-content-wrapper { background: var(--card); color: var(--ink); border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-popup-tip { background: var(--card); }
.leaflet-bar a { color: var(--ink); }
@media (max-width: 900px) {
  .view-map { padding: 10px 10px 6px; }
  .map-layout { grid-template-columns: 1fr; grid-template-rows: 1fr 220px; height: auto; min-height: calc(100dvh - var(--nav-h) - 160px); }
  .map-side { order: 2; }
}

/* ---- blocked-out time ---------------------------------------------------
 * Not a status, so it never borrows a status colour. A block reads as
 * absence: hatched, muted, no pointer, nothing to open. */

.cal-bar.cal-block {
  background: repeating-linear-gradient(135deg,
    var(--line-soft) 0 6px, var(--card) 6px 12px);
  border: 1px dashed var(--line);
  color: var(--ink-soft);
  cursor: default;
  display: flex; align-items: center;
}
.cal-bar.cal-block span {
  font-size: 11px; font-style: italic;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px;
}
.cal-bar.cal-block.blk-sick { border-color: var(--rust); }
.cal-bar.cal-block.blk-training { border-color: var(--teal); }

/* The same idea in the booking list: a reason, not an error. */
.avail-block {
  font-size: 12px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px;
}
.avail-block .blk-tag {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .06em; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px;
}

/* ---- admin page ---------------------------------------------------------
 * Three tables behind three tabs. Deliberately plain: this is maintenance,
 * not a dashboard, and the interesting screens are the calendar and map. */

.admin-tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.admin-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.admin-head > div:first-child { flex: 1; min-width: 0; }
.admin-head h2 { margin-bottom: 4px; }
.hint { font-size: 12.5px; color: var(--ink-soft); margin: 0; max-width: 68ch; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-soft); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--paper);
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.is-off td { opacity: .55; }
table.data .mono { font-size: 12px; }

.chip {
  display: inline-block; font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; white-space: nowrap;
}
.chip.tone-ok { color: var(--green); border-color: var(--green); }
.chip.tone-warn { color: var(--rust-deep); border-color: var(--rust); }

/* Sheet forms. Two columns on a desktop, one on a phone. */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span:first-child {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); font-weight: 700;
}
.field input, .field select, .field textarea {
  font: inherit; padding: 8px 10px; border: 1.5px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink); min-width: 0;
}
.field input:focus, .field select:focus { border-color: var(--teal); outline: none; }
.field .hint { font-size: 11.5px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13.5px; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

/* ---- topbar at narrow widths --------------------------------------------
 * The bar is a fixed-height flex row, so a wrapping nav used to overflow it
 * and print the tabs on top of the brand. Four destinations made that
 * reachable on an ordinary laptop, not just a phone: below 760px the bar
 * becomes two rows, brand and account first, destinations under them. */

.topbar-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.topbar-nav::-webkit-scrollbar { display: none; }

@media (max-width: 760px) {
  .topbar { height: auto; min-height: var(--nav-h); flex-wrap: wrap; padding: 8px 12px; gap: 8px 12px; }
  .topbar-nav { order: 3; width: 100%; margin-left: 0; }
  .topbar-right { margin-left: auto; }
}

/* The chosen project, shown instead of the input once picked. */
.book-project .picked {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card);
}
.book-project .picked .btn { margin-left: auto; }

/* ---- calendar toolbar, rebuilt -------------------------------------------
 * One row. The grid is what people came for, so the controls above it stay
 * to a view toggle, date navigation and two buttons. Filtering lives in a
 * sheet; what is actually on shows as a removable chip row, and only then. */

.cal-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--card);
}
.cal-toolbar .cal-range { margin-left: 2px; font-size: 13px; color: var(--ink-soft); }
.cal-toolbar .cal-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.cal-nav { display: flex; align-items: center; gap: 4px; }

.cal-active {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 18px; border-bottom: 1px solid var(--line-soft); background: var(--paper);
}
.chip-clear { cursor: pointer; border-style: solid; }
.chip-clear:hover { border-color: var(--rust); color: var(--rust-deep); }
.linkish { font-size: 12px; color: var(--teal); text-decoration: underline; margin-left: 4px; }

/* Status chips inside the filter sheet: off is an outline, on is filled. */
#fStatus .chip { cursor: pointer; padding: 4px 10px; font-size: 11px; }
#fStatus .chip.on { background: var(--st, var(--ink)); color: #FFF8F0; border-color: transparent; }

@media (max-width: 700px) {
  .cal-toolbar { padding: 8px 12px; gap: 8px; }
  .cal-toolbar .cal-range { order: 5; width: 100%; margin: 0; }
  .cal-active { padding: 8px 12px; }
}

/* ---- admin: searchable pickers and the add-person flow ------------------ */

.field-picker { position: relative; }
.picker-input {
  font: inherit; padding: 8px 10px; border: 1.5px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink); width: 100%;
}
.picker-input:focus { border-color: var(--teal); outline: none; }
.field-picker .typeahead-list { top: calc(100% - 14px); }
.field-picker .picked, .book-project .picked {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card);
}
.field-picker .picked > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ap-results { margin-top: 4px; max-height: 46dvh; overflow-y: auto; }
.ap-group { margin-bottom: 14px; }
.ap-group h4 {
  margin: 0 0 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-soft); font-weight: 700;
}
.ap-group .hint { margin-top: 6px; }
.ap-linked {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--green);
  border-radius: var(--radius); background: var(--card); margin-bottom: 14px;
}
.ap-linked b { font-size: 16px; }
.ap-linked .hint { margin-top: 4px; }
.admin-sub {
  margin: 22px 0 8px; font-size: 15px;
  display: flex; align-items: center; gap: 8px;
}

/* A .field is a flex column, so its control stretched to whatever the
 * tallest cell in the grid row was, turning every <select> into a tall
 * listbox. Controls size to their content; the field, not the input,
 * absorbs the leftover height. */
.field > input, .field > select, .field > .picker-input, .field > .picked { flex: 0 0 auto; }
.field > select { height: 38px; }
.form-grid > .field { align-self: start; }
