:root {
  --window: #1b1d21; --surface: #24272c; --base: #202227; --raised: #2e3238; --border: #3a3f47;
  --text: #e8eaed; --muted: #a0a7b1; --accent: #8ab4f8; --primary: #2b6cc4;
  --red: #ff8a80; --yellow: #fdd663; --green: #81c995;
  --bg-red: #4d2327; --bg-yellow: #4a3e14; --bg-green: #1e4029; --bg-blue: #1c3653; --bg-grey: #33363c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--window); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; color: var(--accent); margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 600; color: var(--accent); margin: 0 0 8px; }
h3 { font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.muted { color: var(--muted); }
p.muted { margin: 2px 0 10px; }

/* layout */
.side { position: fixed; inset: 0 auto 0 0; width: 240px; background: #141c28; display: flex; flex-direction: column; overflow-y: auto; }
.brand { background: #0f1620; color: #fff; font-weight: 700; font-size: 16px; padding: 16px; letter-spacing: .3px; }
.side nav { flex: 1; }
.side nav a { display: block; padding: 10px 16px; color: #c9d4e3; border-left: 4px solid transparent; }
.side nav a:hover { background: #1d2a3c; text-decoration: none; }
.side nav a.active { background: #24426b; color: #fff; border-left-color: #f9ab00; }
.side .ico { display: inline-block; width: 26px; }
.who { background: #0f1620; padding: 12px 16px; font-size: 13px; }
.who a, .who .linklike { display: block; color: #cfd9e6; margin-top: 8px; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--accent); }
main.with-side { margin-left: 240px; padding: 16px 20px 40px; }
main.centered { max-width: 460px; margin: 8vh auto; padding: 0 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.spacer { flex: 1; }
.cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }
.topbar, .scrim { display: none; }

/* cards, tabs, tiles */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; margin: 10px 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 12px 0 0; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; color: var(--muted); border: 1px solid var(--border); border-bottom: 0; border-radius: 5px 5px 0 0; background: var(--window); }
.tabs a.active { background: var(--surface); color: var(--text); font-weight: 600; border-top: 2px solid var(--accent); }
.tabs + .card { margin-top: 0; border-top-left-radius: 0; }
.tiles { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.tile { flex: 1 1 130px; text-align: center; padding: 12px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--accent); font-weight: 600; }
.tile b { display: block; font-size: 20px; }
.tile:hover { background: var(--raised); border-color: var(--accent); text-decoration: none; }
.tile.active { background: var(--bg-blue); border: 2px solid var(--accent); color: #fff; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, auto) minmax(0, 1fr)); gap: 5px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
@media (max-width: 1100px) { .kv { grid-template-columns: auto 1fr; } }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 4px; background: var(--base); }
table.data { border-collapse: collapse; width: 100%; white-space: nowrap; }
table.data th { background: var(--raised); text-align: left; padding: 6px 9px; position: sticky; top: 0; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); }
table.data th.sorted-asc::after { content: " ▲"; font-size: 10px; } table.data th.sorted-desc::after { content: " ▼"; font-size: 10px; }
table.data td { padding: 5px 9px; border-bottom: 1px solid #2f333a; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
table.data td.wrap { white-space: normal; min-width: 260px; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr[data-href] { cursor: pointer; }
table.data tbody tr:hover { background: #2a2f37; }
table.data tr.selected { background: #2f5a8f !important; }
table.data tr.empty td { color: var(--muted); text-align: center; padding: 18px; }
.table-filter { margin: 0 0 6px; width: 260px; }
.t-red { background: var(--bg-red); } .t-yellow { background: var(--bg-yellow); } .t-green { background: var(--bg-green); }
.t-blue { background: var(--bg-blue); } .t-grey { background: var(--bg-grey); color: var(--muted); }
.fg-red { color: var(--red); } .fg-yellow { color: var(--yellow); } .fg-green { color: var(--green); }

/* forms */
input, select, textarea { background: var(--base); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 5px 7px; font: inherit; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[disabled], select[disabled], textarea[disabled] { color: #7d8590; background: #1f2125; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: middle; }
input.qty { width: 90px; text-align: right; }
textarea { width: 100%; }
button, .btn { background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 6px 12px; font: inherit; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { background: #3a3f47; text-decoration: none; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: #3b7dd8; }
button.danger, .btn.danger { color: var(--red); border-color: #6e3a3d; }
button[disabled] { color: #6b7280; background: #26292e; cursor: not-allowed; border-color: var(--border); }
button.small { padding: 2px 8px; font-size: 12px; }
form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; align-items: center; max-width: 820px; }
.form-grid input[type=text], .form-grid input[type=date], .form-grid input[type=number], .form-grid select, .form-grid input[type=email], .form-grid input[type=password] { width: 100%; }
.form-grid label { color: var(--muted); }
.stack > * { display: block; margin: 8px 0; } .stack input { width: 100%; }

/* badges, flashes, toasts */
.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; font-weight: 600; font-size: 12px; background: var(--bg-grey); margin-right: 4px; }
.banner { padding: 8px 10px; border-radius: 4px; margin: 8px 0; white-space: pre-line; }
.flash { padding: 9px 12px; border-radius: 4px; margin: 0 0 10px; border: 1px solid var(--border); white-space: pre-line; }
.flash.error { background: var(--bg-red); } .flash.success { background: var(--bg-green); } .flash.info { background: var(--bg-blue); } .flash.warning { background: var(--bg-yellow); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; z-index: 50; max-width: 420px; }
.toast { background: var(--surface); border: 1px solid var(--accent); border-left: 5px solid #f9ab00; border-radius: 6px; padding: 12px 14px; box-shadow: 0 6px 24px #0009; }
.toast h4 { margin: 0 0 4px; color: var(--accent); } .toast .row { margin-top: 8px; justify-content: flex-end; }
.copy-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 6px; margin: 4px 0; align-items: center; }
.copy-row input { width: 100%; } .copied { background: var(--bg-green) !important; }
code.key { font: 15px Consolas, monospace; background: var(--base); padding: 8px 10px; border-radius: 4px; display: block; word-break: break-all; }
ul.clean { margin: 4px 0; padding-left: 18px; }

/* catalog & requisition (computers): the page fits the window; only the Results list scrolls. The item and
   requisition tiles are compact and always visible below it. */
.price-input { width: 78px; }
.lead-input { width: 64px; }
.vendor-select { max-width: 210px; }
.result-count { font-size: 13px; }
.cat-search .row { gap: 8px; }
table.data.mini td.num, table.data.mini th.num { white-space: nowrap; }
.results-head { margin-bottom: 6px; }
.results-head h2 { margin: 0; }
.cat-results { container-type: inline-size; }
.cat-results .table-wrap { max-height: 60vh; overflow: auto; }
.cat-results table.data td.wrap { min-width: 140px; }
.cat-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.cat-bottom.single { grid-template-columns: minmax(0, 1fr); }
.cat-bottom > .card { margin: 0; min-width: 0; padding: 8px 12px; }
.tile-title { font-size: 15px; margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0; font-size: 13px; }
.row.tight { gap: 6px; margin-top: 5px; }
.row.tight input:not([type=radio]) { padding: 3px 6px; }
.row.tight button, .row.tight .btn { padding: 4px 10px; }
.mini-wrap { margin-top: 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--base); overflow-y: auto; overflow-x: hidden; max-height: 116px; }
table.data.mini { white-space: normal; font-size: 12.5px; }
table.data.mini th { padding: 4px 6px; cursor: default; }
table.data.mini td { padding: 3px 6px; max-width: none; overflow-wrap: anywhere; }
table.data.mini td.wrap { min-width: 0; }
table.data.mini { table-layout: auto; width: 100%; }
table.data.mini td.tiers { font-size: 11.5px; color: var(--muted); }
table.data.mini input.qty { width: 64px; padding: 2px 4px; }
table.data.mini select { padding: 2px 4px; }
.cart-lines { max-height: 86px; }
.cart-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 10px; margin-top: 4px; font-size: 11.5px; }
.cart-form label { display: flex; flex-direction: column; color: var(--muted); min-width: 0; line-height: 1.3; }
.cart-form label > * { min-width: 0; max-width: 100%; }
.cart-form label.span2 { grid-column: 1 / -1; }
.cart-form input, .cart-form select { width: 100%; padding: 2px 6px; color: var(--text); font-size: 13px; }
#cart-summary .badge { margin-right: 6px; }
table.data.mini input.cost-input { width: 72px; padding: 2px 4px; }
.cat-project select { max-width: 280px; }
.cat-search label.toggle { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cat-search label.toggle:has(input:disabled) { opacity: 0.55; }
.pager { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* right-click menu on catalog results */
.ctx-menu { position: fixed; z-index: 50; min-width: 200px; background: var(--raised); border: 1px solid var(--border);
            border-radius: 6px; box-shadow: 0 6px 24px #0008; padding: 4px; display: flex; flex-direction: column; }
.ctx-menu[hidden] { display: none; }
.ctx-menu button { background: transparent; border: 0; text-align: left; padding: 7px 10px; border-radius: 4px; color: var(--text); }
.ctx-menu button:hover, .ctx-menu button:focus { background: var(--bg-blue); outline: none; }

/* price history pop-up window */
body.popup { display: block; }
.popup-main { max-width: 1000px; margin: 0 auto; padding: 12px 16px; }
.popup-main h1 { margin: 0; }
.price-chart { width: 100%; height: auto; display: block; }
.price-chart .grid { stroke: var(--border); stroke-width: 1; }
.price-chart .axis { fill: var(--muted); font-size: 11px; }
.price-chart .pt { stroke: var(--base); stroke-width: 1; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 8px; font-size: 13px; }
.chart-legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
@media (min-width: 801px) {
  main.with-side.fit-screen { height: 100vh; display: flex; flex-direction: column; overflow: hidden auto; padding-top: 10px;
                               padding-bottom: 10px; }
  main.fit-screen > * { flex: 0 0 auto; }
  main.fit-screen.catalog-page h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }  /* screen readers only */
  main.fit-screen .cat-search { margin: 0 0 8px; padding: 8px 12px; }
  main.fit-screen .cat-results { flex: 1 1 0; min-height: 120px; display: flex; flex-direction: column; margin: 0 0 8px; }
  main.fit-screen .cat-results .table-wrap { flex: 1 1 auto; min-height: 0; max-height: none; }
  /* the bottom tiles take the height they need; only on very short windows do they shrink and scroll inside */
  main.fit-screen .cat-bottom { flex: 0 1 auto; min-height: 0; }
  main.fit-screen .cat-bottom > .card { overflow-y: auto; overflow-x: hidden; min-height: 0; }
  main.fit-screen .flash { margin-bottom: 6px; padding: 6px 10px; }
}
@media (max-width: 900px) { .cat-bottom { grid-template-columns: minmax(0, 1fr); } }

/* any table inside a narrow tile becomes labelled cards (no sideways scrolling), like on phones */
@container (max-width: 900px) {
  .table-wrap { overflow: visible; border: 0; background: transparent; }
  table.data, table.data tbody, table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr { display: flex; flex-direction: column; background: var(--base); border: 1px solid var(--border);
                  border-radius: 8px; margin: 0 0 8px; padding: 4px 10px; }
  table.data tr.t-red { background: var(--bg-red); } table.data tr.t-yellow { background: var(--bg-yellow); }
  table.data tr.t-green { background: var(--bg-green); } table.data tr.t-blue { background: var(--bg-blue); }
  table.data tr.selected { outline: 2px solid var(--accent); }
  table.data td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0;
                  border: 0; border-bottom: 1px solid #ffffff12; white-space: normal; max-width: none; min-width: 0;
                  text-align: right; overflow-wrap: anywhere; }
  table.data td:last-child { border-bottom: 0; }
  table.data td.wrap { min-width: 0; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
  table.data td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: 0 0 auto;
                          max-width: 45%; font-size: 12px; }
  table.data td.wrap::before { max-width: none; }
  table.data td:not([data-label])::before, table.data td[data-label=""]::before { content: none; }
  table.data td:not([data-label]), table.data td[data-label=""] { justify-content: flex-end; order: 99; }
  table.data td:empty { display: none; }
  table.data tr.empty td { justify-content: center; }
}

/* two-step sign-in */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; padding: 0; }
.code-input { font: 22px Consolas, monospace; letter-spacing: 4px; text-align: center; max-width: 220px; }
.mfa-setup .steps { padding-left: 20px; } .mfa-setup .steps li { margin: 10px 0; }
.qr { background: #fff; display: inline-block; padding: 8px; border-radius: 6px; margin: 8px 0; }
.qr svg { width: 200px; height: 200px; display: block; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 24px; margin: 12px 0; }
.recovery-codes code { font: 17px Consolas, monospace; letter-spacing: 1px; }

/* dashboard (computers): tiles, the selected list and notifications all fit the window; lists scroll inside */
.dash-head { align-items: baseline; gap: 12px; }
.dash-head h1 { margin: 0; }
.dash-list .row h2, .dash-notes .row h2 { margin: 0; }
.dash-list, .dash-notes { display: flex; flex-direction: column; }
.dash-list .table-filter, .dash-list > .row, .dash-notes > .row { flex: 0 0 auto; }
.dash-list .table-wrap, .dash-notes .table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; margin-top: 6px; }
@media (min-width: 801px) {
  /* every section shares the window height and scrolls inside itself; nothing has a minimum that could push
     Notifications off the bottom, however many tiles there are or however small the window/zoom */
  main.dash-page .dash-head { margin-bottom: 2px; }
  main.dash-page .dash-head h1 { font-size: 20px; }
  main.dash-page .tiles { flex: 0 1 auto; min-height: 34px; max-height: 24vh; overflow-y: auto; margin: 4px 0 8px; gap: 6px; }
  main.dash-page .tile { flex: 1 1 120px; padding: 5px 6px; font-size: 12.5px; line-height: 1.25; }
  main.dash-page .tile b { display: inline; font-size: 16px; margin-right: 5px; }
  main.dash-page .dash-list { flex: 3 1 0; min-height: 0; margin: 0 0 8px; }
  main.dash-page .dash-notes { flex: 2 1 0; min-height: 0; margin: 0; }
  main.dash-page .dash-list, main.dash-page .dash-notes { padding-top: 8px; padding-bottom: 8px; }
}
@media (max-width: 800px) {
  /* phones: the page scrolls, but a long list can't bury Notifications */
  .dash-list .table-wrap { max-height: 60vh; }
  .dash-notes .table-wrap { max-height: 45vh; }
}

/* Super Admin "View as" */
.view-as { margin-top: 8px; }
.view-as label { display: flex; flex-direction: column; gap: 3px; color: #cfd9e6; font-size: 13px; }
.view-as select { padding: 4px 6px; }
.view-banner { background: #5a3d0a; border: 1px solid #f9ab00; color: #fff; border-radius: 4px; padding: 6px 10px; margin: 0 0 8px;
               display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* suggestions */
.suggestion { border-bottom: 1px solid var(--border); padding: 12px 0; }
.suggestion:last-child { border-bottom: 0; }
.suggestion-text { white-space: pre-wrap; margin: 8px 0; overflow-wrap: anywhere; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.thumbs img { height: 110px; max-width: 200px; object-fit: cover; border: 1px solid var(--border); border-radius: 4px; background: #000; }
.thumb-edit { position: relative; display: inline-block; }
.thumb-edit button { position: absolute; top: 4px; right: 4px; min-height: 0; padding: 1px 6px; }
.decide input[name=note] { flex: 1 1 260px; }
table.rights td:not(:first-child), table.rights th:not(:first-child) { text-align: center; }
table.rights tr.group-row td { padding-top: 10px; }

/* usage & storage */
.gauge-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }
.gauge-big { font-size: 26px; color: var(--text); }
.gauge { height: 22px; background: var(--base); border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 11px 0 0 11px; min-width: 3px; }
.gauge-fill.green { background: #3f9b5c; } .gauge-fill.yellow { background: #c9a227; } .gauge-fill.red { background: #c9504a; }
.small-note { margin: 6px 0 12px; }
.stack-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 0 0 8px; background: var(--base); }
.seg1 { background: #8ab4f8; } .seg2 { background: #81c995; } .seg3 { background: #fdd663; } .seg4 { background: #c58af9; }
.seg5 { background: #78d9ec; } .seg6 { background: #f28b82; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.stat { background: var(--base); border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 19px; color: var(--accent); }
.stat.t-yellow { background: var(--bg-yellow); }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 90px; padding: 4px; background: var(--base);
         border: 1px solid var(--border); border-radius: 4px; }
.spark-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.spark-bar { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; }
.spark-axis { font-size: 12px; margin-top: 2px; }

/* ===================== phones & small tablets ===================== */
@media (max-width: 800px) {
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  /* top bar with a menu button; the side navigation slides in as a drawer */
  .topbar { display: flex; align-items: center; gap: 10px; position: fixed; inset: 0 0 auto 0; z-index: 40;
            height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
            background: #0f1620; border-bottom: 1px solid #24426b; }
  .menu-btn { font-size: 22px; line-height: 1; padding: 6px 12px; min-height: 42px; background: transparent; border-color: #2c3a4d; }
  .topbar-title { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side { z-index: 60; width: min(84vw, 300px); transform: translateX(-105%); transition: transform .2s ease;
          box-shadow: 0 0 30px #000a; padding-top: env(safe-area-inset-top); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: #0009; }
  body.nav-open { overflow: hidden; }
  .side nav a { padding: 13px 18px; font-size: 16px; }
  .who a, .who .linklike { padding: 6px 0; font-size: 15px; }
  main.with-side { margin-left: 0; padding: calc(64px + env(safe-area-inset-top)) 12px 90px; }
  main.centered { margin: 6vh auto; }

  h1 { font-size: 20px; } h2 { font-size: 17px; }
  [id] { scroll-margin-top: calc(62px + env(safe-area-inset-top)); }  /* jumps land below the top bar */
  .card { padding: 10px 12px; }

  /* comfortable touch targets; 16px text stops iPhone zooming into fields */
  input, select, textarea { font-size: 16px; padding: 9px 10px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  button, .btn { min-height: 42px; padding: 9px 14px; }
  button.small, .btn.small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
  .linklike { min-height: 0; padding: 0; }
  input.qty { width: 110px; }
  .row { gap: 8px; }
  .row > input, .row > select, .row > label { flex: 1 1 100%; }
  .row > label input, .row > label select { width: 100%; margin-top: 4px; }
  [style*="min-width"] { min-width: 0 !important; }
  [style*="width:80%"], input[size], select[style] { width: 100% !important; }
  .table-filter { width: 100%; padding: 10px; }

  /* forms: label above field */
  .form-grid { grid-template-columns: 1fr; gap: 4px; }
  .form-grid > label { margin-top: 8px; }
  .copy-row { grid-template-columns: 1fr auto; } .copy-row > :first-child { grid-column: 1 / -1; color: var(--muted); }
  .kv { grid-template-columns: auto 1fr; }

  /* tabs scroll sideways instead of wrapping into a wall of buttons */
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; padding: 10px 14px; }
  .tiles { gap: 8px; } .tile { flex: 1 1 calc(50% - 8px); padding: 10px 6px; font-size: 13px; }

  #toasts { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: none; }
}

/* tables become one card per row, each value labelled with its column name */
@media (max-width: 700px) {
  .table-wrap { overflow: visible; border: 0; background: transparent; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
                  border-radius: 8px; margin: 0 0 10px; padding: 6px 12px; }  table.data tbody tr:hover { background: var(--surface); }
  table.data tr.t-red { background: var(--bg-red); } table.data tr.t-yellow { background: var(--bg-yellow); }
  table.data tr.t-green { background: var(--bg-green); } table.data tr.t-blue { background: var(--bg-blue); }
  table.data tr.t-grey { background: var(--bg-grey); }
  table.data tr.selected { outline: 2px solid var(--accent); }
  table.data td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 5px 0;
                  border: 0; border-bottom: 1px solid #ffffff12; white-space: normal; max-width: none; min-width: 0;
                  text-align: right; overflow-wrap: anywhere; }
  table.data td:last-child { border-bottom: 0; }
  table.data td.wrap { min-width: 0; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
  table.data td.wrap::before { max-width: none; }
  table.data td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: 0 0 auto;
                          max-width: 45%; font-size: 13px; }
  table.data td:not([data-label])::before, table.data td[data-label=""]::before { content: none; }
  table.data td:not([data-label]), table.data td[data-label=""] { justify-content: flex-end; order: 99; }  /* buttons last */
  table.data td:empty { display: none; }
  table.data tr.empty { text-align: center; }
  table.data tr.empty td { justify-content: center; }
  table.data td input.qty { width: 120px; }
}
