/* ============================================================
   Grace Woodworks — design system v2
   Two-tone canvas, boxed panels, clear section dividers.
   ============================================================ */

:root {
  --accent: #059669;
  --accent-strong: #047857;
  --accent-soft: #d9f2e6;

  --bg: #eceef1;            /* canvas — sidebar sits on this */
  --surface: #ffffff;       /* content pane — clean white */
  --surface-2: #f2f3f6;     /* subtle tint for zones */
  --border: #e3e5ea;        /* hairline */
  --text: #17191d;
  --text-dim: #71777f;

  --ok: #0e8a54;   --ok-bg: #e4f4ec;
  --info: #0a66a3; --info-bg: #e3f0fa;
  --mute: #6b7280; --mute-bg: #eef0f3;
  --danger: #c53030; --danger-bg: #fdeceb;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-soft: 0 1px 3px rgba(16, 24, 40, .07), 0 6px 18px rgba(16, 24, 40, .06);
  --shadow-lift: 0 10px 26px rgba(16, 24, 40, .12);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 230px;
  --sidebar-w-narrow: 72px;
}

[data-theme="dark"] {
  --bg: #101012;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --border: #2a2a30;
  --text: #ececee;
  --text-dim: #9a9aa3;

  --accent: #3ecf8e;
  --accent-strong: #6ee7b7;
  --accent-soft: #12271d;

  --ok: #4ade80;   --ok-bg: #12271d;
  --info: #7cc4f8; --info-bg: #11212f;
  --mute: #9a9aa3; --mute-bg: #232328;
  --danger: #f87070; --danger-bg: #301716;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; transition: color .15s ease; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.015em; }

/* ---------- shell: gray canvas + white pane ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 18px 12px 14px;
  transition: width .22s ease;
}
.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; min-width: 0; flex: 1; }
.brand-mark { display: block; border-radius: 10px; flex-shrink: 0; }
.brand-name {
  font-weight: 760; font-size: 13.5px; line-height: 1.2; letter-spacing: -0.01em;
  text-wrap: balance; color: var(--text);
  transition: opacity .15s ease;
}
.sidebar-collapse {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin-top: 4px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text-dim);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .22s ease;
}
.sidebar-collapse:hover { background: var(--surface-2); color: var(--text); }
.sidebar-collapse svg { transition: transform .22s ease; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; scrollbar-width: none; }
.side-nav::-webkit-scrollbar { display: none; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-dim); font-weight: 590; font-size: 13.5px;
  transition: background .12s ease, color .12s ease;
}
.nav-link .icon { flex-shrink: 0; opacity: .72; }
.nav-link:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.nav-link.active {
  background: var(--surface); color: var(--text); font-weight: 680;
  border: 1px solid var(--border);
}
.nav-link.active .icon { opacity: 1; color: var(--accent-strong); }
.nav-sep {
  margin: 20px 12px 7px; font-size: 10px; font-weight: 750;
  letter-spacing: .13em; text-transform: uppercase; color: var(--text-dim);
}
.side-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-link.small { font-size: 12.5px; }
.userchip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  transition: background .12s ease;
}
.userchip:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 800; font-size: 13px;
}
.usermeta { display: flex; flex-direction: column; line-height: 1.3; }
.uname { font-weight: 680; font-size: 13px; color: var(--text); }
.urole { font-size: 11px; font-weight: 560; color: var(--text-dim); }
.logout-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 8px; border: 0; border-radius: var(--radius-sm);
  background: none; cursor: pointer; font-family: inherit;
  color: var(--text-dim); font-weight: 560; font-size: 12.5px;
  transition: background .12s ease, color .12s ease;
}
.logout-btn:hover { background: var(--danger-bg); color: var(--danger); }

html.sidebar-collapsed .sidebar { width: var(--sidebar-w-narrow); }
html.sidebar-collapsed .brand-name,
html.sidebar-collapsed .nav-link span,
html.sidebar-collapsed .nav-sep,
html.sidebar-collapsed .usermeta,
html.sidebar-collapsed .logout-btn span {
  opacity: 0; width: 0; overflow: hidden; white-space: nowrap;
  position: absolute; pointer-events: none;
}
html.sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
html.sidebar-collapsed .nav-link { justify-content: center; padding-left: 10px; padding-right: 10px; }
html.sidebar-collapsed .nav-link.active { border-color: transparent; }
html.sidebar-collapsed .userchip { justify-content: center; padding-left: 8px; padding-right: 8px; }
html.sidebar-collapsed .logout-btn { justify-content: center; }
html.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  transition: margin-left .22s ease;
}
html.sidebar-collapsed .main { margin-left: var(--sidebar-w-narrow); }
.topbar-actions { display: flex; align-items: center; gap: 8px; justify-self: end; grid-column: 3; }
.topbar {
  position: sticky; top: 0; z-index: 25;
  display: grid;
  grid-template-columns: 1fr min(520px, calc(100vw - 120px)) 1fr;
  align-items: center;
  gap: 12px;
  padding: 18px 34px 16px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.page-title { font-size: 25px; font-weight: 760; letter-spacing: -0.022em; line-height: 1.2; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 16px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.content { padding: 24px 34px 60px; width: 100%; }

/* ---------- bottom nav (phones) ---------- */
.bottom-nav { display: none; }
.bn-item { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--text-dim); min-width: 56px; padding: 4px 0; border-radius: 10px; }
.bn-ico { display: flex; align-items: center; justify-content: center; height: 20px; }
.bn-ico svg { width: 19px; height: 19px; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .bottom-nav {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .content { padding: 4px 18px 96px; }
  .topbar { padding: 14px 18px 12px; }
  .page-title { font-size: 21px; }
}

/* ---------- structured sections (boxed panels + clear dividers) ---------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 2px solid color-mix(in srgb, var(--border) 80%, var(--text) 10%);
}
.page-header .page-title { margin-bottom: 0; }
.page-header .breadcrumb { margin-bottom: 6px; }

.page-header .section-lead {
  margin: 8px 0 0; max-width: 680px;
}
.page-header .breadcrumb + .page-title { margin-top: 4px; }

.panel-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card:last-child { margin-bottom: 0; }
.card > h2:first-child,
.card-head h2 {
  font-size: 15px; font-weight: 720; letter-spacing: -0.01em;
  margin: 0 0 14px; padding: 0 0 12px 11px;
  border-left: 3px solid var(--accent);
  border-bottom: 1px solid var(--border);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-bottom: 12px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 {
  margin: 0; padding: 0 0 0 11px;
  border-bottom: 0;
}
.card-head + .stepper,
.card-head + .table-wrap,
.card-head + .grid,
.card-head + form { margin-top: 0; }
.card-head + .section-lead { margin: 0 0 16px; max-width: none; }
.card > h2 + .section-lead {
  margin: 14px 0 16px;
  max-width: none;
}

.card-import .field:last-child { margin-bottom: 0; }

.card-tight { padding: 14px 16px; }
.section-lead {
  margin: -6px 0 14px; max-width: 680px; line-height: 1.45;
  font-size: 12.5px; color: var(--text-dim);
}
.card > .section-lead:first-of-type { margin-top: 0; }

.card .grid-2 > div:has(.kv-label),
.card .grid-3 > div:has(.kv-label) {
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
  border-radius: var(--radius-sm);
}

.summary-strip {
  padding: 16px 18px;
  background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--radius-sm);
}
.summary-strip .summary-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 4px;
}
.summary-strip .summary-value {
  font-size: 28px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.summary-strip .summary-value.accent { color: var(--accent-strong); }

.form-actions {
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

.grid { display: grid; gap: 16px 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--text-dim); }
.small { font-size: 12.5px; }
.mt { margin-top: 18px; }
.num { font-variant-numeric: tabular-nums; }
.kv-value, .tbl td, .forder-title { overflow-wrap: break-word; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 620;
  cursor: pointer; text-decoration: none;
  transition: transform .07s ease, background .14s ease, color .14s ease, box-shadow .14s ease;
}
.btn:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--text) 8%); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 32%, transparent); }
[data-theme="dark"] .btn-primary { color: #06281a; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-big { min-height: 52px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 650;
  background: var(--mute-bg); color: var(--mute);
}
.pill-done { background: var(--ok-bg); color: var(--ok); }
.pill-pending { background: var(--info-bg); color: var(--info); }
.pill-na { background: var(--mute-bg); color: var(--mute); }
.pill-overdue { background: var(--danger-bg); color: var(--danger); }

/* ---------- tables: bordered grid ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-dim);
  padding: 10px 12px; white-space: nowrap;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tbl th.num, .tbl .num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th { white-space: nowrap; }
.tbl td strong, .tbl td:first-child a { white-space: nowrap; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 620; margin-bottom: 6px; color: var(--text-dim); }
.field .hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 8px 11px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 14.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea.input { min-height: 84px; resize: vertical; }

/* file picker: one bordered row aligned like a text input */
.filepick {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 5px 11px 5px 5px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-sizing: border-box;
  transition: border-color .15s ease;
}
.filepick input[type="file"] {
  position: absolute; width: 1px; height: 1px;
  opacity: 0; overflow: hidden; clip: rect(0 0 0 0);
  pointer-events: none;
}
.filepick .filepick-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-shrink: 0;
  height: 30px;
  margin: 0;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 620;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  box-sizing: border-box;
  transition: border-color .15s ease, background .15s ease;
}
.filepick .filepick-btn:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 30%, var(--surface));
}
.filepick .filepick-name {
  flex: 1;
  min-width: 0;
  display: block;
  font-size: 14px;
  line-height: 30px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filepick .filepick-name.has-file { color: var(--text); font-weight: 560; }
.filepick input[type="file"]:focus-visible ~ .filepick-btn {
  outline: none;
  border-color: var(--accent);
  border-width: 2px;
  padding: 0 11px;
}
.filepick:has(input:focus-visible) {
  border-color: var(--accent);
  border-width: 2px;
  padding: 4px 10px 4px 4px;
}

.input:-webkit-autofill,
.input:-webkit-autofill:hover,
select.input:-webkit-autofill,
select.input:-webkit-autofill:hover,
textarea.input:-webkit-autofill,
textarea.input:-webkit-autofill:hover {
  -webkit-box-shadow: 0 0 0 60px var(--surface) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  border-color: var(--border);
}
.input:-webkit-autofill:focus,
select.input:-webkit-autofill:focus,
textarea.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 60px var(--surface) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  border-color: var(--accent);
}

.input:focus,
select.input:focus,
textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  border-width: 2px;
  padding: 7px 10px;
  box-shadow: none;
}
.input.compact { min-height: 36px; padding: 5px 9px; font-size: 13.5px; }
.input.compact:focus { padding: 4px 8px; }

/* date field: hide native dd/mm/yyyy ghost text; show a clear empty hint */
.date-field {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
}
.date-field .input-date {
  flex: 1;
  min-width: 0;
  padding-right: 40px;
}
.date-field-hint {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: color-mix(in srgb, var(--text-dim) 88%, transparent);
  font-size: 14.5px;
  line-height: 1;
}
.date-field.compact .date-field-hint { left: 9px; font-size: 13.5px; }
.input-date.is-empty:not(:focus) + .date-field-hint { display: block; }
.input-date:not(.is-empty) + .date-field-hint,
.input-date:focus + .date-field-hint { display: none; }
.input-date.is-empty:not(:focus)::-webkit-datetime-edit,
.input-date.is-empty:not(:focus)::-webkit-datetime-edit-fields-wrapper,
.input-date.is-empty:not(:focus)::-webkit-datetime-edit-text,
.input-date.is-empty:not(:focus)::-webkit-datetime-edit-month-field,
.input-date.is-empty:not(:focus)::-webkit-datetime-edit-day-field,
.input-date.is-empty:not(:focus)::-webkit-datetime-edit-year-field {
  opacity: 0;
  color: transparent;
}
.input-date::-webkit-calendar-picker-indicator {
  opacity: 0;
  position: absolute;
  right: 0;
  width: 42px;
  height: 100%;
  cursor: pointer;
}
.date-field-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.date-field-btn:hover { color: var(--text); background: var(--surface-2); }
.date-field-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.date-field.compact .date-field-btn { width: 28px; height: 28px; }
.date-field.compact .input-date { padding-right: 34px; }
.check-line { display: inline-flex; align-items: center; gap: 9px; min-height: 40px; cursor: pointer; user-select: none; }
.check-line span { font-size: 14px; color: var(--text); line-height: 1.35; }

.check-line input[type="checkbox"],
.content input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px; height: 20px; flex-shrink: 0; margin: 0;
  border: 1.5px solid color-mix(in srgb, var(--border) 85%, var(--text) 8%);
  border-radius: 6px;
  background: var(--surface); cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.check-line input[type="checkbox"]:checked,
.content input[type="checkbox"]:checked {
  border: 2px solid var(--accent);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.2 6.4 11.1 12.5 5' stroke='%23059669' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}
[data-theme="dark"] .check-line input[type="checkbox"]:checked,
[data-theme="dark"] .content input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.2 6.4 11.1 12.5 5' stroke='%233ecf8e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.check-line input[type="checkbox"]:focus-visible,
.content input[type="checkbox"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  border-width: 2px;
}

/* entity forms: each option is a bordered chip — checked = green ring, no dark fill */
.field-check { margin: 0; height: 100%; display: flex; }
.field-check .check-line {
  display: flex;
  align-items: center;
  width: 100%;
  height: 54px;
  min-height: 54px;
  max-height: 54px;
  padding: 0 12px;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow);
  box-sizing: border-box;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .08s ease;
}
.field-check .check-line .check-label {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 560;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.field-check .check-line:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
}
.field-check .check-line:has(input:checked) {
  border: 2px solid var(--accent);
  padding: 0 11px;
  background: color-mix(in srgb, var(--accent-soft) 42%, var(--surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
}
.field-check .check-line:has(input:checked) .check-label {
  color: var(--accent-strong);
  font-weight: 680;
}
.field-check .check-line:has(input:focus-visible) {
  border-color: var(--accent);
  outline: none;
}
.field-check .check-line:active { transform: scale(.985); }

/* scope of work — iOS-style grouped list: calm, one row per line */
.scope-section {
  margin-top: 22px;
}
.scope-section-title {
  margin: 0 0 8px 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-dim);
}
.scope-section-note {
  margin: -2px 0 8px 4px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--mute);
}
.scope-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.scope-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s ease;
}
.scope-row:last-child { border-bottom: 0; }
.scope-row:active { background: var(--surface-2); }
.scope-row--select-all .scope-row-label {
    font-weight: 600;
}
.scope-row-label {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 450;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--text);
}
.scope-row-check {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin: 0;
  border: 1.5px solid color-mix(in srgb, var(--border) 70%, var(--text) 12%);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.scope-row-check:checked {
  border-color: var(--accent);
  background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 8.2 6.6 10.8 12 5.4' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}
[data-theme="dark"] .scope-row-check:checked {
  background-color: var(--accent);
}
.scope-row-check:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.check-grid-head {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  font-size: 11.5px;
  font-weight: 720;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-dim);
  height: auto;
  min-height: 0;
}
.err { color: var(--danger); font-size: 12.5px; margin-top: 5px; }
.alert-error {
  background: var(--danger-bg); color: var(--danger);
  border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 14px; font-weight: 550;
}

/* ---------- stepper ---------- */
.stepper {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 6px 0 14px;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.step {
  flex: 1 1 0;
  min-width: 112px;
  max-width: 148px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 14px 4px;
  border-right: 1px solid color-mix(in srgb, var(--border) 88%, var(--text) 8%);
  transition: background-color .18s ease;
}
.step:last-child { border-right: 0; }
.step-track { display: flex; align-items: center; width: 100%; margin-bottom: 14px; text-decoration: none; }
.step-track .line { flex: 1; height: 2.5px; border-radius: 3px; background: var(--border); }
.step-track .line.fill { background: var(--ok); }
.step:first-child .line.l, .step:last-child .line.r { visibility: hidden; }
.sdot {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 750; font-size: 12.5px;
  background: var(--surface); border: 2px solid var(--border); color: var(--text-dim);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .15s ease;
}
.sdot .icon { width: 13px; height: 13px; }
.step.done .sdot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.current .sdot { border: 2.5px solid var(--accent); color: var(--accent-strong); animation: current-pulse 2.4s ease-out infinite; }
.step.na .sdot { border-color: var(--mute); color: var(--mute); opacity: .65; }
.step.picked .sdot { background: var(--accent); border-color: var(--accent); color: #fff; }
@keyframes current-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 34%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.step-body { padding: 0 4px; width: 100%; min-height: 118px; }
.step-name {
  display: block;
  font-size: 12.5px;
  font-weight: 680;
  color: var(--text);
  line-height: 1.35;
  padding: 0 2px;
  transition: color .18s ease;
}
a.step-name:hover { color: var(--accent); }
.step.todo .step-name { color: var(--text-dim); font-weight: 600; }
.step.picked .step-name { color: var(--accent-strong); }
.step-meta { font-size: 11px; color: var(--text-dim); margin-top: 6px; min-height: 18px; line-height: 1.35; }
.step-live { color: var(--accent); font-weight: 700; }
.step-opt {
  display: inline-block;
  margin: 6px auto 0;
  font-size: 10px;
  padding: 2px 8px;
  vertical-align: middle;
  min-height: 18px;
}
/* optional tag in kanban column headers */
.col-opt { margin-left: 6px; font-size: 9.5px; padding: 1px 7px; vertical-align: middle; }
.step-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  flex-wrap: wrap;
}
.step.current .step-actions .btn-primary { min-height: 32px; }

.stage-filter-bar { align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-filter-active {
  align-items: center; gap: 8px;
  transition: opacity .18s ease, visibility .18s ease;
}
.stage-filter-active.is-hidden {
  visibility: hidden; opacity: 0; pointer-events: none;
  position: absolute; width: 0; height: 0; overflow: hidden;
}
.stage-section {
  transition: opacity .2s ease, transform .2s ease, margin .2s ease;
  transform-origin: top center;
}
.stage-section.stage-hidden {
  display: none;
}

/* ---------- key-value rows ---------- */
.kv-label { font-size: 11.5px; font-weight: 620; letter-spacing: .03em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 3px; }
.kv-value { font-size: 15px; font-weight: 640; line-height: 1.4; min-height: 22px; }
.kv-value.money-v { color: var(--accent-strong); font-variant-numeric: tabular-nums; }

/* ---------- kanban ---------- */
/* Trello model: the board is a fixed-height horizontal scroller; every column
   stretches to the board height and scrolls its own cards, so stage headers
   stay visible no matter how long the column gets. */
.board {
  display: flex; gap: 14px;
  overflow: auto;
  align-items: stretch;
  padding-bottom: 16px;
  height: calc(100vh - 200px);
  min-height: 340px;
}
.kcol {
  flex: 1 0 212px; min-width: 212px; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--surface-2); border-radius: var(--radius); padding: 10px;
}
.kcol-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 10px;
  flex-shrink: 0;
}
.kcol-body {
  flex: 1 1 auto; min-height: 70px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  border-radius: 10px;
}
.kcol-name { font-weight: 700; font-size: 13.5px; flex: 1 1 auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
.kcol-name .col-opt { flex-shrink: 0; }
.kcol-body.drop-on { outline: 2px dashed var(--accent); outline-offset: 2px; background: var(--accent-soft); }
.kcol-done .kcol-name { color: var(--ok); }
.kcard {
  background: var(--surface); border-radius: 13px; padding: 12px; cursor: grab;
  border: 1px solid var(--border);
  /* horizontal swipe = move the card, vertical swipe still scrolls the column */
  touch-action: pan-y;
}
.kcard[draggable="true"]:active { cursor: grabbing; }
.kcard.dragging {
  opacity: .92; cursor: grabbing; pointer-events: none;
  box-shadow: 0 14px 30px rgba(0,0,0,.24); transform: scale(1.03); z-index: 60;
}
.kcard-title { font-weight: 700; font-size: 13.5px; }
.kcard-money { font-weight: 700; color: var(--accent-strong); font-size: 13px; margin-top: 2px; }
.kcard-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; gap: 8px; }
.kcard-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.kcard-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* station page: this piece's own QR, ready to re-stick */
.station-shell {
  max-width: 680px;
  margin: 0 auto;
}
.station-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.station-header-main { min-width: 0; flex: 1; }
.station-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  margin-bottom: 0;
  font-size: clamp(20px, 4vw, 26px);
}
.station-status { margin-top: 10px; }
.station-details-link { flex-shrink: 0; margin-top: 4px; }
.station-action { padding: 20px 22px; }
.station-qr {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.station-qr img {
  border-radius: 10px;
  background: #fff;
  flex-shrink: 0;
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}
.station-qr-copy { min-width: 0; }
.station-qr strong { font-size: 14px; color: var(--text); display: block; margin-bottom: 4px; }
.station-qr-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--accent-strong);
  text-decoration: none;
}
.station-qr-link:hover { text-decoration: underline; }
.station-complete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--ok-bg);
  color: var(--ok);
  font-weight: 700;
  font-size: 15px;
}
.station-progress .stepper {
  justify-content: center;
  overflow-x: visible;
  padding: 4px 0 10px;
}
.station-stepper .step {
  min-width: 120px;
  max-width: 156px;
  flex: 0 1 156px;
}
.station-stepper .step-body { min-height: 108px; }
.station-spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}
.station-spec-item {
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
  border-radius: var(--radius-sm);
  text-align: center;
}
.station-spec-item .kv-label { margin-bottom: 5px; }
.station-spec-item .kv-value {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  word-break: break-word;
}
@media (max-width: 860px) {
  .station-shell { max-width: none; }
  .station-header { flex-direction: column; align-items: stretch; }
  .station-details-link { align-self: flex-start; }
  .station-progress .stepper { justify-content: flex-start; overflow-x: auto; }
}
.kempty { color: var(--text-dim); font-size: 12px; border: 1.5px dashed var(--border); border-radius: 10px; padding: 14px 10px; text-align: center; }
.kcard-done .kcard-title { color: var(--ok); }
.board-scroll { display: none; gap: 6px; margin-bottom: 10px; }

/* ---------- stats ---------- */
.stat {
  display: block; padding: 16px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.stat:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: var(--shadow-soft);
}
.stat .n { font-size: 30px; font-weight: 780; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.15; }
.stat .l { color: var(--text-dim); font-size: 12.5px; font-weight: 620; margin-top: 2px; }
.stat .money { font-size: 15.5px; font-weight: 760; margin-top: 9px; color: var(--accent-strong); }
.stat .money + .muted { margin-top: 0; }
.stat .muted.small { line-height: 1.35; }
.stat-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent-strong); margin-bottom: 10px;
}

/* ---------- flow diagram: stage chips ---------- */
/* Dot + name live together in one pill, chips wrap and center at every
   width — nothing can stretch, drift, or hide off-screen. */
.flowline { padding: 14px 2px 6px; }
.flowline-track {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 8px 6px;
}
.fchip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  flex: 0 0 auto; max-width: 100%;
  text-decoration: none; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.fchip:hover { border-color: var(--text-dim); }
.fchip-dot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1.5px solid var(--border);
  font-weight: 780; font-size: 12.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.fchip-name { font-size: 12.5px; font-weight: 700; color: var(--text-dim); white-space: nowrap; }
.fchip.hot { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.fchip.hot .fchip-dot { border-color: var(--accent); color: var(--accent-strong); }
.fchip.hot .fchip-name { color: var(--text); }
.fchip.done { background: var(--ok-bg); border-color: transparent; }
.fchip.done .fchip-dot { background: var(--surface); border-color: transparent; color: var(--ok); }
.fchip.done .fchip-name { color: var(--ok); }
/* selected: a quiet highlight — tinted pill, green ring, filled count dot.
   NOTE: keep this class fchip-sel — a bare "sel" collides with .sel dropdowns */
.fchip.fchip-sel { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.fchip.fchip-sel .fchip-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.fchip.fchip-sel .fchip-name { color: var(--accent-strong); }
.fchip-warn { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex-shrink: 0; }
.fchip-warn.stuck { background: #e8960c; }
.fchip-stale { font-size: 10.5px; font-weight: 750; color: #b45309; }
.fchip-sep { color: var(--text-dim); display: inline-flex; opacity: .7; }
.flow-open {
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.flow-open h3 {
  font-size: 14px; font-weight: 720; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}
.forder {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.forder:last-child { margin-bottom: 0; }
.forder-title { font-weight: 700; font-size: 14px; }
.forder:hover .forder-title { color: var(--accent); }
.forder-money { font-weight: 750; color: var(--accent-strong); }

/* ---------- inline quick-add ---------- */
/* quick-add lives inside the table as a footer row: inputs share the exact column widths */
.qadd .table-wrap { overflow-x: auto; }
.tbl-qadd {
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}
.tbl-qadd th,
.tbl-qadd tbody td,
.tbl-qadd .qadd-row td {
  border-right: 1px solid color-mix(in srgb, var(--border) 86%, var(--text) 10%);
  vertical-align: middle;
}
.tbl-qadd thead th:last-child,
.tbl-qadd tbody td:last-child,
.tbl-qadd .qadd-row td:last-child { border-right: 0; }
.tbl-qadd th { min-width: max-content; padding: 12px 14px; }
.tbl-qadd tbody td { padding: 12px 14px; }
.qadd-rate {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  justify-content: flex-start;
}
.qadd-rate label { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.qadd-rate select { width: auto; min-width: 240px; flex: 1 1 280px; max-width: 480px; }
.tbl-qadd .qadd-row td {
  padding: 14px 16px;
  background: color-mix(in srgb, var(--surface-2) 85%, var(--accent-soft));
  border-top: 2px solid var(--border);
  border-bottom: 0;
}
.tbl-qadd .qadd-row input, .tbl-qadd .qadd-row select {
  width: auto; min-width: 100%; max-width: none;
  height: 40px; padding: 0 14px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 9px;
  box-sizing: border-box;
}
.tbl-qadd .qadd-row td:has(select),
.tbl-qadd .qadd-row td:has(.sel) {
  width: 1%;
  white-space: nowrap;
}
.tbl-qadd .qadd-row td.num input { min-width: 96px; }
.tbl-qadd .qadd-row td.qadd-remarks input { min-width: 140px; }
.tbl-qadd .qadd-row td:not(.num):not(.qadd-add):not(.qadd-remarks) input { min-width: 96px; }
.tbl-qadd .qadd-row input:focus, .tbl-qadd .qadd-row select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.tbl-qadd .qadd-row input[type="number"],
.tbl-qadd .qadd-row td.num input[type="number"] {
  text-align: right;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 14px;
  padding-right: 3rem; /* gap between digits and stepper */
  -moz-appearance: textfield;
  appearance: textfield;
}
.tbl-qadd .qadd-row input[type="number"]:focus,
.tbl-qadd .qadd-row td.num input[type="number"]:focus {
  padding-left: 13px;
  padding-right: calc(3rem - 1px);
}
.tbl-qadd .qadd-row input[type="number"]::-webkit-outer-spin-button,
.tbl-qadd .qadd-row td.num input[type="number"]::-webkit-outer-spin-button,
.tbl-qadd .qadd-row input[type="number"]::-webkit-inner-spin-button,
.tbl-qadd .qadd-row td.num input[type="number"]::-webkit-inner-spin-button {
  opacity: 1;
  margin-left: 8px;
}
.tbl-qadd .qadd-row input::placeholder { color: color-mix(in srgb, var(--text-dim) 78%, transparent); }
.tbl-qadd .qadd-add { display: flex; justify-content: flex-end; padding-left: 16px; white-space: nowrap; }
.tbl-qadd .qadd-add button { min-height: 40px; padding: 0 18px; font-weight: 650; }
.tbl-qadd .tbl-empty { color: var(--text-dim); font-size: 13px; padding: 20px 14px; text-align: left; }

/* ---------- empty state ---------- */
.empty {
  text-align: center; padding: 36px 22px;
  background: var(--surface-2);
  border: 1px dashed color-mix(in srgb, var(--border) 85%, var(--text) 8%);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}
.empty-icon {
  width: 60px; height: 60px; border-radius: 18px;
  background: var(--surface-2); color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty .title { font-weight: 700; color: var(--text); font-size: 15.5px; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

/* ---------- segmented control ---------- */
.seg {
  display: inline-flex; padding: 2px; gap: 2px; flex-wrap: wrap;
  background: var(--surface-2); border-radius: 9px;
}
.seg a {
  padding: 4px 14px; border-radius: 7px; white-space: nowrap;
  font-size: 12.5px; font-weight: 650; color: var(--text-dim);
  transition: background .12s ease, color .12s ease;
}
.seg a:hover { color: var(--text); }
.seg a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.13); }

/* ---------- search ---------- */
.search-box { position: relative; max-width: 100%; }
.search-box .icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-dim); pointer-events: none;
}
.search-box .input { padding-left: 32px; }

/* ---------- toasts ---------- */
#toastHost { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: var(--bg);
  padding: 10px 20px; border-radius: 999px; font-weight: 620; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- login — split brand / sign-in ---------- */
.lg-body { margin: 0; }
.lg-shell { display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); min-height: 100vh; }

.lg-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 56px 64px;
  background: #2a1a0e;
  color: #f6ecdc;
}
.lg-rings {
  position: absolute; right: -140px; bottom: -160px; width: 820px; height: 820px;
  opacity: .9; pointer-events: none;
  animation: lg-drift 36s ease-in-out infinite alternate;
}
@keyframes lg-drift { from { transform: translate3d(0, 0, 0) rotate(0deg); } to { transform: translate3d(-18px, 14px, 0) rotate(2.2deg); } }

.lg-hero-inner { position: relative; max-width: 430px; }
.lg-eyebrow {
  font-size: 11.5px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase;
  color: #d8b98a; margin-bottom: 18px;
}
.lg-line {
  font-size: 52px; line-height: 1.04; font-weight: 800; letter-spacing: -.025em;
  margin: 0 0 18px;
}
.lg-sub { font-size: 16.5px; line-height: 1.55; color: rgba(246, 236, 220, .78); margin: 0 0 30px; }
.lg-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.lg-points li { display: flex; align-items: center; gap: 11px; font-size: 14.5px; font-weight: 650; color: rgba(246, 236, 220, .9); }
.lg-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #8fce6a;
}
.lg-hero-foot {
  position: relative; font-size: 12px; letter-spacing: .06em;
  color: rgba(246, 236, 220, .45); font-weight: 650;
}

.lg-panel { display: grid; place-items: center; padding: 40px 32px; background: var(--bg); }
.lg-card {
  width: 100%; max-width: 384px;
  animation: lg-rise .5s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes lg-rise { from { opacity: 0; } to { opacity: 1; } }

.lg-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 34px; }
.lg-brand-name { font-size: 16.5px; font-weight: 780; letter-spacing: -.01em; }
.lg-title { font-size: 30px; font-weight: 800; letter-spacing: -.022em; margin: 0 0 6px; }
.lg-lead { margin: 0 0 26px; color: var(--text-dim); font-size: 15px; }

.lg-alert {
  display: flex; align-items: center; gap: 8px;
  background: var(--danger-bg, #fdecec); color: var(--danger, #c53030);
  font-size: 13.5px; font-weight: 650;
  border-radius: 12px; padding: 11px 14px; margin: 0 0 16px;
}
.lg-form { display: grid; gap: 18px; }
.lg-field { display: grid; gap: 7px; }
.lg-field label {
  font-size: 12px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-dim);
}
.lg-input {
  width: 100%; height: 50px; padding: 0 16px;
  font: inherit; font-size: 15.5px; color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.lg-input::placeholder { color: var(--text-dim); opacity: .65; }
.lg-input:focus {
  outline: none; border-color: var(--accent); border-width: 2px;
  box-shadow: none; padding: 0 15px;
}
.lg-input:-webkit-autofill,
.lg-input:-webkit-autofill:hover,
.lg-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 60px var(--surface) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  border-color: var(--border);
  border-radius: 13px;
}

.lg-pass { position: relative; }
.lg-pass .lg-input { padding-right: 52px; }
.lg-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-dim);
  display: grid; place-items: center; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.lg-eye:hover { background: var(--surface-2); color: var(--text); }
.lg-eye svg[hidden] { display: none; } /* the HTML hidden attr doesn't apply to inline SVG */

.lg-submit {
  margin-top: 6px; height: 52px; border: 0; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  font: inherit; font-size: 16px; font-weight: 800; color: #fff;
  background: var(--accent);
  cursor: pointer; transition: background .14s ease;
}
.lg-submit:hover { background: var(--accent-strong); }
.lg-submit:active { filter: brightness(.97); }

.lg-foot { margin-top: 34px; font-size: 12px; color: var(--text-dim); letter-spacing: .04em; }

@media (max-width: 880px) {
  .lg-shell { grid-template-columns: 1fr; }
  .lg-hero { padding: 34px 28px 38px; gap: 20px; }
  .lg-line { font-size: 34px; }
  .lg-sub { font-size: 14.5px; margin-bottom: 18px; }
  .lg-points { display: none; }
  .lg-hero-foot { display: none; }
  .lg-rings { right: -220px; bottom: -260px; width: 640px; height: 640px; }
  .lg-panel { padding: 34px 24px 44px; align-items: start; }
  .lg-card { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .lg-rings { animation: none; }
  .lg-card { animation: none; }
}

[data-theme="dark"] .lg-hero { background: #180e06; }

/* ---------- QR pop-up ---------- */
#qrModal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; }
.qr-backdrop { position: absolute; inset: 0; background: rgba(12, 14, 18, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.qr-card {
  position: relative; z-index: 1; width: min(320px, calc(100vw - 40px));
  background: var(--surface); border-radius: 18px; padding: 22px 22px 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.35); text-align: center;
  animation: qr-in .18s cubic-bezier(.2,.7,.2,1);
}
@keyframes qr-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.qr-close {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px;
  border: 0; border-radius: 8px; background: var(--surface-2); color: var(--text-dim);
  display: grid; place-items: center; cursor: pointer;
}
.qr-close:hover { color: var(--text); }
.qr-title { font-weight: 750; font-size: 15px; letter-spacing: -.01em; margin-bottom: 6px; overflow-wrap: anywhere; }
.qr-subtitle { font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px; overflow-wrap: anywhere; }
.qr-img { width: 216px; height: 216px; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: #fff; }
.qr-img.dense { width: 240px; height: 240px; image-rendering: auto; }
.qr-url { font: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--text-dim); margin-top: 10px; overflow-wrap: anywhere; }
.qr-hint { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.qr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
body.qr-open { overflow: hidden; }

/* small QR affordance on kanban cards */
.kqr {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text-dim); cursor: pointer;
  transition: border-color .12s ease, color .12s ease;
}
.kqr:hover { border-color: var(--accent); color: var(--accent-strong); }
.kqr svg { width: 15px; height: 15px; }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ---------- focus ---------- */
:focus { outline: none; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- motion ---------- */
.content { animation: content-in .22s ease-out; }
@keyframes content-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- print ---------- */
.print-page { background: var(--surface); }
.pt-doc { background: #fff; color: #111; max-width: 800px; margin: 0 auto; padding: 34px 38px; border-radius: var(--radius); }
.pt-doc h1 { font-size: 21px; margin-bottom: 6px; }
.pt-doc p { margin: 4px 0; }
.pt-section {
  font-size: 12px; font-weight: 750; margin: 22px 0 7px;
  text-transform: uppercase; letter-spacing: .08em; color: #444;
}
.pt-doc h1 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.pt-doc p { margin: 4px 0; font-size: 13px; color: #333; }
.pt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pt-table th, .pt-table td { border: 1px solid #cfcfcf; padding: 6px 9px; text-align: left; }
.pt-table th {
  background: #f3f4f6; font-size: 11px; font-weight: 750;
  text-transform: uppercase; letter-spacing: .05em; color: #555;
}
.pt-table td.num, .pt-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pt-none { color: #888; font-size: 13px; }
.pt-totals { margin-top: 18px; margin-left: auto; width: 300px; border-collapse: collapse; font-size: 13.5px; }
.pt-totals td { padding: 6px 9px; }
.pt-totals td:first-child { color: #555; }
.pt-totals td:last-child { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.pt-grand td { font-weight: 800; font-size: 15px; border-top: 2px solid #111; }
.pt-signs { display: flex; justify-content: space-between; margin-top: 56px; font-size: 13px; }
.pt-signs div { border-top: 1px solid #111; padding-top: 6px; width: 30%; text-align: center; color: #333; }

@media print {
  .sidebar, .bottom-nav, .topbar, .no-print, #toastHost { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .pt-doc { border-radius: 0; padding: 10mm 8mm; max-width: none; }
  body { background: #fff; }
}

/* ---------- stepper: vertical timeline on phones/tablets ---------- */
@media (max-width: 860px) {
  .stepper { flex-direction: column; overflow-x: visible; padding: 0; }
  .step {
    flex-direction: row; align-items: flex-start; text-align: left;
    width: 100%; min-width: 0; max-width: none;
    padding: 0 0 4px;
    border-right: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 88%, var(--text) 8%);
  }
  .step:last-child { border-bottom: 0; }
  .step-track { width: 34px; flex-direction: column; align-self: stretch; min-height: 72px; margin: 0 12px 0 0; }
  .step-track .line { width: 3px; height: auto; flex: 1; }
  /* no leading segment: the dot tops out level with the stage name */
  .step-track .line.l { flex: 0 0 0; }
  .step:last-child .step-track { min-height: 34px; }
  .step-body { padding: 2px 0 14px; width: auto; }
  .step-name { padding: 0; }
  .step-opt { margin: 6px 0 0; }
  .step-actions { justify-content: flex-start; margin-top: 8px; }
}

/* ---------- skip link ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 200;
  background: var(--accent); color: #fff;
  padding: 8px 16px; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { left: 8px; color: #fff; }

/* ---------- piece label sheet ---------- */
.labels-page {
  min-height: 100vh;
  background: color-mix(in srgb, var(--surface-2) 38%, var(--surface));
}
.labels-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  padding: 12px 20px;
}
.labels-topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.labels-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.labels-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}
.labels-header {
  text-align: center;
  margin-bottom: 28px;
  padding: 26px 28px 24px;
}
.labels-header-kicker {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.labels-title {
  margin: 0;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.labels-customer {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text-dim);
}
.labels-lead {
  max-width: 560px;
  margin: 14px auto 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-dim);
}
.labels-count { margin-top: 16px; }
.labels-empty { max-width: 420px; margin: 0 auto; }
.label-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}
.label-tile {
  width: min(100%, 276px);
  background: #fff;
  color: #111;
  border: 1px solid color-mix(in srgb, var(--border) 70%, #ccc);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  break-inside: avoid;
  page-break-inside: avoid;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .04);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.labels-page:not(.print-single) .label-tile:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  box-shadow: 0 6px 20px rgba(16, 24, 40, .08);
}
.label-qr {
  width: 82px;
  height: 82px;
  image-rendering: pixelated;
  flex-shrink: 0;
  padding: 5px;
  background: #fafafa;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
}
.label-info { min-width: 0; flex: 1; text-align: left; }
.label-title {
  display: block;
  font-weight: 750;
  font-size: 14px;
  color: #111;
  line-height: 1.35;
  margin-bottom: 6px;
  text-decoration: none;
}
.label-title:hover { color: var(--accent-strong); }
.label-meta { font-size: 11.5px; color: #555; line-height: 1.45; }
.label-meta + .label-meta { margin-top: 3px; }
@media print {
  .labels-page { background: #fff; }
  .labels-shell { max-width: none; padding: 0; margin: 0; }
  .label-tile { border-color: #bbb; box-shadow: none; transform: none; width: auto; }
}
.print-single .label-grid {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}
.print-single .label-tile {
  width: min(100%, 320px);
  padding: 16px;
}
.print-single .label-qr { width: 112px; height: 112px; }
@media (max-width: 640px) {
  .labels-topbar-inner { justify-content: center; }
  .labels-topbar-actions { width: 100%; justify-content: center; }
  .labels-shell { padding: 20px 16px 48px; }
  .labels-header { padding: 20px 18px; }
}

/* ---------- station queue ---------- */
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.qcard {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--surface); border-radius: var(--radius-sm); padding: 14px 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.qcard-title { font-weight: 750; font-size: 15px; }
.qcard-title:hover { color: var(--accent); }
.seg a.active { background: var(--accent); color: #fff; box-shadow: none; font-weight: 750; }

/* ---------- onboarding ---------- */
.onboarding .step-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-2); border-radius: 12px; padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow .12s ease, transform .12s ease, background .12s ease;
}
.onboarding .step-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); background: var(--surface); }
.step-n {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; margin-bottom: 6px;
}
.step-t { font-weight: 720; font-size: 14.5px; }
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 200;
  background: var(--accent); color: #fff;
  padding: 8px 16px; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { left: 8px; color: #fff; }

/* ---------- admin settings ---------- */
.settings-brand { padding-bottom: 18px; }
.settings-brand-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  margin-bottom: 10px;
}
.settings-brand-mark { display: flex; align-items: center; gap: 14px; min-width: 0; }
.settings-brand-name { font-size: 18px; font-weight: 780; letter-spacing: -0.02em; line-height: 1.2; }
.settings-brand-tag {
  margin-top: 3px; font-size: 11.5px; font-weight: 650;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim);
}
.settings-lock { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; }
.settings-brand-note { margin: 0 0 16px; max-width: 620px; line-height: 1.45; }
.settings-kv-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 18px;
}
.settings-kv {
  background: var(--surface-2); border-radius: 12px; padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}
.settings-kv-k {
  display: block; font-size: 11px; font-weight: 720; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 4px;
}
.settings-kv-v { display: block; font-size: 13.5px; font-weight: 620; line-height: 1.4; color: var(--text); }
.settings-lead { margin: -4px 0 14px; max-width: 640px; line-height: 1.45; }
.settings-inline-form {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.settings-field-inline { margin: 0; flex: 1; min-width: 220px; }
.settings-num-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.settings-num { width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.settings-empty {
  text-align: center; padding: 28px 18px 22px; margin-bottom: 8px;
  background: var(--surface-2); border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--border) 85%, var(--text) 8%);
}
.settings-empty .title { font-size: 14.5px; margin-bottom: 3px; }
.settings-empty .empty-icon { margin-bottom: 8px; }
.settings-tbl .settings-row-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.settings-tbl .settings-row-form .input { flex: 1; min-width: 180px; }
.settings-key {
  font-size: 12.5px; font-weight: 650; padding: 3px 8px; border-radius: 7px;
  background: color-mix(in srgb, var(--surface-2) 80%, var(--accent-soft));
  color: var(--accent-strong);
}
.settings-add {
  margin-top: 18px; padding-top: 18px;
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}
@media (max-width: 700px) {
  .settings-brand-head { flex-direction: column; align-items: stretch; }
  .settings-inline-form { flex-direction: column; align-items: stretch; }
  .settings-inline-form .btn { align-self: flex-start; }
}

.muted.tiny { font-size: 11px; }

/* ---------- topbar global search ---------- */
.topsearch {
  grid-column: 2;
  width: 100%;
  justify-self: center;
}
.topbar .topbar-actions .icon-btn {
  grid-column: auto;
  justify-self: auto;
}
.search-box-premium { width: 100%; }
.search-box-premium .icon {
  left: 16px;
  width: 16px;
  height: 16px;
  color: color-mix(in srgb, var(--text-dim) 80%, var(--accent) 20%);
}
.search-box-premium .input {
  width: 100%;
  min-height: 44px;
  padding: 0 18px 0 44px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 75%, var(--text) 10%);
  background: color-mix(in srgb, var(--surface-2) 50%, var(--surface));
  box-shadow:
    0 1px 2px rgba(16, 24, 40, .05),
    inset 0 1px 0 color-mix(in srgb, #fff 55%, transparent);
  font-size: 14.5px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
[data-theme="dark"] .search-box-premium .input {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, .22),
    inset 0 1px 0 rgba(255, 255, 255, .04);
}
.search-box-premium .input::placeholder { color: color-mix(in srgb, var(--text-dim) 88%, transparent); }
.search-box-premium .input:hover {
  border-color: color-mix(in srgb, var(--border) 55%, var(--text) 18%);
  background: var(--surface);
}
.search-box-premium .input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 6px 18px rgba(16, 24, 40, .08);
}
@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 14px 18px 12px;
  }
  .topsearch { grid-column: 1; justify-self: stretch; width: 100%; max-width: none; }
  .topbar-actions { grid-column: 2; }
}

/* ---------- label sheet print rules ---------- */
@media print {
  .label-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 6mm;
    justify-content: stretch;
  }
  .label-tile { border: 1px dashed #bbb; box-shadow: none; transform: none; width: auto; }
}

/* ---------- station page (phone scan target) ---------- */
.station-done {
    width: 100%;
    max-width: none;
    min-height: 56px;
    font-size: 18px;
    font-weight: 800;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.station-done svg { width: 22px; height: 22px; }

/* ---------- scan page ---------- */
.scan-frame {
    background: var(--canvas, #111);
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
}
.scan-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- placeholder cheat sheet (template editor) ---------- */
.ph-sheet { display: grid; gap: 14px; margin-bottom: 16px; }
.ph-head { font-size: 11.5px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 7px; }
.ph-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.ph-chip {
  font: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 9px; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.ph-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.ph-chip span { font-family: var(--font, inherit); color: var(--text-dim); margin-left: 5px; }

/* ---------- phones: no sideways scrolling anywhere ----------
   Tables become stacked cards (label left, value right). Kanban columns
   stack vertically. Quick-add fields go full width. */

@media (max-width: 700px) {
  .board-scroll { display: none; }
  /* stacked sections: the page scrolls, not the board — undo the desktop
     fixed-height/inner-scroll model entirely */
  .board { display: block; overflow: visible; height: auto; min-height: 0; padding-bottom: 0; }
  .kcol { width: 100%; min-width: 0; margin: 0 0 14px; display: block; }
  .kcol-body { overflow: visible; min-height: 70px; }

  .table-wrap { overflow-x: visible; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tbody tr {
    display: block; background: var(--surface);
    border: 1px solid var(--border); border-radius: 14px;
    padding: 3px 14px; margin: 0 0 10px;
  }
  .tbl tbody tr td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
    padding: 8px 0; border-bottom: 0;
  }
  .tbl tbody tr td::before {
    content: attr(data-label);
    font-size: 12px; font-weight: 720; color: var(--text-dim);
    flex-shrink: 0;
  }
  .tbl tbody tr td[data-label=""]::before { content: none; }
  .tbl tbody tr td:empty { display: none; }
  .tbl tbody tr td:first-child { padding-top: 11px; font-size: 14.5px; }
  .tbl tbody tr td:last-child { padding-bottom: 11px; }
  .tbl tbody tr td[data-label=""] { justify-content: flex-end; }
  .tbl tbody tr td.num { text-align: right; font-variant-numeric: tabular-nums; }
  /* inline desktop widths inside cards (nowrap rows, fixed inputs) must give way */
  .tbl tbody tr td form.row { flex-wrap: wrap !important; }
  .tbl tbody tr td form.row .input { width: 100% !important; }
  /* inline desktop widths (width:1% action cells etc.) must not survive card mode */
  .tbl tbody tr td { width: auto !important; min-width: 0; white-space: normal !important; }
  /* long machine codes etc. must wrap inside the card; desktop keeps break-word */
  .tbl td { overflow-wrap: anywhere; }
  .tbl tbody tr td > * { min-width: 0; max-width: 100%; }

  /* quick-add: the footer row becomes a stacked mini form */
  .tbl-qadd thead { display: none; }
  .tbl-qadd th,
  .tbl-qadd tbody td,
  .tbl-qadd .qadd-row td { border-right: 0; }
  .tbl-qadd tfoot, .tbl-qadd tfoot tr { display: block; }
  .tbl-qadd .qadd-row {
    display: block; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 14px;
    padding: 6px 12px 10px; margin: 10px 0 12px;
  }
  .tbl-qadd .qadd-row td { display: block; padding: 5px 0; background: transparent; width: auto !important; white-space: normal !important; }
  .tbl-qadd .qadd-row td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 4px;
  }
  .tbl-qadd .qadd-row input, .tbl-qadd .qadd-row select {
    width: 100%; text-align: left; min-width: 0; height: 44px; font-size: 15px;
  }
  .tbl-qadd .qadd-add button { width: 100%; height: 46px; }
  .qadd-rate { flex-wrap: wrap; }
  .qadd-rate select { flex: 1 1 100%; }
}

@media (min-width: 701px) {
  .tbl tbody tr td[data-label] { /* desktop: labels are invisible */ }
}

/* ---------- nesting diagram: pieces fitted inside parent boards ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: flex-end; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 680; color: var(--text-dim); }
.legend-swatch { width: 11px; height: 11px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--text) 22%, transparent); display: inline-block; }
.nest-board { margin: 0 0 20px; }
.nest-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 12.5px; color: var(--text-dim); flex-wrap: wrap; }
.nest-head-meta { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.nest-head strong { font-size: 13.5px; color: var(--text); }
.nest-canvas {
  position: relative; width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden;
}
.nest-rect {
  position: absolute; overflow: hidden;
  border: 1.5px solid color-mix(in srgb, var(--text) 32%, transparent);
  border-radius: 4px; display: flex; align-items: flex-start;
  padding: 0; margin: 0; font: inherit; text-align: left;
}
button.nest-rect {
  cursor: pointer;
  transition: box-shadow .12s ease, transform .12s ease;
}
button.nest-rect:hover,
button.nest-rect:focus-visible {
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  transform: translateY(-1px);
  outline: 2px solid var(--accent); outline-offset: 1px;
  z-index: 2;
}
.nest-label {
  font-size: 10.5px; font-weight: 750; color: rgba(0,0,0,.62);
  padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

/* kanban card: shape thumb + typographic hierarchy *//* kanban card: shape thumb + typographic hierarchy */
.kc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.kc-thumb {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.pc-rect { border: 1.5px solid color-mix(in srgb, var(--text) 26%, transparent); border-radius: 3px; }
.kc-name { font-size: 13.5px; font-weight: 720; letter-spacing: -.01em; line-height: 1.2; }
.kc-sub { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.kc-dims {
  font-size: 11.5px; font-weight: 650; color: var(--text-dim);
  font-variant-numeric: tabular-nums; margin: 0 0 7px;
}
@media (max-width: 700px) {
  :root { --cms: .62; }
  .cm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cm-canvas { height: 118px; }
  /* tiny rects can't hold readable labels on a phone — shapes carry the info */
  .cm-tag { display: none; }
  .nest-head { flex-direction: column; align-items: flex-start; gap: 2px; }
}

/* ---------- flow editor (admin: drag stages into order) ---------- */
.flow {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px 6px;
}
.flow-card {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 5px 6px 5px 9px;
}
.flow-card.dragging { opacity: .9; box-shadow: var(--shadow-lift); }
.flow-grip { display: inline-flex; color: var(--text-dim); cursor: grab; touch-action: none; }
.flow-name {
  font: inherit; font-size: 13.5px; font-weight: 650; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 9px; width: 150px;
}
.flow-name:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.flow-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-dim); cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.flow-del:hover { background: var(--danger-bg); color: var(--danger); }
.flow-seq { color: var(--text-dim); font-size: 12px; font-weight: 750; min-width: 14px; text-align: right; }
.flow-arrow { color: var(--text-dim); font-weight: 700; }
.flow-opt {
  border: 1px solid var(--border); border-radius: 99px;
  background: var(--surface); color: var(--text-dim);
  font: inherit; font-size: 10.5px; font-weight: 750; letter-spacing: .04em;
  padding: 3px 8px; cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.flow-opt:hover { border-color: var(--accent); color: var(--accent-strong); }
.flow-opt.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.flow-opt:disabled { opacity: .6; cursor: default; }
.flow-add { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.flow-add input {
  min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 14.5px;
}
.flow-add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- cut calculator ---------- */
.calc-table-wrap { overflow-x: auto; }
.tbl-calc { min-width: 860px; }
.tbl-calc td, .tbl-calc th { white-space: nowrap; }
.tbl-calc td {
  border-bottom: 1px solid color-mix(in srgb, var(--text) 16%, var(--border));
}
.tbl-calc tbody tr:last-child td { border-bottom: 1px solid color-mix(in srgb, var(--text) 16%, var(--border)); }
.tbl-calc .input.compact { min-width: 70px; }
.tbl-calc .c-no { color: var(--text-dim); font-weight: 650; text-align: center; }
.tbl-calc td.neg, .tbl-calc .neg { color: var(--danger); font-weight: 750; }

.tbl-calc .calc-g-hd {
  padding: 7px 10px 6px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface-2);
  border-bottom: 1px solid color-mix(in srgb, var(--text) 18%, var(--border));
  text-align: left;
}
.tbl-calc .calc-g-hd.calc-g-mm,
.tbl-calc .calc-g-hd.calc-g-left { text-align: center; }
.tbl-calc .calc-g-sep {
  border-left: 2px solid color-mix(in srgb, var(--text) 22%, var(--border));
}
.tbl-calc .calc-cols th {
  font-size: 12.5px;
  color: var(--text-dim);
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--text) 18%, var(--border));
}
.tbl-calc td.calc-g-mm,
.tbl-calc td.calc-g-left {
  font-weight: 650;
  color: var(--text);
}
.tbl-calc td.calc-g-mm {
  background: color-mix(in srgb, var(--info-bg) 42%, var(--surface));
}
.tbl-calc td.calc-g-left {
  background: color-mix(in srgb, var(--accent-soft) 52%, var(--surface));
}
.tbl-calc tbody tr:hover td.calc-g-mm {
  background: color-mix(in srgb, var(--info-bg) 58%, var(--surface-2));
}
.tbl-calc tbody tr:hover td.calc-g-left {
  background: color-mix(in srgb, var(--accent-soft) 68%, var(--surface-2));
}
.tbl-calc .calc-g-act { width: 76px; text-align: center; padding-left: 8px; padding-right: 8px; }
.tbl-calc .calc-row-actions { display: inline-flex; gap: 4px; align-items: center; justify-content: center; }
.tbl-calc .calc-clr,
.tbl-calc .calc-rm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-dim);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.tbl-calc .calc-clr:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.tbl-calc .calc-rm:hover {
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
}
.tbl-calc .calc-clr:active,
.tbl-calc .calc-rm:active { transform: scale(.94); }
.tbl-calc input.calc-bad {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger-bg) 70%, var(--surface));
}

@@media (max-width: 900px) {
  .tbl-calc .calc-groups { display: none; }
}

@@media print {
  .tbl-calc .calc-g-hd,
  .tbl-calc .calc-cols th,
  .tbl-calc td { border: 1px solid #999 !important; background: #fff !important; color: #000 !important; }
  .tbl-calc .calc-g-sep { border-left: 2px solid #666 !important; }
  .tbl-calc td.neg, .tbl-calc .neg { color: #000 !important; font-weight: 800 !important; }
}

/* ---------- first-run setup ---------- */
.setup-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.setup-card {
  width: min(440px, 100%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 26px 26px 20px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .10);
}
.setup-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.setup-title { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.setup-sub { font-size: 12.5px; color: var(--text-dim); }
.setup-alert {
  display: flex; align-items: center; gap: 8px;
  background: var(--danger-bg); color: var(--danger);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
  font-size: 13px; font-weight: 650;
}
.setup-form { display: grid; gap: 6px; }
.setup-label { font-size: 12px; font-weight: 700; color: var(--text-dim); margin-top: 8px; }
.setup-optional { font-weight: 550; opacity: .8; }
.setup-input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.setup-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.setup-hint { font-size: 11.5px; color: var(--text-dim); margin: 4px 0 2px; }
.setup-submit {
  margin-top: 16px; min-height: 48px; border: 0; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 800; color: #fff;
  background: var(--accent); cursor: pointer; width: 100%;
  transition: background .15s ease;
}
.setup-submit:hover { background: var(--accent-strong); }
.setup-foot { margin-top: 16px; font-size: 11.5px; color: var(--text-dim); text-align: center; }

/* ---------- account: change password ---------- */
.pw-card { max-width: 460px; margin: 0 auto; }
.pw-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.pw-lock {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-strong);
  display: inline-flex; align-items: center; justify-content: center;
}
.pw-field { position: relative; }
.pw-field .input { padding-right: 42px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-dim);
  display: grid; place-items: center; cursor: pointer;
}
.pw-eye:hover { background: var(--surface-2); color: var(--text); }

/* ---------- dropdowns: styled trigger + panel over native selects ---------- */
.sel-native { display: none !important; }
.sel {
  position: relative; width: 100%; max-width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 42px; padding: 0 12px;
  font: inherit; font-size: 14px; color: var(--text); text-align: left;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 11px;
  cursor: pointer; transition: border-color .13s ease;
}
.sel.compact { height: 38px; font-size: 13.5px; border-radius: 9px; }
.sel:hover { border-color: var(--text-dim); }
.sel.open, .sel:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.sel-text { white-space: nowrap; flex: 1 1 auto; }
.sel-text.sel-placeholder { color: var(--text-dim); }
.sel-chev { flex-shrink: 0; color: var(--text-dim); display: flex; transition: transform .15s ease; }
.sel.open .sel-chev { transform: rotate(180deg); }
.sel-panel {
  position: absolute; z-index: 96; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.16);
  max-height: 264px; overflow-y: auto; padding: 5px;
}
.sel-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: 8px; font-size: 13.5px; color: var(--text);
  cursor: pointer;
}
.sel-opt:hover, .sel-opt.hl { background: var(--surface-2); }
.sel-opt.sel-sel { font-weight: 720; }
.sel-opt .tick { color: var(--accent-strong); font-weight: 800; }
@media (max-width: 700px) {
  .sel { display: none !important; }
  select.input, .sel-native {
    display: block !important;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 14px;
    padding-right: 36px;
  }
}

/* ---------- phones: refinement pass (Apple-scale rhythm, touch targets, no zoom) ---------- */
@media (max-width: 700px) {
  /* iOS zooms into inputs with font-size < 16px — keep every field at 16 */
  .content input, .content select, .content textarea { font-size: 16px; }
  .content input[type="checkbox"], .content input[type="radio"] { font-size: inherit; }

  /* dashboard stats: compact 3-across tiles instead of a tall stack */
  .grid.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 2px 0; }
  .stat .n { font-size: 22px; }
  .stat .l { font-size: 10.5px; margin-top: 1px; }
  .stat .money { font-size: 12.5px; margin-top: 5px; }
  .stat .muted.small { font-size: 10px; }
  .stat-ico svg { width: 16px; height: 16px; }
  .stat-ico { margin-bottom: 4px; }

  /* order page: tidy 3-column action grid instead of ragged wrap */
  .row.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .row.actions .btn { width: 100%; justify-content: center; margin: 0; }

  /* stepper: tighter vertical rhythm */
  .step-track { min-height: 56px; }
  .step-body { padding: 0 0 8px; }
  .step:last-child .step-track { min-height: 30px; }

  /* cut map: shrink to-scale rects so the map fits the phone */
  .cutmap-rect { width: calc(var(--w) * .55) !important; height: calc(var(--h) * .55) !important; }
  .cutmap-rect span { font-size: 9px; padding: 2px 4px; }
  .cutmap-row { gap: 10px 8px; }
  .legend { justify-content: flex-start; }
  .legend-item { font-size: 11px; }

  /* touch targets */
  .qcard .btn-primary { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* flow chips: swipe quietly, no scrollbar */
  .flowdiagram { scrollbar-width: none; }
  .flowdiagram::-webkit-scrollbar { display: none; }

  /* stacked quick-add: keep every field left-aligned, incl. numeric ones
     (the desktop right-align rules are more specific: td.num input[type=number]) */
  .tbl-qadd .qadd-row input[type="number"],
  .tbl-qadd .qadd-row td.num input,
  .tbl-qadd .qadd-row td.num input[type="number"] { text-align: left; }
  .qadd-rate { justify-content: flex-start; }

  /* card title row (cells without a matching header label) reads left-aligned */
  .tbl tbody tr td:not([data-label]) { justify-content: flex-start; }
}

/* ---------- piece board: progress strip + card accents ---------- */
.pb-progress { padding: 14px 16px 16px; }
.pb-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.pb-count { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pb-done { font-size: 22px; font-weight: 800; color: var(--accent-strong); }
.pb-sep { color: var(--text-dim); margin: 0 2px; }
.pb-badges { display: flex; gap: 6px; }
.pb-bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.pb-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s ease; }

.kcol-count {
  min-width: 24px; height: 22px; padding: 0 8px; border-radius: 99px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 11.5px; font-weight: 750; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.kcol-done .kcol-count { background: var(--ok-bg, #e5f5ec); color: var(--ok); border-color: transparent; }

/* ---------- board feel: smooth moves, sticky stage headers, clear dragging ---------- */
.kcard {
  transition: opacity .22s ease, border-color .18s ease, box-shadow .18s ease, transform .18s cubic-bezier(.2, .7, .2, 1);
}
.kcard:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 6px 18px rgba(16, 24, 40, .13);
}
.kcard:active { transform: translateY(0) scale(.99); transition-duration: .06s; }
.kcard.kc-justmoved { border-color: var(--accent); animation: card-land .5s ease; }
@keyframes card-land {
  0% { transform: scale(1.04); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 30%, transparent); }
  100% { transform: none; box-shadow: none; }
}
.kcard.dragging { opacity: .85; box-shadow: 0 10px 26px rgba(0,0,0,.18); transform: rotate(1.2deg); z-index: 5; }
.kcol-body { transition: background .15s ease; }
body.kboard-dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }
.kcol-count.bump, .pill.bump { animation: count-pop .35s ease; }
@keyframes count-pop { 40% { transform: scale(1.35); } }

@media (max-width: 700px) {
  /* stacked stage sections: header sticks under the topbar while you scroll */
  .kcol-head {
    position: sticky; top: 55px; z-index: 6;
    background: var(--bg);
    margin: 0 -2px; padding: 7px 2px;
  }
}

/* next-stage button: bordered accent pill everywhere (was phone-only by accident) */
.kadvance {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 4px 10px; background: var(--surface);
  color: var(--accent-strong); font-weight: 720; font-size: 12.5px;
  cursor: pointer; transition: border-color .12s ease, background .12s ease;
}
.kadvance:hover { border-color: var(--accent); background: var(--accent-soft); }

/* rows are tap/click-to-open everywhere */
tr[data-href] { cursor: pointer; }

/* station page: the piece's cabinet color travels with it */
.st-swatch { width: 16px; height: 16px; border-radius: 5px; display: inline-block; border: 1.5px solid color-mix(in srgb, var(--text) 25%, transparent); }

/* piece board print: the cut map is the paper artifact for the saw */
@media print {
  .cm-rect, .pc-rect { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cm-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .cm-canvas { height: 110px; background: #f5f5f5; }
  .cutmap { border: 0; }
}

/* sortable column headers */
.th-sort { color: inherit; text-decoration: none; }
.th-sort:hover { color: var(--accent-strong); }

/* toolbar date-range filters: compact pickers, not full-width fields */
.date-field.datefilter-wrap { width: 148px; flex: 0 0 auto; }
.input.datefilter { width: 100%; flex: 1 1 auto; }
@media (max-width: 700px) {
  .date-field.datefilter-wrap { width: 100%; flex: 1 1 140px; }
}

/* phones: long tables collapse to the first rows, expandable */
@media (max-width: 700px) {
  .tbl-collapsed tbody tr:nth-child(n+5) { display: none; }
}
