/* THE ONE OMS — mobile-first styles. No external fonts or CDNs (strict CSP, fast on mobile data). */
:root {
  --linen: #eceee9;
  --paper: #fafaf7;
  --sunk: #e2e5df;
  --line: #d3d8d0;
  --ink: #232825;
  --muted: #667069;
  --forest: #1f3d35;
  --forest-2: #2b5448;
  --forest-ink: #f3f6f2;
  --brass: #b48a3c;
  --brass-soft: #f1e6cd;
  --alert: #b3402e;
  --alert-soft: #f6dfd9;
  --ok: #2f6b4a;
  --soon: #9a6c13;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 64px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --linen: #151a18; --paper: #1d2421; --sunk: #252d29; --line: #333d38; --ink: #e8ece8; --muted: #9aa6a0;
    --forest: #7fb5a2; --forest-2: #96c4b3; --forest-ink: #10201b; --brass: #d3a954; --brass-soft: #3a3120;
    --alert: #e27c68; --alert-soft: #3d2420; --ok: #78c299; --soon: #d9a94a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--linen); color: var(--ink); font: 16px/1.5 var(--sans); min-height: 100dvh; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font: 600 26px/1.15 var(--serif); letter-spacing: .01em; }
h2 { font: 600 19px/1.25 var(--serif); }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 .6em; }
a { color: var(--forest); }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.right { margin-left: auto; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
#app { min-height: 100dvh; }
.shell { display: grid; grid-template-rows: var(--top-h) 1fr; min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--forest); color: var(--forest-ink); }
@media (prefers-color-scheme: dark) { .topbar { background: #14201c; color: #e8ece8; } }
.wordmark { font: 600 19px/1 var(--serif); letter-spacing: .24em; text-decoration: none; color: inherit; }
.topbar .who { margin-left: auto; text-align: right; line-height: 1.2; font-size: 13px; opacity: .92; min-width: 0; }
.topbar .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; color: inherit; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.icon-btn svg, .btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.content { padding: 18px 16px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 880px; width: 100%; margin: 0 auto; }
.navbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--paper); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.navbar a { flex: 1; display: grid; justify-items: center; align-content: center; gap: 2px; min-height: var(--nav-h); padding: 6px 2px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; position: relative; }
.navbar a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.navbar a[aria-current="page"] { color: var(--forest); }
.navbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; background: var(--brass); border-radius: 0 0 3px 3px; }
.navbar .dot { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--brass); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

@media (min-width: 900px) {
  .shell { grid-template-columns: 220px 1fr; grid-template-rows: var(--top-h) 1fr; }
  .topbar { grid-column: 1 / -1; }
  .navbar { position: sticky; top: var(--top-h); left: auto; right: auto; bottom: auto; flex-direction: column; align-self: start; height: calc(100dvh - var(--top-h)); border-top: 0; border-right: 1px solid var(--line); padding: 14px 10px; gap: 4px; }
  .navbar a { flex: none; display: flex; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: 10px; font-size: 15px; }
  .navbar a[aria-current="page"] { background: var(--sunk); }
  .navbar a[aria-current="page"]::before { left: 0; right: auto; top: 12px; bottom: 12px; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .navbar .dot { position: static; margin-left: auto; }
  .content { padding: 28px 32px 60px; }
}

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border: 1px solid transparent; border-radius: 10px; background: var(--forest); color: var(--forest-ink); font-weight: 650; cursor: pointer; text-decoration: none; transition: background .15s, transform .05s; }
.btn:hover { background: var(--forest-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--forest); border-color: var(--line); }
.btn.ghost:hover { background: var(--sunk); }
.btn.danger { background: var(--alert); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--alert); border-color: var(--alert); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.brass { background: var(--brass); color: #fff; }

label.field { display: block; margin-top: 16px; }
label.field > span, .field-label { display: block; font-weight: 650; font-size: 14px; margin-bottom: 6px; }
label.field > span em, .field-label em { font-style: normal; font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 13px; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 38px; }
textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brass-soft); border-color: var(--brass); }
.field-error { color: var(--alert); font-size: 13.5px; margin-top: 5px; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--alert); }
.hint { color: var(--muted); font-size: 13.5px; margin-top: 5px; }

.alert { padding: 12px 14px; border-radius: 8px; background: var(--alert-soft); color: var(--alert); border: 1px solid color-mix(in srgb, var(--alert) 35%, transparent); font-size: 14.5px; }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--brass-soft); border: 1px solid color-mix(in srgb, var(--brass) 40%, transparent); font-size: 14.5px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; align-content: center; justify-items: center; padding: 24px 18px; background: var(--forest); color: var(--forest-ink); }
@media (prefers-color-scheme: dark) { .login { background: #101916; } }
.login .brand { text-align: left; width: 100%; max-width: 380px; margin-bottom: 26px; }
.login .brand .wordmark { font-size: 38px; letter-spacing: .3em; display: block; }
.login .brand p { margin: 10px 0 0; opacity: .78; letter-spacing: .02em; }
.login form { width: 100%; max-width: 380px; background: var(--paper); color: var(--ink); border-radius: 14px; padding: 8px 20px 22px; }
.login form .btn { margin-top: 22px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; min-height: 40px; margin: -6px 0 4px -4px; padding: 0 4px; }
.back svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Tabs & search ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--sunk); border-radius: 10px; }
.tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 7px; background: transparent; font-weight: 650; font-size: 14.5px; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.searchbox { position: relative; }
.searchbox svg { position: absolute; left: 13px; top: 13px; width: 22px; height: 22px; stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; }
.searchbox input { padding-left: 44px; }
.toolbar { display: grid; gap: 10px; margin-bottom: 16px; }
@media (min-width: 640px) { .toolbar { grid-template-columns: 1fr auto; align-items: center; } .toolbar .tabs { min-width: 280px; } }

/* ---------- Order ticket (the one distinctive element) ---------- */
.tickets { display: grid; gap: 10px; }
@media (min-width: 760px) { .tickets { grid-template-columns: 1fr 1fr; } }
.ticket { display: grid; grid-template-columns: 76px 1fr auto; background: var(--paper); border: 1px solid var(--line); border-radius: 4px 14px 14px 4px; text-decoration: none; color: inherit; overflow: hidden; min-height: 92px; transition: border-color .15s, box-shadow .15s; }
.ticket:hover { border-color: var(--forest); box-shadow: 0 2px 10px rgba(0,0,0,.07); }
.ticket-date { display: grid; align-content: center; justify-items: center; background: var(--forest); color: var(--forest-ink); padding: 8px 4px; position: relative; }
.ticket-date b { font: 600 30px/1 var(--serif); font-variant-numeric: tabular-nums; }
.ticket-date span { font-size: 12.5px; font-weight: 600; letter-spacing: .04em; margin-top: 3px; text-transform: none; opacity: .9; }
.ticket-date small { font-size: 11px; opacity: .8; margin-top: 4px; }
.ticket-date::after { content: ""; position: absolute; right: -6px; top: 50%; width: 12px; height: 12px; margin-top: -6px; background: var(--linen); border-radius: 50%; border: 1px solid var(--line); }
.ticket.soon .ticket-date { background: var(--soon); color: #fff; }
.ticket.overdue .ticket-date { background: var(--alert); color: #fff; }
.ticket.done .ticket-date { background: var(--muted); color: var(--paper); }
.ticket-main { padding: 12px 6px 12px 16px; min-width: 0; display: grid; align-content: center; gap: 2px; }
.t-no { font: 600 19px/1.15 var(--serif); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-prod { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-meta .gone { font-style: italic; }
.ticket-side { display: grid; align-content: center; justify-items: end; padding: 0 14px 0 4px; gap: 6px; }
.badge { min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px; background: var(--brass); color: #fff; font-weight: 700; font-size: 13px; line-height: 26px; text-align: center; }
.chev { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; background: var(--sunk); color: var(--muted); }
.pill.ongoing { background: var(--brass-soft); color: var(--soon); }
.pill.completed { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.overdue { background: var(--alert-soft); color: var(--alert); }
.pill.inactive { background: var(--alert-soft); color: var(--alert); }

/* ---------- Surfaces ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.panel + .panel { margin-top: 14px; }
.panel > h2 + * { margin-top: 12px; }
.empty { text-align: left; padding: 30px 20px; border: 1.5px dashed var(--line); border-radius: 12px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.skeleton { height: 92px; border-radius: 4px 14px 14px 4px; background: linear-gradient(90deg, var(--sunk), var(--paper), var(--sunk)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton + .skeleton { margin-top: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Owner stats: one dominant figure, the rest supporting */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-decoration: none; color: inherit; display: block; }
.stat b { display: block; font: 600 34px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 6px; font-size: 13.5px; color: var(--muted); }
.stat.lead { grid-column: 1 / -1; background: var(--forest); color: var(--forest-ink); border-color: var(--forest); }
.stat.lead span { color: inherit; opacity: .82; }
.stat.lead b { font-size: 46px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(3, 1fr); } .stat.lead { grid-column: auto; grid-row: span 2; display: grid; align-content: end; } }

/* ---------- Order detail ---------- */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.spec { border-top: 1px solid var(--line); padding: 14px 0; }
.spec:first-child { border-top: 0; padding-top: 0; }
.spec h3 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.spec h3 em { font-style: normal; font-weight: 500; color: var(--muted); }
.spec p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; }
.photos button { padding: 0; border: 1px solid var(--line); background: var(--sunk); border-radius: 8px; overflow: hidden; aspect-ratio: 1; cursor: zoom-in; }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.sticky-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Photo picker (order form) ---------- */
.picker { margin-top: 8px; }
.picker-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.picker .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--sunk); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: flex-end; gap: 4px; padding: 4px; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.thumb .tools button { width: 36px; height: 36px; border: 0; border-radius: 8px; background: rgba(255,255,255,.92); color: #222; display: grid; place-items: center; cursor: pointer; }
.thumb .tools svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.thumb .state { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(250,250,247,.72); font-size: 12.5px; font-weight: 700; color: var(--forest); text-align: center; padding: 6px; }
.thumb.failed .state { background: rgba(246,223,217,.9); color: var(--alert); }
.bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--brass); transition: width .15s; }

.hw { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); overflow: hidden; }
.hw + .hw { margin-top: 10px; }
.hw > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 14px; cursor: pointer; font-weight: 650; }
.hw > summary::-webkit-details-marker { display: none; }
.hw > summary .sel { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 13.5px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.hw > summary .chev { transition: transform .2s; flex: none; }
.hw[open] > summary .chev { transform: rotate(90deg); }
.hw[open] > summary { border-bottom: 1px solid var(--line); }
.hw .body { padding: 4px 14px 16px; }
.hw .filled { width: 9px; height: 9px; border-radius: 50%; background: var(--brass); flex: none; }
.formbar { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 10; margin: 20px -16px 0; padding: 12px 16px; background: color-mix(in srgb, var(--linen) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.formbar .btn { flex: 1; }
@media (min-width: 900px) { .formbar { bottom: 0; margin: 20px 0 0; border-radius: 12px; border: 1px solid var(--line); } }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-head h2 { font-size: 17px; }
.chat-log { padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 220px; max-height: 58dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--linen); }
.msg { max-width: 86%; display: grid; gap: 3px; }
.msg .who { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.msg .who b { color: var(--ink); font-weight: 650; }
.msg .bubble { padding: 9px 12px; border-radius: 14px 14px 14px 4px; background: var(--paper); border: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.mine { align-self: flex-end; }
.msg.mine .who { justify-content: flex-end; }
.msg.mine .bubble { background: var(--forest); color: var(--forest-ink); border-color: var(--forest); border-radius: 14px 14px 4px 14px; }
.msg.comment .bubble { background: var(--brass-soft); border: 1px dashed var(--brass); color: var(--ink); }
.msg.comment .tag { font-size: 11.5px; font-weight: 700; color: var(--soon); }
.msg .imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.msg .imgs button { padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--sunk); aspect-ratio: 1; cursor: zoom-in; }
.msg .imgs img { width: 100%; height: 100%; object-fit: cover; }
.msg audio { width: min(260px, 70vw); height: 44px; }
.msg .time { font-size: 11.5px; color: var(--muted); }
.msg.mine .time { text-align: right; }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); background: var(--sunk); padding: 2px 12px; border-radius: 999px; }
.chat-empty { margin: auto; color: var(--muted); text-align: center; padding: 20px; }
.composer { border-top: 1px solid var(--line); padding: 10px; display: grid; gap: 8px; background: var(--paper); }
.composer textarea { min-height: 46px; max-height: 140px; padding: 10px 12px; border-radius: 10px; }
.composer .tools { display: flex; align-items: center; gap: 6px; }
.composer .tools .icon-btn { color: var(--forest); border: 1px solid var(--line); width: 46px; height: 46px; border-radius: 10px; }
.composer .tools .icon-btn:hover { background: var(--sunk); }
.composer .tools .kind { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); margin-left: 4px; }
.composer .tools .kind input { width: 20px; height: 20px; accent-color: var(--brass); }
.recbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--alert-soft); color: var(--alert); font-weight: 650; }
.recbar .pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--alert); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.attach-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.attach-strip .thumb { width: 64px; aspect-ratio: 1; }
.attach-strip .thumb .tools { padding: 2px; }
.attach-strip .thumb .tools button { width: 26px; height: 26px; }
.readonly-note { padding: 12px 14px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- Users table / list ---------- */
.ulist { display: grid; gap: 10px; }
.urow { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.urow.off { opacity: .78; }
.urow .name { font-weight: 650; }
.urow .ids { font-size: 13px; color: var(--muted); }
.urow .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 650; background: var(--sunk); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }

/* ---------- Modal, lightbox, toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(15,22,19,.55); display: grid; align-items: end; justify-items: center; }
.modal { width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--paper); border-radius: 16px 16px 0 0; padding: 20px 18px calc(18px + var(--safe-b)); animation: sheet .18s ease-out; }
@keyframes sheet { from { transform: translateY(24px); opacity: .4; } }
@media (min-width: 640px) { .modal-back { align-items: center; } .modal { border-radius: 16px; } }
.modal h2 { margin-bottom: 8px; }
.modal .btns { display: flex; gap: 10px; margin-top: 20px; }
.modal .btns .btn { flex: 1; }
.big-number { display: inline-block; font: 600 24px/1.2 var(--serif); padding: 4px 12px; background: var(--alert-soft); color: var(--alert); border-radius: 8px; margin: 6px 0; overflow-wrap: anywhere; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(8,12,10,.94); display: grid; place-items: center; }
.lightbox img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.lightbox .close { position: absolute; top: 10px; right: 10px; color: #fff; background: rgba(255,255,255,.14); }
.lightbox .nav { position: absolute; top: 50%; margin-top: -24px; color: #fff; background: rgba(255,255,255,.14); width: 48px; height: 48px; }
.lightbox .nav.prev { left: 8px; } .lightbox .nav.next { right: 8px; }
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 70; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 24px; left: auto; right: 24px; justify-items: end; } }
.toast { pointer-events: auto; max-width: 420px; padding: 12px 16px; border-radius: 10px; background: var(--ink); color: var(--paper); box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 14.5px; animation: sheet .18s ease-out; }
.toast.error { background: var(--alert); color: #fff; }
.toast.msg-toast { background: var(--forest); color: var(--forest-ink); cursor: pointer; }
.toast b { display: block; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--forest); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 40px; }
.offline { background: var(--brass); color: #fff; text-align: center; font-size: 13.5px; padding: 6px 12px; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .navbar, .topbar, .toasts { display: none !important; } }

/* ---------- Voice note player ---------- */
.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }
.msg.mine .voice { background: color-mix(in srgb, var(--forest) 70%, #000); border-color: transparent; color: var(--forest-ink); }
.vp-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--brass); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.vp-btn svg { width: 20px; height: 20px; }
.vp-track { flex: 1; height: 6px; border-radius: 3px; background: var(--sunk); cursor: pointer; position: relative; }
.msg.mine .vp-track { background: rgba(255,255,255,.28); }
.vp-fill { height: 100%; width: 0; border-radius: 3px; background: var(--brass); }
.vp-time { font-size: 12.5px; min-width: 34px; text-align: right; }

/* Supervisor has a single destination, so no navigation rail */
.shell.nonav { grid-template-columns: 1fr; }
.shell.nonav .navbar { display: none; }
.shell.nonav .content { padding-bottom: 40px; }
@media (min-width: 900px) { .shell.nonav { grid-template-columns: 1fr; } }

/* Fixes found in screenshot review */
.chat-head svg { width: 22px; height: 22px; flex: none; stroke: var(--forest); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat { min-width: 0; }
@media (min-width: 900px) { .navbar a { align-items: center; } }

/* Composer must never be wider than the chat panel (grid tracks otherwise grow to their content) */
.composer { grid-template-columns: minmax(0, 1fr); }
.composer .tools { flex-wrap: wrap; }
.chat { overflow: hidden; overflow: clip; }
@media (max-width: 430px) {
  .composer .tools { gap: 4px; }
  .composer .tools .icon-btn { width: 42px; height: 42px; }
  .composer .tools .kind { margin-left: 2px; gap: 4px; font-size: 13px; }
  .composer .tools .kind input { width: 18px; height: 18px; }
  .composer .tools .btn { padding: 0 14px; }
}
