/* OrderX — styles matched to the Spyder Controls mockups.
   Tokens first; every component below uses them. Mobile rules at the end. */

@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(../fonts/inter-Regular.woff) format('woff'); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(../fonts/inter-Medium.woff) format('woff'); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(../fonts/inter-SemiBold.woff) format('woff'); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(../fonts/inter-Bold.woff) format('woff'); }

:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-disabled: #93b4f5;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-pop: 0 10px 30px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  --header-h: 64px;
  --page-max: 1200px;
  --gutter: 32px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --blue: #2563eb;   --blue-bg: #eff6ff;
  --amber: #d97706;  --amber-bg: #fffbeb;
  --purple: #7c3aed; --purple-bg: #f5f3ff;
  --indigo: #4f46e5; --indigo-bg: #eef2ff;
  --teal: #059669;   --teal-bg: #ecfdf5;
  --green: #15803d;  --green-bg: #f0fdf4;
  --red: #dc2626;    --red-bg: #fef2f2;
  --gray: #6b7280;   --gray-bg: #f3f4f6;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-feature-settings: "cv11", "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.ic { flex: none; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------------------------------------------------------- header */
.app-header { position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: stretch; height: var(--header-h); padding: 0 16px; gap: 8px; }
.brand { display: flex; align-items: center; padding: 0 22px 0 0; flex: none; }
.brand img { width: 112px; height: auto; }
.main-nav { display: flex; align-items: stretch; gap: 2px; flex: 1; min-width: 0; }
.main-nav > a, .utils > a {
  display: flex; align-items: center; gap: 7px; padding: 0 14px; color: var(--muted); font-weight: 500; font-size: 14px;
  white-space: nowrap; border-radius: 10px 10px 0 0; text-decoration: none;
}
.main-nav > a:hover, .utils > a:hover { color: var(--text); text-decoration: none; }
.main-nav > a.active, .utils > a.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.utils { display: flex; align-items: stretch; gap: 0; margin-left: auto; }
.utils > a { font-size: 13.5px; padding: 0 10px; }
.brand-avatar { align-self: center; margin-left: 10px; }
.header-inner .nav-toggle, .nav-utils-mobile, .nav-scrim { display: none; }

/* ---------------------------------------------------------------- layout */
.app-main { max-width: calc(var(--page-max) + var(--gutter) * 2); margin: 0 auto; padding: 28px var(--gutter) 64px; }
.page { animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 6px 0 20px; }
.page-head h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding-top: 4px; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.crumbs > span:last-child { color: var(--text); }
.crumb-back { display: inline-flex; }
.crumb-sep { color: var(--faint); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled { background: var(--primary-disabled); border-color: var(--primary-disabled); opacity: 1; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warn { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.btn-warn:hover { background: #ffedd5; }
.btn-soft-danger { background: #fef2f2; border-color: #fef2f2; color: var(--danger); }
.btn-soft-danger:hover { background: #fee2e2; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.6); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.btn-primary):not(.btn-danger).busy::after { border-color: var(--muted); border-top-color: transparent; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; background: none; border-radius: 6px; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; display: inline-flex; gap: 5px; align-items: center; }
.link-btn:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- avatar / pills */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-weight: 600; flex: none; border: 0; }
.avatar-xs { width: 22px; height: 22px; font-size: 9.5px; background: var(--primary-soft); color: var(--primary); }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 13px; }
.avatar.avatar-brand, .brand-avatar { background: var(--primary); color: #fff; cursor: pointer; }
.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 500; line-height: 20px; white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.tone-blue { background: var(--blue-bg); color: var(--blue); }
.tone-amber { background: var(--amber-bg); color: var(--amber); }
.tone-purple { background: var(--purple-bg); color: var(--purple); }
.tone-indigo { background: var(--indigo-bg); color: var(--indigo); }
.tone-teal { background: var(--teal-bg); color: var(--teal); }
.tone-green { background: var(--green-bg); color: var(--green); }
.tone-red { background: var(--red-bg); color: var(--red); }
.tone-gray { background: var(--gray-bg); color: var(--gray); }
.pill.warn-flat { background: #fef9c3; color: #854d0e; border-radius: 4px; }
.pill.flat { padding-left: 10px; }
.pill.tag { border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 0 6px; }

/* ---------------------------------------------------------------- KPI cards */
.kpis { display: grid; gap: 14px; margin-bottom: 20px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpis-2 { grid-template-columns: repeat(2, 1fr); }
.kpis-4 { grid-template-columns: repeat(4, 1fr); }
.kpis-5 { grid-template-columns: repeat(5, 1fr); }
.kpi {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; padding: 18px 20px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.kpi:hover { border-color: var(--border-strong); }
.kpi.active { border-color: #bfdbfe; box-shadow: 0 0 0 3px var(--primary-soft); }
.kpi-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13.5px; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--text); }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); min-height: 52px; }
.card-head h2 { font-size: 15.5px; font-weight: 600; }
.card-body { padding: 16px; }
.card-link { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--primary); font-size: 13px; cursor: pointer; padding: 2px 0; text-decoration: none; }
.card-link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- filters */
.filters { margin-bottom: 20px; }
.search-row { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.search-input { position: relative; flex: 1; display: flex; align-items: center; }
.search-input .ic { position: absolute; left: 12px; color: var(--faint); }
.search-input input { padding-left: 36px; height: 36px; }
.filters-toggle { display: none; }
.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; padding: 12px 12px 14px; }
.filter-row.more { border-top: 1px dashed var(--border); padding-top: 12px; }
.filter { display: flex; flex-direction: column; gap: 5px; min-width: 120px; flex: 1 1 120px; max-width: 170px; }
.filter > span:first-child { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.filter .input { height: 32px; font-size: 13px; }
.filter-check { flex-direction: row; align-items: center; gap: 8px; max-width: none; flex: 0 0 auto; height: 32px; }
.filter-check > span:first-child, .filter-check span { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text-2); }
.more-filters { display: inline-flex; align-items: center; gap: 6px; height: 32px; border: 0; background: none; color: var(--text-2); font-weight: 500; cursor: pointer; white-space: nowrap; }
.reset { margin-left: auto; height: 32px; }

/* ---------------------------------------------------------------- inputs */
.input {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px; transition: border-color .12s, box-shadow .12s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.45; }
input[type=date].input { padding-right: 6px; }
.select-wrap { position: relative; display: block; }
.select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer; }
.select-caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.input-wrap { position: relative; }
.input-wrap.has-icon .input { padding-left: 34px; }
.input-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.input-wrap.has-prefix .input { padding-left: 26px; }
.input-wrap.has-suffix .input { padding-right: 28px; }
.affix { position: absolute; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.affix.pre { left: 10px; } .affix.suf { right: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.req { color: var(--danger); margin-left: 3px; }
.hint { font-size: 12px; color: var(--muted); }
.field.has-error .input { border-color: var(--danger); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
.err { color: var(--danger); font-size: 12.5px; }
.form-error { background: var(--red-bg); color: #991b1b; border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; }
.span-2 { grid-column: 1 / -1; }
.form-grid { display: grid; gap: 16px 18px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.preset-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.preset-row:has(.preset-custom[hidden]) { grid-template-columns: 1fr; }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.toggle .thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.toggle input:checked + .track { background: var(--primary); }
.toggle input:checked + .track .thumb { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle-label { font-weight: 500; color: var(--text-2); display: flex; flex-direction: column; line-height: 1.25; }
.toggle-label small { font-weight: 400; color: var(--muted); font-size: 12px; }
.toggle-label .on-t { display: none; font-weight: 500; color: var(--primary); }
.toggle-label .off-t { font-weight: 400; }
.toggle input:checked ~ .toggle-label .on-t { display: inline; }
.toggle input:checked ~ .toggle-label .off-t { display: none; }
.field-toggle { justify-content: center; min-height: 62px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text-2); background: var(--surface); }
.chip span .ic { display: none; }
.chip input:checked + span { background: var(--primary-soft); border-color: #93c5fd; color: var(--primary); }
.chip input:checked + span .ic { display: inline; }
.chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.combo { position: relative; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); max-height: 300px; overflow: auto; padding: 4px; }
.combo-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.combo-item.active, .combo-item:hover { background: var(--primary-soft); }
.combo-item b { display: block; font-weight: 600; }
.combo-item small { color: var(--muted); }
.combo-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- table */
.table-card { overflow: hidden; }
.table-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 10px 12px 0; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 7px 14px; border-radius: 6px 6px 0 0; color: var(--text-2); cursor: pointer; white-space: nowrap; font-size: 13.5px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { background: var(--text); color: #fff; font-weight: 600; min-width: 90px; justify-content: center; }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: #ea580c; }
.tab-count { font-size: 11px; background: var(--surface-3); color: var(--muted); border-radius: 999px; padding: 0 6px; }
.tab.active .tab-count { background: rgba(255,255,255,.2); color: #fff; }
.table-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12.5px; padding-bottom: 8px; white-space: nowrap; }
.sort { color: var(--text-2); }
.table-scroll { overflow-x: auto; position: relative; min-height: 120px; }
.table-scroll.is-loading { opacity: .55; transition: opacity .15s; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { text-align: left; font-size: 11px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr.row { cursor: pointer; }
.table tr.row td:first-child { box-shadow: inset 3px 0 0 var(--row-tone, var(--gray)); padding-left: 14px; }
.table tr.row:hover td { background: #fbfbfc; }
.table tr.row.highlight td { background: var(--primary-soft); }
.table tr.row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.table tr:last-child td { border-bottom: 0; }
tr[data-tone=blue] { --row-tone: var(--blue); }
tr[data-tone=amber] { --row-tone: #f59e0b; }
tr[data-tone=purple] { --row-tone: var(--purple); }
tr[data-tone=indigo] { --row-tone: var(--indigo); }
tr[data-tone=teal] { --row-tone: #0d9488; }
tr[data-tone=green] { --row-tone: #16a34a; }
tr[data-tone=red] { --row-tone: #ef4444; }
tr[data-tone=gray] { --row-tone: #6b7280; }
.cell-main { font-weight: 600; color: var(--text); white-space: nowrap; }
.cell-link { font-weight: 600; color: var(--text); }
tr.row:hover .cell-link { color: var(--primary); }
.cell-sub { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; font-weight: 400; }
.nowrap { white-space: nowrap; }
.c-center { text-align: center; }
.table .pill { min-width: 96px; }
.table .pill.compact { min-width: 0; }
.speed { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.speed-zap .ic { color: #f59e0b; fill: #f59e0b; }
.date-planned { color: var(--faint); }
.flag-btn { border: 0; background: none; padding: 4px; cursor: pointer; display: inline-flex; color: #e5e7eb; border-radius: 4px; }
.flag-btn:hover { background: var(--surface-3); }
.flag-btn .flag.on { color: #ef1b1b; }
.flag-btn.static { cursor: default; }
.flag-btn.static:hover { background: none; }
.notes-btn { color: var(--text-2); display: inline-flex; padding: 4px; border-radius: 4px; }
.notes-btn:hover { background: var(--surface-3); }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pager { display: flex; gap: 6px; align-items: center; }
.page-num { min-width: 30px; padding: 0 8px; }
.page-num.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-gap { color: var(--faint); padding: 0 2px; }
.timebar { min-width: 200px; }
.timebar-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; gap: 8px; white-space: nowrap; }
.timebar-top .est { color: var(--faint); }
.bar { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.bar.done > span { background: #15803d; }
.bar.over > span { background: var(--danger); }
.state { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.state-active { color: var(--primary); }
.state-inactive, .state-not-started { color: var(--muted); }
.state-complete { color: #15803d; }
.state-active::before { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------------------------------------------------------------- detail pages */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 364px; gap: 20px; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.detail-main > .card + .card, .detail-side > .card + .card { margin-top: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.pair > .card + .card { margin-top: 0; }
.info-grid { display: grid; gap: 18px 24px; }
.info-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.info-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.info-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.info-label { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.info-value { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.info-value a { color: var(--primary); }
.divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 1px 220px; gap: 0 20px; }
.split > .vr { background: var(--border); }
.address-lines div { line-height: 1.6; }
.prefill-note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.skeleton-lines span { display: block; height: 8px; background: var(--surface-3); border-radius: 4px; margin: 6px 0; }
.part-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.part-icon { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--surface-2); flex: none; }
.part-head b { display: block; font-weight: 600; }
.part-head small { color: var(--muted); font-size: 12.5px; }
.part-head .pill { margin-left: auto; }
.codebox { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.codebox span { flex: 1; }
.notebox { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; margin-top: 14px; }
.notebox .nb-title { font-size: 12.5px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.notebox .nb-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.notebox p { margin: 0; white-space: pre-line; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { background: var(--surface-3); border-radius: 6px; padding: 2px 10px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.pre-line { white-space: pre-line; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.callout.warn { background: #fffbeb; color: #92400e; }
.callout.info { background: var(--primary-soft); color: #1e40af; }
.callout.ok { background: var(--teal-bg); color: #065f46; }
.sum-row { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--border); }
.sum-row b { font-size: 14.5px; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.chain a { display: inline-flex; gap: 6px; align-items: center; }

/* quick actions */
.quick .card-body { display: flex; flex-direction: column; gap: 10px; }
.status-select { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 13px; color: var(--muted); }
.status-select > span { display: flex; align-items: center; gap: 10px; }
.status-select:disabled { cursor: default; }
.quick .btn { height: 32px; font-size: 13px; }
.quick .btn-primary { height: 34px; }
.quick-note { font-size: 12px; color: var(--muted); text-align: center; margin: -2px 0 0; }

/* time card */
.tc-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tc-spent { font-size: 22px; font-weight: 700; }
.tc-btn { min-width: 160px; }
.tc-bar { height: 4px; border-radius: 999px; background: var(--surface-3); margin: 14px 0; overflow: hidden; }
.tc-bar span { display: block; height: 100%; background: var(--primary); transition: width .5s; }
.tc-bar.over span { background: var(--danger); }
.tc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.over-text { color: var(--danger); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #16a34a; margin-left: 4px; animation: pulse 1.6s infinite; vertical-align: middle; }
.time-log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.time-log li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.time-log li:last-child { border-bottom: 0; }
.time-log small { display: block; color: var(--muted); font-size: 11.5px; }

/* timeline */
.composer { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.composer-box { display: flex; gap: 10px; padding: 10px; }
.composer-box textarea { flex: 1; border: 0; resize: vertical; font: inherit; font-size: 13.5px; min-height: 56px; outline: none; background: none; color: var(--text); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; background: var(--surface-2); border-top: 1px solid var(--border); }
.composer-tools { display: flex; gap: 2px; }
.composer-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: 8px 0 14px; }
.tl-filter { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; margin-bottom: 8px; }
.select-inline { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.select-inline select { appearance: none; border: 0; background: none; font: inherit; font-weight: 500; color: var(--text); padding-right: 16px; cursor: pointer; }
.select-inline .ic { position: absolute; right: 0; pointer-events: none; }
.tl-day { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .03em; margin: 16px 0 6px; }
.tl-list { position: relative; }
.tl-item { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 8px 0; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 12.5px; top: 34px; bottom: -8px; width: 1px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-icon { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--muted); }
.tl-item.is-comment .tl-icon { background: none; }
.tl-title { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.4; padding-top: 3px; }
.tl-title time { color: var(--faint); font-size: 11.5px; font-weight: 400; white-space: nowrap; }
.tl-body { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.tl-bubble { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; color: var(--text-2); white-space: pre-line; }
.tl-empty { padding: 8px 0; }
.last-updated { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 4px 0 0; }

/* photos */
.photo-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-tile { position: relative; display: flex; align-items: center; gap: 12px; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.photo-tile .thumb { width: 96px; height: 72px; flex: none; border: 0; padding: 0; cursor: zoom-in; background: var(--surface-3); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile figcaption { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.photo-tile .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-tile .remove { position: absolute; top: 4px; right: 4px; background: rgba(255,255,255,.9); }
.photo-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); margin: 18px 0 8px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gallery figure { margin: 0; min-width: 0; }
.gallery .thumb { width: 100%; aspect-ratio: 16 / 9; border: 0; padding: 0; border-radius: 6px; overflow: hidden; cursor: zoom-in; background: var(--surface-3); }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.gallery figcaption { display: flex; flex-direction: column; font-size: 12.5px; margin-top: 6px; }
.gallery figcaption b { font-weight: 500; }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(17, 24, 39, .88); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lightbox .icon-btn { position: absolute; top: 14px; right: 14px; color: #fff; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dz-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.dz-tiles:not(:empty) { margin-bottom: 12px; }
.dz-tile { position: relative; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.dz-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.dz-tile figcaption { font-size: 11.5px; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.dz-tile .remove { position: absolute; top: 4px; right: 4px; background: rgba(255,255,255,.92); width: 24px; height: 24px; }
.dz-progress { aspect-ratio: 4 / 3; display: flex; align-items: center; padding: 0 12px; }
.dz-progress span { display: block; height: 4px; background: var(--primary); border-radius: 2px; transition: width .2s; }
.dz-target { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; cursor: pointer; text-align: left; color: var(--muted); padding: 6px; }
.dz-target b { display: block; color: var(--primary); font-weight: 600; }
.dz-target small { font-size: 12px; }

/* documents */
.docs { display: flex; flex-direction: column; gap: 10px; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.doc-ic { width: 32px; height: 32px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; flex: none; }
.doc-row .doc-text { flex: 1; min-width: 0; }
.doc-row b { font-weight: 500; display: block; }
.doc-row small { color: var(--muted); font-size: 12px; }
.doc-row .doc-actions { display: flex; align-items: center; gap: 12px; }

/* live shipping card */
.live-carrier { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.live-carrier b { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.eta { background: var(--primary-soft); border-radius: var(--radius); padding: 14px 12px; margin: 14px 0; }
.eta .info-label { margin: 0; }
.eta b { display: block; font-size: 18px; font-weight: 700; margin: 2px 0; }
.eta small { color: var(--text-2); font-size: 12.5px; }
.progress-steps { display: grid; grid-template-columns: repeat(3, 1fr); font-size: 12px; color: var(--muted); margin-top: 4px; }
.progress-steps span:nth-child(2) { text-align: center; }
.progress-steps span:nth-child(3) { text-align: right; }
.progress-steps .on { color: var(--primary); font-weight: 500; }
.progress-track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 6px 0 16px; }
.progress-track i { height: 4px; border-radius: 2px; background: var(--surface-3); }
.progress-track i.on { background: var(--primary); }
.scan { display: grid; grid-template-columns: 18px 1fr; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.scan .ic { color: var(--muted); margin-top: 2px; }
.scan:first-of-type .ic { color: var(--primary); }
.scan b { font-weight: 500; display: block; }
.scan small { color: var(--muted); display: block; font-size: 12px; }
.payload { background: #0f172a; color: #e2e8f0; border-radius: 6px; padding: 12px; font: 11.5px/1.5 var(--mono); max-height: 360px; overflow: auto; white-space: pre; }
.mode-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: #fef3c7; color: #92400e; }
.mode-badge.live { background: var(--teal-bg); color: var(--teal); }

/* ---------------------------------------------------------------- intake form */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.form-sections { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.form-section { margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 0; box-shadow: var(--shadow); }
.form-section > legend { float: left; width: 100%; display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 15.5px; font-weight: 600; }
.form-section > legend + * { clear: both; }
.legend-aside { margin-left: auto; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.form-section > .form-grid { padding: 16px; }
.form-sub { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-top: 4px; }
.form-sub::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.sticky-side { position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: 14px; }
.side-actions { display: flex; flex-direction: column; gap: 10px; }
.demo-card { border-color: #bfdbfe; background: linear-gradient(180deg, #f5f9ff, #fff); }
.demo-card .card-body { display: flex; flex-direction: column; gap: 10px; }
.demo-card p { margin: 0; font-size: 12.5px; color: var(--text-2); }
.checklist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: var(--muted); }
.checklist li.done { color: var(--text); }
.checklist li .ic { color: var(--border-strong); }
.checklist li.done .ic { color: var(--ok); }
.part-preview { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.part-preview.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.rma-picks { display: flex; flex-direction: column; gap: 8px; }
.rma-pick { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.rma-pick:has(input:checked) { border-color: #93c5fd; background: var(--primary-soft); }
.rma-pick input { margin-top: 3px; }
.rma-pick b { font-weight: 600; }
.rma-pick small { display: block; color: var(--muted); }
.calc { font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- RMA */
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.mode-switch a { display: flex; align-items: center; justify-content: center; gap: 10px; height: 50px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text-2); font-size: 15px; font-weight: 500; text-decoration: none; }
.mode-switch a.active { background: var(--text); border-color: var(--text); color: #fff; }
.kv { display: flex; flex-direction: column; gap: 10px; }
.kv-row { display: flex; justify-content: space-between; gap: 16px; font-size: 13.5px; }
.kv-row > span:first-child { color: var(--muted); }
.kv-row > span:last-child { text-align: right; font-weight: 500; white-space: pre-line; }
.req-cell b { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.req-cell b::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--gray)); }
.req-cell small { display: block; color: var(--muted); font-size: 12.5px; max-width: 280px; white-space: normal; }

/* ---------------------------------------------------------------- menus, modals, toasts */
.menu { position: absolute; z-index: 80; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 4px; max-height: 70vh; overflow: auto; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: 6px; text-align: left; cursor: pointer; font-size: 13.5px; }
.menu-item:hover:not(:disabled) { background: var(--surface-2); }
.menu-item:disabled { opacity: .7; cursor: default; }
.menu-item.active { background: var(--primary-soft); color: var(--primary); }
.menu-item.danger { color: var(--danger); }
.menu-item small { margin-left: auto; color: var(--muted); font-size: 11.5px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(17, 24, 39, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; opacity: 0; transition: opacity .15s; }
.modal-backdrop.show { opacity: 1; }
.modal { width: 100%; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-pop); transform: translateY(8px); transition: transform .15s; }
.modal-backdrop.show .modal { transform: none; }
.modal-sm { max-width: 420px; } .modal-md { max-width: 560px; } .modal-lg { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
.modal-text { margin: 0 0 12px; color: var(--text-2); }
.modal-sub { font-size: 13px; font-weight: 600; margin: 18px 0 8px; }
.modal-summary { display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.modal-summary b { display: block; }

.toasts { position: fixed; z-index: 100; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 460px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; background: #111827; color: #fff; font-size: 13.5px; box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }
.toast-ok .ic { color: #34d399; }
.toast-error { background: #7f1d1d; }
.toast button { margin-left: auto; border: 0; background: rgba(255,255,255,.15); color: #fff; border-radius: 5px; padding: 3px 9px; cursor: pointer; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); }
.loading.boot { min-height: 50vh; }
.spin { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state h2, .empty-state h3 { color: var(--text); font-size: 16px; }
.empty-state p { margin: 0 0 8px; }
.boot-error { min-height: 60vh; justify-content: center; }

/* users / watch / import */
.list-plain { display: flex; flex-direction: column; }
.list-plain > * { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.list-plain > *:last-child { border-bottom: 0; }
.list-plain a:hover { background: var(--surface-2); text-decoration: none; }
.list-plain .grow { flex: 1; min-width: 0; }
.list-plain small { display: block; color: var(--muted); }
.import-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.import-grid .card { margin: 0; }
.import-grid .card-body { display: flex; flex-direction: column; gap: 12px; height: calc(100% - 52px); }
.import-grid .card-body p { margin: 0; color: var(--text-2); font-size: 13.5px; flex: 1; }
.log-table td, .log-table th { font-size: 12.5px; }

.mobile-demo { display: none !important; }

/* ---------------------------------------------------------------- print */
@media print {
  .app-header, .head-actions, .quick, .composer, .composer-note, .toasts, .filters, .table-foot, .card-link { display: none !important; }
  .app-main { padding: 0; max-width: none; }
  .detail { grid-template-columns: 1fr; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .main-nav > a { padding: 0 10px; }
  .utils > a span { display: none; }
  .utils > a { padding: 0 9px; }
  .detail { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (max-width: 1020px) {
  :root { --gutter: 20px; }
  .kpis-5 { grid-template-columns: repeat(3, 1fr); }
  .form-layout { grid-template-columns: 1fr; }
  .sticky-side { position: static; }
  .main-nav > a .ic { display: none; }
}

/* Tablet & phone: drawer nav, single column, cards instead of tables */
@media (max-width: 860px) {
  :root { --header-h: 56px; --gutter: 16px; }
  .header-inner { padding: 0 8px; gap: 4px; }
  .header-inner .nav-toggle { display: inline-flex; align-self: center; width: 40px; height: 40px; }
  .brand { padding: 0 6px; }
  .brand img { width: 100px; }
  .utils > a { display: none; }
  .main-nav {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(82vw, 300px); z-index: 60; background: var(--surface); flex-direction: column;
    padding: 16px 10px calc(16px + env(safe-area-inset-bottom)); gap: 2px; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-pop); overflow-y: auto;
  }
  .main-nav > a, .nav-utils-mobile a { height: 44px; border-radius: 8px; padding: 0 12px; font-size: 15px; display: flex; align-items: center; gap: 10px; color: var(--text-2); }
  .main-nav > a .ic, .nav-utils-mobile a .ic { display: inline; }
  .main-nav > a.active, .nav-utils-mobile a.active { background: var(--surface-3); color: var(--text); }
  .nav-utils-mobile { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(17,24,39,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .main-nav { transform: none; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .brand-avatar { margin-left: auto; }

  .app-main { padding: 16px var(--gutter) calc(48px + env(safe-area-inset-bottom)); }
  .page-head { flex-direction: column; gap: 10px; margin-top: 0; }
  .page-head h1 { font-size: 22px; }
  .head-actions { justify-content: flex-start; width: 100%; }
  .head-actions .btn { flex: 1 1 auto; }
  .kpis, .kpis-4, .kpis-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 22px; }
  .filters-toggle { display: inline-flex; }
  .search-row .btn-primary span { display: none; }
  .search-row .btn-primary { width: 40px; padding: 0; }
  .filters .filter-row { display: none; }
  .filters.open .filter-row:not([hidden]) { display: flex; }
  .filter { max-width: none; flex: 1 1 140px; }

  .table-top { flex-direction: column; align-items: stretch; padding: 8px 8px 0; }
  .table-meta { justify-content: space-between; padding: 6px 4px 8px; }
  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tr.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 10px; padding: 12px 14px 12px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: inset 4px 0 0 var(--row-tone, var(--gray)); }
  .table tr.row td { display: block; padding: 0; border: 0; box-shadow: none !important; min-width: 0; background: none !important; }
  .table tr.row td::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); margin-bottom: 1px; }
  .table tr.row td:first-child { grid-column: 1 / -1; padding: 0; }
  .table tr.row td:first-child::before { display: none; }
  .table tr.row td.hide-sm { display: none; }
  .table tr.row td.wide-sm { grid-column: 1 / -1; }
  .table tr.row.highlight { background: var(--primary-soft); }
  .table .pill { min-width: 0; }
  .cell-main, .cell-sub { white-space: normal; }
  .timebar { min-width: 0; }
  .table-foot { flex-direction: column; align-items: stretch; text-align: center; }
  .pager { justify-content: center; }
  .pager .btn span { display: none; }

  /* detail pages: flatten columns so quick actions + timer come first */
  .detail { display: flex; flex-direction: column; gap: 14px; }
  .detail-main, .detail-side { display: contents; }
  .detail .card { margin: 0 !important; width: 100%; }
  .detail .quick, .detail .timecard { order: -2; }
  .detail .live-ship { order: -1; }
  .detail .timeline { order: 5; }
  .detail .last-updated { order: 6; }
  .pair { grid-template-columns: 1fr; gap: 14px; }
  .info-grid.cols-3, .info-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; gap: 18px; }
  .split > .vr { display: none; }
  .photo-tiles { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .import-grid { grid-template-columns: 1fr; }
  .crumbs { font-size: 13px; }

  .form-grid.cols-2, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .form-layout { display: flex; flex-direction: column-reverse; }
  .sticky-side { position: sticky; bottom: 0; top: auto; z-index: 20; margin: 0 calc(var(--gutter) * -1); padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--border); backdrop-filter: blur(6px); gap: 0; }
  .sticky-side > .card:not(.side-actions-card) { display: none; }
  .side-actions-card { border: 0; box-shadow: none; background: none; }
  .side-actions-card .card-head { display: none; }
  .side-actions-card .card-body { padding: 0; }
  .side-actions { flex-direction: row; flex-wrap: wrap; }
  .side-actions .btn { flex: 1 1 30%; }
  .mobile-demo { display: flex !important; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: 14px 14px 0 0; max-width: none !important; max-height: 92vh; display: flex; flex-direction: column; }
  .modal-form { display: flex; flex-direction: column; min-height: 0; max-height: 92vh; }
  .modal-body { overflow-y: auto; }
  .modal-foot { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .input, .btn { height: 42px; }
  .input { font-size: 16px; } /* prevents iOS zoom on focus */
  .btn-sm { height: 34px; }
  .quick .btn { height: 40px; font-size: 14px; }
  .mode-switch a { height: 44px; font-size: 14px; }
}

@media (max-width: 420px) {
  .kpi-label { font-size: 12.5px; }
  .tc-top { flex-direction: column; align-items: stretch; }
  .tc-btn { width: 100%; }
  .gallery { grid-template-columns: 1fr; }
}
