/* RackForge WMS — StackForge two-tone: slate app chrome, light work surface, copper for actions.
   Layout: fixed slate sidebar + scrolling light canvas; below 760px it becomes a top bar + bottom tab bar. */
:root {
  --page: #f6f7f8;
  --surface: #ffffff;
  --sunk: #eef0f2;
  --line: #dde1e5;
  --ink: #1c2125;
  --ink-2: #4d5760;
  --ink-3: #78828b;
  --copper: #a85a28;
  --copper-hover: #8e4a1f;
  --copper-tint: #f6ebe3;
  --on-copper: #ffffff;
  --slate: #2b3036;
  --slate-2: #353b42;
  --slate-line: #444c55;
  --slate-ink: #eef1f3;
  --slate-ink-2: #aab3bb;
  --slate-copper: #e39a63;
  --ok: #2f7a4f; --ok-tint: #e5f2ea;
  --warn: #9a6400; --warn-tint: #fbf0d9;
  --bad: #a33a2a; --bad-tint: #f8e6e2;
  --off: #6b737b; --off-tint: #eceef0;

  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 15px/1.55 var(--f-body); }
h1, h2, h3 { font-family: var(--f-display); font-stretch: 104%; margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; }
a { color: var(--copper); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-weight: 500; letter-spacing: .01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--slate); color: var(--slate-ink); display: flex; flex-direction: column; padding: 18px 14px; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; color: inherit; text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand-name { font: 800 17px/1.1 var(--f-display); font-stretch: 108%; }
.brand-name small { display: block; font: 500 10.5px/1.3 var(--f-mono); letter-spacing: .12em; color: var(--slate-ink-2); text-transform: uppercase; margin-top: 2px; }
.nav { display: grid; gap: 2px; }
.nav-label { font: 500 10.5px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--slate-ink-2); padding: 12px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--slate-ink); padding: 9px 10px; border-radius: 8px; text-decoration: none; }
.nav a .icon { opacity: .8; }
.nav a:hover { background: var(--slate-2); }
.nav a[aria-current="page"] { background: var(--slate-2); box-shadow: inset 3px 0 0 var(--slate-copper); }
.nav a[aria-current="page"] .icon { opacity: 1; color: var(--slate-copper); }
.side-foot { margin-top: auto; border-top: 1px solid var(--slate-line); padding: 14px 8px 0; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.side-foot form { margin: 0; }
.link-btn { border: 0; background: none; padding: 0; color: var(--slate-ink-2); cursor: pointer; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--slate-ink); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--slate-copper); color: #1f150d; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; text-transform: uppercase; }

.content { min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; min-width: 0; width: 100%; max-width: 1240px; padding: 26px clamp(16px, 3vw, 36px) 48px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; justify-content: space-between; margin-bottom: 22px; }
.eyebrow { font: 500 11px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--copper); margin-bottom: 8px; }
.eyebrow a { color: inherit; }
.page-head h1 { font-size: 26px; font-weight: 700; }
.page-head p { margin-top: 4px; color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: inline; margin: 0; }

/* Phone chrome (hidden on desktop) */
.topbar-m, .tabbar { display: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--copper); border-color: var(--copper); color: var(--on-copper); }
.btn-primary:hover { background: var(--copper-hover); border-color: var(--copper-hover); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-small { padding: 6px 11px; min-height: 34px; font-size: 13px; }

/* ---------- Flash messages ---------- */
.flash-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.flash { padding: 11px 14px; border-radius: 8px; border: 1px solid; font-size: 14px; }
.flash-success { background: var(--ok-tint); border-color: #bfdcc9; color: #1f5a38; }
.flash-error { background: var(--bad-tint); border-color: #ebc4bc; color: #7d2a1e; }
.flash-warning, .flash-message, .flash-info { background: var(--warn-tint); border-color: #ecd9ae; color: #6b4600; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; font-weight: 700; }
.panel-body { padding: 18px; }
.stack { display: grid; gap: 20px; }
.empty { padding: 34px 18px; text-align: center; color: var(--ink-3); display: grid; gap: 12px; justify-items: center; }
.empty .icon { width: 34px; height: 34px; color: #c3c9cf; }

/* KPI strip: one bordered band, not a row of floating cards */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 20px; }
.kpi { padding: 16px 18px; display: grid; gap: 4px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi-label { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.kpi-value { font: 700 26px/1.1 var(--f-display); font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 12.5px; color: var(--ink-2); }
.kpi-note b { color: var(--ok); font-weight: 600; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 600 11.5px/1 var(--f-body); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafbfb; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #fbf8f5; }
td.r, th.r { text-align: right; }
td a.row-anchor { color: inherit; text-decoration: none; }
.item-cell { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.item-cell .t { font-weight: 600; }
.item-cell .mono { font-size: 12px; color: var(--ink-3); }
.sub { font-size: 13px; color: var(--ink-3); }
.table-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }

/* Thumbnails: real photos, or a neutral tile with a line icon */
.thumb { width: 44px; height: 44px; border-radius: 7px; flex: none; overflow: hidden; background: linear-gradient(135deg, #8a8f95, #5d6268); display: grid; place-items: center; color: rgba(255,255,255,.8); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .icon { width: 50%; height: 50%; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-tint); color: var(--ok); }
.pill-warn { background: var(--warn-tint); color: var(--warn); }
.pill-off { background: var(--off-tint); color: var(--off); }
.pill-bad { background: var(--bad-tint); color: var(--bad); }
.code-tag { display: inline-flex; align-items: center; gap: 8px; font: 600 13px/1 var(--f-mono); background: var(--slate); color: var(--slate-ink); padding: 7px 10px; border-radius: 6px; letter-spacing: .03em; }
.code-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--slate-copper); }

/* Lists (recent intake) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: inherit; text-decoration: none; }
.list a:hover { background: #fbf8f5; }
.list .grow { min-width: 0; flex: 1; }
.list .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .s { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bars (volume by designer) */
.bars { display: grid; gap: 14px; }
.bar-row { display: grid; gap: 6px; }
.bar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.bar-top b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 8px; background: var(--sunk); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--copper); border-radius: 999px; }
.bar i.rest { background: #c9b4a4; }

/* ---------- Filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--surface); min-width: 0; }
.search .icon { width: 17px; height: 17px; color: var(--ink-3); }
.search input { border: 0; outline: 0; padding: 9px 0; width: 100%; background: transparent; min-width: 0; }
.search:focus-within { border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-tint); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--ink); text-decoration: none; }
.chip:hover { border-color: var(--ink-3); }
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Forms ---------- */
.form-wrap { max-width: 760px; }
.fset { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.fset > .panel-body { display: grid; gap: 14px; }
.fset-title { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.fset-title .n { width: 24px; height: 24px; border-radius: 50%; background: var(--slate); color: var(--slate-ink); display: grid; place-items: center; font: 600 12px/1 var(--f-mono); flex: none; }
.fset-title h2 { font-size: 15.5px; font-weight: 700; }
.fset-title .spacer { flex: 1; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-picks { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .label { font-size: 13.5px; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--ink-3); }
.inp, select.inp { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); min-height: 44px; }
select.inp { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.inp:focus { border-color: var(--copper); outline: 0; box-shadow: 0 0 0 3px var(--copper-tint); }
textarea.inp { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--copper); }
.unit { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.unit label { position: relative; }
.unit input { position: absolute; opacity: 0; inset: 0; }
.unit span { display: block; padding: 7px 14px; font-size: 13.5px; cursor: pointer; background: var(--surface); }
.unit input:checked + span { background: var(--ink); color: #fff; }
.unit input:focus-visible + span { outline: 2px solid var(--copper); outline-offset: -2px; }
.calc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--sunk); border-radius: 8px; }
.calc div { padding: 12px 14px; display: grid; gap: 2px; min-width: 0; }
.calc div + div { border-left: 1px solid var(--line); }
.calc span { font-size: 12px; color: var(--ink-3); }
.calc b { font: 700 18px/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
.shots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.shot { position: relative; aspect-ratio: 1; border: 1.5px dashed #c3c9cf; border-radius: 10px; display: grid; place-items: center; text-align: center; color: var(--ink-3); font-size: 12.5px; cursor: pointer; background: var(--surface); overflow: hidden; }
.shot:hover { border-color: var(--copper); }
.shot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.shot .icon { width: 26px; height: 26px; display: block; margin: 0 auto 6px; color: var(--copper); }
.shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.shot.filled { border-style: solid; border-color: var(--line); }
.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 12px 0; background: linear-gradient(to top, var(--page) 70%, transparent); }
.inline-fields { display: flex; gap: 6px; align-items: center; }
.inline-fields .inp { min-height: 36px; padding: 6px 10px; max-width: 180px; }

/* ---------- Item detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.gallery { display: grid; gap: 8px; }
.gallery-main { aspect-ratio: 4 / 3; border-radius: var(--r); overflow: hidden; border: 0; padding: 0; background: var(--sunk); cursor: zoom-in; display: block; width: 100%; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery-thumbs button { aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 0; padding: 0; cursor: pointer; background: var(--sunk); }
.gallery-thumbs button img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs button[aria-current="true"] { outline: 2px solid var(--copper); outline-offset: 2px; }
.no-photos { min-height: 180px; border-radius: var(--r); border: 1.5px dashed #c3c9cf; display: grid; place-items: center; color: var(--ink-3); text-align: center; background: var(--surface); }
.no-photos .icon { width: 34px; height: 34px; margin: 0 auto 8px; color: #c3c9cf; }
dl.facts { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); }
dl.facts dt, dl.facts dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
dl.facts dt { color: var(--ink-3); font-size: 13.5px; padding-right: 22px; }
dl.facts dd { font-weight: 500; overflow-wrap: anywhere; }
dl.facts > :nth-last-child(-n+2) { border-bottom: 0; }
.ledger { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.ledger div { padding: 14px 16px; display: grid; gap: 2px; min-width: 0; }
.ledger div + div { border-left: 1px solid var(--line); }
.ledger span { font-size: 12.5px; color: var(--ink-3); }
.ledger b { font: 700 20px/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
.note { background: var(--warn-tint); border: 1px solid #ecd9ae; border-radius: var(--r); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; }
.note .icon { color: var(--warn); margin-top: 2px; }
.note.plain { background: var(--surface); border-color: var(--line); color: var(--ink-3); }
.danger-zone { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--ink-3); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(15, 18, 21, .85); }
.lightbox-content { position: relative; width: min(96vw, 1200px); max-height: 94vh; display: grid; gap: 10px; }
.lightbox-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #e6e9ec; font-size: 14px; }
.lightbox-bar .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); color: #fff; }
.lightbox img { width: 100%; max-height: calc(94vh - 60px); object-fit: contain; border-radius: 8px; }

/* ---------- Login ---------- */
.login { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.login-art { background: var(--slate); color: var(--slate-ink); padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.login-art h2 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 700; max-width: 14ch; }
.login-art p { color: var(--slate-ink-2); max-width: 38ch; margin-top: 14px; }
.label-demo { font: 600 13px/1 var(--f-mono); color: var(--slate-ink-2); display: flex; gap: 14px; flex-wrap: wrap; }
.label-demo span { border: 1px solid var(--slate-line); padding: 8px 10px; border-radius: 6px; }
.login-form { display: grid; place-items: center; padding: 32px 16px; }
.login-form form { width: 100%; max-width: 340px; display: grid; gap: 16px; }
.login-form h1 { font-size: 24px; font-weight: 700; }

.cards { display: none; }
.cards a { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center; color: inherit; text-decoration: none; }
.cards a:last-child { border-bottom: 0; }
.cards .thumb { width: 56px; height: 56px; }
.cards .t { font-weight: 600; }
.cards .s { font-size: 12.5px; color: var(--ink-3); }
.cards .grow { flex: 1; min-width: 0; }

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar-m { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--slate); color: var(--slate-ink); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); position: sticky; top: 0; z-index: 20; }
  .topbar-m .brand-name { font-size: 15px; }
  .topbar-m details { position: relative; }
  .topbar-m summary { list-style: none; cursor: pointer; }
  .topbar-m summary::-webkit-details-marker { display: none; }
  .menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); min-width: 210px; padding: 6px; box-shadow: 0 16px 40px -16px rgba(0,0,0,.35); display: grid; }
  .menu a, .menu button { display: block; text-align: left; padding: 10px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; border: 0; background: none; width: 100%; cursor: pointer; }
  .menu a:hover, .menu button:hover { background: var(--sunk); }
  .menu form { margin: 0; }
  .menu .menu-who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 13px; color: var(--ink-3); }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 20; }
  .tabbar a { padding: 8px 4px 10px; display: grid; justify-items: center; align-content: center; gap: 3px; font-size: 11px; color: var(--ink-3); text-decoration: none; }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--copper); }
  .tabbar .add .dot { width: 42px; height: 42px; border-radius: 50%; background: var(--copper); color: #fff; display: grid; place-items: center; }
  .main { padding: 18px 14px 24px; }
  .page-head h1 { font-size: 22px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .kpi-value { font-size: 22px; }
  .two-col, .three-col, .detail, .login { grid-template-columns: 1fr; }
  .hide-phone { display: none !important; }
  .ledger b { font-size: 17px; }
  .login-art { min-height: 200px; gap: 20px; }
  .label-demo { display: none; }
  .desk-table { display: none; }
  .cards { display: grid; }
}
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }

/* ---------- Client portal: slate header band over a light page, photo-first item cards ---------- */
.portal-head { background: var(--slate); color: var(--slate-ink); padding-top: env(safe-area-inset-top, 0px); }
.portal-head-inner, .portal-hero, .portal-main, .portal-foot { width: 100%; max-width: 1120px; margin: 0 auto; padding-left: clamp(16px, 4vw, 32px); padding-right: clamp(16px, 4vw, 32px); }
.portal-head-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.portal-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.portal-nav a, .portal-nav button { color: var(--slate-ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; border: 0; background: none; cursor: pointer; font-size: 14px; }
.portal-nav a:hover, .portal-nav button:hover { color: var(--slate-ink); background: var(--slate-2); }
.portal-nav a[aria-current="page"] { color: var(--slate-ink); background: var(--slate-2); box-shadow: inset 0 -2px 0 var(--slate-copper); }
.portal-nav form { margin: 0; }
.portal-hero { padding-top: 18px; padding-bottom: 26px; border-top: 1px solid var(--slate-line); }
.portal-hero h1 { font-size: clamp(24px, 3.4vw, 32px); font-weight: 700; margin-bottom: 18px; }
.portal-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--slate-line); border-radius: var(--r); }
.portal-stats div { padding: 12px 16px; display: grid; gap: 2px; min-width: 0; }
.portal-stats div + div { border-left: 1px solid var(--slate-line); }
.portal-stats span { font-size: 12.5px; color: var(--slate-ink-2); }
.portal-stats b { font: 700 20px/1.2 var(--f-display); }
.portal-main { padding-top: 24px; padding-bottom: 32px; min-height: 50vh; }
.portal-foot { padding-top: 8px; padding-bottom: 32px; font-size: 13px; color: var(--ink-3); }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; padding: 16px; }
.portal-card { display: grid; grid-template-rows: auto 1fr; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; color: inherit; text-decoration: none; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.portal-card:hover { border-color: #c9b4a4; box-shadow: 0 10px 24px -18px rgba(28,33,37,.5); }
.portal-card-photo { aspect-ratio: 4 / 3; background: linear-gradient(135deg, #8a8f95, #5d6268); display: grid; place-items: center; color: rgba(255,255,255,.8); }
.portal-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.portal-card-photo .icon { width: 30%; height: 30%; }
.portal-card-body { padding: 12px 14px; display: grid; gap: 3px; align-content: start; }
.portal-card-body .t { font-weight: 600; }
.portal-card-body .s { font-size: 12.5px; color: var(--ink-3); }
.portal-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; font-weight: 600; }
@media (max-width: 760px) {
  .portal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-stats div:nth-child(3) { border-left: 0; }
  .portal-stats div:nth-child(n+3) { border-top: 1px solid var(--slate-line); }
  .portal-stats b { font-size: 17px; }
  .portal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; }
  .portal-card-body { padding: 10px; }
}
@media (max-width: 380px) { .portal-grid { grid-template-columns: 1fr; } }

/* ---------- Storage location + item history ---------- */
.loc { display: inline-flex; align-items: center; gap: 6px; font: 500 12.5px/1.3 var(--f-mono); color: var(--ink-2); background: var(--sunk); border-radius: 5px; padding: 3px 7px; white-space: nowrap; }
.loc::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--copper); flex: none; }
.move { display: inline-block; margin-left: 8px; vertical-align: middle; }
.move summary { list-style: none; min-height: 30px; padding: 4px 10px; }
.move summary::-webkit-details-marker { display: none; }
.move[open] summary { display: none; }
.move form { margin-top: 2px; }
.move .inp { max-width: 220px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.timeline li { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 12px; font-size: 14px; position: relative; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); margin-top: 6px; box-shadow: 0 0 0 3px var(--sunk); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 4.5px; top: 20px; bottom: -12px; width: 1px; background: var(--line); }
.timeline li.ev-received::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint); }
.timeline li.ev-moved::before { background: var(--copper); box-shadow: 0 0 0 3px var(--copper-tint); }
.timeline li.ev-released::before { background: var(--off); box-shadow: 0 0 0 3px var(--off-tint); }
.timeline .when { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.ev-tag { font: 600 10.5px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--warn); background: var(--warn-tint); padding: 2px 5px; border-radius: 4px; }

/* ---------- Settings ---------- */
.settings-list li { padding: 16px 18px; }
.setting-row { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; }
.setting-row .grow { min-width: 0; flex: 1; }
.setting-row p.sub { max-width: 60ch; line-height: 1.5; }
@media (max-width: 520px) { .setting-row { flex-direction: column; } }

/* ---------- Invoices (screen and print) ---------- */
.invoice-doc { padding: clamp(18px, 3vw, 32px); display: grid; gap: 22px; max-width: 900px; }
.inv-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.inv-pre { white-space: pre-line; margin-top: 8px; max-width: 42ch; }
.inv-title { font: 700 24px/1 var(--f-display); font-stretch: 104%; text-align: right; margin-bottom: 10px; color: var(--copper); }
.inv-meta dl, .inv-totals dl { margin: 0; display: grid; grid-template-columns: max-content max-content; gap: 4px 18px; font-size: 14px; }
.inv-meta dt, .inv-totals dt { color: var(--ink-3); }
.inv-meta dd, .inv-totals dd { margin: 0; text-align: right; }
.inv-to { border-top: 1px solid var(--line); padding-top: 14px; }
.inv-lines td { vertical-align: top; }
.inv-totals { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 14px; }
.inv-totals .grand { font: 700 18px/1.4 var(--f-display); color: var(--ink); border-top: 1px solid var(--line); padding-top: 6px; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .side, .topbar-m, .tabbar, .no-print, .portal-head, .portal-foot, .flash-list { display: none !important; }
  .app { display: block; }
  .main, .portal-main { padding: 0; max-width: none; }
  .invoice-doc { border: 0; padding: 0; max-width: none; }
  .table-wrap { overflow: visible; }
  th { background: #fff; }
}

/* ---------- Photos: show the whole picture (no cropping) wherever it's big enough to matter ----------
   Tall and wide photos sit on a light band instead of being trimmed to the box. The tiny list
   thumbnails stay cropped squares, where a whole photo would be too small to read. */
.gallery-main, .gallery-thumbs button, .portal-card-photo:has(img) { background: var(--sunk); }
.gallery-main img, .gallery-thumbs button img, .portal-card-photo img { object-fit: contain; }
.gallery-main { border: 1px solid var(--line); }
.shot.filled { background: var(--sunk); }
.shot img { object-fit: contain; }
/* Keep card photos inside their 4:3 box: without clipping, a tall photo stretched the whole card. */
.portal-card-photo { position: relative; overflow: hidden; }
.portal-card-photo img { position: absolute; inset: 0; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); }
.danger-panel { border-color: #ebc4bc; }
.danger-panel .panel-head { background: var(--bad-tint); border-bottom-color: #ebc4bc; }
.danger-panel .panel-head h2 { color: #7d2a1e; }
.clear-list { margin: 0; padding-left: 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 18px; font-size: 14px; }

/* Item page: add and remove photos after intake */
.photo-manage > summary { cursor: pointer; list-style: none; }
.photo-manage > summary::-webkit-details-marker { display: none; }
.photo-manage:not([open]) > summary { border-bottom: 0; }
.photo-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.photo-list li { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--sunk); display: grid; place-items: center; }
.photo-list img { width: 100%; height: 100%; object-fit: cover; }
.photo-list form { position: absolute; top: 6px; right: 6px; }
.photo-list .btn { background: var(--surface); }

/* Pull lists: printed for the crew in warehouse order */
.pull-head { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.pull-meta { display: grid; grid-template-columns: auto auto; gap: 4px 14px; margin: 0; font-size: 14px; }
.pull-meta dt { color: var(--ink-3); }
.pull-meta dd { margin: 0; font-weight: 600; }
.pull-table .tick { width: 64px; text-align: center; }
.pull-table .pull-id { font: 700 17px/1.2 var(--f-mono); white-space: nowrap; letter-spacing: .02em; }
.pull-table .pull-id a { color: var(--ink); text-decoration: none; }
.pull-table .pull-id .sub { font: 400 11px/1.3 var(--f-mono); }
.pull-table .pull-loc { font-weight: 600; white-space: nowrap; }
.pull-table .box { display: inline-block; width: 18px; height: 18px; border: 1.5px solid var(--ink-3); border-radius: 3px; }
.pull-sign { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; padding-top: 18px; font-size: 13px; color: var(--ink-3); }
.pull-sign span { display: block; border-bottom: 1px solid var(--ink-3); height: 26px; }
@media print {
  .pull-doc { border: 0; box-shadow: none; }
  .pull-doc .panel-body { padding: 0; }
  .pull-table a { color: inherit; text-decoration: none; }
  .pull-table tr { break-inside: avoid; }
}

/* Item page: release menu (dock pickup or delivery) and handling charges */
.move-menu { position: relative; }
.move-menu > summary { list-style: none; }
.loc-menu > summary { font-family: var(--f-mono); }
.move-menu > summary::-webkit-details-marker { display: none; }
.move-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 12px; }
.move-menu form { display: grid; gap: 8px; }
.move-menu label { font-size: 13px; color: var(--ink-2); }
.move-menu form .btn { justify-self: start; }
@media (max-width: 640px) { .move-menu .menu { left: 0; right: auto; } }
.release-menu { position: relative; }
.release-menu > summary { list-style: none; }
.release-menu > summary::-webkit-details-marker { display: none; }
.release-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: grid; }
.release-menu .menu button, .release-menu .menu a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 6px; font: inherit; color: var(--ink); cursor: pointer; text-decoration: none; }
.release-menu .menu button:hover, .release-menu .menu a:hover { background: var(--sunk); }
.release-menu .menu a { font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--line); border-radius: 0; margin-top: 4px; }
.charge-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.charge-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.charge-list li:last-child { border-bottom: 0; padding-bottom: 0; }

.ledger-split { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; font-weight: 400; }

/* Label previews: the real label image, as it reads */
.label-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 18px; }
.label-previews figure { margin: 0; }
.label-previews img { width: 100%; height: auto; display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.label-previews figcaption { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.label-pick { position: relative; display: block; cursor: pointer; }
.label-previews figcaption input { width: 18px; height: 18px; vertical-align: -4px; margin: 0 4px 0 0; accent-color: var(--copper); }
.label-previews figure:has(input[data-label]:not(:checked)) img { opacity: .4; }
.btn.is-disabled { opacity: .45; pointer-events: none; }
