/* Visual language: a clinical instrument panel — graphite and steel blue,
   monospaced readouts for codes and counts, and LED-style indicators for state
   (the screw racks borrow the look of a PLC panel / cinema seat map). */
:root {
  --bg: #eceef2;
  --surface: #ffffff;
  --panel: #f4f5f8;
  --ink: #14181f;
  --muted: #5f6877;
  --line: #d5d9e1;
  --accent: #2d4fa8;
  --accent-ink: #ffffff;
  --accent-soft: #dde5f7;
  --amber: #c9820f;
  --amber-glow: rgba(201, 130, 15, 0.45);
  --red: #c8412e;
  --led: #2f7fd0;
  --led-glow: rgba(47, 127, 208, 0.45);
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.06), 0 6px 20px rgba(20, 24, 31, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --surface: #151a24;
    --panel: #11151e;
    --ink: #e6e9f0;
    --muted: #8f98a9;
    --line: #262d3b;
    --accent: #8aa8ff;
    --accent-ink: #0b1633;
    --accent-soft: #1b2745;
    --amber: #e5a53c;
    --amber-glow: rgba(229, 165, 60, 0.5);
    --red: #f06a55;
    --led: #5aa6f0;
    --led-glow: rgba(90, 166, 240, 0.5);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font-family: inherit; color: inherit; }
/* 16px minimum: iOS Safari zooms the page in when a smaller input is focused, and never zooms back out. */
input, select, textarea { font-size: 16px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font: 700 1rem var(--mono); }
.brand b { display: block; font-size: 0.98rem; line-height: 1.2; }
.brand small { color: var(--muted); font: 500 0.66rem var(--mono); letter-spacing: 0.06em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: none; border-radius: 9px; background: none; color: var(--muted); font: 600 0.9rem var(--sans); text-align: left; cursor: pointer; }
.nav button svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav button:hover { background: var(--panel); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.who { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.who label { font: 600 0.62rem var(--mono); letter-spacing: 0.12em; color: var(--muted); }
.who select { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.role-chip { align-self: flex-start; font: 600 0.68rem var(--mono); letter-spacing: 0.06em; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

.main { padding: 26px 30px 70px; min-width: 0; }
.page-head { margin-bottom: 18px; }
.page-head .eyebrow { font: 600 0.66rem var(--mono); letter-spacing: 0.16em; color: var(--accent); text-transform: uppercase; }
.page-head h1 { font-size: 1.55rem; line-height: 1.25; margin-top: 2px; }
.page-head p { color: var(--muted); font-size: 0.85rem; margin-top: 3px; }

.bottomnav { display: none; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden; }
.card-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 14px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 0.98rem; }
.card-h .eyebrow { font: 600 0.64rem var(--mono); letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.card-b { padding: 18px; }
.card-b > h4, h4.sub { margin: 20px 0 10px; font: 600 0.72rem var(--mono); letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.card-b > h4:first-child { margin-top: 0; }

.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.readout { position: relative; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.readout small { display: block; color: var(--muted); font: 600 0.64rem var(--mono); letter-spacing: 0.1em; }
.readout b { display: block; margin-top: 6px; font: 600 1.55rem var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.readout .led { position: absolute; top: 14px; right: 14px; }

.led { width: 9px; height: 9px; border-radius: 50%; background: var(--led); box-shadow: 0 0 9px var(--led-glow); }
.led.amber { background: var(--amber); box-shadow: 0 0 9px var(--amber-glow); }
.led.red { background: var(--red); box-shadow: 0 0 9px rgba(200, 65, 46, 0.5); }
.led.off { background: var(--line); box-shadow: none; }

/* ---------- form controls ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; font: 600 0.74rem var(--mono); letter-spacing: 0.04em; color: var(--muted); }
.field input, .field select, .cellinput { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--ink); font-family: var(--sans); font-weight: 400; letter-spacing: 0; min-width: 0; width: 100%; }
.field input[readonly] { opacity: 0.75; }
.field input:disabled, .field select:disabled, .cellinput:disabled { opacity: 0.6; }
.field input:focus, .field select:focus, .cellinput:focus, .who select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: auto; }
.radios { display: flex; gap: 14px; align-items: center; padding: 9px 0; font: 400 0.9rem var(--sans); color: var(--ink); letter-spacing: 0; }
.radios label { display: flex; gap: 6px; align-items: center; }

.btn { padding: 9px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font: 600 0.84rem var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { color: var(--accent-ink); filter: brightness(1.08); }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-danger:hover:not(:disabled) { border-color: var(--red); color: var(--red); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.seg button { padding: 6px 14px; border: none; border-radius: 7px; background: none; color: var(--muted); font: 600 0.8rem var(--sans); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font: 600 0.68rem var(--mono); letter-spacing: 0.02em; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.badge.pending::before, .badge.warn::before, .badge.draft::before { background: var(--amber); box-shadow: 0 0 6px var(--amber-glow); }
.badge.approved::before, .badge.confirmed::before { background: var(--led); box-shadow: 0 0 6px var(--led-glow); }
.badge.rejected::before, .badge.expired::before, .badge.scrap::before { background: var(--red); }
.badge.scrap, .badge.expired { color: var(--red); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 68vh; background: var(--surface); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.84rem; }
.table th, .table td { padding: 8px 11px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.table thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); font: 600 0.66rem var(--mono); letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.table td.num, .table th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table td.code { font-family: var(--mono); font-size: 0.8rem; }
.table tr.group td { background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.78rem; }
.table .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.table thead .sticky { z-index: 3; background: var(--panel); }
.table tfoot td { border-top: 2px solid var(--line); background: var(--panel); }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--panel); }
.qtybtn { min-width: 34px; padding: 3px 7px; border: 1px solid transparent; border-radius: 7px; background: none; font: 400 0.84rem var(--mono); color: var(--muted); cursor: pointer; }
.qtybtn.has { border-color: var(--line); background: var(--panel); color: var(--ink); font-weight: 600; }
.qtybtn:hover { border-color: var(--accent); }

/* ---------- screw racks: PLC lamp panel / cinema seat map ---------- */
.racks { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.rack { padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.rack-h { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; margin-bottom: 10px; }
.rack-h b { font: 600 0.88rem var(--sans); }
.rack-h span { font: 500 0.68rem var(--mono); color: var(--muted); }
.rack-cols { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 2px; }
.rcol { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1 0 38px; padding: 8px 0 6px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.seat { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid var(--line); background: transparent; display: block; }
.seat.on { background: var(--led); border-color: var(--led); box-shadow: 0 0 9px var(--led-glow); }
.seat.sel { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 9px var(--amber-glow); }
button.seat { cursor: pointer; }
button.seat:hover:not(:disabled) { transform: scale(1.12); }
button.seat:disabled { cursor: default; }
.rcol .len { margin-top: 2px; font: 600 0.78rem var(--mono); }
.rcol .cnt { font: 500 0.66rem var(--mono); color: var(--muted); }
.rcol.low .cnt { color: var(--amber); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font: 500 0.7rem var(--mono); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .seat { width: 11px; height: 11px; border-width: 1.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-size: 0.8rem; }
.chip.scrap { border-color: var(--red); }
.chip .mono { font: 500 0.7rem var(--mono); color: var(--muted); }
.chip button { border: none; background: none; padding: 2px 7px; border-radius: 6px; color: var(--muted); font: inherit; cursor: pointer; }
.chip button:hover { color: var(--accent); }

/* ---------- report form / list ---------- */
.mainrow { display: grid; grid-template-columns: 2fr 2fr 90px auto auto; gap: 10px; align-items: end; margin-bottom: 10px; }
.report { padding: 13px 16px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.report-h { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 8px; }
.report-h b { font: 600 0.95rem var(--mono); }
.report ul { margin: 0; padding-left: 18px; font-size: 0.84rem; }
.report .meta { margin-top: 8px; color: var(--muted); font: 400 0.72rem var(--mono); }
.actions { margin-left: auto; display: flex; gap: 6px; }

/* ---------- sales order ---------- */
.sales-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 18px; align-items: start; }
.totals { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.totals dl { margin: 0; }
.totals div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 0.85rem; }
.totals div:last-child { border-bottom: none; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font: 600 0.95rem var(--mono); font-variant-numeric: tabular-nums; }
.totals .grand dd { font-size: 1.25rem; color: var(--accent); }
.detail-table input, .detail-table select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); min-width: 0; width: 100%; font-weight: 400; }
.detail-table input:focus, .detail-table select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.muted { color: var(--muted); font-size: 0.82rem; }
.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- dialog / toast ---------- */
dialog { width: min(720px, 94vw); max-height: 88vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
dialog::backdrop { background: rgba(6, 8, 14, 0.6); }
.dlg { max-height: 88vh; overflow: auto; }
.dlg-h { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.dlg-h h3 { font-size: 1rem; }
.dlg-h button { border: none; background: none; font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; }
.dlg-b { padding: 18px; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 300; max-width: 92vw; padding: 10px 18px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 0.88rem; box-shadow: var(--shadow); }
.toast.err { background: var(--red); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .app { display: block; }
  .side { position: sticky; z-index: 50; height: auto; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 10px calc(14px + env(safe-area-inset-left)); border-right: none; border-bottom: 1px solid var(--line); }
  .side .nav { display: none; }
  .brand small { display: none; }
  .who { margin: 0; flex-direction: row; align-items: center; padding: 4px 8px; border: none; background: none; }
  .who label { display: none; }
  .who select { width: auto; max-width: 138px; padding: 6px 8px; }
  .main { padding: 18px 12px calc(104px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 1.3rem; }
  /* Tab bar at the bottom (Apple HIG: thumb reach), kept above the home indicator by the safe area. */
  .bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) max(8px, env(safe-area-inset-bottom)) env(safe-area-inset-left); }
  .bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; padding: 8px 2px 6px; -webkit-tap-highlight-color: transparent; touch-action: manipulation; border: none; background: none; color: var(--muted); font: 600 0.64rem var(--sans); cursor: pointer; }
  .bottomnav button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .bottomnav button[aria-current="page"] { color: var(--accent); }

  .card-b { padding: 14px; }
  .card-h { padding: 11px 14px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .field.wide { grid-column: 1 / -1; }
  .readouts { grid-template-columns: 1fr 1fr; gap: 10px; }
  .readout b { font-size: 1.2rem; }
  .mainrow { grid-template-columns: 1fr 1fr; }
  .mainrow > :first-child { grid-column: 1 / -1; }
  .racks { grid-template-columns: 1fr; }
  .sales-layout { grid-template-columns: 1fr; }
  .actions { margin-left: 0; width: 100%; }
}

/* ---------- screw boxes: one physical rack as a lamp grid ---------- */
.loc-badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: 600 0.66rem var(--mono); letter-spacing: 0.02em; white-space: nowrap; }
.loc-badge.company { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.loc-badge.hospital { color: var(--ink); }
.loc-badge.rep { border-style: dashed; }

.boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.boxcard { padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; }
.boxcard:hover { border-color: var(--accent); }
.boxcard-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 10px; margin-bottom: 4px; }
.boxcard-h b { font-size: 0.92rem; }
.boxcard-f { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font: 500 0.7rem var(--mono); color: var(--muted); }
.boxcard-f b { color: var(--ink); white-space: nowrap; }

.boxscroll { overflow-x: auto; padding: 2px 0 4px; }
.bband { margin-bottom: 12px; width: max-content; min-width: 100%; }
.bband-h { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 5px; font: 600 0.74rem var(--mono); color: var(--muted); }
.bband-h b { color: var(--ink); }
.bgrid { display: grid; grid-template-columns: repeat(var(--cols), 13px); gap: 3px; width: max-content; }
.bgrid.thumb { grid-template-columns: repeat(var(--cols), 4px); gap: 2px; }
.blabel { width: 13px; text-align: center; font: 600 0.56rem var(--mono); color: var(--muted); }
.slot { display: block; width: 13px; height: 13px; padding: 0; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; }
.bgrid.thumb .slot { width: 4px; height: 4px; border-width: 1px; }
.slot.on { background: var(--led); border-color: var(--led); box-shadow: 0 0 6px var(--led-glow); }
.slot.sel { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 6px var(--amber-glow); }
.bgrid.thumb .slot.on, .bgrid.thumb .slot.sel { box-shadow: none; }
button.slot { cursor: pointer; }
button.slot:hover:not(:disabled) { transform: scale(1.35); }
button.slot:disabled { cursor: default; }
.legend .slot { width: 11px; height: 11px; display: inline-block; }
.boxhead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 0.86rem; }
.boxhead .loc-badge { font-size: 0.72rem; }

.table th.lt-company { box-shadow: inset 0 3px 0 var(--accent); }
.table th.lt-hospital { box-shadow: inset 0 3px 0 var(--line); }
.table th.lt-rep { box-shadow: inset 0 3px 0 var(--amber); }
.table th small { display: block; margin-top: 2px; font: 500 0.58rem var(--mono); letter-spacing: 0.04em; text-transform: none; opacity: 0.8; }

dialog.wide { width: min(980px, 96vw); }

/* ---------- touch / small screens: nothing may drag the layout sideways ---------- */
.table-wrap, .boxscroll { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.matrix-list { display: none; }
.mgroup { margin: 16px 0 8px; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font: 600 0.78rem var(--sans); }
.mgroup:first-child { margin-top: 0; }
.mitem { padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.mitem-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.mitem-h .code { font: 600 0.8rem var(--mono); }
.mitem-h em { margin-left: auto; font: normal 500 0.72rem var(--mono); color: var(--muted); }
.mlocs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mloc { display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); font: 500 0.78rem var(--sans); cursor: pointer; }
.mloc b { font: 600 0.82rem var(--mono); }
.mloc.company { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.mloc.rep { border-style: dashed; }

@media (max-width: 900px) {
  .matrix-wrap { display: none; }
  .matrix-list { display: block; }
  .table-wrap { overflow: visible; max-height: none; border: none; background: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; }
  .table.stack thead, .table.stack tfoot { display: none; }
  .table.stack tr { margin-bottom: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .table.stack tr.group { margin: 12px 0 4px; padding: 0; border: none; background: none; }
  .table.stack tr.click:hover td { background: none; }
  .table.stack td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 5px 0; border: none; white-space: normal; text-align: right; }
  .table.stack td::before { content: attr(data-label); flex-shrink: 0; color: var(--muted); font: 600 0.64rem var(--mono); letter-spacing: 0.08em; text-align: left; }
  .table.stack td input, .table.stack td select { width: auto; flex: 1; min-width: 0; max-width: 64%; }
  .table.stack td:empty { display: none; }
  .table .sticky { position: static; }
}

/* ---------- task-first additions ---------- */
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin-bottom: 14px; padding: 10px 16px; border: 1px solid var(--amber); border-radius: 12px; background: var(--surface); font-size: 0.88rem; }
.banner::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 9px var(--amber-glow); flex-shrink: 0; }
.banner span { flex: 1; }
.scope-line { margin: 14px 0 4px; color: var(--muted); font-size: 0.86rem; }
.scope-line b { color: var(--ink); }
.usage-empty { padding: 16px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 0.86rem; text-align: center; }
.btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rack.picker { margin-top: 12px; }
.chip-kind { margin-right: 2px; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font: 600 0.62rem var(--mono); }
.submitbar { margin-top: 20px; }
@media (max-width: 900px) {
  .submitbar { margin-top: 16px; }
  .submitbar .btn { width: 100%; padding: 12px; }
}

/* ---------- statistics + accounting + mobile "more" ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.stat-grid .card { margin-bottom: 0; }
.more-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.more-list .btn { display: flex; align-items: center; gap: 10px; justify-content: flex-start; padding: 12px 14px; }
.more-list svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ---------- charts (form follows the question) ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.kpi small { display: block; color: var(--muted); font: 600 0.66rem var(--mono); letter-spacing: 0.08em; }
.kpi b { display: block; margin: 6px 0 4px; font: 600 1.6rem var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.delta { font: 500 0.74rem var(--mono); color: var(--muted); }
.delta.up { color: var(--led); }
.delta.down { color: var(--red); }

.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.dashed { stroke-dasharray: 3 4; }
.chart .col { fill: var(--accent); }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: 0.13; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .val { fill: var(--ink); font: 600 10px var(--mono); }
.chart .lab { fill: var(--muted); font: 500 10px var(--mono); }

.table.compact th, .table.compact td { padding: 7px 9px; }
.table.compact .rank { width: 28px; color: var(--muted); }
.table.compact td.share { white-space: nowrap; }
.mini { display: inline-block; width: 54px; height: 7px; margin-right: 8px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); vertical-align: middle; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--accent); }
td.share em { display: inline-block; min-width: 32px; font: normal 500 0.76rem var(--mono); color: var(--muted); text-align: right; }

.segbar { display: flex; height: 18px; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.seg { display: block; min-width: 4px; }
.seg-expired { background: var(--red); }
.seg-d30 { background: var(--amber); }
.seg-d60 { background: var(--amber); opacity: 0.6; }
.seg-d90 { background: var(--amber); opacity: 0.32; }
.seg-ok { background: var(--led); }
.stack-legend { display: grid; gap: 7px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 0.84rem; }
.stack-legend li { display: flex; align-items: center; gap: 9px; }
.stack-legend i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.stack-legend b { margin-left: auto; font: 600 0.82rem var(--mono); }
.stack-legend em { min-width: 36px; text-align: right; font: normal 500 0.76rem var(--mono); color: var(--muted); }

/* ---------- stock page: list on the left, map on the right ---------- */
.stock-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, 1fr); gap: 20px; align-items: start; }
.stock-main { min-width: 0; }
:root { color-scheme: light dark; }
.stock-side { position: sticky; top: 20px; min-width: 0; }
.stock-side .card { margin-bottom: 0; }
.stock-main .table.matrix th, .stock-main .table.matrix td { padding: 7px 14px; }
.focus-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 12px; padding: 8px 12px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); font-size: 0.86rem; }
.focus-chip span { color: var(--muted); }
.focus-chip .btn { margin-left: auto; }

.tw-box { position: relative; height: clamp(360px, 62vh, 640px); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.tw-svg { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
.tw-svg.dragging { cursor: grabbing; }
.tw-county { fill: var(--surface); stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.tw-county:hover { fill: var(--accent-soft); }
.tw-ctl { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; }
.tw-ctl .btn { padding: 5px 10px; background: var(--surface); }
.tw-tip { position: absolute; z-index: 3; max-width: 230px; padding: 8px 11px; border-radius: 9px; background: var(--ink); color: var(--bg); font-size: 0.78rem; line-height: 1.55; white-space: pre-line; pointer-events: none; box-shadow: var(--shadow); }

.mk { cursor: pointer; }
.mk-shape { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.mk-company .mk-shape { fill: var(--accent); stroke: var(--accent); }
.mk-hospital .mk-shape { fill: var(--panel); stroke: var(--ink); }
.mk-rep .mk-shape { fill: var(--amber); stroke: var(--amber); }
.mk.warn .mk-shape { stroke: var(--amber); stroke-width: 3.2; }
.mk.exp .mk-shape { stroke: var(--red); stroke-width: 3.2; }
.mk.sel .mk-shape { fill: var(--accent); stroke: var(--accent); }
.mk.dim { opacity: 0.32; }
@media (hover: hover) { .mk:hover .mk-shape { stroke-width: 3.4; } }
.mk-label { fill: var(--ink); font: 600 11px var(--sans); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; opacity: 0; transition: opacity 0.15s; pointer-events: none; }
.show-labels .mk-label, .mk.sel .mk-label { opacity: 1; }
@media (hover: hover) { .mk:hover .mk-label { opacity: 1; } }
.pulse { fill: none; stroke: var(--amber); stroke-width: 2; opacity: 0.6; transform-box: fill-box; transform-origin: center; animation: twPulse 1.8s ease-out infinite; }
@keyframes twPulse { from { transform: scale(0.55); opacity: 0.8; } to { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.tw-layers { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 4px; }
.layer { display: inline-flex; align-items: center; gap: 7px; font-size: 0.84rem; cursor: pointer; }
.layer input { accent-color: var(--accent); }
.lg { display: inline-block; width: 11px; height: 11px; border: 2px solid var(--ink); background: var(--panel); }
.lg-sq { border-radius: 3px; background: var(--accent); border-color: var(--accent); }
.lg-ci { border-radius: 50%; }
.lg-di { transform: rotate(45deg) scale(0.85); background: var(--amber); border-color: var(--amber); }
.tw-sel { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.tw-sel-h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.tw-note { margin-top: 10px; font-size: 0.72rem; }

@media (max-width: 1280px) {
  .stock-layout { grid-template-columns: minmax(0, 1fr); }
  .stock-side { position: static; order: -1; }
  .stock-main .matrix-wrap { width: auto; }
  .stock-main .table.matrix { width: 100%; }
  .tw-box { height: clamp(300px, 52vh, 480px); }
}
@media (max-width: 900px) {
  .stock-main .table.matrix th, .stock-main .table.matrix td { padding: 7px 10px; }
  .tw-box { height: 300px; }
}

/* ---------- stock ledger + detail lists ---------- */
.mv-up { color: var(--accent); }
.mv-down { color: var(--red); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 16px; font-size: 0.88rem; }
dl.kv dt { color: var(--muted); font: 600 0.7rem var(--mono); letter-spacing: 0.08em; padding-top: 3px; }
dl.kv dd { margin: 0; }
.table.moves td { vertical-align: top; }
.table.moves .sub2 { display: block; margin-top: 2px; color: var(--muted); font-size: 0.72rem; white-space: normal; }

/* ---------- intro page ---------- */
.intro-hero { margin-bottom: 18px; padding: 28px 28px 26px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(135deg, var(--accent-soft), var(--surface) 62%); box-shadow: var(--shadow); }
.intro-hero .eyebrow { font: 600 0.66rem var(--mono); letter-spacing: 0.14em; color: var(--accent); text-transform: uppercase; }
.intro-hero h2 { margin-top: 6px; font-size: 1.7rem; line-height: 1.25; text-wrap: balance; }
.intro-hero p { max-width: 62ch; margin: 10px 0 18px; color: var(--muted); line-height: 1.7; }
.flow-wrap { overflow-x: auto; }
.flow-svg { display: block; width: 100%; min-width: 860px; height: auto; }
.fl-lane { fill: var(--panel); stroke: var(--line); }
.fl-lane.sys { fill: var(--accent-soft); stroke: transparent; opacity: 0.55; }
.fl-lane-t { fill: var(--muted); font: 600 13px var(--sans); }
.fl-node { fill: var(--surface); stroke: var(--line); stroke-width: 1.4; }
.fl-node.sys { stroke: var(--accent); }
.fl-n { fill: var(--accent); font: 600 12px var(--mono); }
.fl-t { fill: var(--ink); font: 700 15px var(--sans); }
.fl-d { color: var(--muted); font: 400 11.5px/1.4 var(--sans); }
.fl-arrow { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.fl-head { fill: var(--muted); }
.fl-base { fill: none; stroke: var(--line); stroke-dasharray: 5 4; }
.fl-base-t { fill: var(--muted); font: 500 13px var(--sans); }
.flow-list { display: none; margin: 0; padding: 0; list-style: none; }
.flow-list li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.flow-list li .muted { grid-column: 2; font-size: 0.82rem; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.feat { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.feat svg { width: 24px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.feat h3 { font-size: 1rem; }
.feat p { flex: 1; margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.65; }
.table td.wrap { white-space: normal; min-width: 180px; line-height: 1.6; }
.intro-two { margin-top: 18px; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.tour { display: grid; gap: 12px; margin: 0 0 12px; padding-left: 22px; }
.tour li::marker { color: var(--accent); font-weight: 700; }
.tour b { display: block; }
.tour span { color: var(--muted); font-size: 0.88rem; }
@media (max-width: 720px) {
  .flow-wrap { display: none; }
  .flow-list { display: block; }
  .intro-hero { padding: 20px 16px; }
  .intro-hero h2 { font-size: 1.4rem; }
  .intro-two { grid-template-columns: minmax(0, 1fr); }
}

.brand-mark.logo { padding: 0; background: #fff; border: 1px solid var(--line); overflow: hidden; }
.brand-mark.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-mark.logo { width: 46px; height: 46px; border-radius: 50%; }

/* ---------- 產品別 editor ---------- */
.ce-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 10px; align-items: end; margin-bottom: 10px; }
@media (max-width: 560px) { .ce-row { grid-template-columns: minmax(0, 1fr) 100px; } .ce-row .btn { grid-column: 1 / -1; } }
.mitem-h small { display: block; flex-basis: 100%; }

/* ---------- phone: dropdowns and rows need the full width ---------- */
select { max-width: 100%; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mainrow { grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; }
  .mainrow > :nth-child(1), .mainrow > :nth-child(2) { grid-column: 1 / -1; }
  .mainrow > :nth-child(3) { grid-column: 1; }
  .mainrow .field.check { align-self: center; padding-top: 18px; }
  .mainrow .btn { align-self: end; }
  .ce-row { grid-template-columns: minmax(0, 1fr); }
  .card-b > h4, .card-b > .usage-title { margin-top: 18px; }
}

/* iOS Safari draws date inputs (and selects) with their own intrinsic width and centred text;
   reset them so they obey the grid cell like every other field. */
.field input:not([type="checkbox"]):not([type="radio"]), .field select { display: block; max-width: 100%; box-sizing: border-box; -webkit-appearance: none; appearance: none; }
.field select { padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.field input[type="date"], .field input[type="month"] { min-height: 42px; text-align: left; }
.field input::-webkit-date-and-time-value { text-align: left; min-width: 0; }
.field input::-webkit-datetime-edit { padding: 0; }

/* Phone: bigger lamps so a screw slot can be tapped without pinch-zooming first. */
@media (max-width: 560px) {
  .bgrid { grid-template-columns: repeat(var(--cols), 22px); gap: 4px; }
  .bgrid.thumb { grid-template-columns: repeat(var(--cols), 4px); gap: 2px; }
  .blabel { width: 22px; }
  .slot { width: 22px; height: 22px; }
  .bgrid.thumb .slot { width: 4px; height: 4px; }
}

/* ---------- GDP 單據 ---------- */
.post-check { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 16px; padding: 12px 14px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.check-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.table.audit tr.day-first td { border-top: 2px solid var(--line); }

/* ---------- 報刀 v34 flow: 刀表 tag, record sections, history, changes, notifications ---------- */
.ktag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.ktag.t-yb { background: #d6f2ee; color: #0f6b60; border-color: transparent; }
.ktag.t-zh { background: #e3e4fb; color: #3b3f9c; border-color: transparent; }
.ktag.t-bv { background: #efdffb; color: #6c2a9a; border-color: transparent; }
.ktag.t-tw { background: #fde6cf; color: #8a4a06; border-color: transparent; }
.ktag.t-dl { background: #e1e7ef; color: #3b4a5e; border-color: transparent; }
.seg button.seg-alert { color: #c2410c; font-weight: 700; }
.rec-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; }
.rec-sec { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.rec-sec-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.rec-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 4px 0; }
.rec-line > span:first-child { min-width: 72px; color: var(--muted); font-size: 0.85rem; }
.note-red, .note-amber { margin: 8px 0; padding: 8px 12px; border-radius: 8px; font-size: 0.86rem; line-height: 1.6; }
.note-red { background: rgba(220, 38, 38, 0.1); color: #b91c1c; }
.note-amber { background: rgba(217, 119, 6, 0.12); color: #92400e; }
.hist { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.hist-h { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.hist-h small { color: var(--muted); }
.hist-c { display: grid; grid-template-columns: minmax(90px, 30%) auto auto 1fr; gap: 6px; padding-left: 4px; font-size: 0.86rem; }
.old { color: #b91c1c; text-decoration: line-through; }
.new { color: #15803d; font-weight: 600; }
.cf { font-size: 0.82rem; color: #b45309; white-space: nowrap; }
.cf.ok { color: #15803d; }
.cf small { color: var(--muted); }
.notif { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: start; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.notif i { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--line); }
.notif.unread i { background: var(--accent); }
.notif.unread b { font-weight: 800; }
.notif div span { display: block; color: var(--muted); font-size: 0.85rem; }
.notif small { color: var(--muted); white-space: nowrap; margin-top: 3px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ktag.t-yb { background: #0f3d38; color: #7ee0d2; }
  :root:not([data-theme="light"]) .ktag.t-zh { background: #26285e; color: #b8bbff; }
  :root:not([data-theme="light"]) .ktag.t-bv { background: #3c2050; color: #e0b6ff; }
  :root:not([data-theme="light"]) .ktag.t-tw { background: #4a2d0a; color: #ffc98a; }
  :root:not([data-theme="light"]) .ktag.t-dl { background: #2a3442; color: #b9c6d8; }
  :root:not([data-theme="light"]) .note-red { color: #fca5a5; }
  :root:not([data-theme="light"]) .note-amber { color: #fcd34d; }
  :root:not([data-theme="light"]) .old { color: #fca5a5; }
  :root:not([data-theme="light"]) .new { color: #86efac; }
}
@media (max-width: 560px) {
  .hist-c { grid-template-columns: 1fr; gap: 0; padding: 4px 0; }
  .notif { grid-template-columns: 10px minmax(0, 1fr); }
  .notif small, .notif .btn { grid-column: 2; justify-self: start; }
}
.table td .sub2 { display: block; margin-top: 2px; color: var(--muted); font-size: 0.74rem; white-space: normal; }
.table tr.row-off td { opacity: 0.55; }
.table.items td { vertical-align: middle; }
.cellstack { display: inline-flex; flex-direction: column; gap: 2px; }
.cellstack small, .cellnote { color: var(--muted); font-size: 0.74rem; }
.cellnote { display: block; }
.item-acts { display: grid; grid-template-columns: repeat(3, auto); gap: 6px; justify-content: start; }
.table.items td:nth-child(2) { min-width: 160px; max-width: 240px; }

/* sidebar groups */
.nav-group { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 12px 4px 4px 12px; font: 700 0.68rem var(--sans); letter-spacing: 0.06em; color: var(--muted); }
.nav-group .ph { padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font: 600 0.62rem var(--mono); font-style: normal; letter-spacing: 0; }
.nav-group .ph.ph2 { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.fl-lane-h { display: flex; align-items: center; height: 100%; color: var(--muted); font: 600 12.5px/1.35 var(--sans); }
@media (min-width: 721px) {
  .side { overflow-y: auto; gap: 16px; }
  .nav button { padding: 8px 12px; }
}

/* 報刀 form per 刀表 */
.rf-help { margin: 8px 0 12px; font-size: 0.86rem; }
.rf-table select, .rf-table input { min-width: 0; }
.rf-table td { vertical-align: middle; }
.hosp-pick { display: flex; gap: 6px; align-items: center; }
.hosp-pick select { flex: 1; min-width: 0; }
.btn.star { min-width: 38px; font-size: 1rem; }
.btn.star.on { color: #d97706; }
.lot-fill { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 14px; margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); }
.lot-fill > b { width: 100%; }
.rep-filters { margin-bottom: 12px; }
.nhi-alert { border-color: #dc2626; }
.nhi-alert h2 { color: #dc2626; }
.nhi-alert .row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.badge.src-dl { border-style: dashed; }
.badge.src-nhi { color: #b91c1c; }
textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.rf-table [data-bind="rf-p-sku"], .rf-table [data-bind="rf-c-sku"] { min-width: 190px; }
.rf-table [data-bind="rf-s-series"] { min-width: 170px; }
.rf-table [data-bind="rf-s-len"] { min-width: 96px; }
.rf-table [data-bind$="-lot"] { min-width: 150px; }

/* 基本資料 + 登入 */
.linkbtn { align-self: flex-start; margin-top: 4px; padding: 0; border: none; background: none; color: var(--accent); font: 600 0.78rem var(--sans); cursor: pointer; text-decoration: underline; }
.role-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.role-counts .rc { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-size: 0.82rem; color: var(--muted); }
.role-counts .rc b { color: var(--ink); font-size: 1rem; }
.who .logout { margin-top: 4px; }
.login { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: var(--bg, #0b0f17); overflow-y: auto; }
.login[hidden] { display: none; }
.login-card { display: flex; flex-direction: column; gap: 12px; width: min(420px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 6px; }
.login-err { margin: 0; color: #dc2626; font-size: 0.86rem; }
.login-demo { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.login-demo > div { display: flex; flex-wrap: wrap; gap: 6px; }
.login-demo .btn small { margin-left: 4px; color: var(--muted); font-weight: 500; }
@media (max-width: 720px) { .who .logout { margin: 0; } }
.mk-hit { fill: transparent; stroke: none; pointer-events: all; }
.map-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.map-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); font: 600 0.86rem var(--sans); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.map-chip i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); }
.map-chip.mc-company i { border-radius: 3px; background: var(--accent); border-color: var(--accent); }
.map-chip.mc-rep i { border-radius: 2px; transform: rotate(45deg); background: var(--amber); border-color: var(--amber); }
.map-chip small { color: var(--muted); font: 500 0.74rem var(--mono); }
.map-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
