/*
 * Includes all stylesheet files in app/assets/stylesheets automatically.
 *
 * Hallmark · pre-emit critique: P5 H4 E4 S4 R5 V4
 * Hallmark · genre: modern-minimal (internal tool) · macrostructure: app shell (rail + board)
 * theme: light warm-neutral · anchor hue: warm (shop red) · design-system: design.md · designed-as-app
 * Full redesign 2026-09-09: dark -> light, top tab strip -> left rail nav,
 * Oswald/Space Grotesk -> Inter Tight + Inter + JetBrains Mono, hairline cards,
 * tabular-nums money, instrument-register controls (5px radius).
 */

:root {
  /* ---- design system (source of truth) ---- */
  --color-paper:       oklch(98% 0.004 60);
  --color-paper-2:     oklch(100% 0 0);
  --color-paper-3:     oklch(96% 0.005 60);
  --color-ink:         oklch(24% 0.012 55);
  --color-ink-2:       oklch(46% 0.012 55);
  --color-ink-3:       oklch(60% 0.010 55);
  --color-rule:        oklch(90% 0.006 55);
  --color-rule-2:      oklch(83% 0.008 55);
  --color-accent:      oklch(56% 0.187 27);
  --color-accent-ink:  oklch(99% 0 0);
  --color-accent-dim:  oklch(95% 0.032 30);
  --color-accent-press: oklch(50% 0.17 27);
  --color-focus:       oklch(56% 0.187 27);

  --color-pos:         oklch(50% 0.12 155);
  --color-pos-bg:      oklch(95% 0.04 155);
  --color-neg:         oklch(52% 0.19 25);
  --color-neg-bg:      oklch(95% 0.04 25);
  --color-warn:        oklch(52% 0.10 70);
  --color-warn-bg:     oklch(95% 0.05 78);
  --color-info:        oklch(50% 0.07 240);
  --color-info-bg:     oklch(95% 0.03 240);

  --font-display: "Inter Tight", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-body:    "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --space-3xs: 2px;  --space-2xs: 4px;  --space-xs: 8px;
  --space-sm:  12px; --space-md:  16px; --space-lg: 24px;
  --space-xl:  32px; --space-2xl: 48px; --space-3xl: 72px;

  --text-xs: 11.5px; --text-sm: 12.5px; --text-md: 13.5px; --text-base: 14px;
  --text-lg: 16px;   --text-xl: 20px;   --text-2xl: 26px;  --text-3xl: 33px;

  --radius-sm: 5px; --radius-md: 8px; --radius-lg: 12px; --radius-pill: 999px;

  --ease-out:    cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --dur:         .13s;

  --shadow-sm: 0 1px 2px rgba(30, 24, 22, .05);
  --shadow-md: 0 4px 16px -4px rgba(30, 24, 22, .12);

  /* ---- legacy aliases: existing views + SVG chart helper reference these ---- */
  --bg:         var(--color-paper);
  --panel:      var(--color-paper-2);
  --panel-2:    var(--color-paper-3);
  --line:       var(--color-rule);
  --text:       var(--color-ink);
  --text-dim:   var(--color-ink-2);
  --orange:     var(--color-accent);
  --orange-dim: var(--color-accent-dim);
  --steel:      var(--color-info);
  --green:      var(--color-pos);
  --red:        var(--color-neg);
  --amber:      var(--color-warn);
  --radius:     var(--radius-md);

  color-scheme: light;
  font-family: var(--font-body);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font: 400 var(--text-base)/1.5 var(--font-body);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--color-accent); color: var(--color-accent-ink); }
a { color: var(--color-accent); text-underline-offset: 2px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; font-style: normal; letter-spacing: -0.015em; }

/* ======================================================================
   App shell — rail (desktop) + content
   ====================================================================== */

.shell { display: flex; align-items: stretch; min-height: 100dvh; }
body.no-chrome .shell { display: block; }

.app {
  flex: 1; min-width: 0;
  width: 100%; max-width: 1160px;
  margin: 0 auto;
  padding: var(--space-lg);
  padding-bottom: var(--space-2xl);
}
body.no-chrome .app { max-width: 420px; margin: 8vh auto 0; }

.rail {
  flex: none; width: 240px;
  position: sticky; top: 0; align-self: flex-start;
  height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-sm);
  background: var(--color-paper);
  border-right: 1px solid var(--color-rule);
}

.rail-brand { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-2xs) var(--space-xs); }
.rail-brand svg, .rail-brand img { width: 26px; height: 26px; flex: none; object-fit: contain; }
.rail-brand .name {
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg);
  letter-spacing: -0.02em; color: var(--color-ink); line-height: 1.15;
  text-decoration: none; display: block;
}
.rail-brand small { display: block; color: var(--color-ink-3); font-size: var(--text-xs); margin-top: 1px; }

.rail-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.rail-group {
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em;
  color: var(--color-ink-3); text-transform: uppercase;
  padding: var(--space-md) var(--space-xs) var(--space-2xs);
}
.rail-group:first-child { padding-top: var(--space-2xs); }
.rail-link {
  display: block; padding: 7px var(--space-xs);
  border-left: 2px solid transparent; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-ink-2); text-decoration: none;
  font-size: var(--text-md); font-weight: 500;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.rail-link:hover { background: var(--color-paper-3); color: var(--color-ink); }
.rail-link.active {
  background: var(--color-accent-dim); border-left-color: var(--color-accent);
  color: var(--color-ink); font-weight: 600;
}

.rail-foot { border-top: 1px solid var(--color-rule); padding-top: var(--space-xs); }
.rail-logout button {
  width: 100%; text-align: left; background: none; border: none;
  padding: 7px var(--space-xs); border-radius: var(--radius-sm);
  color: var(--color-ink-2); font-size: var(--text-md); font-weight: 500;
}
.rail-logout button:hover { background: var(--color-neg-bg); color: var(--color-neg); }

/* Slim mobile top bar (wordmark only) — hidden on desktop */
.topbar { display: none; }

/* ======================================================================
   Flash, page scaffolding
   ====================================================================== */

.flash {
  padding: 10px var(--space-sm); border-radius: var(--radius-sm);
  margin-bottom: var(--space-md); font-size: var(--text-md); border: 1px solid;
}
.flash-notice { background: var(--color-pos-bg); border-color: var(--color-pos); color: var(--color-pos); }
.flash-alert  { background: var(--color-neg-bg); border-color: var(--color-neg); color: var(--color-neg); }

.grid   { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-sm); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
@media (max-width: 820px) {
  .grid, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.panel {
  background: var(--color-paper-2); border: 1px solid var(--color-rule);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: var(--space-md); margin-bottom: var(--space-md);
}
.panel h2 {
  font-size: var(--text-lg); font-weight: 600; color: var(--color-ink);
  margin: 0 0 var(--space-sm) 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--space-xs); margin-bottom: var(--space-xs);
}
.panel-head h2 { margin-bottom: 0; }
.panel-head .page-title { margin-bottom: 0; }
.panel-head .actions-row { margin-top: 0; }

h1.page-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-2xl); letter-spacing: -0.02em;
  margin: 0 0 var(--space-md) 0; color: var(--color-ink);
}

/* ======================================================================
   Forms
   ====================================================================== */

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); margin-bottom: var(--space-sm); }
.field-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-row.cols-4 { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .field-row, .field-row.cols-3, .field-row.cols-4 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: var(--space-2xs); margin-bottom: var(--space-sm); }
.field label { font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-2); letter-spacing: 0; text-transform: none; }
.field input, .field select, .field textarea {
  background: var(--color-paper-2); border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm); padding: 9px 10px;
  color: var(--color-ink); font-size: var(--text-md); width: 100%;
  transition: border-color var(--dur) var(--ease-out);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-dim);
}
.field input::placeholder, .field textarea::placeholder { color: var(--color-ink-3); }
.field textarea { resize: vertical; }
.field--end { justify-content: flex-end; }
.field .error { color: var(--color-neg); font-size: var(--text-sm); }
.checkbox-field { flex-direction: row; align-items: center; gap: var(--space-xs); }
.checkbox-field input { width: auto; accent-color: var(--color-accent); }

.error-summary {
  background: var(--color-neg-bg); border: 1px solid var(--color-neg);
  border-radius: var(--radius-sm); padding: 10px var(--space-sm);
  margin-bottom: var(--space-sm); color: var(--color-neg); font-size: var(--text-md);
}
.error-summary ul { margin: 0; padding-left: var(--space-md); }

/* ======================================================================
   Tables
   ====================================================================== */

table.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
table.data-table th {
  text-align: left; color: var(--color-ink-2); font-weight: 600;
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.03em;
  padding: var(--space-xs) 10px; border-bottom: 1px solid var(--color-rule-2);
}
table.data-table td {
  padding: 9px 10px; border-bottom: 1px solid var(--color-rule);
  vertical-align: middle; overflow-wrap: anywhere;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background-color var(--dur) var(--ease-out); }
table.data-table tr:hover td, table.data-table tbody tr:hover td { background: var(--color-paper-3); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.num strong { font-weight: 600; }

/* ======================================================================
   Buttons
   ====================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: var(--text-md); font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color var(--dur) var(--ease-out), filter var(--dur) var(--ease-out), transform .08s var(--ease-out);
}
.btn-primary   { background: var(--color-accent); color: var(--color-accent-ink); }
.btn-secondary { background: var(--color-paper-2); color: var(--color-ink); border-color: var(--color-rule-2) !important; }
.btn-danger    { background: var(--color-neg); color: #fff; }
.btn-green     { background: var(--color-pos); color: #fff; }
.btn-steel     { background: var(--color-info); color: #fff; }
.btn:hover { filter: brightness(1.07); }
.btn-secondary:hover { background: var(--color-paper-3); filter: none; }
.btn:active { transform: translateY(1px); filter: brightness(.95); }
.btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; transform: none; }
.btn-sm { padding: 6px 10px; font-size: var(--text-sm); }
.btn-block { width: 100%; }

.actions-row { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-sm); }
.link-muted { color: var(--color-ink-2); font-size: var(--text-sm); text-decoration: none; }
a.link-muted { text-decoration: underline; }
a.link-muted:hover { color: var(--color-accent); }

hr, hr.rule { border: none; border-top: 1px solid var(--color-rule); margin: var(--space-md) 0; }

/* ======================================================================
   Badges
   ====================================================================== */

.badge {
  font-size: var(--text-xs); padding: 2px 8px; border-radius: var(--radius-pill);
  font-weight: 600; letter-spacing: 0.01em; display: inline-block; white-space: nowrap;
}
.badge-lunas      { background: var(--color-pos-bg);  color: var(--color-pos); }
.badge-utang      { background: var(--color-warn-bg); color: var(--color-warn); }
.badge-cat        { background: var(--color-info-bg); color: var(--color-info); }
.badge-income     { background: var(--color-pos-bg);  color: var(--color-pos); }
.badge-expense    { background: var(--color-neg-bg);  color: var(--color-neg); }
.badge-antri      { background: var(--color-info-bg); color: var(--color-info); }
.badge-analisa    { background: var(--color-warn-bg); color: var(--color-warn); }
.badge-tunggu_part{ background: var(--color-neg-bg);  color: var(--color-neg); }
.badge-dikerjakan { background: var(--color-info-bg); color: var(--color-info); }
.badge-selesai    { background: var(--color-pos-bg);  color: var(--color-pos); }
.badge-batal      { background: var(--color-paper-3); color: var(--color-ink-3); }

/* ======================================================================
   Work-order board
   ====================================================================== */

.wo-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-sm); align-items: start; }
@media (max-width: 900px) { .wo-board { grid-template-columns: 1fr; } }
.wo-col { background: var(--color-paper-3); border-radius: var(--radius-md); padding: var(--space-xs); }
.wo-col h3 {
  font-family: var(--font-display); font-size: var(--text-sm); font-weight: 600;
  letter-spacing: 0; color: var(--color-ink-2); margin: 0 0 var(--space-xs) 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-2xs) var(--space-2xs) var(--space-xs);
  border-bottom: 1px solid var(--color-rule);
}
.wo-col h3 span:last-child {
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500;
  background: var(--color-paper-2); border: 1px solid var(--color-rule);
  border-radius: var(--radius-pill); padding: 1px 7px; color: var(--color-ink-2);
}
.wo-card {
  background: var(--color-paper-2); border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm); padding: 10px; margin-bottom: var(--space-xs);
  box-shadow: var(--shadow-sm);
}
.wo-card .q { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.wo-card .q::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 2px;
  margin-right: 6px; background: var(--color-info); vertical-align: baseline;
}
.wo-card.wo-analisa .q::before     { background: var(--color-warn); }
.wo-card.wo-tunggu_part .q::before { background: var(--color-neg); }
.wo-card.wo-dikerjakan .q::before  { background: var(--color-info); }
.wo-card.wo-selesai .q::before     { background: var(--color-pos); }
.wo-card .cust { font-weight: 600; font-size: var(--text-md); margin-top: 3px; }
.wo-card .cust a { color: var(--color-ink); text-decoration: none; }
.wo-card .cust a:hover { color: var(--color-accent); }
.wo-card .veh { font-size: var(--text-sm); color: var(--color-ink-2); }
.wo-card .cmpl { font-size: var(--text-sm); margin: 5px 0; }
.wo-card .meta { font-size: var(--text-xs); color: var(--color-ink-3); }
.wo-card .wo-actions { display: flex; gap: var(--space-2xs); margin-top: var(--space-xs); flex-wrap: wrap; }
.wo-card .wo-actions .btn-sm { padding: 5px 8px; font-size: var(--text-xs); }

/* ======================================================================
   Stat boxes
   ====================================================================== */

.stat-box { background: var(--color-paper-3); border-radius: var(--radius-sm); padding: var(--space-sm) var(--space-md); }
.stat-label { font-size: var(--text-xs); color: var(--color-ink-2); margin-bottom: var(--space-2xs); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.stat-value { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 600; color: var(--color-ink); font-variant-numeric: tabular-nums; }
.stat-value.green  { color: var(--color-pos); }
.stat-value.red    { color: var(--color-neg); }
.stat-value.orange { color: var(--color-accent); }
.stat-box--accent { border-bottom: 2px solid var(--color-accent); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

.chart-legend { display: flex; gap: var(--space-md); margin-bottom: var(--space-xs); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--color-ink-2); }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart svg text { font-family: var(--font-body); }

/* ======================================================================
   Invoice cart / totals / pill select
   ====================================================================== */

.cart-item-row {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) auto;
  gap: var(--space-xs); align-items: end; margin-bottom: var(--space-xs);
  padding-bottom: var(--space-xs); border-bottom: 1px solid var(--color-rule);
}
@media (max-width: 820px) { .cart-item-row { grid-template-columns: 1fr; } }
.cart-item-row .field { margin-bottom: 0; }
.remove-item-btn { background: none; border: 1px solid var(--color-rule-2); color: var(--color-neg); border-radius: var(--radius-sm); height: 38px; width: 38px; }
.remove-item-btn:hover { background: var(--color-neg-bg); }

.totals { margin-top: var(--space-sm); border-top: 1px solid var(--color-rule-2); padding-top: var(--space-sm); }
.totals .row { display: flex; justify-content: space-between; font-size: var(--text-md); margin-bottom: var(--space-xs); color: var(--color-ink-2); align-items: center; }
.totals .row.grand { color: var(--color-ink); font-size: var(--text-xl); font-weight: 600; font-family: var(--font-mono); font-variant-numeric: tabular-nums; margin-top: 6px; }

.pill-select { display: flex; gap: var(--space-xs); }
.pill-select label { flex: 1; text-align: center; padding: 9px; border: 1px solid var(--color-rule-2); border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--color-ink-2); font-weight: 600; cursor: pointer; transition: background-color var(--dur) var(--ease-out); }
.pill-select label:hover { background: var(--color-paper-3); }
.pill-select input { position: absolute; opacity: 0; pointer-events: none; }
.pill-select label:has(input:checked) { background: var(--color-accent-dim); border-color: var(--color-accent); color: var(--color-ink); }

.trash-item { opacity: .65; }

/* ======================================================================
   Mobile — top bar + bottom nav + sheet
   ====================================================================== */

.bottom-nav { display: none; }
.mobile-sheet { display: none; }

@media (max-width: 820px) {
  input, select, textarea,
  .field input, .field select, .field textarea { font-size: 16px; }

  .shell { display: block; }
  .app { padding: var(--space-sm); padding-bottom: 92px; max-width: none; }
  .rail { display: none; }

  .topbar {
    display: flex; align-items: center; gap: var(--space-xs);
    position: sticky; top: 0; z-index: 30;
    padding: 10px var(--space-sm);
    background: color-mix(in srgb, var(--color-paper) 92%, transparent);
    backdrop-filter: saturate(1.3) blur(8px);
    border-bottom: 1px solid var(--color-rule);
  }
  .topbar img, .topbar svg { width: 22px; height: 22px; flex: none; object-fit: contain; }
  .topbar .name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-base); letter-spacing: -0.02em; color: var(--color-ink); text-decoration: none; }

  h1.page-title { font-size: var(--text-xl); margin: var(--space-2xs) 0 var(--space-sm); }
  .panel { padding: var(--space-sm); }

  .btn { min-height: 44px; padding: 11px 16px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; font-size: var(--text-sm); }
  .actions-row > .btn,
  .actions-row > form.button_to { flex: 1 1 auto; }
  .actions-row > form.button_to .btn { width: 100%; }
  .panel-head .actions-row { width: 100%; margin-top: var(--space-2xs); }

  .actions-row.sticky-submit {
    position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 20;
    margin: var(--space-sm) calc(-1 * var(--space-sm)) calc(-1 * var(--space-sm));
    padding: 10px var(--space-sm) calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--color-paper-2) 94%, transparent);
    backdrop-filter: blur(6px); border-top: 1px solid var(--color-rule);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }

  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat-value { font-size: var(--text-lg); }

  .table-wrap:has(th:nth-child(5)) table.data-table { min-width: 560px; }
  table.data-table th, table.data-table td { padding: 8px; }

  .wo-card .wo-actions .btn-sm { flex: 1 1 auto; min-height: 38px; }
}

/* ---- List tables become cards on phones ---- */
@media (max-width: 640px) {
  table.data-table.stacked thead { display: none; }
  table.data-table.stacked,
  table.data-table.stacked tbody,
  table.data-table.stacked tr,
  table.data-table.stacked td { display: block; width: 100%; }

  table.data-table.stacked tr {
    border: 1px solid var(--color-rule); border-radius: var(--radius-md);
    background: var(--color-paper-2); padding: 2px; margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
  }
  table.data-table.stacked tr:hover td { background: none; }

  table.data-table.stacked td {
    border: none; border-bottom: 1px solid var(--color-rule);
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    text-align: right; padding: 9px 12px; white-space: normal;
  }
  table.data-table.stacked td:last-child { border-bottom: none; }
  table.data-table.stacked td[data-label]::before {
    content: attr(data-label); text-align: left; flex: 0 0 auto;
    color: var(--color-ink-2); font-size: var(--text-xs); letter-spacing: 0.03em;
    text-transform: uppercase; font-weight: 600;
  }
  table.data-table.stacked td:not([data-label]) { justify-content: flex-end; }
  table.data-table.stacked td.num { justify-content: space-between; }

  .table-wrap:has(table.data-table.stacked) { overflow-x: visible; }
  .table-wrap:has(th:nth-child(5)) table.data-table.stacked { min-width: 0; }
}

/* ---- Bottom nav + slide-up sheet ---- */
@media (max-width: 820px) {
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--color-paper-2) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    border-top: 1px solid var(--color-rule);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-2xs);
    background: none; border: none; color: var(--color-ink-3); cursor: pointer;
    font-family: inherit; font-size: 10px; font-weight: 600;
    letter-spacing: 0.02em; text-decoration: none;
    padding: 6px 2px; min-height: 46px; border-radius: var(--radius-md);
    transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
  }
  .bottom-nav a.active { color: var(--color-accent); background: var(--color-accent-dim); }
  .bottom-nav svg { width: 22px; height: 22px; }

  .mobile-sheet {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(20, 16, 15, .4);
    opacity: 0; pointer-events: none; transition: opacity .15s var(--ease-out);
  }
  .mobile-sheet.open { opacity: 1; pointer-events: auto; }
  .mobile-sheet-inner {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: var(--color-paper-2); border-top: 1px solid var(--color-rule);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 6px var(--space-xs) calc(16px + env(safe-area-inset-bottom));
    max-height: 82vh; overflow-y: auto;
    box-shadow: var(--shadow-md);
    transform: translateY(100%); transition: transform .2s var(--ease-out);
  }
  .mobile-sheet.open .mobile-sheet-inner { transform: translateY(0); }
  .mobile-sheet-grip { display: block; width: 100%; height: 22px; padding: 0; border: none; background: none; cursor: pointer; margin: 2px 0 6px; }
  .mobile-sheet-grip::before { content: ""; display: block; width: 40px; height: 4px; margin: 9px auto 0; background: var(--color-rule-2); border-radius: 2px; }
  .mobile-sheet a, .mobile-sheet .sheet-logout button {
    display: block; width: 100%; text-align: left;
    padding: 13px 14px; margin-bottom: 2px; border-radius: var(--radius-md);
    color: var(--color-ink); background: none; border: none;
    font-family: inherit; font-size: var(--text-base); font-weight: 500; text-decoration: none;
  }
  .mobile-sheet a.active { background: var(--color-accent-dim); color: var(--color-accent); font-weight: 600; }
  .mobile-sheet .sheet-group {
    font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--color-ink-3); padding: 12px 14px 4px;
  }
  .mobile-sheet .sheet-group:first-of-type { padding-top: 4px; }
  .mobile-sheet .sheet-sep { border-top: 1px solid var(--color-rule); margin: var(--space-xs) 6px; }
  .mobile-sheet .sheet-logout { display: block; }
  .mobile-sheet .sheet-logout button { color: var(--color-neg); cursor: pointer; }
}

/* ======================================================================
   Print — receipt only
   ====================================================================== */

.print-only { display: none; }
@media print {
  .rail, .topbar, .bottom-nav, .mobile-sheet, .actions-row, .flash, .no-print { display: none !important; }
  .shell { display: block; }
  body, .app { background: #fff; color: #000; }
  .app { max-width: none; padding: 0; }
  .panel { border: none; box-shadow: none; }
  .print-only { display: block; }
  .print-only .receipt-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; border-bottom: 2px solid #000; padding-bottom: 10px; }
  .print-only .receipt-head h2 { margin: 0; }
  .print-only .receipt-head p { margin: 2px 0; font-size: 12px; }
  .print-only .receipt-logo { max-height: 64px; max-width: 120px; object-fit: contain; }
}

form.button_to { display: inline; }

.login-panel { max-width: 400px; margin: 0 auto; }
.login-panel h1 { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
