/* Shopverse Wholesale
   Spreadsheet vernacular (Google Sheets greys, Arial, gridlines) so it feels like the old sheet,
   with the sales order template's colours as accents: orange headers, yellow SO cell with red
   number, peach computed amounts, blue address blocks. */

:root {
  --ink: #202124;
  --ink-2: #5f6368;
  --ink-3: #80868b;
  --grid: #dadce0;
  --grid-strong: #bdc1c6;
  --head: #f1f3f4;
  --canvas: #f6f7f8;
  --paper: #ffffff;
  --brand: #e8590c;
  --brand-dark: #c2410c;
  --brand-tint: #fff1e6;
  --calc: #fff3e4;
  --flag: #fff59d;
  --flag-ink: #b3261e;
  --addr: #e3ecf8;
  --focus: #1a73e8;
  --pos: #188038;
  --neg: #c5221f;
  --warn-bg: #fef7e0;
  --warn-ink: #8a5300;
  --radius: 4px;
  --font: Arial, 'Liberation Sans', Helvetica, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 14px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--canvas); line-height: 1.4; }
a { color: #1558d6; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 700; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 16px 0 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--ink-2); }
.neg { color: var(--neg); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Controls */
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--grid-strong); border-radius: var(--radius); background: #fff; padding: 5px 8px; min-height: 32px; width: 100%; }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--head); color: var(--ink-2); cursor: not-allowed; }
input[type='checkbox'], input[type='radio'] { width: auto; min-height: 0; accent-color: var(--pos); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border: 1px solid var(--grid-strong); border-radius: var(--radius); background: #fff; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--head); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-approve { background: var(--pos); border-color: var(--pos); color: #fff; }
.btn-approve:hover { background: #12652c; }
.btn-danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-danger:hover { background: #a50e0e; }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: #1558d6; font: inherit; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: var(--ink-3); cursor: not-allowed; text-decoration: none; }
.link-btn.danger { color: var(--neg); }
.icon-btn { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 2px 6px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px; height: 52px; padding: 0 20px; background: #fff; border-bottom: 3px solid var(--brand); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 18px; height: 18px; flex: none; background: var(--brand); border-radius: 3px; box-shadow: 4px 4px 0 var(--flag); }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 12px; border-radius: var(--radius); color: var(--ink-2); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.nav a:hover { background: var(--head); color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--ink); background: var(--brand-tint); }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--flag); color: var(--flag-ink); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; }
.user-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.role-tag { font-weight: 400; font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--head); color: var(--ink-2); }

/* Pages */
.app:focus { outline: none; }
.page { max-width: 1480px; margin: 0 auto; padding: 22px 24px 64px; }
.page.narrow { max-width: 1040px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search { width: 320px; }
select.compact { width: auto; }
.loading, .empty-state { padding: 48px 16px; text-align: center; color: var(--ink-2); }
.empty-state h1 { margin-bottom: 8px; color: var(--ink); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--grid); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 9px 14px; color: var(--ink-2); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--ink); border-bottom-color: var(--brand); }
.list-section { margin-bottom: 26px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.section-head h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.section-head p { margin: 0; font-size: 13px; }
.count { font-size: 12px; font-weight: 700; color: var(--ink-2); background: var(--head); border-radius: 10px; padding: 1px 8px; }
.empty-line { padding: 8px 2px; }

/* Sheet tables */
.sheet-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--grid); border-radius: 6px; }
.sheet { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); padding: 0 8px; height: 30px; text-align: left; white-space: nowrap; }
.sheet th:last-child, .sheet td:last-child { border-right: 0; }
.sheet thead th { background: var(--head); color: var(--ink-2); font-weight: 700; font-size: 12px; }
.sheet .num { text-align: right; }
.sheet tfoot td { background: var(--head); font-weight: 700; }
.foot-label { color: var(--ink-2); }
.list-sheet tbody tr { cursor: pointer; }
.list-sheet tbody tr:hover td { background: #f8f9fa; }
.list-sheet tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.list-sheet .so a { font-weight: 700; color: var(--ink); }
.list-sheet tr.needs-approval td:first-child { box-shadow: inset 4px 0 0 #f2c200; }
.list-sheet tr.inactive td { color: var(--ink-3); }
.code, .so { font-weight: 700; letter-spacing: 0.02em; }

/* Status pills and tags */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill-pending_sv { background: #fff1b8; color: #6d4c00; }
.pill-pending_cust { background: var(--addr); color: #1e4e8c; }
.pill-pending_pay { background: #fde4d3; color: #9a3412; }
.pill-completed { background: #e6f4ea; color: #137333; }
.pill-cancelled { background: var(--head); color: var(--ink-2); }
.pill-legacy { background: #ececec; color: #444; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 3px; font-size: 11px; font-weight: 700; background: var(--head); color: var(--ink-2); }
.tag-pre { background: #ede7f6; color: #4527a0; }
.tag-rebuild { background: #e0f2f1; color: #00695c; }

/* Order page */
.order-page { padding: 14px 20px 64px; max-width: 2200px; margin: 0 auto; }
.order-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.back-link { color: var(--ink-2); font-weight: 700; }
.back-link::before { content: '‹ '; }
.so-badge { background: var(--flag); border: 1px solid #e3d24a; border-radius: 3px; padding: 4px 14px 5px; line-height: 1.15; }
.so-badge-label { display: block; font-size: 11px; color: #6b5c00; font-weight: 700; }
.so-badge-number { font-size: 21px; font-weight: 700; color: var(--flag-ink); letter-spacing: 0.015em; }
.head-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-customer { font-weight: 700; font-size: 15px; margin-left: 4px; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.save-state { font-size: 12px; color: var(--ink-3); margin-right: 6px; }
.save-state.saving { color: var(--ink-2); }
.save-state.error { color: var(--neg); font-weight: 700; }
.banner { padding: 9px 14px; border-radius: 6px; border: 1px solid; margin-bottom: 12px; font-size: 13px; }
.banner-info { background: #e8f0fe; border-color: #c6dafc; color: #174ea6; }
.banner-attention { background: #fff8c5; border-color: #ead96b; color: #5c4a00; font-weight: 700; }
.banner-muted { background: var(--head); border-color: var(--grid); color: var(--ink-2); }

.order-body { display: grid; gap: 16px; align-items: start; grid-template-columns: minmax(0, 1fr); grid-template-areas: 'meta' 'summary' 'lines' 'extras' 'history'; }
.meta { grid-area: meta; }
.lines { grid-area: lines; }
.summary { grid-area: summary; }
.extras { grid-area: extras; }
.history { grid-area: history; }
/* Laptops: details and summary side by side, the lines grid gets the full width. */
@media (min-width: 1100px) and (max-width: 1499px) {
  .order-body { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-areas: 'meta summary' 'lines lines' 'extras extras' 'history history'; }
  .extras-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .extras-group + .extras-group { border-left: 1px solid var(--grid); }
}
/* Desktop: the old sheet's left-to-right order, details | lines. */
@media (min-width: 1500px) {
  .order-body { grid-template-columns: 340px minmax(0, 1fr); grid-template-areas: 'meta lines' 'summary lines' 'extras lines' 'history history'; }
}
/* Wide screens: summary on the right like columns L-M. */
@media (min-width: 2100px) {
  .order-body { grid-template-columns: 340px minmax(0, 1fr) 300px; grid-template-areas: 'meta lines summary' 'extras lines summary' 'history history history'; }
  .summary { position: sticky; top: 68px; }
}
.panel { background: #fff; border: 1px solid var(--grid); border-radius: 6px; }
.panel-title { font-size: 13px; font-weight: 700; color: var(--ink-2); padding: 10px 12px 6px; }

/* Order details: two columns like column A and B of the old sheet */
.meta-cols { display: grid; grid-template-columns: 1fr 1fr; }
.meta-col { min-width: 0; }
.meta-col + .meta-col { border-left: 1px solid var(--grid); }
.meta-item { padding: 7px 10px 9px; border-bottom: 1px solid var(--grid); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.meta-col .meta-item:last-child { border-bottom: 0; }
.meta-label { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.meta-item input, .meta-item select { min-height: 30px; padding: 4px 6px; }
.meta-static { min-height: 30px; display: flex; align-items: center; font-weight: 700; word-break: break-all; }
.so-static { color: var(--flag-ink); }
.meta-note { font-size: 11.5px; color: var(--ink-3); }
.meta-note.warn { color: var(--warn-ink); }
.with-action { display: flex; gap: 6px; align-items: center; }
.with-action > input, .with-action > select { flex: 1; min-width: 0; }
.rate-row { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.meta-item .rate-in { width: 84px; min-height: 26px; padding: 2px 6px; text-align: right; }

/* Lines grid */
.lines-head { display: flex; align-items: center; gap: 16px; padding-right: 10px; flex-wrap: wrap; }
.lines-info { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.lines-info .ok { color: var(--pos); font-weight: 700; }
.lines-info .warn { color: #9a3412; font-weight: 700; }
.lines-tools { margin-left: auto; display: flex; gap: 8px; padding: 6px 0; }
.grid-wrap { overflow-x: auto; border-top: 1px solid var(--grid); }
.grid { table-layout: fixed; min-width: 1100px; }
.grid thead th { background: var(--brand); color: #fff; font-size: 12.5px; border-right-color: rgba(255, 255, 255, 0.35); height: 34px; white-space: normal; line-height: 1.15; }
.grid td { padding: 0; height: 30px; overflow: hidden; }
.grid td.num, .grid td.calc { padding: 0 8px; }
.cell-in { border: 0; border-radius: 0; height: 30px; min-height: 30px; width: 100%; padding: 0 8px; background: transparent; }
.cell-in:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: #fff; border: 0; }
.cell-in:disabled { background: transparent; color: var(--ink); -webkit-text-fill-color: var(--ink); cursor: default; opacity: 1; }
.cell-in.num { text-align: right; }
.cell-in::placeholder { color: var(--ink-3); }
.calc { background: var(--calc); text-align: right; }
.c-tick { text-align: center; }
.tick { width: 16px; height: 16px; margin: 0; cursor: pointer; vertical-align: middle; }
.tick:disabled { cursor: default; }
tr.audited td.c-tick { background: #e6f4ea; }
.name-text { display: block; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-target.tgt-ok { background: #e6f4ea; }
.c-target.tgt-mid { background: var(--warn-bg); }
.c-target.tgt-low { background: #fce8e6; }
.c-sell.overridden { position: relative; }
.c-sell.overridden::after { content: ''; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent var(--brand) transparent transparent; pointer-events: none; }
.c-qty.zero .cell-in { background: #fce8e6; }
td.short { color: var(--neg); font-weight: 700; }
tr.manual .c-name .cell-in, tr.manual .c-cost .cell-in { background: #fffbea; }
.c-cost { text-align: right; }
.row-remove { width: 100%; height: 30px; border: 0; background: none; color: var(--ink-3); font-size: 18px; cursor: pointer; }
.row-remove:hover { color: var(--neg); background: #fce8e6; }
.row-remove:disabled { visibility: hidden; }
.new-row td { background: #fcfcfd; overflow: visible; }
.new-row .cell-in { background: #fff; box-shadow: inset 0 0 0 1px var(--grid); }
.new-hint { padding: 0 8px !important; color: var(--ink-3); font-size: 12px; white-space: normal !important; line-height: 1.2; }
.totals-row td { background: var(--head); font-weight: 700; }
.pos-rel { position: relative; }
.search-pop { position: absolute; left: 0; top: 100%; z-index: 20; width: min(660px, 80vw); background: #fff; border: 1px solid var(--grid-strong); border-radius: 6px; box-shadow: 0 6px 24px rgba(32, 33, 36, 0.18); max-height: 320px; overflow-y: auto; }
.pop-item { display: grid; grid-template-columns: 100px 1fr 76px 80px; gap: 10px; padding: 7px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--head); white-space: normal; }
.pop-item.hi, .pop-item:hover { background: #e8f0fe; }
.pop-sku { font-weight: 700; }
.pop-num { text-align: right; color: var(--ink-2); }
.pop-empty { padding: 10px; color: var(--ink-2); }

/* Online 30d column and the marketplace popup */
.c-online { text-align: right; }
.online-btn { width: 100%; height: 30px; border: 0; background: none; font: inherit; color: var(--ink); padding: 0 8px; cursor: help; display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.online-btn:hover, .online-btn:focus-visible { background: #e8f0fe; outline: none; }
.online-btn.muted { color: var(--ink-3); }
.cover-flag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 3px; background: #fde4d3; color: #9a3412; white-space: nowrap; }
tr.over-cover td.c-online { background: #fff4ec; }
.market-pop { position: fixed; z-index: 70; width: 660px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--grid-strong); border-radius: 8px; box-shadow: 0 10px 32px rgba(32, 33, 36, 0.22); padding: 10px 12px 12px; font-size: 12.5px; pointer-events: none; }
.market-pop h3 { margin: 0 0 8px; font-size: 13.5px; }
.mp-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.mp-table th, .mp-table td { padding: 4px 6px; border-top: 1px solid var(--head); text-align: right; white-space: nowrap; }
.mp-table th:first-child, .mp-table td:first-child { text-align: left; }
.mp-table thead th { border-top: 0; color: var(--ink-2); font-size: 11.5px; }
.mp-table tr.mp-wholesale td { background: var(--calc); font-weight: 700; }
.mp-table tr.mp-total td { font-weight: 700; border-top: 1px solid var(--grid); }
.mp-table td.mp-best { color: var(--pos); font-weight: 700; }
.mp-small { color: var(--ink-3); font-weight: 400; }
.mp-note { margin: 6px 0 0; color: var(--ink-2); }
.mp-flag { margin: 8px 0 0; padding: 6px 8px; background: #fde4d3; color: #9a3412; border-radius: 4px; font-weight: 700; }
.mp-foot { margin: 8px 0 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }

/* Summary box, like L-M of the old sheet */
.sum-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sum-table th, .sum-table td { padding: 7px 12px; border-top: 1px solid var(--grid); text-align: right; font-size: 13.5px; white-space: nowrap; }
.sum-table tbody th { text-align: left; font-weight: 700; color: var(--ink); }
.sum-table thead th { border-top: 0; font-size: 11.5px; color: var(--ink-2); padding-top: 0; }
.sum-table tr.minor th, .sum-table tr.minor td { font-size: 12.5px; color: var(--ink-2); font-weight: 400; padding-top: 5px; padding-bottom: 5px; }
.sum-table tr.strong td { font-weight: 700; }
.sum-table tr.muted-row th, .sum-table tr.muted-row td { color: var(--ink-3); }
.sum-table tr.final th, .sum-table tr.final td { background: var(--calc); font-size: 15px; font-weight: 700; border-top: 2px solid var(--brand); }
.sum-table td.neg { color: var(--neg); }
.sum-facts { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr; gap: 4px 8px; margin: 0; padding: 10px 12px; border-top: 1px solid var(--grid); font-size: 12.5px; }
.sum-facts dt { color: var(--ink-2); }
.sum-facts dd { margin: 0; font-weight: 700; }
.summary .meta-note { padding: 0 12px 10px; margin: 0; display: block; }

/* Shipping, tax, addresses */
.extras-body { border-top: 1px solid var(--grid); }
.extras-group > :last-child { border-bottom: 0; }
.meta-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.small-link { font-size: 12px; }
.extras .meta-item { border-bottom: 1px solid var(--grid); }
.meta-item .pct-in { width: 80px; text-align: right; }
.custom-tax { display: inline-flex; align-items: center; gap: 4px; }
.addr-block { padding: 8px 10px 10px; border-bottom: 1px solid var(--grid); display: flex; flex-direction: column; gap: 6px; }
.addr-head { display: flex; justify-content: space-between; align-items: center; }
.addr-preview { background: var(--addr); border-radius: 3px; padding: 7px 10px; font-size: 13px; line-height: 1.45; }
.addr-preview.empty { background: var(--head); color: var(--ink-3); }
.notes-grid .meta-item:last-child { border-bottom: 0; }

/* History */
.history-head { display: flex; align-items: center; justify-content: space-between; padding-right: 12px; }
.history-list { list-style: none; margin: 0; padding: 0 12px 12px; }
.history-list li { display: grid; grid-template-columns: 230px 1fr; gap: 12px; padding: 7px 0; border-top: 1px solid var(--head); font-size: 13px; }
.hist-meta { color: var(--ink-2); display: flex; gap: 10px; }
.hist-detail { white-space: pre-wrap; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.field-hint { font-size: 11.5px; color: var(--ink-3); }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-error { color: var(--neg); font-weight: 700; margin: 4px 0 0; }
.so-preview { padding: 8px 10px; background: var(--flag); border-radius: 3px; font-size: 13px; }
.so-preview strong { color: var(--flag-ink); }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.check { margin-top: 10px; }
input.code-input { text-transform: uppercase; font-weight: 700; letter-spacing: 0.06em; width: 110px; }
.form-section { background: #fff; border: 1px solid var(--grid); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.form-section > h2 { margin-bottom: 12px; }
.addr-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.addr-list { display: grid; gap: 12px; }
.addr-box { border: 1px solid var(--grid); border-radius: 6px; padding: 10px 12px; }
.addr-box-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.addr-bill { border-left: 4px solid var(--brand); }
.addr-ship { border-left: 4px solid #4a7fd4; }
.section-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.paste-area { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; margin: 8px 0; }
.mini-sum { border-collapse: collapse; margin-bottom: 10px; }
.mini-sum th { text-align: left; padding: 3px 16px 3px 0; color: var(--ink-2); font-weight: 400; }
.mini-sum td { font-weight: 700; text-align: right; }
.warn-list { margin: 8px 0; padding: 8px 12px 8px 28px; background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; }
.choice-list { display: grid; gap: 6px; }
.choice { text-align: left; display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; padding: 8px 10px; border: 1px solid var(--grid); border-radius: 6px; background: #fff; cursor: pointer; font: inherit; }
.choice:hover { background: #e8f0fe; }

/* Modal and toasts */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(32, 33, 36, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 12px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 8px; width: min(520px, 100%); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
.modal:focus { outline: none; }
.modal-wide { width: min(800px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 4px 16px 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--head); }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(440px, calc(100vw - 32px)); }
.toast { background: #202124; color: #fff; padding: 10px 14px; border-radius: 6px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); border-left: 4px solid #8ab4f8; transition: opacity 0.25s, transform 0.25s; }
.toast-ok { border-left-color: #81c995; }
.toast-warn { border-left-color: #fdd663; }
.toast-error { border-left-color: #f28b82; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-form { width: min(360px, 100%); display: grid; gap: 14px; background: #fff; border: 1px solid var(--grid); border-top: 4px solid var(--brand); border-radius: 6px; padding: 26px 24px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.login-sub { color: var(--ink-2); margin: -6px 0 4px; }
.btn-google { height: 40px; }
.login-emergency { border-top: 1px solid var(--grid); padding-top: 10px; }
.login-emergency summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.login-emergency form { display: grid; gap: 12px; margin-top: 12px; }

/* Admin */
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 6px 12px; margin: 0 0 12px; font-size: 13px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-word; }
.err-text { color: var(--neg); }

@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .usermenu .link-btn:first-of-type { display: none; }
  .page, .order-page { padding: 14px 12px 48px; }
  .search { width: 100%; }
  .meta-cols { grid-template-columns: 1fr; }
  .meta-col + .meta-col { border-left: 0; border-top: 1px solid var(--grid); }
  .form-grid.two, .form-grid.three, .addr-grid { grid-template-columns: 1fr 1fr; }
  .head-actions { margin-left: 0; }
  .history-list li { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
@media print {
  .topbar, .head-actions, .new-row, .lines-tools, .row-remove, .history { display: none !important; }
}
