/* Transload Ops - one stylesheet, no inline styles (strict CSP).
   Layout: top bar in the client's brand color, menu down the left on desktop
   and as a scrolling strip on phones; content in cards. Big touch targets -
   floor workers use it on phones with gloves on. Company colors arrive as
   --brand / --accent from /brand.css; the values below are the defaults. */
:root {
  --bg: #f1f3f6;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #5b6676;
  --line: #d9dfe6;
  --line-strong: #b9c2cd;
  --brand: #1f4e79;
  --brand-ink: #ffffff;
  --accent: #f2b705;
  --accent-ink: #14181d;
  --focus: #2b6cb0;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #18794e;
  --ok-soft: #e6f4ec;
  --warn: #8a5300;
  --warn-soft: #fdf3dc;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--brand); }
img { max-width: 100%; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .75rem; text-wrap: balance; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---- top bar + menu ---- */
.topbar { background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.topbar a { color: inherit; text-decoration: none; }
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brandmark img { height: 34px; width: auto; max-width: 140px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px 4px; }
.brandmark span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.usermenu { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.usermenu form { margin: 0; }
.usermenu .btn-link { color: var(--brand-ink); }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidenav { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 10px; }
.sidenav a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
.sidenav a:hover { background: var(--bg); }
.sidenav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
main.content { padding: 24px; min-width: 0; max-width: 1100px; }
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidenav { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav a { white-space: nowrap; padding: 8px 12px; }
  main.content { padding: 16px; }
  .usermenu .who { display: none; }
}

/* ---- cards, alerts ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card > h2:first-child { margin-top: 0; }
.alert { border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f5c2bd; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #b7dfc8; }
.alert-info { background: #eaf2fb; color: #1d4f85; border-color: #c4dbf3; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #f0d9a4; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

/* ---- forms ---- */
form.stacked { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .85rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], select, textarea {
  font: inherit; width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--ink); }
input[type=color] { width: 64px; height: 44px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
input[type=file] { font: inherit; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: 0 0 auto; }
.code-input { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .2em; max-width: 14ch; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  font: 600 1rem var(--font); cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #e7a59e; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f7f9fb; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-off { background: #eef1f4; color: var(--muted); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-brand { background: var(--accent); color: var(--accent-ink); }

/* ---- sign-in pages ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand .wordmark { font-weight: 800; font-size: 1.5rem; letter-spacing: -.01em; color: var(--brand); }
.auth-brand .tagline { color: var(--muted); font-size: .9rem; }
.langbar { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; margin-top: 16px; font-size: .9rem; }
.langbar a[aria-current="true"] { font-weight: 700; color: var(--ink); text-decoration: none; }
.qr { display: block; width: 200px; height: 200px; margin: 12px 0; image-rendering: pixelated; }
.secret { font-family: var(--mono); font-size: 1.05rem; letter-spacing: .08em; word-break: break-all; user-select: all; background: var(--bg); padding: 8px 10px; border-radius: 6px; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-family: var(--mono); font-size: 1.1rem; margin: 12px 0; }
.codes span { background: var(--bg); border-radius: 6px; padding: 8px; text-align: center; }
.linkbox { display: flex; gap: 8px; flex-wrap: wrap; }
.linkbox input { flex: 1 1 260px; font-family: var(--mono); font-size: .9rem; }

/* ---- misc ---- */
.swatches { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.logo-preview { max-height: 64px; width: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.05rem; }
.footer { color: var(--muted); font-size: .8rem; padding: 16px 24px 24px; }
.pager { display: flex; gap: 12px; margin-top: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 180px; }
@media (prefers-reduced-motion: no-preference) { .btn, .sidenav a { transition: background-color .12s, filter .12s; } }
a.stat { color: var(--ink); text-decoration: none; display: grid; gap: 4px; }
a.stat:hover { border-color: var(--brand); }

/* ---- step B: calendar, appointments, gate ---- */
.top-gap { margin-top: 14px; }
.crumbs { margin: 0 0 6px; font-size: .9rem; }
.inline { display: inline; }
.grow { flex: 1 1 260px; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
fieldset.card.plain { margin: 0; min-width: 0; }
.table-wrap.flat { border: 0; border-radius: 0; }
tr.is-off td { color: var(--muted); }
.btn-big { min-height: 56px; font-size: 1.1rem; padding: 12px 24px; }
input[type=date], input[type=time] { font: inherit; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink); }
table.hours input[type=time] { width: 100%; min-width: 110px; }
.calendar-wrap { max-height: 75vh; overflow: auto; }
table.calendar { border-collapse: separate; border-spacing: 0; min-width: 100%; }
table.calendar th, table.calendar td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
table.calendar thead th { position: sticky; top: 0; z-index: 2; background: #f7f9fb; min-width: 150px; text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--ink); }
table.calendar .time-col { position: sticky; left: 0; z-index: 1; background: #f7f9fb; min-width: 70px; width: 70px; font-family: var(--mono); font-size: .85rem; color: var(--muted); }
table.calendar thead .time-col { z-index: 3; }
td.slot { vertical-align: top; padding: 6px; min-width: 150px; height: 64px; }
td.slot.closed { background: repeating-linear-gradient(135deg, #f3f5f7, #f3f5f7 6px, #eceff3 6px, #eceff3 12px); }
td.slot.past { background: #fafbfc; }
td.slot .free { display: inline-block; padding: 6px 10px; border-radius: 6px; border: 1px dashed var(--line-strong); text-decoration: none; font-weight: 600; font-size: .85rem; }
td.slot .free:hover { border-color: var(--brand); background: var(--bg); }
a.appt { display: grid; gap: 1px; padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; text-decoration: none; color: var(--ink); font-size: .82rem; line-height: 1.3; border-left: 4px solid var(--brand); background: #eef3f8; }
a.appt b { font-size: .88rem; }
a.appt-requested, a.appt-arrived { border-left-color: var(--warn); background: var(--warn-soft); }
a.appt-at_door { border-left-color: var(--ok); background: var(--ok-soft); }
a.appt-completed { border-left-color: var(--line-strong); background: #f3f5f7; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; }
.facts .label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.big-door { font-size: 1.5rem; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.timeline li { padding-left: 14px; border-left: 3px solid var(--line); }
details.card > summary { cursor: pointer; }
.gate-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.gate-item { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); background: var(--surface); }
.gate-item:hover { border-color: var(--brand); }
.gate-time { font-family: var(--mono); font-weight: 700; }
.gate-main { display: grid; gap: 2px; min-width: 0; }
.gate-side { display: grid; gap: 4px; justify-items: end; }
@media (max-width: 520px) { .gate-item { grid-template-columns: 60px minmax(0, 1fr); } .gate-side { grid-column: 2; justify-items: start; } }
/* Receiving and inventory */
table.counts td, table.counts th { font-variant-numeric: tabular-nums; }
tr.is-diff td, tr.is-diff th { background: var(--danger-soft); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.unit-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.unit-row { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.unit-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.putaway .unit-list { margin-bottom: 12px; }
.putaway { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 16px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs a { display: block; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.small-thumbs img { width: 64px; height: 64px; }
.thumb-file { display: grid; place-items: center; width: 96px; height: 96px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; font-size: .75rem; word-break: break-all; text-align: center; }
.sig-thumbs figure { margin: 0; }
.sig-thumbs img { width: 240px; height: auto; object-fit: contain; background: #fff; }
canvas.sig-pad { display: block; width: 100%; height: 160px; border: 1px dashed var(--line-strong); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; margin-top: 4px; }
canvas.sig-pad.is-signed { border-style: solid; border-color: var(--brand); }
.hold-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
@media (max-width: 520px) {
  .unit-row { grid-template-columns: minmax(0, 1fr) auto; }
  .unit-row > .small { grid-column: 1 / -1; grid-row: 2; }
  .unit-tags { justify-content: flex-start; }
  .hold-row { grid-template-columns: minmax(0, 1fr); }
}
/* Releases and outbound */
input.qty { width: 6.5em; text-align: right; }
.release-block + .release-block { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.release-block p { margin: 0 0 6px; }
/* Billing */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }
.nowrap { white-space: nowrap; }
.hidden-form { display: none; }
.inline-details summary { cursor: pointer; color: var(--danger); }
.remove-box { display: flex; gap: 6px; margin-top: 6px; }
.remove-box input { min-width: 140px; }
.big-total { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
tfoot td { border-top: 2px solid var(--line-strong); }
table.rates select { min-width: 150px; }
.card.attention { border-color: var(--warn); background: var(--warn-soft); }
.card.attention-ok { border-color: var(--ok); background: var(--ok-soft); }
