/* NABOLY Parts — "precision parts catalog / engineering drawing"
   Stage 0 design. One accent (signal orange), ruled lines instead of shadows, square corners. */

:root {
  --paper: #f3f1ea;
  --paper-2: #ebe8df;          /* inset areas: composer, table head */
  --grid-minor: rgba(35, 40, 45, .045);
  --grid-major: rgba(35, 40, 45, .085);
  --ink: #22262a;              /* graphite */
  --ink-2: #555b61;
  --ink-3: #868b90;
  --rule: #cdc9be;
  --rule-strong: #22262a;
  --accent: #e2530a;           /* signal orange — sparingly */
  --accent-ink: #ffffff;
  --accent-soft: rgba(226, 83, 10, .10);
  --ok: #2f6b3a;
  --warn: #9a5b00;
  --bad: #a3271b;
  --label-bg: #fbfaf6;
  --overlay: #f3f1ea;
  --hatch: rgba(34, 38, 42, .28);

  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --t: 160ms;
  --gut: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15181b; --paper-2: #1c2024;
    --grid-minor: rgba(230, 227, 218, .035); --grid-major: rgba(230, 227, 218, .07);
    --ink: #e7e4db; --ink-2: #aeb0ae; --ink-3: #7d8184;
    --rule: #353a3f; --rule-strong: #e7e4db;
    --accent: #ff7a33; --accent-ink: #15181b; --accent-soft: rgba(255, 122, 51, .14);
    --ok: #7cc48a; --warn: #e3a64a; --bad: #ff8a7a;
    --label-bg: #1b1f23; --overlay: #15181b; --hatch: rgba(231, 228, 219, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15181b; --paper-2: #1c2024;
  --grid-minor: rgba(230, 227, 218, .035); --grid-major: rgba(230, 227, 218, .07);
  --ink: #e7e4db; --ink-2: #aeb0ae; --ink-3: #7d8184;
  --rule: #353a3f; --rule-strong: #e7e4db;
  --accent: #ff7a33; --accent-ink: #15181b; --accent-soft: rgba(255, 122, 51, .14);
  --ok: #7cc48a; --warn: #e3a64a; --bad: #ff8a7a;
  --label-bg: #1b1f23; --overlay: #15181b; --hatch: rgba(231, 228, 219, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  color: var(--ink);
  font: 400 16px/1.6 var(--font);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* LTR islands: part numbers, VINs, codes — always left-to-right, never wrap */
.ltr, .pn, .vin, code { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: var(--mono); }

h1, h2, h3 { font-weight: 700; line-height: 1.25; margin: 0; letter-spacing: 0; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.tag-label {   /* tiny drawing annotation, e.g. "OEM", "REV" */
  font: 500 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}

/* ---------------------------------------------------------------- wordmark */
.wordmark { display: inline-flex; align-items: baseline; gap: 6px; text-decoration: none; direction: ltr; }
.wordmark b { font: 700 18px/1 var(--mono); letter-spacing: .14em; }
.wordmark span { font: 500 14px/1 var(--font); color: var(--ink-2); }
.wordmark i { width: 8px; height: 8px; background: var(--accent); display: inline-block; align-self: center; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 var(--gut);
  background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
}
.topbar nav { display: flex; gap: 2px; margin-inline-start: auto; }
.topbar nav a {
  text-decoration: none; padding: 6px 10px; font-size: 14px; color: var(--ink-2);
  border-bottom: 2px solid transparent;
}
.topbar nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.topbar nav a:hover { color: var(--ink); }
.iconbtn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  background: none; border: 1px solid var(--rule); border-radius: 0; cursor: pointer; color: var(--ink);
}
.iconbtn:hover { border-color: var(--ink); }
.iconbtn svg { width: 18px; height: 18px; }
.only-mobile { display: none; }
@media (max-width: 760px) {
  .topbar nav.main { display: none; }
  .only-mobile { display: inline-grid; }
}

/* mobile bottom tabs */
.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 20; display: none;
  background: var(--paper); border-top: 1px solid var(--rule-strong);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; text-decoration: none; padding: 8px 0 7px; font-size: 12px; color: var(--ink-2);
  border-top: 2px solid transparent; margin-top: -1px;
}
.tabbar a svg { display: block; margin: 0 auto 2px; width: 20px; height: 20px; }
.tabbar a[aria-current="page"] { color: var(--ink); border-top-color: var(--accent); }
@media (max-width: 760px) { .tabbar { display: flex; } body.has-tabbar { padding-bottom: 64px; } }

/* ---------------------------------------------------------------- page frame */
.page { max-width: 1080px; margin: 0 auto; padding: 24px var(--gut) 48px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--rule-strong); padding-bottom: 10px; margin-bottom: 20px;
}
.page-head .sheet { font: 500 11px/1 var(--mono); color: var(--ink-3); letter-spacing: .08em; direction: ltr; }

/* ---------------------------------------------------------------- buttons & fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; cursor: pointer; text-decoration: none;
  background: transparent; border: 1px solid var(--ink); border-radius: 0; color: var(--ink);
  font-weight: 600; font-size: 15px; transition: background var(--t), color var(--t);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.94); background: var(--accent); color: var(--accent-ink); }
.btn.quiet { border-color: var(--rule); color: var(--ink-2); }
.btn.quiet:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: var(--paper); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 14px; font-weight: 600; }
.field small { color: var(--ink-3); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  background: var(--label-bg); border: 1px solid var(--rule); border-radius: 0; outline: none;
  transition: border-color var(--t);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.input.mono { font-family: var(--mono); letter-spacing: .04em; direction: ltr; text-align: left; }
.textarea { min-height: 88px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 22px; border: 1px solid var(--ink); position: relative; margin: 0; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 14px; height: 14px; background: var(--ink-3); transition: inset-inline-start var(--t), background var(--t); }
.switch input:checked::after { inset-inline-start: 21px; background: var(--accent); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 10px; border: 1px solid var(--rule); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.check:has(input:checked) { border-color: var(--ink); }

/* ---------------------------------------------------------------- status tags */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px; border: 1px solid currentColor; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.status.active { color: var(--ok); }
.status.pending { color: var(--accent); }
.status.suspended { color: var(--bad); }
.status.expired { color: var(--ink-3); }
.status.resolved { color: var(--ink-3); }
.role { font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 4px 6px; border: 1px solid var(--rule); color: var(--ink-2); }
.role.admin { border-color: var(--ink); color: var(--ink); }

/* ---------------------------------------------------------------- part-number label (the signature element) */
.pn-label {
  display: inline-flex; align-items: stretch; direction: ltr;
  border: 1px solid var(--ink); background: var(--label-bg); max-width: 100%;
}
.pn-label .pn {
  font: 600 20px/1 var(--mono); letter-spacing: .03em; padding: 10px 12px; white-space: nowrap;
  user-select: all; -webkit-user-select: all;
}
.pn-label .copy {
  border: 0; border-inline-start: 1px solid var(--ink); background: transparent; cursor: pointer;
  width: 44px; display: grid; place-items: center; color: var(--ink); transition: background var(--t), color var(--t);
}
.pn-label .copy:hover { background: var(--ink); color: var(--paper); }
.pn-label .copy svg { width: 18px; height: 18px; }
.pn-label.copied { border-color: var(--accent); }
.pn-label.copied .copy { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pn-label.new { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.pn-label.old .pn { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1px; }
@media (max-width: 420px) { .pn-label .pn { font-size: 18px; padding: 10px; } }

.vin { font: 600 15px/1 var(--mono); letter-spacing: .1em; }

/* drawing balloon: circled callout number */
.balloon {
  flex: none; display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 5px;
  border: 1.5px solid var(--ink); border-radius: 999px; font: 600 12px/1 var(--mono); background: var(--label-bg);
  direction: ltr;
}

/* ---------------------------------------------------------------- chat layout */
.chat-shell { display: grid; grid-template-columns: 290px 1fr; height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.side { border-inline-end: 1px solid var(--rule-strong); display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
.side .side-head { padding: 12px; border-bottom: 1px solid var(--rule); display: grid; gap: 8px; }
.side .list { overflow-y: auto; flex: 1; }
.conv { display: block; padding: 10px 12px; border-bottom: 1px solid var(--rule); text-decoration: none; }
.conv:hover { background: var(--paper-2); }
.conv[aria-current="true"] { box-shadow: inset -3px 0 0 var(--accent); background: var(--paper-2); }
.conv .t { font-size: 14px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .m { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; justify-content: space-between; }
.conv .m .vin { font-size: 11px; letter-spacing: .06em; font-weight: 500; }
.side-group { padding: 10px 12px 4px; font-size: 12px; color: var(--ink-3); }

.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.titleblock {   /* like the title block of a drawing sheet */
  display: grid; grid-template-columns: 1fr auto auto; border-bottom: 1px solid var(--rule-strong); background: var(--paper);
}
.titleblock > div { padding: 8px 14px; border-inline-start: 1px solid var(--rule); min-width: 0; }
.titleblock > div:first-child { border-inline-start: 0; }
.titleblock .k { display: block; }
.titleblock .v { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titleblock .v.vin { font-size: 14px; }
@media (max-width: 760px) {
  .chat-shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 52px 0; inset-inline-start: 0; width: min(86vw, 320px); z-index: 30;
          transform: translateX(100%); transition: transform 200ms ease; }
  [dir="rtl"] .side { transform: translateX(100%); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 52px 0 0; background: rgba(0,0,0,.25); z-index: 25; display: none; }
  .scrim.open { display: block; }
  .titleblock { grid-template-columns: 1fr auto; }
  .titleblock .hide-sm { display: none; }
}

.thread { flex: 1; overflow-y: auto; padding: 20px var(--gut) 24px; }
.thread-inner { max-width: 760px; margin: 0 auto; display: grid; gap: 22px; }
.msg { animation: rise 220ms ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg, .fade { animation: none !important; } * { transition: none !important; } }

.msg.user { justify-self: start; max-width: 85%; }   /* RTL: start = right */
.msg.user .bubble { border: 1px solid var(--ink); padding: 8px 12px; background: var(--label-bg); }
.msg.user .meta { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.msg.user .photo-chip { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-2); border: 1px dashed var(--rule); padding: 3px 8px; margin-bottom: 6px; }

.msg.bot { border-top: 1px solid var(--rule-strong); padding-top: 12px; }
.msg.bot .who { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.car-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 14px; }
.car-line h3 { font-size: 17px; }

.parts { display: grid; gap: 0; }
.part { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.part:first-child { border-top: 1px solid var(--rule); }
.part .names { display: grid; gap: 2px; min-width: 0; }
.part .ar { font-weight: 700; font-size: 16px; }
.part .en { font: 500 12px/1.4 var(--mono); color: var(--ink-2); direction: ltr; text-align: right; unicode-bidi: isolate; letter-spacing: .02em; }
.part .nums { grid-column: 2; display: grid; gap: 8px; margin-top: 8px; justify-items: start; }
.part .numrow { display: grid; gap: 4px; }
.part .numrow .lbl { font-size: 13px; color: var(--ink-2); }
.part .numrow .lbl.newl { color: var(--accent); font-weight: 600; }
.part .note { font-size: 12px; color: var(--ink-3); }
.supersede { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.supersede .arrow { color: var(--accent); font: 600 16px/1 var(--mono); }
.section-title { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 18px 0 4px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ""; flex: 1; border-top: 1px dashed var(--rule); }

.choice { border: 1px solid var(--accent); padding: 10px 12px; margin-top: 14px; background: var(--accent-soft); font-weight: 600; font-size: 14px; }

.msg-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.report-box { border: 1px solid var(--rule); padding: 12px; margin-top: 10px; display: none; }
.report-box.open { display: block; animation: rise 180ms ease-out; }

.confirm-vin { display: grid; gap: 10px; justify-items: start; }
.confirm-vin .bigvin { font: 600 22px/1 var(--mono); letter-spacing: .12em; padding: 12px 14px; border: 1px solid var(--ink); background: var(--label-bg); direction: ltr; }
.confirm-vin .bigvin em { font-style: normal; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }

/* typing indicator: a plotter pen tracing */
.tracing { display: inline-flex; gap: 4px; align-items: center; color: var(--ink-3); font-size: 13px; }
.tracing i { width: 18px; height: 1px; background: var(--ink-3); transform-origin: right; animation: trace 1.1s ease-in-out infinite; }
.tracing i:nth-child(2) { animation-delay: .15s; } .tracing i:nth-child(3) { animation-delay: .3s; }
@keyframes trace { 0%, 100% { transform: scaleX(.2); opacity: .4; } 50% { transform: scaleX(1); opacity: 1; } }

/* composer */
.composer { border-top: 1px solid var(--rule-strong); background: var(--paper-2); padding: 10px var(--gut) calc(10px + env(safe-area-inset-bottom)); }
.composer form { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: end; }
.composer textarea { min-height: 44px; max-height: 140px; resize: none; padding: 10px 12px; border: 1px solid var(--ink); background: var(--label-bg); border-radius: 0; outline: none; line-height: 1.5; }
.composer textarea:focus { box-shadow: inset 0 -2px 0 var(--accent); }
.composer .iconbtn { width: 44px; height: 44px; border-color: var(--ink); }
.composer .send { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.composer .hint { max-width: 760px; margin: 6px auto 0; font-size: 11px; color: var(--ink-3); }

/* ---------------------------------------------------------------- diagram */
.diagram-thumb { margin-top: 14px; border: 1px solid var(--ink); background: var(--label-bg); cursor: zoom-in; position: relative; display: block; width: 100%; padding: 0; text-align: inherit; }
.diagram-thumb .cap { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--ink); font-size: 13px; }
.diagram-thumb svg { display: block; width: 100%; height: auto; }
.callout-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0; margin-top: 10px; border-top: 1px solid var(--rule); }
.callout-list button { display: flex; align-items: center; gap: 10px; padding: 8px 4px; background: none; border: 0; border-bottom: 1px solid var(--rule); cursor: pointer; text-align: start; }
.callout-list button:hover .balloon { border-color: var(--accent); color: var(--accent); }

.viewer { position: fixed; inset: 0; z-index: 50; background: var(--overlay); display: none; flex-direction: column; }
.viewer.open { display: flex; animation: fadein 160ms ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 8px var(--gut); border-bottom: 1px solid var(--rule-strong); }
.viewer-bar .title { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage { flex: 1; position: relative; overflow: hidden; touch-action: none; cursor: grab; }
.stage.dragging { cursor: grabbing; }
.canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.canvas svg { display: block; }
.hotspot {
  position: absolute; border: 1.5px solid var(--accent); background: var(--accent-soft); cursor: pointer;
  display: grid; place-items: center; padding: 0; transition: background var(--t);
}
.hotspot:hover, .hotspot.sel { background: var(--accent); }
.hotspot span { font: 700 11px/1 var(--mono); color: var(--accent); direction: ltr; }
.hotspot:hover span, .hotspot.sel span { color: var(--accent-ink); }
.viewer-foot { border-top: 1px solid var(--rule-strong); padding: 10px var(--gut); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; min-height: 62px; }
.viewer-foot .picked { display: flex; align-items: center; gap: 10px; }
.zoomctl { display: flex; }
.zoomctl .iconbtn + .iconbtn { border-inline-start: 0; }

/* ---------------------------------------------------------------- auth screens */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gut); }
.auth-card { width: 100%; max-width: 420px; background: var(--paper); border: 1px solid var(--rule-strong); }
.auth-card .head { padding: 18px 20px; border-bottom: 1px solid var(--rule-strong); display: flex; justify-content: space-between; align-items: center; }
.auth-card .body { padding: 22px 20px 8px; }
.auth-card .foot { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule); }
.auth-card .foot > div { padding: 8px 12px; border-inline-start: 1px solid var(--rule); }
.auth-card .foot > div:first-child { border-inline-start: 0; }
.alert { border: 1px solid var(--bad); color: var(--bad); padding: 8px 12px; font-size: 14px; margin-bottom: 16px; }
.alert.info { border-color: var(--rule-strong); color: var(--ink); }
.dim-line { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; margin: 16px 0; }
.dim-line::before, .dim-line::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.steps { list-style: none; padding: 0; margin: 0 0 18px; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); align-items: center; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border: 1.5px solid var(--ink-3); border-radius: 999px; display: grid; place-items: center; font: 600 12px/1 var(--mono); color: var(--ink-3); }
.steps li.done::before { content: "✓"; border-color: var(--ink); color: var(--ink); }
.steps li.now::before { border-color: var(--accent); color: var(--accent); }
.steps li.now { font-weight: 700; }

/* ---------------------------------------------------------------- garage */
.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); border-top: 1px solid var(--rule-strong); border-inline-start: 1px solid var(--rule); }
.car { border-bottom: 1px solid var(--rule); border-inline-end: 1px solid var(--rule); padding: 16px; display: grid; gap: 10px; background: var(--paper); }
.car .top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.car .name { font-weight: 700; font-size: 17px; }
.car .spec { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; }
.car .spec dt { color: var(--ink-3); }
.car .spec dd { margin: 0; }
.car .acts { display: flex; gap: 8px; }
.car.add { place-items: center; text-align: center; color: var(--ink-2); border-style: dashed; min-height: 180px; cursor: pointer; }

/* ---------------------------------------------------------------- tables */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .input { max-width: 320px; flex: 1 1 200px; }
.chips { display: flex; gap: 0; flex-wrap: wrap; }
.chip { padding: 6px 12px; border: 1px solid var(--rule); background: transparent; cursor: pointer; font-size: 13px; margin-inline-start: -1px; }
.chip:first-child { margin-inline-start: 0; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); position: relative; z-index: 1; }
.chip .n { font-family: var(--mono); font-size: 11px; margin-inline-start: 4px; opacity: .7; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--rule-strong); }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: start; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; background: var(--paper-2); }
table.grid td { padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.grid tr:hover td { background: var(--paper-2); }
table.grid td.num, table.grid th.num { text-align: left; direction: ltr; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.u-name { font-weight: 600; display: block; }
.u-mail { font: 400 12px/1.3 var(--mono); color: var(--ink-3); direction: ltr; display: block; text-align: right; }
.meter { display: grid; gap: 3px; min-width: 90px; }
.meter .bar { height: 4px; background: var(--paper-2); border: 1px solid var(--rule); position: relative; }
.meter .bar i { position: absolute; inset-block: 0; inset-inline-start: 0; background: var(--ink); }
.meter .bar i.hot { background: var(--accent); }
.meter .t { font: 500 11px/1 var(--mono); color: var(--ink-2); direction: ltr; text-align: right; }

/* admin layout */
.admin-shell { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 52px); }
.admin-nav { border-inline-end: 1px solid var(--rule-strong); padding: 16px 0; background: var(--paper); }
.admin-nav .grp { padding: 4px 16px; font-size: 11px; color: var(--ink-3); margin-top: 10px; }
.admin-nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; text-decoration: none; font-size: 14px; color: var(--ink-2); }
.admin-nav a:hover { color: var(--ink); background: var(--paper-2); }
.admin-nav a[aria-current="page"] { color: var(--ink); font-weight: 700; box-shadow: inset -3px 0 0 var(--accent); background: var(--paper-2); }
.admin-nav .count { font: 600 11px/1 var(--mono); padding: 3px 6px; border: 1px solid var(--accent); color: var(--accent); }
.admin-main { min-width: 0; }
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { padding: 0; display: flex; overflow-x: auto; border-inline-end: 0; border-bottom: 1px solid var(--rule-strong); position: sticky; top: 52px; z-index: 10; }
  .admin-nav .grp { display: none; }
  .admin-nav a { white-space: nowrap; padding: 10px 12px; }
  .admin-nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
}

/* key figures — title-block cells, not cards */
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-top: 1px solid var(--rule-strong); border-inline-start: 1px solid var(--rule); margin-bottom: 28px; }
.fig { padding: 12px 14px; border-inline-end: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--paper); }
.fig .v { font: 600 26px/1.1 var(--mono); direction: ltr; text-align: right; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.fig .s { font-size: 12px; color: var(--ink-3); }
.fig.accent .v { color: var(--accent); }

/* simple bar chart */
.chart { border-top: 1px solid var(--rule-strong); padding-top: 12px; margin-bottom: 28px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border: 1px solid var(--ink); }
.sw.paid { background: var(--ink); }
.sw.cached { background: repeating-linear-gradient(45deg, var(--hatch) 0 1.5px, transparent 1.5px 5px); }
.bars { position: relative; height: 180px; display: flex; align-items: flex-end; gap: 2px; direction: ltr; border-bottom: 1px solid var(--ink); }
.bars .gl { position: absolute; inset-inline: 0; border-top: 1px dashed var(--rule); font: 500 10px/1 var(--mono); color: var(--ink-3); }
.bars .gl span { position: absolute; top: -12px; left: 0; }
.bars .col { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; height: 100%; position: relative; cursor: default; }
.bars .col i { display: block; }
.bars .col i.paid { background: var(--ink); border-radius: 0; }
.bars .col i.cached { background: repeating-linear-gradient(45deg, var(--hatch) 0 1.5px, transparent 1.5px 5px); border: 1px solid var(--hatch); border-bottom: 0; }
.bars .col:hover i.paid { background: var(--accent); }
.bars .col .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); font: 500 11px/1.4 var(--mono); padding: 5px 8px; white-space: nowrap; display: none; z-index: 2; }
.bars .col:hover .tip { display: block; }
.bars-x { display: flex; gap: 2px; direction: ltr; font: 500 10px/1 var(--mono); color: var(--ink-3); margin-top: 4px; }
.bars-x span { flex: 1; text-align: center; }

/* forms in admin */
.formgrid { display: grid; grid-template-columns: 220px 1fr; border-top: 1px solid var(--rule-strong); }
.formgrid > .lab { padding: 14px 0; border-bottom: 1px solid var(--rule); font-weight: 700; font-size: 14px; }
.formgrid > .lab small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.formgrid > .ctl { padding: 12px 0; border-bottom: 1px solid var(--rule); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.formgrid .ctl .input, .formgrid .ctl .select { max-width: 280px; }
@media (max-width: 700px) {
  .formgrid { grid-template-columns: 1fr; }
  .formgrid > .lab { border-bottom: 0; padding-bottom: 0; }
}
.savebar { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-start; padding: 12px 0; background: var(--paper); border-top: 1px solid var(--rule-strong); margin-top: 20px; }

/* reports */
.report { border-top: 1px solid var(--rule-strong); padding: 14px 0; display: grid; gap: 10px; }
.report .rh { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.report blockquote { margin: 0; padding: 8px 12px; border-inline-start: 3px solid var(--accent); background: var(--paper-2); font-size: 14px; }
.transcript { border: 1px solid var(--rule); display: none; }
.transcript.open { display: block; }
.transcript .line { display: grid; grid-template-columns: 70px 1fr; border-bottom: 1px solid var(--rule); font-size: 14px; }
.transcript .line:last-child { border-bottom: 0; }
.transcript .line > b { padding: 8px; font-size: 12px; color: var(--ink-3); border-inline-end: 1px solid var(--rule); font-weight: 500; }
.transcript .line > div { padding: 8px 10px; }
.transcript code { font-family: var(--mono); font-size: 13px; }

.tabs { display: flex; border-bottom: 1px solid var(--rule-strong); margin-bottom: 16px; gap: 0; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--ink-2); margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
[hidden] { display: none !important; }

/* toast */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translate(-50%, 8px); background: var(--ink); color: var(--paper); padding: 8px 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity var(--t), transform var(--t); z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* design-review gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); border-top: 1px solid var(--rule-strong); border-inline-start: 1px solid var(--rule); }
.gallery a { padding: 14px 16px; border-inline-end: 1px solid var(--rule); border-bottom: 1px solid var(--rule); text-decoration: none; display: grid; gap: 4px; background: var(--paper); transition: background var(--t); }
.gallery a:hover { background: var(--paper-2); }
.gallery a b { font-size: 16px; }
.gallery a .no { font: 500 11px/1 var(--mono); color: var(--accent); direction: ltr; text-align: right; }
.design-banner { background: var(--ink); color: var(--paper); font-size: 12px; text-align: center; padding: 3px 8px; }
.design-banner b { color: var(--accent); }

/* chat page fills the screen exactly (banner + top bar + thread + composer) */
body[data-page="chat"] { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
body[data-page="chat"] .chat-shell { flex: 1; min-height: 0; height: auto; }
.side-links { display: none; gap: 0; border-top: 1px solid var(--rule); }
.side-links a { flex: 1; text-align: center; padding: 8px 0; font-size: 13px; text-decoration: none; border-inline-start: 1px solid var(--rule); }
.side-links a:first-child { border-inline-start: 0; }
@media (max-width: 760px) {
  .side { inset-block: 0; z-index: 40; }
  .scrim { inset: 0; z-index: 35; }
  .side-links { display: flex; }
}
.scrim { display: none; }
@media (max-width: 760px) { .scrim.open { display: block; } }
/* review fixes */
table.grid th.num { direction: rtl; text-align: left; }
.bars { margin-inline-end: 0; margin-left: 30px; }
.bars .gl span { left: -30px; width: 26px; text-align: right; }
.bars-x { margin-left: 30px; }

/* ---------------------------------------------------------------- VIN log + devices */
.status.paid { color: var(--accent); }
.status.free { color: var(--ink-3); }
.status.free::before { background: none; border: 1px solid currentColor; }
.status.failed { color: var(--bad); }
.status.failed::before { background: none; content: "×"; width: auto; height: auto; font: 700 11px/1 var(--mono); }
.status.flag { color: var(--bad); border-style: dashed; }
.range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range .input { max-width: 160px; min-height: 36px; padding: 4px 8px; }
.toolbar .spacer { flex: 1; }
.totals { display: flex; flex-wrap: wrap; border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule); margin-bottom: 16px; }
.totals > div { padding: 8px 14px; border-inline-start: 1px solid var(--rule); }
.totals > div:first-child { border-inline-start: 0; padding-inline-start: 0; }
.totals b { font: 600 18px/1.2 var(--mono); display: block; direction: ltr; text-align: right; }
.rank { font: 600 12px/1 var(--mono); color: var(--ink-3); }
.rank.top { color: var(--accent); }
.device { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.device:first-child { border-top: 1px solid var(--rule); }
.device .ico { width: 36px; height: 36px; border: 1px solid var(--ink); display: grid; place-items: center; }
.device .ico svg { width: 18px; height: 18px; }
.device .d1 { font-weight: 600; }
.device .d2 { font-size: 12px; color: var(--ink-3); }
.device.current .ico { border-color: var(--accent); color: var(--accent); }
.flagbox { border: 1px dashed var(--bad); padding: 10px 12px; color: var(--ink); background: transparent; display: grid; gap: 4px; margin-bottom: 16px; }
.flagbox b { color: var(--bad); }
.sub-h { display: flex; justify-content: space-between; align-items: end; gap: 10px; flex-wrap: wrap; margin: 28px 0 10px; }
table.grid th.num { font-family: var(--font); }
.topbar .open-chat { gap: 6px; border-color: var(--accent); color: var(--accent); }
.topbar .open-chat svg { width: 16px; height: 16px; }
.topbar .open-chat:hover { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 760px) { .topbar .open-chat span { display: none; } .topbar .open-chat { padding: 0 9px; } }
.design-banner a { text-decoration: underline; }
.fig .v { white-space: nowrap; font-size: clamp(20px, 2.4vw, 26px); }

/* ---------------------------------------------------------------- app (stage 1+) */
.notice { border: 1px solid var(--ok); color: var(--ok); padding: 8px 12px; font-size: 14px; margin-bottom: 16px; }
.temp-pass { border: 1px solid var(--accent); padding: 12px 14px; margin-bottom: 18px; display: grid; gap: 8px; justify-items: start; }
.inline-form { display: inline; margin: 0; }
.empty { border: 1px dashed var(--rule); padding: 28px 16px; text-align: center; color: var(--ink-2); }
.logout-form { margin: 0; display: inline-flex; }

.input:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------------------------------------------------------- chat (stage 3) */
.answer { display: grid; gap: 2px; }
.answer .ln { line-height: 1.7; overflow-wrap: anywhere; }
.answer .ln.pt { font-weight: 700; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
.answer .ln.pt:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.answer .ln.num { margin: 4px 0 2px; }
.answer .ln.lbl-new { color: var(--accent); font-weight: 600; font-size: 14px; margin-top: 4px; }
.answer .ln.lbl-old { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.answer .gap { height: 6px; }
.answer code, .utext code { font-family: var(--mono); font-size: .95em; padding: 0 3px; border: 1px solid var(--rule); background: var(--label-bg); }
.utext { white-space: pre-wrap; overflow-wrap: anywhere; }
.diagram-thumb img { display: block; width: 100%; max-height: 340px; object-fit: contain; background: #fff; }
.canvas img { user-select: none; -webkit-user-select: none; pointer-events: none; background: #fff; }
.hotspot { border-width: 2px; border-radius: 2px; }
.hotspot.sel { box-shadow: 0 0 0 3px var(--accent-soft); }
/* the selected callout keeps its printed number visible: tint + thick outline, not a solid fill */
.canvas .hotspot:hover, .canvas .hotspot.sel { background: rgba(226, 83, 10, .22); border-width: 3px; }

/* ---------------------------------------------------------------- diagram with markers ON the drawing */
figure.diagram { margin: 14px 0 0; border: 1px solid var(--ink); background: var(--label-bg); max-width: 100%; }
figure.diagram .dwrap { position: relative; width: 100%; background: #fff; line-height: 0; }
figure.diagram .dwrap img { display: block; width: 100%; height: auto; cursor: zoom-in; }
figure.diagram .cap { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px;
  border-top: 1px solid var(--ink); }
figure.diagram .cap b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs { position: absolute; padding: 0; margin: 0; cursor: pointer; border: 2px solid var(--accent); border-radius: 2px;
  background: rgba(226, 83, 10, .10); transition: background var(--t); }
.hs:hover, .hs:focus-visible, .hs.sel { background: rgba(226, 83, 10, .30); outline: none; border-width: 3px; }
@media (hover: none) { .hs { border-width: 2px; } }
.canvas .hs { position: absolute; }
.callout-list .cname { min-width: 0; overflow-wrap: anywhere; }
.callout-chip { display: inline-flex; align-items: center; gap: 8px; background: none; border: 1px dashed var(--rule);
  padding: 4px 10px; cursor: pointer; color: var(--ink-2); font-size: 14px; }

/* ---------------------------------------------------------------- never wider than the screen */
.main-col, .thread, .thread-inner, .msg, .answer, .answer .ln, .callout-list, .callout-list button { min-width: 0; }
.thread { overflow-x: hidden; }
.thread-inner { width: 100%; grid-template-columns: minmax(0, 1fr); }
.msg.user { max-width: min(85%, 100%); }
.msg.user .bubble, .utext { overflow-wrap: anywhere; min-width: 0; }
.answer .ln.num { max-width: 100%; }
.pn-label { max-width: 100%; }
.pn-label .pn { overflow: hidden; text-overflow: ellipsis; }
.callout-list { grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); }
.titleblock { grid-template-columns: minmax(0, 1fr) auto auto; }
@media (max-width: 760px) { .titleblock { grid-template-columns: minmax(0, 1fr) auto; } }

/* =====================================================================================================
   MOBILE PASS (cheap Android phones in a workshop): 360-412px phones, 768px tablets.
   No sideways scrolling, 44px touch targets, 15px+ text, keyboard-safe composer, tables as cards.
   ===================================================================================================== */
html, body { overflow-x: hidden; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
.titleblock > div > * { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wordmark { min-height: 44px; align-items: center; }

/* chat page height follows the visible area (shrinks when the keyboard opens) */
body[data-page="chat"] { height: var(--app-h, 100dvh); }

/* camera / gallery menu */
.photo-wrap { position: relative; }
.photo-menu { position: absolute; bottom: calc(100% + 8px); inset-inline-start: 0; z-index: 30; display: none;
  width: min(260px, calc(100vw - 32px)); background: var(--paper); border: 1px solid var(--ink); padding: 10px; gap: 8px;
  flex-direction: column; box-shadow: 0 6px 0 -4px var(--rule); }
.photo-menu.open { display: flex; animation: rise 160ms ease-out; }
.photo-menu .btn { width: 100%; justify-content: flex-start; }

/* diagram markers: small visible box, bigger invisible touch area centred on it */
.hs::before { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 40px); height: max(100%, 36px);
  transform: translate(-50%, -50%); }
.canvas .hs::before { width: 100%; height: 100%; }

/* tables -> cards (phones and small tablets) */
@media (max-width: 900px) {
  .table-wrap { overflow: visible; border-top: 0; }
  table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
  table.grid thead { display: none; }
  table.grid tr { border: 1px solid var(--rule); border-top: 2px solid var(--ink); background: var(--paper);
    margin-bottom: 12px; padding: 4px 14px; }
  table.grid tr:hover td { background: transparent; }
  table.grid td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0;
    border-bottom: 1px dashed var(--rule); text-align: start; font-size: 15px; min-height: 44px; }
  table.grid td:last-child { border-bottom: 0; }
  table.grid td.num, table.grid th.num { direction: rtl; text-align: start; font-family: var(--font); }
  table.grid td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--ink-3); font-size: 14px;
    font-weight: 600; font-family: var(--font); }
  table.grid td[data-label=""]::before { display: none; }
  table.grid td[data-label=""] { justify-content: flex-start; flex-wrap: wrap; }
  table.grid td:first-child { font-size: 17px; }
  table.grid td:first-child::before { display: none; }
  table.grid td .cv { min-width: 0; overflow-wrap: anywhere; text-align: end; }
  table.grid td .cv.ltr { font-family: var(--mono); font-size: 15px; }
  table.grid td:first-child .cv { text-align: start; }
  table.grid td .cv:has(.btn), table.grid td .cv:has(form) { display: flex; flex-wrap: wrap; gap: 8px; width: 100%;
    justify-content: flex-start; }
  table.grid td:has(.btn)::before { display: none; }
  table.grid td .cv .btn, table.grid td .cv form { flex: 1 1 120px; }
  table.grid td .cv form .btn { width: 100%; }
  table.grid .meter { width: 140px; }
  .u-mail { text-align: start; }
}

/* phones */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .small, small, .u-mail, .muted.small, .faint.small, .field small, .conv .m, .msg.user .meta, .hint, .note,
  .side-group, .chip, .chip .n, .status, .role, .legend, .dim-line, .auth-card .foot, .who .faint { font-size: 15px; }
  .composer .hint { font-size: 13px; }
  .topbar { height: 56px; padding: 0 12px; gap: 8px; }
  .chat-shell { height: auto; }
  .iconbtn { width: 44px; height: 44px; }
  .btn, .btn.sm { min-height: 44px; font-size: 15px; }
  .chip { min-height: 44px; display: inline-flex; align-items: center; padding: 6px 14px; }
  .check { min-height: 44px; font-size: 15px; }
  .input, .select, .textarea { min-height: 48px; font-size: 16px; }   /* 16px: phones don't zoom into the field */
  .page { padding: 18px 14px 40px; }
  .page-head { gap: 10px; }
  .page-head > .btn, .page-head > a.btn { width: 100%; }
  h1 { font-size: 23px; }

  /* conversations list: a slide-in menu, really gone (not off-screen) while closed */
  .side { display: none; position: fixed; inset-block: 0; inset-inline-start: 0; width: min(88vw, 340px); z-index: 40;
    transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .side.open { display: flex; animation: slidein 200ms ease-out; }
  @keyframes slidein { from { transform: translateX(30%); opacity: .4; } to { transform: none; opacity: 1; } }
  .scrim { display: none !important; }
  .side .side-head { padding: 12px; }
  .conv { padding: 12px 14px; min-height: 56px; }
  .conv .t { font-size: 16px; }
  .side-links a { padding: 12px 0; font-size: 15px; min-height: 44px; }

  /* title block: one line with the car, the save button beside it */
  .titleblock > div { padding: 6px 12px; }
  .titleblock .v { font-size: 15px; }

  /* answers: big numbers, one-tap copy */
  .thread { padding: 14px 12px 20px; }
  .pn-label .pn { font-size: 22px; padding: 12px 14px; }
  .pn-label .copy { width: 52px; min-height: 48px; }
  .pn-label .copy svg { width: 22px; height: 22px; }
  .answer .ln { font-size: 16px; }
  .msg-actions .btn { min-height: 44px; }
  .callout-list button { min-height: 52px; padding: 8px 4px; }
  .callout-chip { min-height: 44px; }
  .confirm-vin .bigvin { font-size: 19px; letter-spacing: .06em; max-width: 100%; overflow-wrap: anywhere; }

  /* diagram: full screen width */
  figure.diagram { margin-inline: -12px; border-inline: 0; }
  .viewer-bar { padding: 6px 10px; }
  .viewer-bar .title { font-size: 15px; }
  .viewer-foot { min-height: 56px; }

  /* composer: always at the bottom, big targets */
  .composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer form { grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 6px; }
  .composer .iconbtn { width: 48px; height: 48px; }
  .composer textarea { min-height: 48px; font-size: 16px; }

  /* admin: menu wraps (no sideways scrolling), forms stack */
  .admin-nav { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .admin-nav a { min-height: 44px; padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: normal; }
  .admin-nav > span.faint { display: none !important; }
  .figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fig .v { font-size: 22px; }
  .formgrid .ctl .input, .formgrid .ctl .select, .formgrid .ctl .textarea { max-width: 100% !important; }
  .savebar { flex-wrap: wrap; }
  .savebar .btn { flex: 1 1 120px; }
  .device { grid-template-columns: auto minmax(0, 1fr); }
  .device > form { grid-column: 1 / -1; }
  .device > form .btn { width: 100%; }
  .flagbox .row > * { flex: 1 1 100%; }
  .toolbar .input { max-width: 100%; flex: 1 1 100%; }
  .cars { grid-template-columns: minmax(0, 1fr); }
  .car .acts { flex-wrap: wrap; }
  .car .acts > * { flex: 1 1 30%; }
  .car .acts .btn { width: 100%; }
  .temp-pass .pn-label { max-width: 100%; }
}

/* touch screens up to tablet size: 44px targets, 15px+ text (layout changes above stay phone-only) */
@media (max-width: 1024px) {
  body { font-size: 16px; }
  .small, small, .u-mail, .field small, .conv .m, .conv .m .vin, .msg.user .meta, .hint, .composer .hint, .note,
  .side-group, .chip, .chip .n, .status, .role, .legend, .dim-line, .auth-card .foot, .who .faint, .fig .s,
  .meter .t, .formgrid > .lab, .formgrid > .lab small, .titleblock .v.small, .tabbar a, .side-links a,
  .callout-chip, .admin-nav a, .wordmark span, table.grid td, table.grid th { font-size: 15px; }
  .balloon { font-size: 14px; min-width: 34px; height: 34px; }
  .iconbtn { width: 44px; height: 44px; }
  .btn, .btn.sm { min-height: 44px; font-size: 15px; }
  .chip { min-height: 44px; display: inline-flex; align-items: center; padding: 6px 14px; }
  .check { min-height: 44px; }
  .input, .select, .textarea { min-height: 48px; font-size: 16px; }
  .sub-h a, .page-head a.small, .chat-cta a { min-height: 44px; display: inline-flex; align-items: center; }
  .admin-nav a { min-height: 44px; }
  .pn-label .pn { font-size: 22px; padding: 12px 14px; }
  .pn-label .copy { width: 52px; min-height: 48px; }
  .tabbar a { min-height: 56px; }
  .callout-list button { min-height: 52px; }
  .conv { min-height: 56px; }
  .viewer .iconbtn { width: 48px; height: 48px; }
}
@media (max-width: 760px) {
  .wordmark b { font-size: 17px; }
  .wordmark span { font-size: 16px; }
}
@media (max-width: 1024px) {
  .field > span, .device .d2, .device .d2 .mono, .conv .t, .titleblock .v, .titleblock .v.vin, .titleblock .v.small,
  .topbar nav a { font-size: 15px; }
  .balloon { font-size: 15px; }
  .topbar nav a { min-height: 44px; display: inline-flex; align-items: center; }
}
/* mobile polish */
.titleblock .v, figure.diagram .cap b, .viewer-bar .title { unicode-bidi: plaintext; }   /* long Latin names: show the start */
.conv .m { flex-wrap: nowrap; }
.conv .m > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .m > span:first-child { flex: 1 1 auto; unicode-bidi: plaintext; }
.conv .m .vin { flex: none; }
.canvas .hs::before { width: max(100%, calc(40px * var(--inv, 1))); height: max(100%, calc(36px * var(--inv, 1))); }
@media (max-width: 760px) {
  .composer .hint { display: none; }
  figure.diagram { max-width: none; width: calc(100% + 24px); margin-inline: -12px; }
}

/* ---------------------------------------------------------------- admin stage 4 */
.todo-list { display: grid; }
.todo-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--rule); text-decoration: none; min-height: 56px; }
.todo-item:hover { background: var(--paper-2); }
.todo-item .n { font: 600 22px/1 var(--mono); min-width: 36px; text-align: center; }
.todo-item .n.hot { color: var(--accent); }
.todo-item .n.bad { color: var(--bad); }
.todo-item small { display: block; color: var(--ink-3); font-size: 13px; overflow-wrap: anywhere; }
.dash2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin-top: 8px; }
@media (max-width: 1100px) { .dash2 { grid-template-columns: minmax(0, 1fr); } }
.tabs a { padding: 8px 14px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
  min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.period { gap: 10px; }
.period .range .input { max-width: 170px; }
.admin-transcript { max-width: 820px; margin: 0; gap: 14px; }
.meta-box { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); border-inline-start: 3px solid var(--rule);
  padding: 6px 10px; margin-top: -8px; background: var(--paper-2); }
.meta-box .fb { color: var(--accent); }
.price-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.price-row b { min-width: 150px; }
.price-row .input { max-width: 110px; }
.report details summary::-webkit-details-marker { display: none; }
@media (max-width: 1024px) { .todo-item small, .meta-box { font-size: 15px; } }
/* stage 4 mobile/tablet fixes */
@media (max-width: 860px) {
  .admin-nav { position: static; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); overflow: visible; }
  .admin-nav a { white-space: normal; border-bottom: 1px solid var(--rule); }
  .admin-nav .grp { display: none; }
}
@media (max-width: 1024px) {
  .rank, .report blockquote, .report .vin, .bars-x { font-size: 15px; }
  .period .range .input { min-height: 48px; }
  table.grid td a:not(.btn), .meta-box a { min-height: 44px; display: inline-flex; align-items: center; }
  .bars-x span { overflow: visible; }
}
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btns .btn { flex: 0 0 auto; min-width: 88px; }
.meta-box .run { display: inline-block; text-align: left; }

/* admin: type a specific password for a user */
.set-pw > summary { list-style: none; display: inline-flex; width: fit-content; }
.set-pw > summary::-webkit-details-marker { display: none; }
.set-pw[open] > summary { border-color: var(--ink); color: var(--ink); }
