/* Jersey Order Management — styles. No build step; plain CSS. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/inter-600.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("/static/fonts/inter-700.woff2") format("woff2"); }

/* Design tokens (change request v2, update 2). These are the only colours used in the app;
   soft tints are mixed from them with color-mix(). */
:root {
  /* brand + text */
  --c-primary: #0D9B77;
  --c-logo-start: #10B981;
  --c-logo-end: #0D9488;
  --c-text: #1E293B;          /* also dark surfaces */
  --c-text-2: #64748B;
  --c-border: #E2E8F0;
  --c-white: #FFFFFF;
  --c-subtle: #F8FAFC;
  /* status */
  --c-success: #10B981;
  --c-warning: #F59E0B;
  --c-danger: #EF4444;
  --c-info: #3B82F6;
  /* chart order: primary, info, warning, danger, then these */
  --c-purple: #8B5CF6;
  --c-cyan: #06B6D4;
  --c-slate: #64748B;

  /* roles used by the stylesheet */
  --bg: var(--c-subtle);
  --surface: var(--c-white);
  --surface-2: var(--c-subtle);
  --border: var(--c-border);
  --border-strong: color-mix(in srgb, var(--c-border) 70%, var(--c-text-2));
  --text: var(--c-text);
  --muted: var(--c-text-2);
  --primary: var(--c-primary);
  --primary-hover: color-mix(in srgb, var(--c-primary) 85%, var(--c-text));
  --primary-ink: var(--c-white);
  --primary-soft: color-mix(in srgb, var(--c-primary) 10%, var(--c-white));
  --accent: var(--c-primary);
  --danger: var(--c-danger);
  --danger-ink: color-mix(in srgb, var(--c-danger) 80%, var(--c-text));
  --danger-soft: color-mix(in srgb, var(--c-danger) 9%, var(--c-white));
  --warn: color-mix(in srgb, var(--c-warning) 65%, var(--c-text));
  --warn-soft: color-mix(in srgb, var(--c-warning) 12%, var(--c-white));
  --ok: color-mix(in srgb, var(--c-success) 75%, var(--c-text));
  --ok-soft: color-mix(in srgb, var(--c-success) 12%, var(--c-white));
  --info: var(--c-info);
  --info-soft: color-mix(in srgb, var(--c-info) 10%, var(--c-white));
  --focus: color-mix(in srgb, var(--c-primary) 35%, var(--c-white));
  --radius: 12px;
  --shadow: 0 1px 2px color-mix(in srgb, var(--c-text) 6%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, var(--c-text) 16%, transparent);
  --sidebar: 236px;
  --logo-gradient: linear-gradient(135deg, var(--c-logo-start), var(--c-logo-end));
  /* phases: Intake blue, Preparation amber, Production purple, Delivery green */
  --g-intake: var(--c-info);       --g-intake-bg: color-mix(in srgb, var(--c-info) 11%, var(--c-white));
  --g-preparation: color-mix(in srgb, var(--c-warning) 70%, var(--c-text)); --g-preparation-bg: color-mix(in srgb, var(--c-warning) 14%, var(--c-white));
  --g-production: var(--c-purple); --g-production-bg: color-mix(in srgb, var(--c-purple) 11%, var(--c-white));
  --g-delivery: var(--c-primary);  --g-delivery-bg: var(--primary-soft);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-weight: 700; } h2, h3 { font-weight: 600; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.icon { width: 20px; height: 20px; flex: none; }
.icon-xs { width: 14px; height: 14px; flex: none; vertical-align: -2px; }
.w-full { width: 100%; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--surface); color: var(--text); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar .brand { color: var(--text); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 10px; }
.sidebar-foot .btn-ghost { color: var(--muted); border-color: var(--border); background: transparent; }
.who { display: flex; gap: 10px; align-items: center; color: var(--text); }
.who:hover { text-decoration: none; }
.who small { display: block; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--logo-gradient); color: var(--c-white); display: grid; place-items: center; font-weight: 700; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.main { margin-left: var(--sidebar); padding: 24px 28px 48px; max-width: 1240px; }
.topbar, .tabbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 14px;
  }
  .topbar .brand { color: var(--text); font-size: .95rem; }
  .topbar .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar > a, .tabbar summary {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px;
    font-size: 11px; color: var(--muted); list-style: none; cursor: pointer;
  }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar > a.active { color: var(--primary); font-weight: 600; }
  .tabbar a:hover { text-decoration: none; }
  .more { position: relative; }
  .more-sheet {
    position: absolute; right: 8px; bottom: calc(100% + 8px); width: 210px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
  }
  .more-sheet a, .more-sheet button {
    display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px; color: var(--text);
    width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
  }
  .more-sheet a:hover, .more-sheet button:hover { background: var(--surface-2); text-decoration: none; }
  h1 { font-size: 1.25rem; }
}

/* ---------- page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: .85rem; color: var(--muted); margin-bottom: 4px; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- cards / grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 18px 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .card { padding: 14px; } }

.tile { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; color: var(--text); }
.tile.warn { border-left-color: var(--c-warning); } .tile.danger { border-left-color: var(--c-danger); } .tile.info { border-left-color: var(--c-info); }
a.tile:hover { text-decoration: none; border-color: var(--primary); }
.tile .k { font-size: .72rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 1.6rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.danger .v { color: var(--danger); }
.tile.warn .v { color: var(--warn); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; line-height: 1.2; min-height: 40px; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--c-white); }
.btn-accent:hover { background: var(--primary-hover); }
.btn-danger { background: var(--surface); border-color: color-mix(in srgb, var(--c-danger) 35%, var(--c-white)); color: var(--danger-ink); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; min-height: 32px; font-size: .85rem; }
.btn .icon { width: 18px; height: 18px; }
.btn-sm .icon { width: 16px; height: 16px; }
.link-btn { background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; padding: 0; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: .85rem; font-weight: 500; color: var(--text); }
.field .hint { font-size: .8rem; color: var(--muted); }
.req::after { content: " *"; color: var(--danger); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=date],
input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; min-height: 40px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--primary); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  input, select, textarea { font-size: 16px; } /* prevents iOS zoom */
}
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
@media (max-width: 640px) { .form-actions .btn { flex: 1; } }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 4px 0 10px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  display: block; padding: 10px; border: 1px solid var(--border); border-radius: 8px; text-align: center; cursor: pointer;
  font-weight: 500; font-size: .9rem; background: var(--surface);
}
.choice input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.choice input:focus-visible + span { outline: 2px solid var(--focus); }

/* ---------- flash / alerts ---------- */
.flash, .alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--c-success) 30%, var(--c-white)); }
.flash-error, .alert-error { background: var(--danger-soft); color: var(--danger-ink); border-color: color-mix(in srgb, var(--c-danger) 30%, var(--c-white)); }
.alert-warn, .flash-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--c-warning) 35%, var(--c-white)); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--c-info) 30%, var(--c-white)); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-intake { background: var(--g-intake-bg); color: var(--g-intake); }
.badge-preparation { background: var(--g-preparation-bg); color: var(--g-preparation); }
.badge-production { background: var(--g-production-bg); color: var(--g-production); }
.badge-delivery { background: var(--g-delivery-bg); color: var(--g-delivery); }
.badge-cancelled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.badge-hold { background: var(--warn-soft); color: var(--warn); }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }
.badge-today { background: var(--warn-soft); color: var(--warn); }
.badge-urgent { background: var(--danger); color: var(--c-white); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.overdue td { background: var(--danger-soft); }
.table tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Order rows become cards on phones */
@media (max-width: 760px) {
  table.table.stack thead { display: none; }
  table.table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table.stack td { border: 0; padding: 2px 0; }
  .table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .82rem; }
  .table.stack td.num { text-align: left; }
  .table.stack tr.overdue { background: var(--danger-soft); box-shadow: inset 3px 0 0 var(--danger); }
  .table.stack tr.overdue td { background: transparent; box-shadow: none; }
}

.row-title { font-weight: 600; color: var(--text); }
.row-title:hover { color: var(--primary); }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { flex: 1 1 160px; }
.filters .field.grow { flex: 3 1 240px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: .85rem; font-weight: 500; }
.chip:hover { text-decoration: none; border-color: var(--primary); }
.chip.active { background: var(--primary); color: var(--c-white); border-color: var(--primary); }

/* ---------- stage board ---------- */
.g-intake h3 { color: var(--g-intake); } .g-preparation h3 { color: var(--g-preparation); } .g-production h3 { color: var(--g-production); }
.g-delivery h3 { color: var(--g-delivery); }
@media (max-width: 1000px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .board { grid-template-columns: 1fr; } }

/* ---------- progress tracker ---------- */
.progress { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.progress li { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 8px; background: var(--surface-2); font-size: .85rem; color: var(--muted); }
.progress .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; background: var(--surface); }
.progress li.done { color: var(--ok); background: var(--ok-soft); }
.progress li.done .dot { background: var(--ok); border-color: var(--ok); color: var(--c-white); }
.progress li.current { color: var(--primary); background: var(--primary-soft); font-weight: 700; outline: 2px solid var(--primary); }
.progress li.current .dot { border-color: var(--primary); box-shadow: inset 0 0 0 4px var(--c-white); background: var(--primary); }

/* ---------- timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: -6px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li.t-STAGE::after { border-color: var(--ok); background: var(--ok); }
.timeline li.t-REMARK::after { border-color: var(--primary); }
.timeline li.t-STATUS::after, .timeline li.t-DATE::after { border-color: var(--warn); background: var(--warn-soft); }
.timeline .meta { font-size: .8rem; color: var(--muted); }
.timeline .msg { white-space: pre-wrap; }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* ---------- line items editor ---------- */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: .75rem; text-transform: uppercase; color: var(--muted); text-align: left; padding: 4px 6px; }
.lines td { padding: 4px 6px; vertical-align: top; }
.lines .qty { width: 80px; }
.lines .size { width: 120px; }
.lines .sleeve { width: 110px; }
.lines .warn-cell { font-size: .78rem; color: var(--warn); }
.lines .rm { color: var(--danger); }
.totals-bar { display: flex; gap: 18px; flex-wrap: wrap; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; margin-top: 8px; font-size: .9rem; }
.totals-bar b { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr { display: block; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr 70px 36px; gap: 6px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
  .lines td { padding: 0; }
  .lines td.nums { grid-column: 1 / -1; }
  .lines .qty, .lines .size, .lines .sleeve { width: auto; }
  .lines.shorts tr { grid-template-columns: 1fr 80px 36px; }
}

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: .75rem; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 0; text-transform: uppercase; }
.cal a.day {
  min-height: 78px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); padding: 6px; color: var(--text);
  display: flex; flex-direction: column; gap: 4px;
}
.cal a.day:hover { text-decoration: none; border-color: var(--primary); }
.cal a.day.other { opacity: .45; }
.cal a.day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal a.day.selected { background: var(--primary-soft); border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal .dnum { font-weight: 700; font-size: .85rem; }
.cal .count { font-size: .78rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); align-self: flex-start; }
.cal .count.overdue { background: var(--danger); color: var(--c-white); }
.cal .count.done { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 640px) {
  .cal a.day { min-height: 54px; padding: 4px; }
  .cal .count { font-size: .7rem; padding: 0 5px; }
}

/* ---------- quick stage panel ---------- */
.quick { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.quick input[type=text] { flex: 1 1 160px; min-height: 34px; padding: 6px 9px; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.file { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--c-white); font-size: .8rem; }
.file .thumb { height: 96px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file .fn { padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .fa { display: flex; justify-content: space-between; padding: 0 8px 6px; }
details.panel { border: 1px solid var(--border); border-radius: 8px; background: var(--c-white); }
details.panel > summary { padding: 10px 12px; cursor: pointer; font-weight: 600; }
details.panel > div { padding: 0 12px 12px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.stat-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.stat-line:last-child { border-bottom: 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); }
.login-card .brand { justify-content: center; margin-bottom: 6px; font-size: 1.15rem; }
.demo { margin-top: 18px; font-size: .82rem; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.demo table { width: 100%; border-collapse: collapse; }
.demo td { padding: 2px 0; }

@media print {
  .sidebar, .topbar, .tabbar, .no-print, .flash { display: none !important; }
  .main { margin: 0; padding: 0; max-width: none; }
  body { background: var(--c-white); }
  .card { box-shadow: none; border-color: var(--border); }
}

/* ---------- quick order rows (calendar / dashboard) ---------- */
.qrow { padding: 12px 14px; }
.qrow + .qrow { margin-top: 10px; }
.qrow-top { display: flex; justify-content: space-between; gap: 10px; }
.qrow-meta { font-size: .85rem; margin-top: 4px; }
.qrow-overdue { border-color: color-mix(in srgb, var(--c-danger) 30%, var(--c-white)); box-shadow: inset 4px 0 0 var(--danger); background: var(--danger-soft); }
.mt-xs { margin-top: 4px; }
.htmx-request .btn { opacity: .6; pointer-events: none; }

/* phone tweaks: remove button sits on the first line of a size row; filters collapse */
@media (max-width: 640px) {
  .lines td.nums { order: 2; }
}
details.filters-box > summary { display: none; }
@media (max-width: 860px) {
  details.filters-box { margin-bottom: 14px; }
  details.filters-box > summary {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border);
    border-radius: 8px; background: var(--surface); font-weight: 600; cursor: pointer; list-style: none;
  }
  details.filters-box > summary::-webkit-details-marker { display: none; }
  details.filters-box[open] > summary { margin-bottom: 10px; }
}
.row-title { white-space: nowrap; }

/* undo */
.undo-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.timeline li.t-UNDO::after { border-color: var(--warn); background: var(--surface); }

/* ---- Change request v2: shared bits ---- */
.card-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.section-label { font-size: .72rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.brand img, .login-card .brand img { border-radius: 8px; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; min-width: 0; }
.input-group select { width: auto; flex: none; }
.warn-text { color: var(--warn); }
input.is-warn { border-color: var(--c-warning); outline-color: color-mix(in srgb, var(--c-warning) 40%, var(--c-white)); background: var(--warn-soft); }
.soonest { display: block; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--primary-soft); color: var(--text); font-size: .85rem; }
.soonest:empty { display: none; }
.soonest b { color: var(--primary); }
.holiday-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.holiday-form .field { margin: 0; }
.holiday-form .grow { flex: 1; min-width: 180px; }
.table tr.is-past td { color: var(--muted); opacity: .6; }
details.inline-edit { display: inline-block; }
details.inline-edit[open] { display: block; margin-bottom: 8px; }
details.inline-edit summary { list-style: none; display: inline-flex; }
details.inline-edit summary::-webkit-details-marker { display: none; }
details.inline-edit .holiday-form { justify-content: flex-end; margin-top: 8px; }
form.inline { display: inline; }

/* ---- Home: Orders by stage (phase tiles) ---- */
a.phase-card { display: block; color: var(--text); }
a.phase-card:hover { text-decoration: none; border-color: var(--primary); }
.phase-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.phase-tile { padding: 14px 16px; border-left: 4px solid var(--ph); background: var(--surface); }
.phase-tile + .phase-tile { border-top: 0; box-shadow: inset 1px 0 0 var(--border); }
.phase-tile .k { display: flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.phase-tile .v { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.phase-stages { font-size: .78rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ph, var(--primary)); display: inline-block; flex: none; }
.ph-intake { --ph: var(--g-intake); --ph-bg: var(--g-intake-bg); }
.ph-preparation { --ph: var(--c-warning); --ph-ink: var(--g-preparation); --ph-bg: var(--g-preparation-bg); }
.ph-production { --ph: var(--g-production); --ph-bg: var(--g-production-bg); }
.ph-delivery { --ph: var(--g-delivery); --ph-bg: var(--g-delivery-bg); }
@media (max-width: 860px) { .phase-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .phase-tile:nth-child(3) { box-shadow: inset 0 1px 0 var(--border); } .phase-tile:nth-child(4) { box-shadow: inset 1px 1px 0 var(--border); } }

/* ---- Board (kanban) ---- */
.board-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.board-filters input[type=search] { flex: 1; min-width: 200px; }
.board-filters select, .board-filters input[type=date] { width: auto; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); min-height: 200px; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); border-top: 3px solid var(--ph); border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); }
.kcol-head h2 { margin: 0; font-size: .95rem; }
.kcount { margin-left: auto; font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.kcol-body { overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.kcard { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text); box-shadow: var(--shadow); }
.kcard:hover { text-decoration: none; border-color: var(--primary); }
.kcard.is-overdue { box-shadow: inset 3px 0 0 var(--c-danger), var(--shadow); }
.kcard-top { display: flex; align-items: center; gap: 6px; }
.kcard-no { font-weight: 600; color: var(--primary); font-size: .88rem; }
.kcard-client { font-weight: 500; margin: 2px 0 6px; }
.kcard-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.overdue-text { color: var(--c-danger); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.stage-chip { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--ph-bg); color: var(--ph-ink, var(--ph)); }
.pill { font-size: .7rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.pill-urgent { background: var(--danger-soft); color: var(--danger-ink); }
.pill-hold { background: var(--warn-soft); color: var(--warn); }
.avatar-xs { width: 24px; height: 24px; border-radius: 50%; background: var(--logo-gradient); color: var(--c-white); font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
.kempty { color: var(--muted); font-size: .85rem; text-align: center; padding: 18px 0; }
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(4, 260px); } .kcol { max-height: none; } }

/* ---- Capacity calendar (home) and capacity marks (Calendar page) ---- */
.cap-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cap-cal .dow { font-size: .72rem; font-weight: 500; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .05em; padding: 2px 0; }
.cap-day { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-height: 54px; display: flex; flex-direction: column; justify-content: space-between; background: var(--surface); }
.cap-day .dnum { font-size: .8rem; font-weight: 600; }
.cap-v { font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap-day.past { opacity: .4; background: var(--surface-2); }
.cap-day.open .cap-v { color: var(--primary); }
.cap-day.full, .sw-full { background: var(--danger-soft); border-color: color-mix(in srgb, var(--c-danger) 30%, var(--c-white)); }
.cap-day.full .cap-v { color: var(--danger-ink); }
.cap-day.sun, .sw-sun { background: var(--surface-2); background-image: repeating-linear-gradient(135deg, transparent 0 6px, var(--border) 6px 7px); color: var(--muted); }
.cap-day.hol, .sw-hol { background: var(--warn-soft); border-color: color-mix(in srgb, var(--c-warning) 35%, var(--c-white)); }
.cap-day.hol .cap-v { color: var(--warn); }
.cap-day.next, .sw-next { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); background: var(--primary-soft); }
.cap-day.today .dnum { color: var(--primary); }
.sw-open { background: var(--surface); }
.cap-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .78rem; color: var(--muted); }
.cap-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cap-legend .sw { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; }
.cal a.day .cap-free { font-size: .7rem; font-weight: 600; color: var(--primary); }
.cal a.day.k-full { background: var(--danger-soft); } .cal a.day.k-full .cap-free { color: var(--danger-ink); }
.cal a.day.k-sun { background-color: var(--surface-2); background-image: repeating-linear-gradient(135deg, transparent 0 6px, var(--border) 6px 7px); }
.cal a.day.k-hol { background: var(--warn-soft); } .cal a.day.k-hol .cap-free { color: var(--warn); }
.cal a.day.k-next { box-shadow: inset 0 0 0 2px var(--primary); }
@media (max-width: 640px) { .cap-day { min-height: 46px; padding: 4px 5px; } .cap-v { font-size: .68rem; } }
