/* ============================================================
   Alderline CRM · styles.css
   Alderline's own brand (not SQS): roast brown, bark, cream, leaf green,
   clay. Fraunces for display, Inter for text. One light theme; a coffee
   roaster prints route sheets and works in daylight.
   ============================================================ */

:root {
  --roast: #3B2418; --roast-deep: #2A1810; --bark: #6B4A34; --bark-soft: #EFE4D6;
  --cream: #F6F1E7; --cream-2: #EFE7D8;
  --leaf: #3E7C4A; --leaf-deep: #2F6139; --leaf-soft: #E3EFE5;
  --clay: #C8763A; --clay-deep: #A85F2B; --clay-soft: #F7E6D8;
  --red: #B3392B; --red-deep: #8E2C21; --red-soft: #F6E2DF;
  --info: #4C6A8A; --info-soft: #E4EAF1;
  --ink: #1F1712; --ink-2: #4A3B33; --muted: #7A6A60; --faint: #A99C92;
  --line: #E7DCCB; --line-2: #D9CBB7; --surface: #FFFFFF; --surface-2: #FBF8F2;

  /* chart series (validated for colour-vision safety) */
  --series-1: #9C4A21; --series-muted: #C4B4A3;
  --ord-1: #E0A583; --ord-2: #C97B4E; --ord-3: #A9522A; --ord-4: #7A2E12;
  --roast-morning: #C9772A; --roast-slowriver: #3A72C4; --roast-bridgetown: #8F2F14; --roast-harvest: #7D4FA8;
  --grid: rgba(31, 23, 18, .10); --axis: var(--faint);

  /* the crew, same values as shared/tokens.css */
  --c-anvil: hsl(215 70% 25%); --c-ember: hsl(18 88% 52%); --c-flint: hsl(262 55% 52%); --c-gauge: hsl(150 60% 36%);
  --c-warden: hsl(0 65% 46%); --c-beacon: hsl(35 90% 46%); --c-ledger: hsl(190 85% 34%); --c-quill: hsl(300 40% 42%);
  --c-bellows: hsl(210 80% 44%); --c-founder: hsl(215 50% 14%);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;
  --r: 10px; --r-lg: 14px; --r-sm: 6px;
  --shadow: 0 1px 2px rgba(59, 36, 24, .06), 0 10px 30px -18px rgba(59, 36, 24, .35);
  --shadow-lg: 0 2px 6px rgba(59, 36, 24, .08), 0 28px 60px -28px rgba(59, 36, 24, .45);
  --ease: cubic-bezier(.2, .6, .2, 1);
  --sidebar: 236px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--cream); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; color: var(--roast); font-family: var(--display); font-weight: 600; letter-spacing: -.01em; line-height: 1.15; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.15rem; } h3 { font-size: .98rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .75em; } p:last-child { margin-bottom: 0; }
a { color: var(--leaf-deep); text-decoration: none; } a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .86em; background: var(--cream-2); padding: 1px 5px; border-radius: 4px; }
b, strong { font-weight: 600; }
time { color: var(--muted); }
mark { background: #FBEBC2; color: inherit; border-radius: 3px; padding: 0 2px; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--roast); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 8px; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; }

/* ------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.sidebar { grid-row: 1 / 3; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--roast); color: var(--cream); padding: 18px 14px 14px; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; color: inherit; font-family: var(--display); font-weight: 700; font-size: 1.35rem; letter-spacing: -.01em; padding: 4px 8px; }
.wordmark:hover { text-decoration: none; }
.wordmark .leaf-mark { width: 26px; height: 26px; color: #9CCB9F; }
.wordmark.compact { display: none; color: var(--roast); }
.wordmark.compact .leaf-mark { color: var(--leaf); }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 22px; }
.navlink { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: rgba(246, 241, 231, .78); font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease); }
.navlink:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.navlink.active { background: rgba(255, 255, 255, .13); color: #fff; }
.navlink .ic { width: 19px; height: 19px; opacity: .9; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--clay); color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .12); display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.me b { display: block; color: #fff; font-size: .9rem; } .me span:not(.avatar) { display: block; color: rgba(246, 241, 231, .6); font-size: .78rem; }
.me .avatar { background: var(--leaf); color: #fff; }
.foot-link { color: rgba(246, 241, 231, .6); font-size: .78rem; padding: 0 6px; }
.foot-link:hover { color: #fff; }

.topbar { grid-column: 2; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: rgba(246, 241, 231, .88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.global-search { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; max-width: 520px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 14px; color: var(--muted); }
.global-search:focus-within { border-color: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-soft); }
.global-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); padding: 3px 0; }
.global-search input::placeholder { color: var(--faint); }
.badge.demo { background: var(--roast); color: var(--cream); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .68rem; padding: 4px 9px; }
.crew-toggle.top { margin-left: auto; }

.content { grid-column: 2; width: 100%; max-width: 1360px; padding: 20px 28px 56px; min-width: 0; }
main { display: block; outline: none; min-width: 0; }
.view { min-width: 0; }
.view { animation: rise .28s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.app-foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

/* banner */
.banner { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--leaf); border-radius: var(--r); box-shadow: var(--shadow); }
.banner > .ic { color: var(--leaf); margin-top: 2px; }
.banner p { flex: 1; margin: 0; color: var(--ink-2); }
.banner a { font-weight: 600; white-space: nowrap; }

/* bottom bar (mobile) */
.bottombar { display: none; }
.sheet { display: none; }

/* ------------------------------------------------------------ page head, stats, grids */
.pagehead { margin-bottom: 18px; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .82rem; margin-bottom: 8px; }
.crumbs .ic { width: 14px; height: 14px; }
.pagehead-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pagehead h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagehead .h-sub { font-family: var(--font); font-weight: 500; color: var(--muted); font-size: 1rem; }
.pagehead .sub { margin: 6px 0 0; color: var(--muted); max-width: 70ch; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .label { color: var(--muted); font-size: .78rem; font-weight: 500; }
.stat .value { font-size: 1.6rem; font-weight: 600; color: var(--roast); line-height: 1.15; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat .sub { color: var(--muted); font-size: .78rem; }
.stat.warn { border-left: 3px solid var(--clay); }
.delta { font-weight: 600; } .delta.up { color: var(--leaf-deep); } .delta.down { color: var(--red); }
.load { display: inline-flex; align-items: center; gap: 4px; font-size: 1.1rem; margin-right: 8px; }

.grid { display: grid; gap: 16px; }
.grid.dash { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.routes { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.grid.detail { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.span2 { grid-column: span 2; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack-cards { display: flex; flex-direction: column; gap: 16px; }

/* ------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 0; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-aside { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: .82rem; flex-wrap: wrap; }
.card-body { padding: 14px 18px 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 10px 18px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.table-card { overflow: hidden; }
.crew-card { background: linear-gradient(160deg, #FFFDF8, var(--bark-soft)); }
.link { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: .85rem; }
.link .ic { width: 14px; height: 14px; }
.fine { color: var(--muted); font-size: .8rem; margin: 10px 0 0; }
.fine .ic { width: 13px; height: 13px; vertical-align: -2px; }
.count-pill { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--cream-2); color: var(--bark); font-family: var(--font); font-size: .75rem; font-weight: 700; }

.empty { text-align: center; padding: 26px 18px; color: var(--muted); }
.empty-mark { width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 50%; background: var(--leaf-soft); color: var(--leaf); display: grid; place-items: center; }
.empty-mark .leaf-mark { width: 24px; height: 24px; }
.empty h3 { color: var(--ink-2); font-family: var(--font); font-size: .95rem; margin-bottom: 4px; }
.empty p { max-width: 42ch; margin: 0 auto; font-size: .88rem; }
.empty-action { margin-top: 12px; }

/* ------------------------------------------------------------ buttons, badges, chips */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .88rem; cursor: pointer; line-height: 1.2; text-decoration: none; transition: background .15s var(--ease), border-color .15s var(--ease), transform .08s var(--ease); white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--bark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.btn.primary:hover { background: var(--leaf-deep); border-color: var(--leaf-deep); }
.btn.danger { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--bark); }
.btn.ghost:hover { background: var(--bark-soft); border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: .8rem; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.iconbtn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.iconbtn:hover { background: var(--cream-2); color: var(--ink); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; line-height: 1.5; background: var(--cream-2); color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.badge .ic { width: 12px; height: 12px; }
.badge.good { background: var(--leaf-soft); color: var(--leaf-deep); }
.badge.warn { background: var(--clay-soft); color: var(--clay-deep); }
.badge.bad { background: var(--red-soft); color: var(--red-deep); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: var(--cream-2); color: var(--muted); }
.badge.bark { background: var(--bark-soft); color: var(--bark); }
.badge.flag { background: #F1E6F7; color: #6A3D8F; font-family: var(--mono); font-weight: 600; letter-spacing: .01em; }
.badge.cat { background: var(--bark-soft); color: var(--bark); text-transform: lowercase; }
.badge.linear { background: #E9E6F7; color: #4B3C9A; font-family: var(--mono); }
.badge.gate { background: var(--clay-soft); color: var(--clay-deep); }
.badge.ready { background: var(--leaf-soft); color: var(--leaf-deep); }
.badge.link { background: var(--surface-2); border: 1px solid var(--line); color: var(--leaf-deep); }
.badge.link:hover { border-color: var(--leaf); text-decoration: none; }
.badge.prio { font-family: var(--mono); min-width: 32px; justify-content: center; }
.badge.dot-badge i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.route-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--bark); font-weight: 600; font-size: .78rem; white-space: nowrap; }
.route-chip .ic { width: 13px; height: 13px; }
.route-chip:hover { border-color: var(--bark); text-decoration: none; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); font-size: .8rem; font-weight: 600; color: var(--ink); white-space: nowrap; vertical-align: middle; }
.chip .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--ac, var(--bark)); color: #fff; font-family: var(--display); font-size: .68rem; font-weight: 700; display: grid; place-items: center; }
.chip-link { display: inline-flex; text-decoration: none; }
.chip-link:hover .chip { border-color: var(--ac, var(--bark)); }
.crew-row { display: flex; flex-wrap: wrap; gap: 6px; }

.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--bark-soft); color: var(--bark); font-size: .72rem; font-weight: 700; flex: 0 0 auto; }
.actor { display: inline-flex; align-items: center; gap: 8px; }
.actor.person .avatar { width: 24px; height: 24px; font-size: .66rem; }
.actor b { font-weight: 600; white-space: nowrap; }

.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

/* ------------------------------------------------------------ toolbar, forms */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search-field { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px; padding: 6px 12px; color: var(--muted); min-width: 240px; flex: 1 1 260px; max-width: 420px; }
.search-field.wide { max-width: 640px; }
.search-field:focus-within { border-color: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-soft); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.sel { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px; padding: 0 0 0 10px; color: var(--muted); font-size: .82rem; }
.sel span { white-space: nowrap; }
.sel select { border: 0; background: transparent; padding: 8px 8px 8px 4px; color: var(--ink); font-weight: 500; max-width: 220px; }
.sel:focus-within { border-color: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-soft); }
.sel select:focus-visible { outline: none; }
.count { margin-left: auto; color: var(--muted); font-size: .82rem; }

.form { display: grid; gap: 12px; }
.form.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form.stack { grid-template-columns: 1fr; margin-bottom: 14px; }
.form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.form.inline label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); font-weight: 500; }
.form.inline label.grow { flex: 1 1 200px; }
.form.inline .btn-row { margin: 0; }
.form.wrap { margin-bottom: 14px; }
.card-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .note-form > label { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--muted); font-size: .76rem; }
input:not([type="search"]):not([type="checkbox"]), select, textarea { width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; background: var(--surface); color: var(--ink); transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.form.inline input, .form.inline select { width: auto; min-width: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-soft); }
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
textarea[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; min-width: 0; }
legend { font-size: .8rem; font-weight: 600; color: var(--ink-2); padding: 0 4px; }
.mixinputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mixinputs label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); }
.mix-sum { display: block; margin-top: 6px; color: var(--muted); font-size: .76rem; }
.mix-sum.bad { color: var(--red); font-weight: 600; }
.alert { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; padding: 9px 12px; border-radius: 8px; background: var(--red-soft); color: var(--red-deep); font-weight: 500; }
.alert .ic { width: 16px; height: 16px; flex: 0 0 auto; }

/* ------------------------------------------------------------ tables */
/* contain: inline-size keeps a wide table from widening the page; the wrap scrolls instead. */
.table-wrap { overflow-x: auto; max-height: min(70vh, 720px); overflow-y: auto; border-radius: inherit; contain: inline-size; position: relative; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.table th { position: sticky; top: 0; z-index: 2; text-align: left; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .74rem; letter-spacing: .03em; text-transform: uppercase; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .meta, .meta { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; }
.table .meta .ic { width: 12px; height: 12px; vertical-align: -2px; }
.table .rowlink { color: var(--ink); } .table .rowlink:hover { color: var(--leaf-deep); }
.table .rowlink .avatar { margin-right: 8px; vertical-align: middle; }
.table.dense th, .table.dense td { padding: 8px 12px; }
.table tfoot td { background: var(--surface-2); border-top: 2px solid var(--line-2); border-bottom: 0; font-weight: 600; }
.mixcell { min-width: 120px; }
.nowrap { white-space: nowrap; }
.quiet { color: var(--muted); }
tr.me td { background: var(--leaf-soft) !important; }
td .avatar { margin-right: 8px; vertical-align: middle; }

/* ------------------------------------------------------------ roast mix */
.mixbar { display: flex; gap: 2px; height: 10px; border-radius: 4px; overflow: hidden; background: var(--cream-2); }
.mixbar.tall { height: 18px; border-radius: 6px; }
.mixbar .seg { display: block; min-width: 3px; }
.mixbar.empty { background: var(--cream-2); }
.mixlegend { display: grid; gap: 6px; margin-top: 10px; }
.mixlegend li { display: flex; align-items: center; gap: 6px; font-size: .84rem; }
.mixlegend li span { color: var(--ink-2); flex: 1; }
.mixlegend li b { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ lists */
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li a, .list li > span { display: block; }
.list.risk li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; }
.list.risk a { color: var(--ink); flex: 1; min-width: 0; }
.list.risk a b { display: block; }
.list.risk .right { text-align: right; } .list.risk .right b { color: var(--red); display: block; }
.list.tickets li a { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 9px 0; color: var(--ink); align-items: baseline; }
.list.tickets li a:hover b { color: var(--leaf-deep); }
.list.tickets .meta { grid-column: 2; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tid { font-family: var(--mono); font-size: .78rem; font-weight: 600; color: var(--bark); background: var(--bark-soft); padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.tid.big { font-size: 1rem; padding: 2px 8px; vertical-align: middle; }
.people li a { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--ink); border-bottom: 1px solid var(--line); }
.people li:last-child a { border-bottom: 0; }
.people li a:hover b { color: var(--leaf-deep); }
.people b { display: block; }
.acct-link { display: block; color: var(--ink); }
.acct-link b { display: block; color: var(--roast); font-family: var(--display); font-size: 1.05rem; }
.facts { display: grid; gap: 10px; margin: 0; }
.facts div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; }
.facts dt { color: var(--muted); font-size: .8rem; font-weight: 500; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts-list li:last-child { border-bottom: 0; }
.facts-list b { display: block; } .facts-list .right { text-align: right; }
.results li { border-bottom: 1px solid var(--line); }
.results li:last-child { border-bottom: 0; }
.results li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; color: var(--ink); align-items: center; }
.results li a b { display: block; }
.results li a .tid { justify-self: start; margin-bottom: 2px; }
.results li a .meta { grid-column: 1; }
.results .right { grid-column: 2; grid-row: 1 / 4; display: flex; gap: 6px; }

/* feed */
.feed li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.feed li:last-child { border-bottom: 0; }
.feed li > time { font-variant-numeric: tabular-nums; font-size: .8rem; padding-top: 3px; min-width: 44px; }
.feed .text { color: var(--ink-2); line-height: 1.45; padding-top: 2px; }
.feed .text a { color: inherit; } .feed .text a:hover { color: var(--leaf-deep); }
.feed.compact li { grid-template-columns: auto 1fr auto; }
.feed.compact li > time { grid-column: 3; padding-top: 3px; font-size: .76rem; white-space: nowrap; }
.feed .actor { padding-top: 1px; }
.day { position: sticky; top: 62px; z-index: 1; margin: 6px -18px 0; padding: 8px 18px 6px; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-family: var(--font); font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; text-transform: uppercase; }
.feed-card { padding: 0 18px 12px; }
.feed-card .day:first-child { margin-top: 0; border-top: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.feed-card .empty { padding-top: 26px; }
.more { padding: 14px 0 0; text-align: center; }

/* ------------------------------------------------------------ charts */
.chart { display: flex; flex-direction: column; gap: 6px; }
.chart-wrap { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .tick, .chart .xlab { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.chart .val { font-size: 11.5px; font-weight: 600; fill: var(--ink-2); font-family: var(--font); }
.chart .bar { fill: var(--series-1); transition: opacity .15s var(--ease); }
.chart .marker { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:hover ~ .bar, .chart .bar-g:hover .bar { opacity: .85; }
.chart .hit:focus-visible { stroke: var(--leaf); stroke-width: 2; stroke-dasharray: 0; rx: 4; }
.chart .tip { position: absolute; transform: translate(-50%, calc(-100% - 6px)); background: var(--roast); color: #fff; font-size: .76rem; padding: 5px 9px; border-radius: 6px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); z-index: 3; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--series-1); }
.legend .key.marker { height: 2px; width: 16px; border-radius: 1px; background: var(--ink); }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: .78rem; font-weight: 600; padding: 4px 0; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: .84rem; margin-top: 6px; }
.chart-table th, .chart-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.chart-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.hbars { display: grid; gap: 8px; }
.hb { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; align-items: center; gap: 10px; color: var(--ink); font-size: .86rem; }
.hb:hover .hb-fill { opacity: .85; }
.hb-label { color: var(--ink-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 14px; background: var(--cream-2); border-radius: 4px; overflow: hidden; }
.hb-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; transition: width .4s var(--ease); }
.hb-val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 56px; padding: 4px 0; }
.spark .sp { flex: 1; display: block; background: var(--series-muted); border-radius: 3px 3px 0 0; min-width: 4px; }
.spark .sp.cur { background: var(--series-1); }

/* ------------------------------------------------------------ account detail */
.note-form { display: flex; flex-direction: column; gap: 6px; }
.note-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.note-row .count { margin: 0; }
.note-row .count.over { color: var(--red); font-weight: 600; }
.note-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.saved { display: inline-flex; align-items: center; gap: 4px; color: var(--leaf-deep); font-weight: 600; font-size: .85rem; min-height: 1em; }
.saved .ic { width: 15px; height: 15px; }
.note-view { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; background: var(--cream); border: 1px dashed var(--line-2); border-radius: var(--r); }
.note-view > .ic { color: var(--bark); margin-top: 2px; }
.note-view.empty { border-style: dashed; color: var(--muted); }
.note-text { margin: 0 0 2px; font-family: var(--display); font-size: 1.05rem; color: var(--roast); }
.note-view time { color: inherit; }
.pattern { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.pattern h3 { font-family: var(--font); font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.thisweek { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.thisweek-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thisweek-head h3 { font-family: var(--font); font-size: .9rem; color: var(--ink); }
.thisweek-head .meta { display: inline; }
.thisweek-head .btn { margin-left: auto; }
.thisweek .form.inline { margin-top: 12px; }
.qlog li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.qlog li:last-child { border-bottom: 0; }
.qlog p { margin: 4px 0 0; color: var(--ink-2); font-size: .88rem; }
.q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .88rem; }
.q-head .right { margin-left: auto; }
.score { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--leaf-deep); }
.score.low { color: var(--red); }

/* ------------------------------------------------------------ pipeline */
/* position: relative so absolutely positioned descendants (the sr-only labels) are clipped with the rest and cannot widen the page. */
.board { display: grid; grid-template-columns: repeat(6, minmax(200px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; contain: inline-size; position: relative; }
.col-stage { background: var(--cream-2); border-radius: var(--r-lg); padding: 10px; min-height: 240px; scroll-snap-align: start; transition: background .15s var(--ease), box-shadow .15s var(--ease); }
.col-stage.closed { background: #EFEAE2; }
.col-stage.over { background: var(--leaf-soft); box-shadow: inset 0 0 0 2px var(--leaf); }
.col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 6px 10px; }
.col-head h2 { font-size: .95rem; }
.col-meta { color: var(--muted); font-size: .76rem; font-weight: 600; white-space: nowrap; }
.col-body { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col-empty { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 18px 10px; text-align: center; color: var(--faint); font-size: .8rem; }
.deal-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; user-select: none; -webkit-user-select: none; transition: box-shadow .15s var(--ease), transform .15s var(--ease); }
.deal-card:hover { box-shadow: var(--shadow-lg); }
.deal-card.dragging { opacity: .35; }
.deal-card.ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; cursor: grabbing; box-shadow: var(--shadow-lg); transform-origin: 0 0; rotate: 1.5deg; }
body.is-dragging { cursor: grabbing; user-select: none; }
.deal-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.deal-name { color: var(--roast); font-family: var(--display); font-size: 1rem; }
.grip { color: var(--faint); touch-action: none; cursor: grab; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; }
.grip .ic { width: 16px; height: 16px; }
.grip:hover { color: var(--bark); background: var(--cream-2); }
.deal-value { font-weight: 700; margin-top: 2px; color: var(--ink); }
.deal-value .meta { display: inline; font-weight: 400; }
.deal-next { margin: 6px 0 0; font-size: .82rem; color: var(--ink-2); padding: 6px 8px; background: var(--cream); border-radius: 6px; }
.deal-foot { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.move select { width: 100%; padding: 5px 8px; font-size: .8rem; border-radius: 7px; background: var(--surface-2); }

/* ------------------------------------------------------------ orders and route sheet */
.route-card .route-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.route-nums div { display: flex; flex-direction: column; }
.route-nums b { font-size: 1.25rem; color: var(--roast); line-height: 1.1; }
.route-nums span { color: var(--muted); font-size: .72rem; }
.sheet-card { margin-bottom: 16px; }
.table.sheet td { vertical-align: middle; }
.table.sheet .stopno { font-family: var(--display); font-size: 1.15rem; color: var(--bark); }
.table.sheet .big { font-size: 1.15rem; font-weight: 700; color: var(--roast); }
.table.sheet .unit { display: none; }
.table.sheet .mixline { display: block; font-size: .82rem; margin-bottom: 4px; }
.table.sheet .mixbar { max-width: 160px; }
.notecell { min-width: 160px; max-width: 260px; }
.notecell .ic { width: 14px; height: 14px; vertical-align: -2px; color: var(--bark); margin-right: 4px; }
.notecell .note-text { display: inline; font-size: .95rem; }
.sign { width: 110px; }
.signbox { display: block; height: 30px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--surface-2); }
.skipped { padding: 10px 18px 14px; margin: 0; border-top: 1px solid var(--line); }
.lede-num { font-size: .9rem; color: var(--muted); }
.lede-num b { font-size: 2rem; color: var(--roast); font-weight: 600; margin-right: 6px; }
.driver-notes li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; color: var(--ink-2); }
.driver-notes li:last-child { border-bottom: 0; }
.driver-notes .ic { color: var(--bark); margin-top: 2px; }
.print-head { display: none; }
.sel.inline { background: var(--surface); }

/* ------------------------------------------------------------ tickets */
.ticket-list li { border-bottom: 1px solid var(--line); }
.ticket-list li:last-child { border-bottom: 0; }
.ticket-row a { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 18px; color: var(--ink); }
.ticket-row a:hover { background: var(--surface-2); text-decoration: none; }
.ticket-row.is-new a { box-shadow: inset 3px 0 0 var(--info); }
.t-main { min-width: 0; }
.t-main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty-row { padding: 12px; }
.msg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.msg-head b { display: block; }
.msg-text { margin: 0; padding: 14px 16px; background: var(--cream); border-left: 3px solid var(--bark); border-radius: 0 var(--r) var(--r) 0; font-family: var(--display); font-size: 1.1rem; line-height: 1.5; color: var(--roast); }
.chips { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.chip-fact { display: inline-flex; flex-direction: column; gap: 3px; max-width: 100%; min-width: 0; }
.chip-fact .badge { white-space: normal; text-align: left; line-height: 1.4; }
.chip-fact > span:first-child { color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--cream); border: 1px solid var(--line); border-radius: var(--r); font-size: .9rem; color: var(--ink-2); }
.callout p { margin: 4px 0 0; }
.callout b { color: var(--ink); }
.replies li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.replies li:last-child { border-bottom: 0; }
.reply-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.reply-text { margin: 0; white-space: pre-wrap; font-family: var(--font); font-size: .92rem; line-height: 1.55; color: var(--ink-2); background: var(--surface-2); padding: 10px 12px; border-radius: 8px; }
.reply-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.replies + .reply-form { margin-top: 6px; }
.reply-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.reply-label label { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.reply-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.reply-actions .fine { margin: 0; display: inline-flex; align-items: center; gap: 4px; }
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip { position: absolute; bottom: calc(100% + 8px); right: 0; background: var(--roast); color: #fff; font-size: .76rem; padding: 5px 9px; border-radius: 6px; white-space: nowrap; opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity .15s var(--ease), transform .15s var(--ease); }
.tooltip::after { content: ''; position: absolute; right: 14px; top: 100%; border: 5px solid transparent; border-top-color: var(--roast); }
.tooltip-wrap:hover .tooltip, .tooltip-wrap:focus-within .tooltip { opacity: 1; transform: none; }

/* ------------------------------------------------------------ crew panel */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(31, 23, 18, .35); animation: fade .2s var(--ease); }
.scrim.light { z-index: 34; background: rgba(31, 23, 18, .25); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.crew-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: min(460px, 100%); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .25s var(--ease); }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.crew-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.crew-head h2 { font-size: 1.35rem; }
.eyebrow { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--bark); margin-bottom: 2px; }
.crew-body { flex: 1; overflow-y: auto; padding: 16px 20px 20px; }
.crew-body h3 { margin: 22px 0 10px; font-family: var(--font); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.crew-lede { color: var(--ink-2); line-height: 1.6; }
.crew-lede .chip { vertical-align: -3px; }
.crew-timeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; position: relative; }
.crew-timeline::before { content: ''; position: absolute; left: 6%; right: 6%; top: 5px; height: 2px; background: var(--line-2); }
.crew-timeline li { position: relative; text-align: center; font-size: .72rem; color: var(--muted); padding-top: 14px; }
.crew-timeline li::before { content: ''; position: absolute; top: 0; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--bark); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.crew-timeline li.now::before { background: var(--leaf); }
.crew-timeline b { display: block; color: var(--ink); }
.slices { display: grid; gap: 10px; }
.slice { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--surface-2); }
.slice header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.slice-id { font-family: var(--mono); font-weight: 700; color: var(--bark); font-size: .8rem; }
.pts { font-size: .72rem; font-weight: 600; color: var(--muted); background: var(--cream-2); padding: 1px 7px; border-radius: 999px; }
.slice h4 { font-family: var(--font); font-weight: 600; color: var(--ink); font-size: .95rem; margin-bottom: 8px; }
.slice-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.slice-meta .who { display: inline-flex; align-items: center; gap: 6px; }
.slice-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; margin: 10px 0 0; font-size: .8rem; }
.slice-facts div { display: flex; gap: 6px; }
.slice-facts dt { color: var(--muted); } .slice-facts dd { margin: 0; color: var(--ink-2); }
.slice-note { margin: 10px 0 0; font-size: .82rem; color: var(--ink-2); padding: 8px 10px; background: var(--surface); border-radius: 6px; border-left: 3px solid var(--clay); }
.review { padding: 10px 0; border-bottom: 1px solid var(--line); }
.review:last-of-type { border-bottom: 0; }
.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: .9rem; }
.review ul { display: grid; gap: 4px; padding-left: 4px; }
.review li { font-size: .82rem; color: var(--ink-2); padding-left: 12px; position: relative; }
.review li::before { content: ''; position: absolute; left: 0; top: .55em; width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); }
.crew-body .callout { margin-top: 12px; display: block; }
.crew-numbers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0 8px; }
.crew-numbers div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 8px; text-align: center; }
.crew-numbers b { display: block; font-size: 1.35rem; color: var(--roast); font-weight: 600; line-height: 1.1; }
.crew-numbers span { color: var(--muted); font-size: .7rem; }
.crew-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.crew-card .crew-numbers div { background: rgba(255, 255, 255, .7); }

/* ------------------------------------------------------------ toasts, dialog */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--roast); color: #fff; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: opacity .25s var(--ease), transform .25s var(--ease); max-width: min(420px, calc(100vw - 32px)); }
.toast.in { opacity: 1; transform: none; }
.toast .ic { color: #9CCB9F; }
.toast.error .ic { color: #F2A99C; }
.toast.info .ic { color: #BBD1EA; }
.dialog { border: 0; border-radius: var(--r-lg); padding: 22px 24px; max-width: 420px; width: calc(100% - 32px); box-shadow: var(--shadow-lg); color: var(--ink); }
.dialog::backdrop { background: rgba(31, 23, 18, .45); }
.dialog h2 { margin-bottom: 8px; }
.dialog .dlg-body { color: var(--ink-2); }
.dialog .btn-row { justify-content: flex-end; margin-top: 18px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .grid.dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.routes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(6, 220px); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { grid-column: 1; padding: 10px 16px; gap: 10px; }
  .wordmark.compact { display: inline-flex; font-size: 1.15rem; padding: 0; }
  .wordmark.compact .leaf-mark { width: 22px; height: 22px; }
  .crew-toggle.top span { display: none; }
  .crew-toggle.top { padding: 8px; }
  .content { grid-column: 1; padding: 16px 16px 96px; }
  .grid.detail { grid-template-columns: minmax(0, 1fr); }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .grid.dash { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pagehead h1 { overflow-wrap: anywhere; }
  .bottombar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--roast); padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 24px -16px rgba(0, 0, 0, .5); }
  .bottom-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border: 0; background: transparent; color: rgba(246, 241, 231, .7); font-size: .66rem; font-weight: 600; border-radius: 8px; position: relative; cursor: pointer; }
  .bottom-item .ic { width: 22px; height: 22px; }
  .bottom-item.active { color: #fff; }
  .bottom-item.active::after { content: ''; position: absolute; top: 0; width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: #9CCB9F; }
  .bottom-item .nav-badge { position: absolute; top: 2px; right: calc(50% - 22px); min-width: 16px; height: 16px; font-size: .62rem; }
  .sheet { display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 36; background: var(--surface); border-radius: 16px 16px 0 0; padding: 8px 12px calc(16px + env(safe-area-inset-bottom, 0px)); box-shadow: var(--shadow-lg); animation: up .22s var(--ease); }
  @keyframes up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 10px; color: var(--muted); }
  .sheet-link { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 10px; color: var(--ink); font-weight: 500; border: 0; background: transparent; text-align: left; width: 100%; font-size: 1rem; cursor: pointer; }
  .sheet-link:hover, .sheet-link.active { background: var(--cream); text-decoration: none; }
  .sheet-link .ic { color: var(--bark); width: 20px; height: 20px; }
  .toasts { right: 16px; left: 16px; bottom: 84px; align-items: center; }
  .day { top: 54px; }
  /* Fixed-width columns make the page wider than a phone; below 960px the stages stack instead. Drag and "Move to" still work. */
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; contain: none; }
  .col-stage { min-height: 0; }
  .pattern { grid-template-columns: minmax(0, 1fr); }
  .crew-panel { width: 100%; }
  .mixinputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  body { font-size: 14px; }
  h1 { font-size: 1.5rem; }
  .content { padding: 12px 12px 96px; }
  .topbar { padding: 8px 12px; }
  .global-search { padding: 5px 10px; }
  .global-search input::placeholder { color: transparent; }
  .badge.demo { display: none; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; } .stat .value { font-size: 1.3rem; }
  .grid { gap: 12px; } .grid.routes { grid-template-columns: minmax(0, 1fr); }
  .card-head { padding: 12px 14px 0; } .card-body { padding: 12px 14px 14px; }
  .toolbar .search-field { min-width: 0; flex-basis: 100%; max-width: none; }
  .count { flex-basis: 100%; margin-left: 0; }
  .form.grid2 { grid-template-columns: minmax(0, 1fr); }
  .form.grid2 .span2 { grid-column: auto; }
  .board { grid-template-columns: minmax(0, 1fr); }
  /* Route sheet on a phone: each stop becomes a card. ARIA roles in the markup keep the table semantics. */
  .table.sheet, .table.sheet tbody, .table.sheet tfoot, .table.sheet tr, .table.sheet td { display: block; }
  .table.sheet thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table.sheet tbody tr { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; column-gap: 10px; row-gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table.sheet tbody tr:hover td { background: transparent; }
  .table.sheet tbody td { padding: 0; border: 0; text-align: left; }
  .table.sheet td.stopno { grid-column: 1; grid-row: 1 / span 5; padding-top: 2px; }
  .table.sheet td.acct { grid-column: 2; grid-row: 1; }
  .table.sheet td.big { grid-column: 3; grid-row: 1; text-align: right; white-space: nowrap; }
  .table.sheet .unit { display: inline; font-size: .78rem; font-weight: 500; color: var(--muted); }
  .table.sheet td.contact { grid-column: 2 / 4; grid-row: 2; }
  .table.sheet td.mix { grid-column: 2 / 4; grid-row: 3; }
  .table.sheet td.notecell { grid-column: 2 / 4; grid-row: 4; min-width: 0; max-width: none; }
  .table.sheet td.sign { grid-column: 2 / 4; grid-row: 5; width: auto; display: flex; align-items: center; gap: 10px; }
  .table.sheet td.sign::before { content: 'Signed'; font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
  .table.sheet td.sign .signbox { flex: 1; max-width: 220px; }
  .table.sheet tbody tr.emptyrow { display: block; }
  .table.sheet tfoot tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 14px; background: var(--surface-2); border-top: 2px solid var(--line-2); }
  .table.sheet tfoot td { padding: 0; border: 0; background: transparent; }
  .table.sheet tfoot td:empty { display: none; }
  .ticket-row a { grid-template-columns: auto 1fr; padding: 12px 14px; }
  .t-badges { grid-column: 1 / -1; justify-content: flex-start; }
  .feed li { grid-template-columns: auto 1fr; }
  .feed li .text { grid-column: 1 / -1; }
  .feed.compact li > time { grid-column: 2; }
  .day { margin: 6px -14px 0; padding: 8px 14px 6px; }
  .feed-card { padding: 0 14px 12px; }
  .crew-numbers { grid-template-columns: repeat(2, 1fr); }
  .crew-timeline { grid-template-columns: repeat(2, 1fr); gap: 10px 6px; }
  .crew-timeline::before { display: none; }
  .results li a { grid-template-columns: minmax(0, 1fr); }
  .results .right { grid-column: 1; grid-row: auto; margin-top: 4px; }
  .facts div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .note-actions { margin-left: 0; width: 100%; justify-content: space-between; }
  .pagehead .actions { width: 100%; }
  .thisweek-head .btn { margin-left: 0; }
  .list.risk li { flex-wrap: wrap; } .list.risk .right { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ------------------------------------------------------------ print (route sheet) */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .sidebar, .topbar, .bottombar, .sheet, .scrim, .crew-panel, .toasts, #banner, .app-foot, .toolbar, .actions, .crumbs, .skip, .chart-table, .grid.two .card:first-child { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .view { animation: none; }
  .print-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 2px solid #000; font-size: 10pt; }
  .print-head .wordmark { font-size: 16pt; color: #000; padding: 0; }
  .print-head .leaf-mark { color: #000; width: 20px; height: 20px; }
  .pagehead h1 { font-size: 18pt; }
  .pagehead .sub { color: #333; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
  .stat, .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .stat .value { font-size: 14pt; }
  .table-wrap { overflow: visible; max-height: none; }
  .table th { position: static; background: #eee; color: #000; }
  .table th, .table td { border-bottom: 1px solid #bbb; padding: 7px 8px; }
  .table.sheet .rowlink, .table a { color: #000; text-decoration: none; }
  .table.sheet .big { font-size: 14pt; }
  .signbox { border: 1px solid #000; height: 34px; background: #fff; }
  .mixbar { display: none; }
  .table.sheet .mixline { font-size: 10pt; margin: 0; }
  .grid.two { display: block; }
  .grid.two .card { margin-top: 10px; }
  .badge, .tid { border: 1px solid #999; background: #fff !important; color: #000 !important; }
}
