/* Orderflow: Craft-Unified Minimalistic Design System
 *
 * - Light neutral canvas with crisp white cards; tinted dark slate canvas with raised cards
 * - Single rem-based type scale (--text-xs .. --text-2xl), 4px spacing rhythm, unified radii
 * - Paired state tokens (--state-surface / --state-ink / --state-border / --focus-ring)
 * - Mobile-first baseline (360px), 44px touch targets on interactive controls
 * - High-contrast A4 black-and-white print sheet preserved intact
 */

:root {
  color-scheme: light;

  /* Surface ramp */
  --background: 220 16% 95%;        /* soft neutral page canvas */
  --card: 0 0% 100%;                /* pure white floating card */
  --card-raised: 0 0% 100%;
  --surface-hover: 220 16% 97%;     /* subtle lift on hover */
  --muted: 220 14% 92%;
  --muted-subtle: 220 16% 97%;
  --border: 220 13% 87%;
  --border-subtle: 220 13% 92%;
  --input: 220 13% 56%;

  /* Ink / Typography */
  --foreground: 222 47% 11%;        /* deep obsidian */
  --card-foreground: 222 47% 11%;
  --muted-foreground: 215 16% 42%;  /* slate, >= 4.5:1 on card and canvas */

  /* Primary accent (single primary action + focus ring only) */
  --primary: 222 47% 11%;
  --primary-foreground: 0 0% 100%;
  --ring: 222 47% 11%;
  --destructive: 0 72% 45%;
  --destructive-foreground: 0 0% 100%;

  /* State tokens: quiet tint in light mode */
  --state-surface: 220 14% 92%;
  --state-ink: 222 47% 11%;
  --state-border: 220 13% 81%;
  --focus-ring: 222 47% 11%;

  /* Surface-specific utility tokens (no hardcoded hexes in component rules) */
  --toast-surface: 222 47% 11%;
  --toast-ink: 0 0% 100%;
  --gmail-mark-bg: 0 0% 100%;
  --gmail-mark-fg: 215 28% 17%;

  /* Status hues */
  --st-new: 215 25% 33%;
  --st-new-bg: 210 20% 95%;
  --st-new-border: 214 20% 86%;

  --st-production: 204 88% 33%;
  --st-production-bg: 204 90% 95%;
  --st-production-border: 203 75% 85%;

  --st-blocked: 26 91% 34%;
  --st-blocked-bg: 48 96% 94%;
  --st-blocked-border: 45 80% 84%;

  --st-ready: 142 72% 26%;
  --st-ready-bg: 140 70% 95%;
  --st-ready-border: 141 55% 83%;

  --st-neutral: 215 16% 42%;
  --st-urgent: 36 90% 40%;

  /* Type scale (minimum readable text: 12px / 0.75rem) */
  --text-xs: 0.75rem;               /* 12px: captions, badges, counts, table heads */
  --text-sm: 0.8125rem;             /* 13px: controls, chips, sidebar nav, hints */
  --text-base: 0.875rem;            /* 14px: buttons, standard secondary copy */
  --text-md: 0.9375rem;             /* 15px: body baseline, prose, desktop row titles */
  --text-lg: 1rem;                  /* 16px: form inputs (iOS zoom guard), empty titles */
  --text-heading: 1.125rem;         /* 18px: card headings, dialog titles */
  --text-xl: 1.25rem;               /* 20px: mobile page title, login/profile hero */
  --text-2xl: 1.5rem;               /* 24px: desktop page title, customer hero */

  /* 4px spacing rhythm */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Radius scale */
  --radius: 8px;                    /* cards, rows, panels, dialogs, brand mark */
  --radius-sm: 8px;                 /* controls, inputs, buttons, tabs, filter chips */
  --radius-badge: 6px;              /* compact badges, tags, leftover size chips */
  --radius-pill: 999px;             /* live status dot, scrollbars */
  --tap: 44px;

  /* Elevation */
  --shadow-sm: none;
  --shadow-card: 0 1px 2px hsl(222 47% 11% / 0.04);
  --shadow-hover: none;
  --shadow-popover: 0 18px 48px -12px hsl(222 47% 11% / 0.28), 0 2px 6px hsl(222 47% 11% / 0.06);
}

[data-theme="dark"] {
  color-scheme: dark;

  --background: 222 44% 7%;
  --card: 222 35% 12%;
  --card-raised: 222 32% 16%;
  --surface-hover: 222 32% 16%;
  --muted: 222 28% 18%;
  --muted-subtle: 222 36% 10%;
  --border: 222 25% 22%;
  --border-subtle: 222 26% 17%;
  --input: 222 18% 46%;

  --foreground: 210 40% 98%;
  --card-foreground: 210 40% 98%;
  --muted-foreground: 215 16% 68%;

  --primary: 210 40% 98%;
  --primary-foreground: 222 47% 11%;
  --ring: 213 90% 66%;
  --destructive: 0 84% 68%;
  --destructive-foreground: 0 0% 100%;

  /* State tokens: tinted elevation of --card in dark mode, never a near-white slab */
  --state-surface: 222 28% 21%;
  --state-ink: 210 40% 98%;
  --state-border: 222 24% 31%;
  --focus-ring: 213 90% 66%;

  --toast-surface: 222 32% 16%;
  --toast-ink: 210 40% 98%;
  --toast-bad-surface: 0 46% 20%;

  --st-new: 215 25% 78%;
  --st-new-bg: 215 25% 18%;
  --st-new-border: 215 20% 30%;

  --st-production: 204 94% 70%;
  --st-production-bg: 204 90% 16%;
  --st-production-border: 203 75% 30%;

  --st-blocked: 45 93% 60%;
  --st-blocked-bg: 45 90% 16%;
  --st-blocked-border: 45 80% 28%;

  --st-ready: 142 70% 58%;
  --st-ready-bg: 142 70% 15%;
  --st-ready-border: 142 55% 28%;

  --st-neutral: 215 16% 68%;
  --st-urgent: 45 93% 60%;

  --shadow-sm: 0 1px 2px 0 hsl(0 0% 0% / 0.3);
  --shadow-card: 0 2px 6px 0 hsl(0 0% 0% / 0.3);
  --shadow-hover: 0 4px 10px 0 hsl(0 0% 0% / 0.4);
  --shadow-popover: 0 22px 56px -12px hsl(0 0% 0% / 0.65), 0 4px 10px hsl(0 0% 0% / 0.4);
}

/* ---------------------------------------------------------- base */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: var(--text-md);
  line-height: 1.5;
  letter-spacing: 0;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.view { min-height: 100vh; min-height: 100dvh; }

/* [hidden] must win over any class/id display rule. */
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

::selection { background: hsl(var(--primary) / 0.14); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: var(--radius-pill);
  border: 2px solid hsl(var(--background));
}
::-webkit-scrollbar-thumb:hover { background: hsl(var(--input)); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------- controls */

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 550;
  color: hsl(var(--foreground));
  margin: 0 0 var(--space-2);
}

input, textarea, select, button { font: inherit; color: inherit; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="search"],
textarea,
select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  /* 16px minimum prevents iOS Safari auto-zoom on focus. */
  font-size: var(--text-lg);
  line-height: 1.4;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  box-shadow: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

input::placeholder, textarea::placeholder { color: hsl(var(--muted-foreground) / 0.78); }

textarea { resize: vertical; line-height: 1.5; }

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.55;
  cursor: pointer;
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.7;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
}

:is(button, a, summary, [tabindex]):focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: hsl(var(--focus-ring));
  box-shadow: 0 0 0 3px hsl(var(--focus-ring) / 0.16);
}

/* Base button = primary action */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  touch-action: manipulation;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

button svg { width: 16px; height: 16px; flex: none; }

button:not(:disabled):hover {
  background: hsl(var(--primary) / 0.9);
  color: hsl(var(--primary-foreground));
}
button:not(:disabled):active {
  background: hsl(var(--primary) / 0.82);
  color: hsl(var(--primary-foreground));
  transform: scale(0.985);
}
button:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* Legible disabled current-status control */
button.secondary:disabled {
  opacity: 1;
  background: hsl(var(--muted-subtle));
  border-color: hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
button.primary:disabled { opacity: 0.72; }

input:disabled, textarea:disabled, select:disabled {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
}

input[readonly] {
  background: hsl(var(--muted-subtle));
  color: hsl(var(--muted-foreground));
  cursor: default;
}

/* Secondary button */
button.secondary {
  background: hsl(var(--card));
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}
button.secondary:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
button.secondary:not(:disabled):active {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

button.primary {
  background: hsl(var(--primary));
  border-color: transparent;
  color: hsl(var(--primary-foreground));
}
button.primary:not(:disabled):hover {
  background: hsl(var(--primary) / 0.9);
  color: hsl(var(--primary-foreground));
}
button.primary:not(:disabled):active {
  background: hsl(var(--primary) / 0.82);
  color: hsl(var(--primary-foreground));
}

/* Ghost icon button: 44px target */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  min-width: var(--tap);
  height: var(--tap);
  min-height: var(--tap);
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  box-shadow: none;
}
.icon-btn svg { width: 16px; height: 16px; }
.gmail-logo { display: block; width: 20px; height: auto; flex: none; }
.icon-btn .gmail-logo { width: 20px; height: auto; }
.icon-btn:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--border-subtle));
  color: hsl(var(--foreground));
}
.icon-btn:not(:disabled):active {
  background: hsl(var(--muted));
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}
.icon-btn.is-linked { color: hsl(var(--st-ready)); }
.icon-btn-outlined {
  background: hsl(var(--card));
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}
.icon-btn-outlined:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

/* Theme glyph swap */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
[data-theme="dark"] .theme-icon-sun { display: block; }
[data-theme="dark"] .theme-icon-moon { display: none; }

.link-btn {
  background: transparent;
  border-color: transparent;
  color: hsl(var(--muted-foreground));
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2);
  min-height: var(--tap);
}
.link-btn:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  border-color: transparent;
  color: hsl(var(--foreground));
}
.link-btn:not(:disabled):active {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  touch-action: manipulation;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: var(--text-base);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn-link:hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.btn-link:active {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

.error {
  color: hsl(var(--destructive));
  font-size: var(--text-sm);
  line-height: 1.45;
  margin: var(--space-3) 0 0;
  padding: var(--space-3);
  border: 1px solid hsl(var(--destructive) / 0.25);
  border-radius: var(--radius-sm);
  background: hsl(var(--destructive) / 0.06);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------- login */

#login-view {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: 72px var(--space-4) 40px;
  background: hsl(var(--background));
}

.login-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4);
}

.login-utils {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.login-head { margin-bottom: var(--space-5); }

.login-head .login-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  margin-bottom: var(--space-3);
}
.login-head .login-mark svg { width: 20px; height: 20px; }

.login-head h1 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
}

.login-sub {
  margin: var(--space-2) 0 0;
  font-size: var(--text-base);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

.field { margin-top: var(--space-4); }
.field:first-of-type { margin-top: 0; }
.login-head + .field { margin-top: 0; }

.login-card button[type="submit"] {
  width: 100%;
  margin-top: var(--space-6);
  font-size: var(--text-md);
}

.input-affix-wrap { position: relative; }

.input-affix-wrap input { padding-right: 52px; }

.input-affix {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: var(--tap);
  min-width: var(--tap);
  height: var(--tap);
  min-height: var(--tap);
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
}
.input-affix svg { width: 16px; height: 16px; }
.input-affix:not(:disabled):hover {
  background: transparent;
  color: hsl(var(--foreground));
}
.input-affix:not(:disabled):active {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  transform: translateY(-50%);
}
.input-affix[aria-pressed="true"] { color: hsl(var(--foreground)); }

.pw-eye-off { display: none; }
.input-affix[aria-pressed="true"] .pw-eye { display: none; }
.input-affix[aria-pressed="true"] .pw-eye-off { display: block; }

.mark-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: var(--radius);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.mark-tile svg { width: 16px; height: 16px; }

.lang-switch {
  display: inline-flex;
  align-items: center;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.lang-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-badge);
  color: hsl(var(--muted-foreground));
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.03em;
  padding: 0 var(--space-2);
  min-height: var(--tap);
  min-width: var(--tap);
  box-shadow: none;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}
.lang-btn:not(:disabled):hover {
  color: hsl(var(--foreground));
  background: hsl(var(--surface-hover));
  border-color: transparent;
}
.lang-btn:not(:disabled):active {
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}
.lang-btn.is-active {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
}
.lang-btn.is-active:hover,
.lang-btn.is-active:active {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
}
.lang-btn.is-active:focus-visible {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

/* ---------------------------------------------------------- app shell & sidebar */

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand actions"
    "tabs tabs";
  align-items: center;
  z-index: 10;
  container-type: inline-size;
}

.sidebar-top { display: contents; }
.sidebar-bottom { display: contents; }

.sidebar-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  min-width: 0;
}

.brand-title {
  font-size: var(--text-md);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: hsl(var(--foreground));
  white-space: nowrap;
}

.sidebar-brand .mark-tile { width: 28px; height: 28px; border-radius: var(--radius); }
.sidebar-brand .mark-tile svg { width: 16px; height: 16px; }

.tabs {
  grid-area: tabs;
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--space-3) var(--space-1);
  background: transparent;
}
.tab {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 0;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: hsl(var(--muted-subtle));
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  font-size: var(--text-sm);
  font-weight: 550;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.tab > span { min-width: 0; overflow-wrap: anywhere; }
.tab:not(:disabled):hover {
  background: hsl(var(--muted));
  border-color: transparent;
  color: hsl(var(--foreground));
}
.tab:not(:disabled):active {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.tab.is-active {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
  font-weight: 600;
}
.tab.is-active:hover,
.tab.is-active:active {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
}
.tab.is-active:focus-visible {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

.tab-icon { display: none; width: 16px; height: 16px; flex: none; }
.tab-label-full { display: none; }
.tab-label-short { display: inline; }

/* At large text the five tabs wrap cleanly instead of stacking 5 tall rows. */
@container (max-width: 15em) {
  .tabs {
    flex-wrap: wrap;
  }
  .tab {
    flex: 1 1 30%;
    min-width: max-content;
    padding: var(--space-1) var(--space-2);
  }
}

.sidebar-section { display: none; }

.sidebar-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding-right: var(--space-2);
}

.sidebar-actions .lang-switch { display: none; }

.profile-card { display: none; }

.live-state {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: currentColor;
  display: inline-block;
  flex: none;
}
.live-dot.is-live { background: hsl(var(--st-ready)); }
.live-state.is-live { color: hsl(var(--st-ready)); }

.connection-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid hsl(var(--st-blocked-border));
  border-radius: var(--radius-sm);
  background: hsl(var(--st-blocked-bg));
  color: hsl(var(--st-blocked));
  font-size: var(--text-sm);
  font-weight: 550;
  line-height: 1.4;
}
.connection-banner svg { width: 16px; height: 16px; flex: none; }

.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  font-size: var(--text-xs);
  font-weight: 550;
}
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:not(:disabled):hover {
  background: hsl(var(--destructive) / 0.08);
  border-color: hsl(var(--destructive) / 0.18);
  color: hsl(var(--destructive));
}
.logout-btn:not(:disabled):active {
  background: hsl(var(--destructive) / 0.14);
  border-color: hsl(var(--destructive) / 0.25);
  color: hsl(var(--destructive));
}
.logout-label { display: none; }

.main-content {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-2) var(--space-3) var(--space-6);
}

.main-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid hsl(var(--border-subtle));
}

.main-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: hsl(var(--foreground));
  overflow-wrap: break-word;
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

#detail-back:not([hidden]) ~ .main-header-actions .lang-switch { display: none; }

.header-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  flex: none;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
}
.header-back svg { width: 16px; height: 16px; }
.header-back:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.header-back:not(:disabled):active {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

.quick-new-btn { display: none; }

.board-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.board-toolbar-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.board-toolbar-actions button { font-size: var(--text-sm); padding: var(--space-2) var(--space-3); }
.board-toolbar-actions button svg { width: 16px; height: 16px; }

.board-toolbar-title {
  display: none;
  margin: 0;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: hsl(var(--foreground));
}

.board-view-count {
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
  padding: 0;
  min-width: 0;
}
.board-view-count::before {
  content: "·";
  margin-right: var(--space-2);
  color: hsl(var(--muted-foreground) / 0.7);
}

/* ---------------------------------------------------------- status badges */

.pill {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-badge);
  white-space: nowrap;
  flex: none;
  color: hsl(var(--st-neutral));
  background: hsl(var(--muted-subtle));
  border: 1px solid hsl(var(--border));
}

.pill-new { color: hsl(var(--st-new)); background: hsl(var(--st-new-bg)); border-color: hsl(var(--st-new-border)); }
.pill-in_production { color: hsl(var(--st-production)); background: hsl(var(--st-production-bg)); border-color: hsl(var(--st-production-border)); }
.pill-blocked { color: hsl(var(--st-blocked)); background: hsl(var(--st-blocked-bg)); border-color: hsl(var(--st-blocked-border)); }
.pill-ready { color: hsl(var(--st-ready)); background: hsl(var(--st-ready-bg)); border-color: hsl(var(--st-ready-border)); }
.pill-scheduled,
.pill-installed,
.pill-cancelled { color: hsl(var(--st-neutral)); background: hsl(var(--muted-subtle)); border-color: hsl(var(--border)); }

/* ---------------------------------------------------------- filter chips */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

@media (max-width: 767px) {
  .main-content {
    padding: var(--space-1) var(--space-3) var(--space-6);
  }
  .main-header {
    padding-bottom: var(--space-1);
    margin-bottom: var(--space-2);
  }
  .main-header .lang-switch {
    padding: 0;
    gap: 0;
  }
  .board-toolbar {
    gap: var(--space-1);
    margin-bottom: var(--space-1);
  }
  .filters {
    gap: var(--space-1);
  }
  .filters .chip {
    padding: var(--space-1) var(--space-2);
    gap: var(--space-1);
  }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 550;
  white-space: nowrap;
  flex: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.chip:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  color: hsl(var(--foreground));
  border-color: hsl(var(--input));
}
.chip:not(:disabled):active {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border-color: hsl(var(--input));
}
.chip.is-active {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
  font-weight: 600;
}
.chip.is-active:not(:disabled):hover,
.chip.is-active:not(:disabled):active {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
}
.chip.is-active:focus-visible {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

.chip-count {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
  padding: 0;
  min-width: 0;
  text-align: right;
  transition: color 120ms ease;
}
.chip.is-active .chip-count { color: hsl(var(--state-ink)); }
.chip-count[data-empty="true"] { color: hsl(var(--muted-foreground)); font-weight: 500; }
.chip.is-active .chip-count[data-empty="true"] { color: hsl(var(--muted-foreground)); font-weight: 500; }

/* ---------------------------------------------------------- order list */

.order-list {
  list-style: none;
  margin: 0;
  padding: 0 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.order-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "ref pill"
    "name name"
    "meta meta"
    "action action";
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: var(--space-3) 40px var(--space-3) var(--space-4);
  cursor: pointer;
  min-height: var(--tap);
  overflow: hidden;
  touch-action: manipulation;
  box-shadow: var(--shadow-card);
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.order-row > .row-ref { grid-area: ref; align-self: center; }
.order-row > .pill { grid-area: pill; }
.order-row > .row-name { grid-area: name; margin-top: var(--space-1); }
.order-row > .row-meta { grid-area: meta; margin-top: var(--space-1); }
.order-row > .card-mount-btn { grid-area: action; margin-top: var(--space-3); justify-self: start; }

@media (hover: hover) {
  .order-row:not(:active):hover {
    border-color: hsl(var(--input));
    background: hsl(var(--surface-hover));
    color: hsl(var(--foreground));
  }
  .order-row:hover .row-go { color: hsl(var(--foreground)); }
}
.order-row:active {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.order-row:focus-visible { outline-offset: -2px; }
.order-row:focus-visible .row-go { color: hsl(var(--foreground)); }

.row-ref {
  flex: 0 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}

.row-name {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: hsl(var(--foreground));
  overflow-wrap: anywhere;
}

.row-go {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  color: hsl(var(--muted-foreground) / 0.55);
  pointer-events: none;
  transition: color 120ms ease;
}
.row-go svg { width: 16px; height: 16px; }

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
}
.row-meta > span { min-width: 0; overflow-wrap: anywhere; }

.meta-due[data-overdue="true"] { color: hsl(var(--destructive)); font-weight: 600; }
.meta-due[data-soon="true"] { color: hsl(var(--st-blocked)); font-weight: 600; }
.meta-due[data-none="true"] { color: hsl(var(--muted-foreground)); }

.tag-urgent {
  color: hsl(var(--st-blocked));
  font-weight: 600;
  background: hsl(var(--st-blocked-bg));
  border: 1px solid hsl(var(--st-blocked-border));
  padding: 2px var(--space-2);
  border-radius: var(--radius-badge);
  font-size: var(--text-xs);
  line-height: 1.25;
}

.card-mount-btn {
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  width: auto;
  z-index: 1;
}

/* ---------------------------------------------------------- empty state */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  text-align: center;
  color: hsl(var(--muted-foreground));
  min-height: 280px;
  padding: var(--space-8) var(--space-5);
  margin: var(--space-1) 0 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  box-shadow: var(--shadow-card);
}

.empty-art {
  width: 40px;
  height: 40px;
  margin-bottom: var(--space-3);
  color: hsl(var(--muted-foreground) / 0.45);
}

.empty-title {
  font-size: var(--text-lg);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: hsl(var(--foreground));
}

.empty-hint {
  font-size: var(--text-base);
  max-width: 34ch;
  margin: var(--space-1) 0 0;
  line-height: 1.5;
}

.empty button { margin-top: var(--space-5); }

/* ---------------------------------------------------------- cards */

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: var(--space-4);
  margin: 0 0 var(--space-3);
  box-shadow: var(--shadow-card);
}

.card h2 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-heading);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
}

.card h3 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
}

.card-sub {
  margin: 0 0 var(--space-1);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

.row2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr));
  gap: var(--space-3);
}
.row2 > .field { min-width: 0; margin-top: var(--space-4); }

.items-fieldset {
  container-type: inline-size;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin: var(--space-5) 0 0;
  background: hsl(var(--muted-subtle));
}
#items-card {
  container-type: inline-size;
}

.items-fieldset legend {
  font-size: var(--text-xs);
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  padding: 0 var(--space-2);
}

.conflict-banner {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  border: 1px solid hsl(var(--st-blocked-border));
  border-radius: var(--radius-sm);
  background: hsl(var(--st-blocked-bg));
  color: hsl(var(--foreground));
}
.conflict-msg {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: 550;
  line-height: 1.45;
  color: hsl(var(--st-blocked));
}
.conflict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.item-head,
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.25rem var(--tap);
  gap: var(--space-2);
  align-items: center;
}

.item-head {
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}
.item-head span { min-width: 0; overflow: hidden; }
.item-head span:nth-child(2) { text-align: center; }
.item-head span:nth-child(3) { display: none; }

.item-row { margin-bottom: var(--space-2); }
.item-row input { min-height: var(--tap); padding: var(--space-2) var(--space-3); }
.item-row .item-qty { text-align: center; font-variant-numeric: tabular-nums; }
.item-row .item-spec { grid-column: 1 / -1; }

@container (max-width: 15em) {
  .item-head { display: none; }
  .item-row { grid-template-columns: minmax(0, 1fr) var(--tap); }
  .item-row .item-code { grid-column: 1; }
  .item-row .item-remove { grid-column: 2; grid-row: 1; }
  .item-row .item-qty { grid-column: 1 / -1; text-align: left; }
  .item-row .item-spec { grid-column: 1 / -1; }
}

@container (min-width: 30em) {
  .item-head,
  .item-row {
    grid-template-columns: minmax(0, 1fr) 68px minmax(0, 1.2fr) var(--tap);
  }
  .item-head span:nth-child(3) { display: inline; }
  .item-row .item-spec { grid-column: auto; }
}

.item-remove {
  background: transparent;
  color: hsl(var(--muted-foreground));
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0;
  min-height: var(--tap);
  width: var(--tap);
  font-size: var(--text-heading);
  line-height: 1;
}
.item-remove:not(:disabled):hover {
  background: hsl(var(--destructive) / 0.08);
  border-color: hsl(var(--destructive) / 0.25);
  color: hsl(var(--destructive));
}
.item-remove:not(:disabled):active {
  background: hsl(var(--destructive) / 0.14);
  border-color: hsl(var(--destructive) / 0.35);
  color: hsl(var(--destructive));
}

#add-item,
#d-add-item {
  width: 100%;
  margin-top: var(--space-1);
  background: hsl(var(--card));
  border: 1px dashed hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-weight: 550;
}
#add-item:not(:disabled):hover,
#d-add-item:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
#add-item:not(:disabled):active,
#d-add-item:not(:disabled):active {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

.item-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.item-actions button { min-height: var(--tap); margin-top: 0; }

.item-note {
  grid-column: 1 / -1;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
}

#order-submit {
  width: 100%;
  margin-top: var(--space-6);
  font-size: var(--text-md);
}

/* ---------------------------------------------------------- profile */

.profile-pane { max-width: 920px; margin: 0; }

.profile-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.profile-avatar {
  min-width: 1.75rem;
  width: auto;
  height: 1.75rem;
  padding: 0 var(--space-1);
  border-radius: var(--radius-badge);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.profile-avatar-lg {
  min-width: 52px;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: var(--radius);
  font-size: var(--text-lg);
}
[data-theme="dark"] .profile-avatar-lg {
  background: hsl(var(--state-surface));
  border: 1px solid hsl(var(--state-border));
  color: hsl(var(--state-ink));
}

.profile-hero-text { min-width: 0; }
.profile-hero h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.profile-hero-position {
  margin: var(--space-1) 0 0;
  font-size: var(--text-md);
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}
.profile-local-note {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  line-height: 1.45;
  color: hsl(var(--muted-foreground));
}

.profile-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }

.profile-section { margin: 0; min-width: 0; }
.profile-section h3 { margin-bottom: var(--space-3); }

.profile-form .row2 { grid-template-columns: 1fr; }
.profile-actions { display: flex; justify-content: flex-end; margin-top: var(--space-4); }

.profile-facts { margin: 0; padding: 0; }
.profile-facts > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid hsl(var(--border-subtle));
}
.profile-facts > div:first-child { border-top: 0; padding-top: 0; }
.profile-facts dt { font-size: var(--text-sm); font-weight: 550; color: hsl(var(--muted-foreground)); }
.profile-facts dd {
  margin: 0;
  min-width: 0;
  font-size: var(--text-base);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--foreground));
  text-align: right;
  overflow-wrap: anywhere;
}

.profile-note { margin: var(--space-3) 0 0; }

.profile-gmail-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.profile-gmail-row .gmail-mark { flex: none; }
.profile-gmail-row .secondary { flex: none; }
.profile-gmail-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 120px; min-width: 0; }
.profile-gmail-text strong { font-size: var(--text-base); font-weight: 600; color: hsl(var(--foreground)); }
.profile-gmail-status {
  font-size: var(--text-xs);
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}
.profile-gmail-status.is-linked { color: hsl(var(--st-ready)); }

.profile-signout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.profile-signout h3 { margin-bottom: var(--space-1); }
.profile-signout .card-sub { margin: 0; }
.profile-signout .secondary { flex: none; }

@media (min-width: 768px) {
  .profile-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: start;
  }
  .profile-section:not(.profile-signout) {
    display: flex;
    flex-direction: column;
  }
  .profile-signout {
    grid-column: 1 / -1;
  }
  .profile-note {
    margin-top: auto;
    padding-top: var(--space-3);
  }
  .profile-form .row2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
}

@media (max-width: 767px) {
  .profile-actions button,
  .profile-signout .secondary { width: 100%; }
  .profile-signout { align-items: flex-start; }
}

/* ---------------------------------------------------------- detail */

.detail-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.detail-head { container-type: inline-size; }

.detail-bar h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}

.detail-customer {
  font-size: var(--text-xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: hsl(var(--foreground));
  margin: var(--space-3) 0 0;
  overflow-wrap: anywhere;
}

.detail-tel {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--muted-subtle));
  text-decoration: none;
  color: inherit;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.detail-tel:hover {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.detail-tel:active {
  background: hsl(var(--state-surface));
  border-color: hsl(var(--state-border));
  color: hsl(var(--state-ink));
}

.detail-tel-icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: hsl(var(--muted-foreground));
}

.detail-tel-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.detail-tel-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.detail-tel-number {
  font-size: var(--text-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--foreground));
  overflow-wrap: anywhere;
}

.detail-tel-go {
  width: 16px;
  height: 16px;
  flex: none;
  color: hsl(var(--muted-foreground) / 0.6);
}

.detail-facts {
  margin: var(--space-4) 0 0;
  padding: 0;
}

.fact {
  display: grid;
  grid-template-columns: minmax(5.25rem, auto) minmax(0, 1fr);
  gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-3) 0;
  border-top: 1px solid hsl(var(--border-subtle));
}
@container (max-width: 14em) {
  .fact {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
  }
}
.fact:first-child { border-top: 0; padding-top: 0; }

.fact dt {
  font-size: var(--text-xs);
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.fact dd {
  margin: 0;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.fact-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.detail-meta {
  margin: 0;
  font-size: var(--text-md);
  color: hsl(var(--foreground));
  overflow-wrap: anywhere;
}
.detail-meta a { color: inherit; }

.detail-meta[data-overdue="true"] { color: hsl(var(--destructive)); font-weight: 600; }
.detail-meta[data-soon="true"] { color: hsl(var(--st-blocked)); font-weight: 600; }
.detail-meta[data-urgent="true"] { color: hsl(var(--st-blocked)); font-weight: 600; }

.detail-danger {
  display: flex;
  justify-content: flex-start;
  margin: 0 0 var(--space-2);
}

.danger-link {
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: hsl(var(--destructive));
  font-size: var(--text-sm);
  font-weight: 600;
}
.danger-link:not(:disabled):hover {
  background: hsl(var(--destructive) / 0.08);
  border-color: hsl(var(--destructive) / 0.22);
  color: hsl(var(--destructive));
}
.danger-link:not(:disabled):active {
  background: hsl(var(--destructive) / 0.14);
  border-color: hsl(var(--destructive) / 0.35);
  color: hsl(var(--destructive));
}
.danger-link svg { width: 16px; height: 16px; flex: none; }

.due-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.25;
  padding: 2px var(--space-2);
  border-radius: var(--radius-badge);
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  border: 1px solid transparent;
  white-space: normal;
}
.due-tag[data-overdue="true"] { color: hsl(var(--destructive)); background: hsl(var(--destructive) / 0.1); }
.due-tag[data-soon="true"] { color: hsl(var(--st-blocked)); background: hsl(var(--st-blocked-bg)); border-color: hsl(var(--st-blocked-border)); }

.h3-count {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 2px var(--space-2);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-badge);
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  font-size: var(--text-xs);
  line-height: 1.1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  vertical-align: 1px;
}
.h3-count[data-empty="true"] {
  color: hsl(var(--muted-foreground));
  background: transparent;
}

.status-print {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid hsl(var(--border-subtle));
}
.status-print svg { width: 16px; height: 16px; flex: none; }

.items-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.items-li {
  border-top: 1px solid hsl(var(--border-subtle));
  padding: var(--space-3) 0;
}
.items-li:first-child { border-top: 0; padding-top: 0; }
.items-li:last-child { padding-bottom: 0; }

.items-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.items-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-base);
  font-weight: 650;
  letter-spacing: 0.01em;
  color: hsl(var(--foreground));
  overflow-wrap: anywhere;
}

.items-qty {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: var(--text-md);
  font-weight: 650;
  color: hsl(var(--foreground));
  white-space: nowrap;
}
.items-qty::before { content: "\00d7 "; color: hsl(var(--muted-foreground)); font-weight: 500; }

.items-detail {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.status-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr));
  gap: var(--space-2);
}

.status-buttons .primary { grid-column: 1 / -1; }

.status-hint {
  margin: var(--space-3) 0 0;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

/* ---------------------------------------------------------- notes */

.notes {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.note {
  border-top: 1px solid hsl(var(--border-subtle));
  padding-top: var(--space-3);
}
.note:first-child { border-top: 0; padding-top: 0; }

.note-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: hsl(var(--muted-foreground));
}

.note-head strong {
  color: hsl(var(--foreground));
  font-weight: 600;
  font-size: var(--text-sm);
}

.note-time { font-variant-numeric: tabular-nums; }

.note-body {
  margin: var(--space-1) 0 0;
  font-size: var(--text-md);
  line-height: 1.55;
  color: hsl(var(--foreground));
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.note-empty {
  color: hsl(var(--muted-foreground));
  font-size: var(--text-base);
  line-height: 1.5;
  padding: var(--space-1) 0 var(--space-2);
}

.note-form textarea { margin-bottom: var(--space-2); }
.note-form button { width: 100%; }

/* ---------------------------------------------------------- file attachments */

.field-hint {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

.file-field { margin-top: var(--space-5); }
.file-pick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.file-pick-btn {
  flex: none;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}
.file-pick-name {
  flex: 1 1 160px;
  min-width: 0;
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}

.detail-file {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid hsl(var(--border-subtle));
  min-width: 0;
}
.detail-file-icon {
  width: 20px;
  height: 20px;
  flex: none;
  color: hsl(var(--muted-foreground));
}
.detail-file-icon svg { width: 100%; height: 100%; }
.detail-file-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 180px;
  min-width: 0;
}
.detail-file-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: hsl(var(--foreground));
  overflow-wrap: anywhere;
}
.detail-file-meta {
  font-size: var(--text-xs);
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
}
.detail-file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex: none;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  margin-inline-start: auto;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.detail-file-btn:hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.detail-file-btn:active {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.detail-file-btn svg { width: 16px; height: 16px; }
.detail-file-note {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

/* ---------------------------------------------------------- messages */

.messages-pane {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1040px;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  box-shadow: var(--shadow-card);
}

.messages-thread {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  margin: auto 0 0;
  padding: 0;
  list-style: none;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(78%, 640px);
}
.message.is-own {
  align-self: flex-end;
  align-items: flex-end;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0 var(--space-1) var(--space-1);
}
.message-author {
  font-size: var(--text-xs);
  font-weight: 650;
  color: hsl(var(--foreground));
}
.message-time {
  font-size: var(--text-xs);
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
}

.message-bubble {
  padding: var(--space-2) var(--space-3);
  border: 1px solid hsl(var(--border-subtle));
  border-radius: var(--radius-sm);
  background: hsl(var(--muted-subtle));
  color: hsl(var(--foreground));
}
.message.is-own .message-bubble {
  border-color: transparent;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
[data-theme="dark"] .message.is-own .message-bubble {
  border-color: hsl(var(--state-border));
  background: hsl(var(--state-surface));
  color: hsl(var(--state-ink));
}
.message-body {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.5;
  color: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.is-own .message-body { color: inherit; }

.messages-state {
  max-width: 34ch;
  margin: auto;
  padding: var(--space-6) var(--space-2);
  text-align: center;
  font-size: var(--text-base);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

.message-composer {
  flex: none;
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  border-top: 1px solid hsl(var(--border-subtle));
  background: hsl(var(--card));
}
.message-composer-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
}
.message-composer textarea {
  flex: 1 1 auto;
  min-height: var(--tap);
  max-height: 120px;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  line-height: 1.45;
  resize: none;
  background: hsl(var(--muted-subtle));
}
.message-composer button {
  flex: none;
  min-height: var(--tap);
  padding: 0 var(--space-4);
}
.message-composer .error { margin: var(--space-2) 0 0; }

/* The chat owns the viewport: thread scrolls, composer stays at the bottom. */
body.is-messages { overflow: hidden; }
body.is-messages .app-layout {
  height: 100vh;
  height: 100dvh;
}
body.is-messages .main-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: var(--space-3);
  overflow: hidden;
}
body.is-messages .main-header { flex: none; }
body.is-messages .messages-pane { flex: 1 1 auto; min-height: 0; }

@media (min-width: 768px) {
  body.is-messages .main-content {
    height: 100vh;
    height: 100dvh;
    padding-bottom: var(--space-5);
  }
  body.is-messages .messages-pane { margin-bottom: 0; }
}

@media (max-width: 767px) {
  .message { max-width: 86%; }
  .message-composer {
    padding: var(--space-3) var(--space-3) calc(var(--space-3) + env(safe-area-inset-bottom));
  }
  .tab { padding: var(--space-2) var(--space-1); font-size: var(--text-xs); }
  .detail-file-btn { width: 100%; justify-content: center; margin-inline-start: 0; }
  #pane-detail:not([hidden]) {
    display: flex;
    flex-direction: column;
  }
  #pane-detail > .detail-head { order: 1; }
  #items-card { order: 2; }
  #status-card { order: 3; }
  #notes-card { order: 4; }
  #pane-detail > .detail-danger { order: 5; }
}

/* ---------------------------------------------------------- material stock sheet */

.materials-pane {
  width: 100%;
  max-width: 1040px;
  margin: 0;
}

.stock-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.stock-search {
  position: relative;
  display: flex;
  flex: 1 1 220px;
  min-width: 0;
}

.stock-search input[type="search"] {
  width: 100%;
  padding-inline-start: 36px;
  padding-inline-end: 44px;
  -webkit-appearance: none;
  appearance: none;
}
.stock-search input[type="search"]::-webkit-search-cancel-button,
.stock-search input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.stock-search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  pointer-events: none;
  color: hsl(var(--muted-foreground));
}

.stock-search-clear {
  position: absolute;
  right: var(--space-1);
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
}
.stock-search-clear:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  border-color: transparent;
  color: hsl(var(--foreground));
}
.stock-search-clear:not(:disabled):active {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  transform: translateY(-50%);
}
.stock-search-clear svg { width: 16px; height: 16px; }

.stock-add-btn { flex: none; }

.stock-results {
  margin: 0 0 var(--space-2);
  min-height: 1.25em;
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground));
}

.stock-table {
  container-type: inline-size;
}

.stock-head { display: none; }

.stock-list {
  list-style: none;
  margin: 0;
  padding: 0 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stock-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "name"
    "qty"
    "note"
    "updated"
    "actions";
  column-gap: var(--space-3);
  row-gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  min-height: var(--tap);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.stock-name {
  grid-area: name;
  min-width: 0;
  font-size: var(--text-md);
  font-weight: 600;
  color: hsl(var(--foreground));
  overflow-wrap: anywhere;
}

/* Every leftover measurement is its own chip. Align-items/content flex-start prevents
   short chip lists from stretching vertically next to the stacked mobile action buttons. */
.stock-qty {
  grid-area: qty;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  align-self: start;
  gap: var(--space-1);
  font-size: var(--text-base);
  color: hsl(var(--foreground));
}
.stock-qty[data-empty="true"] { color: hsl(var(--muted-foreground)); }

.stock-size {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  color: hsl(var(--foreground));
  background: hsl(var(--muted-subtle));
  border: 1px solid hsl(var(--border-subtle));
  border-radius: var(--radius-badge);
  overflow-wrap: anywhere;
}

.stock-note {
  grid-area: note;
  min-width: 0;
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  line-height: 1.45;
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}

.stock-updated {
  grid-area: updated;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
}
.stock-updated-by { font-weight: 600; }
.stock-updated-by + .stock-updated-at::before {
  content: "·";
  margin-right: var(--space-2);
  color: hsl(var(--muted-foreground) / 0.7);
}

.stock-actions {
  grid-area: actions;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  align-self: stretch;
  flex: none;
}

.stock-btn {
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
}
.stock-btn:not(:disabled):hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.stock-btn:not(:disabled):active {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

.stock-btn-danger {
  color: hsl(var(--destructive));
  border-color: hsl(var(--border));
  background: hsl(var(--card));
}
.stock-btn-danger:not(:disabled):hover {
  background: hsl(var(--destructive) / 0.08);
  border-color: hsl(var(--destructive) / 0.5);
  color: hsl(var(--destructive));
}
.stock-btn-danger:not(:disabled):active {
  background: hsl(var(--destructive) / 0.14);
  border-color: hsl(var(--destructive) / 0.65);
  color: hsl(var(--destructive));
}

.stock-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  margin: var(--space-1) 0 var(--space-6);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  font-size: var(--text-base);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  box-shadow: var(--shadow-card);
}

.stock-dialog { width: min(480px, calc(100vw - 32px)); }

@media (max-width: 767px) {
  .stock-add-btn { width: 100%; }
  .stock-btn { min-height: var(--tap); padding: var(--space-2) var(--space-3); }
}

@container (min-width: 34em) {
  .stock-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr) minmax(0, 1fr) 8.5rem 11rem;
    column-gap: var(--space-3);
    padding: 0 var(--space-3) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    color: hsl(var(--muted-foreground));
  }
  .stock-list { gap: var(--space-1); }
  .stock-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr) minmax(0, 1fr) 8.5rem 11rem;
    grid-template-areas: none;
    align-items: start;
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    box-shadow: none;
  }
  .stock-name { grid-area: auto; grid-column: 1; }
  .stock-qty { grid-area: auto; grid-column: 2; align-self: start; }
  .stock-note { grid-area: auto; grid-column: 3; margin-top: 0; }
  .stock-updated { grid-area: auto; grid-column: 4; margin-top: 0; flex-direction: column; gap: 0; }
  .stock-updated-by + .stock-updated-at::before { content: none; margin: 0; }
  .stock-actions { grid-area: auto; grid-column: 5; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; align-self: start; }
}

/* ---------------------------------------------------------- toast */

.toast {
  position: fixed;
  top: calc(var(--space-3) + env(safe-area-inset-top));
  right: var(--space-3);
  left: auto;
  bottom: auto;
  width: max-content;
  max-width: calc(100vw - var(--space-6));
  z-index: 40;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: hsl(var(--toast-surface));
  color: hsl(var(--toast-ink));
  border: 1px solid transparent;
  box-shadow: var(--shadow-popover);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
  cursor: pointer;
  transform-origin: top right;
  opacity: 0;
  transform: translate3d(0, -10px, 0) scale(0.96);
  pointer-events: none;
  will-change: transform, opacity;
  transition:
    opacity 110ms cubic-bezier(0.4, 0, 1, 1),
    transform 110ms cubic-bezier(0.4, 0, 1, 1);
}

.toast.is-open {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  pointer-events: auto;
  transition:
    opacity 120ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 120ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .toast {
  background: hsl(var(--toast-surface));
  color: hsl(var(--toast-ink));
  border: 1px solid hsl(var(--state-border));
}

.toast[data-kind="bad"] {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-color: transparent;
}
[data-theme="dark"] .toast[data-kind="bad"] {
  background: hsl(var(--toast-bad-surface));
  color: hsl(var(--toast-ink));
  border-color: hsl(var(--destructive) / 0.55);
}

/* ---------------------------------------------------------- dialogs */

.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 780px);
  overflow-y: auto;
  padding: 0;
  margin: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-popover);
}

.dialog::backdrop { background: hsl(222 47% 11% / 0.45); }

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) 0;
}

.dialog-head h2 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-heading);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
}

.dialog-head .card-sub { margin: 0; max-width: 46ch; }

.dialog-close { margin: -8px -8px 0 0; flex: none; }

.dialog-body { padding: var(--space-4) var(--space-5) var(--space-5); }

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.dialog-actions button { font-size: var(--text-sm); }

button.danger {
  background: hsl(var(--card));
  border-color: hsl(var(--destructive) / 0.45);
  color: hsl(var(--destructive));
}
button.danger:not(:disabled):hover {
  background: hsl(var(--destructive) / 0.08);
  border-color: hsl(var(--destructive) / 0.7);
  color: hsl(var(--destructive));
}
button.danger:not(:disabled):active {
  background: hsl(var(--destructive) / 0.14);
  border-color: hsl(var(--destructive) / 0.8);
  color: hsl(var(--destructive));
}

.delete-warning {
  margin: 0 0 var(--space-1);
  color: hsl(var(--destructive));
  font-size: var(--text-sm);
  font-weight: 600;
}

.dialog > .error { margin: 0 var(--space-5) var(--space-5); }

.field-note {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.mono-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.import-dialog { width: min(680px, calc(100vw - 32px)); }

.import-file-box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.import-file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.import-file-btn svg { width: 16px; height: 16px; }
.import-file-btn:hover {
  background: hsl(var(--surface-hover));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.import-file-btn:active {
  background: hsl(var(--muted));
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

.import-file-name {
  font-size: var(--text-sm);
  color: hsl(var(--muted-foreground));
  overflow-wrap: anywhere;
}

.import-mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.import-map-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.import-map-col label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: hsl(var(--foreground));
  overflow-wrap: anywhere;
}

.import-map-col select { min-height: 40px; font-size: var(--text-base); padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3); }

.import-preview-table-wrap {
  max-height: 220px;
  overflow: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--card));
}

.import-result-list {
  max-height: 220px;
  overflow-y: auto;
  font-size: var(--text-sm);
  line-height: 1.5;
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
}
.import-result-list li { margin-bottom: var(--space-1); }
.import-result-list .is-ok { color: hsl(var(--st-ready)); }
.import-result-list .is-warn { color: hsl(var(--st-blocked)); }
.import-result-list .is-bad { color: hsl(var(--destructive)); }

/* ---------------------------------------------------------- gmail linking */

.gmail-dialog { width: min(440px, calc(100vw - 32px)); }

.gmail-head-lockup {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
}

.gmail-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius);
  background: hsl(var(--gmail-mark-bg));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--gmail-mark-fg));
}
.gmail-mark .gmail-logo { width: 24px; height: auto; }

.linked-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-bottom: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-badge);
  border: 1px solid hsl(var(--st-ready-border));
  background: hsl(var(--st-ready-bg));
  color: hsl(var(--st-ready));
  font-size: var(--text-xs);
  font-weight: 600;
}

.gmail-stub-note {
  margin: var(--space-4) 0 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border-subtle));
  background: hsl(var(--muted-subtle));
  font-size: var(--text-xs);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

/* ---------------------------------------------------------- print (screen) */

.print-body {
  background: hsl(var(--background));
  padding: 0 0 var(--space-6);
}

.print-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  position: sticky;
  top: 0;
  z-index: 10;
}

.print-toolbar button { min-height: var(--tap); padding: var(--space-2) var(--space-3); }

.print-toolbar a {
  color: hsl(var(--muted-foreground));
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
}
.print-toolbar a:hover { color: hsl(var(--foreground)); }

.sheet {
  background: #ffffff;
  color: #111214;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  margin: var(--space-4);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid #d5d6da;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.sheet-head h1 {
  margin: 0;
  font-size: 1.0625rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.sheet-sub {
  margin: 4px 0 0;
  font-weight: 600;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.sheet-meta p {
  margin: 0 0 2px;
  font-size: 0.8125rem;
  color: #55565c;
  text-align: right;
  white-space: nowrap;
}

.sheet-contact { margin-bottom: 12px; font-size: 0.875rem; color: #26272b; }
.sheet-contact p { margin: 0 0 3px; overflow-wrap: anywhere; }
.sheet-contact strong { color: #7a7b81; font-weight: 600; font-size: 0.75rem; }

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid #d5d6da;
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.sheet-table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: #55565c;
  background: #f4f4f6;
}

.sheet-table .tick { width: 32px; text-align: center; font-size: 1.1rem; }

.sheet-table .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
}

.sheet-table .qty { white-space: nowrap; font-weight: 700; }

.sheet-foot {
  margin-top: 14px;
  font-size: 0.75rem;
  color: #7a7b81;
}

.sheet-batch-order { margin-bottom: 24px; }

/* ---------------------------------------------------------- print (paper) */

@page {
  size: A4;
  margin: 14mm;
}

@media print {
  html, body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .print-body {
    background: #fff;
    padding: 0;
  }

  .print-toolbar, .toast { display: none !important; }

  .sheet {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: #000;
    box-shadow: none;
  }

  .sheet-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .sheet-head h1 {
    margin: 0;
    font-size: 18pt;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #000;
  }

  .sheet-sub {
    margin: 4px 0 0;
    font-size: 13pt;
    font-weight: 700;
    color: #000;
  }

  .sheet-meta p {
    margin: 0 0 2px;
    font-size: 10pt;
    color: #000;
    text-align: right;
  }

  .sheet-contact {
    margin-bottom: 12px;
    font-size: 10.5pt;
    color: #000;
  }
  .sheet-contact p { margin: 0 0 3px; }
  .sheet-contact strong { color: #000; font-size: 9.5pt; }

  .sheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11pt;
  }

  .sheet-table th,
  .sheet-table td {
    border: 1px solid #000;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
    color: #000;
  }

  .sheet-table th {
    background: #eee;
    color: #000;
    font-size: 10pt;
    font-weight: 700;
  }

  .sheet-table .tick {
    width: 10mm;
    text-align: center;
    font-size: 14pt;
    line-height: 1;
  }

  .sheet-table .code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 700;
    font-size: 13pt;
    white-space: nowrap;
  }

  .sheet-table .qty {
    width: 18mm;
    text-align: center;
    font-weight: 700;
    font-size: 12pt;
    white-space: nowrap;
  }

  .sheet-table th { overflow-wrap: normal; }

  .sheet-table .spec {
    font-size: 10.5pt;
  }

  .sheet-foot {
    margin-top: 14px;
    font-size: 9pt;
    color: #444;
  }

  .sheet-batch-order {
    page-break-inside: avoid;
    break-inside: avoid;
    page-break-after: always;
    break-after: page;
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0 0 24pt 0;
  }
  .sheet-batch-order:last-of-type {
    page-break-after: auto;
    break-after: auto;
    margin-bottom: 0;
  }
  .sheet-table thead {
    display: table-header-group;
  }
  .sheet-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* ---------------------------------------------------------- desktop */

@media (min-width: 768px) {
  body { font-size: var(--text-md); }

  .app-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 100vh;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    width: clamp(236px, 14.75rem, 300px);
    box-sizing: border-box;
    flex: none;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
    padding: var(--space-3);
    gap: var(--space-2);
    border-right: 1px solid hsl(var(--border));
    border-bottom: none;
  }

  .sidebar-top {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--border)) transparent;
  }
  .sidebar-top::-webkit-scrollbar { width: 6px; }
  .sidebar-top::-webkit-scrollbar-thumb {
    background: hsl(var(--border));
    border-radius: var(--radius-pill);
  }
  .sidebar-top::-webkit-scrollbar-track { background: transparent; }

  .sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
    gap: var(--space-2);
    padding-top: var(--space-2);
    margin-top: 0;
    flex: 0 0 auto;
    border-top: 1px solid hsl(var(--border-subtle));
  }

  .sidebar-brand {
    padding: var(--space-1) var(--space-2) var(--space-4);
    border-inline: 1px solid transparent;
    box-sizing: border-box;
    width: 100%;
  }
  .sidebar-brand .mark-tile { width: 28px; height: 28px; border-radius: var(--radius); }
  .sidebar-brand .mark-tile svg { width: 16px; height: 16px; }
  .brand-title { font-size: var(--text-lg); }

  .tabs {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
    gap: var(--space-1);
    padding: 0;
  }

  .tab {
    flex: none;
    justify-content: flex-start;
    text-align: left;
    gap: var(--space-2);
    padding: var(--space-2);
    box-sizing: border-box;
    width: 100%;
    font-size: var(--text-base);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: hsl(var(--muted-foreground));
  }
  .tab-icon {
    display: block;
    width: 28px;
    height: 16px;
    flex: none;
  }
  .tab-label-full { display: inline; }
  .tab-label-short { display: none; }
  .tab:not(:disabled):hover {
    background: hsl(var(--surface-hover));
    border-color: transparent;
    color: hsl(var(--foreground));
  }
  .tab:not(:disabled):active {
    background: hsl(var(--muted));
    border-color: transparent;
    color: hsl(var(--foreground));
  }
  .tab.is-active {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
    font-weight: 600;
  }
  .tab.is-active:hover,
  .tab.is-active:active {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
  }
  .tab.is-active:focus-visible {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
    outline: 2px solid hsl(var(--focus-ring));
    outline-offset: 2px;
  }

  .sidebar-section {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
    gap: var(--space-1);
    padding: var(--space-3) 0 0;
    margin-top: var(--space-3);
    border-top: 1px solid hsl(var(--border-subtle));
  }

  .sidebar-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    padding: 0 var(--space-2);
    border-inline: 1px solid transparent;
    margin-bottom: var(--space-1);
    box-sizing: border-box;
    width: 100%;
  }

  .sidebar-filters {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
    gap: 2px;
  }

  .sidebar-filter-btn {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    min-height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    background: transparent;
    color: hsl(var(--muted-foreground));
    font-size: var(--text-sm);
    font-weight: 500;
    text-align: left;
    width: 100%;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
  }
  .sidebar-filter-btn:not(:disabled):hover {
    background: hsl(var(--surface-hover));
    border-color: transparent;
    color: hsl(var(--foreground));
  }
  .sidebar-filter-btn:not(:disabled):active {
    background: hsl(var(--muted));
    border-color: transparent;
    color: hsl(var(--foreground));
  }
  .sidebar-filter-btn.is-active {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
    font-weight: 600;
  }
  .sidebar-filter-btn.is-active:hover,
  .sidebar-filter-btn.is-active:active {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
  }
  .sidebar-filter-btn.is-active:focus-visible {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
    outline: 2px solid hsl(var(--focus-ring));
    outline-offset: 2px;
  }

  .sb-label {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .sb-count {
    font-size: var(--text-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: hsl(var(--muted-foreground));
    text-align: right;
    justify-self: end;
  }
  .sidebar-filter-btn.is-active .sb-count { color: hsl(var(--state-ink)); }

  .profile-card {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-2);
    min-height: var(--tap);
    padding: var(--space-2);
    background: hsl(var(--muted-subtle));
    border: 1px solid hsl(var(--border-subtle));
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    width: 100%;
    color: hsl(var(--foreground));
    font-size: var(--text-sm);
    font-weight: 500;
    text-align: left;
    white-space: normal;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  }
  .profile-card:not(:disabled):hover {
    background: hsl(var(--muted));
    border-color: hsl(var(--input));
    color: hsl(var(--foreground));
  }
  .profile-card:not(:disabled):active {
    background: hsl(var(--muted));
    border-color: hsl(var(--input));
    color: hsl(var(--foreground));
  }
  .profile-card.is-active {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
  }
  .profile-card.is-active:not(:disabled):hover,
  .profile-card.is-active:not(:disabled):active {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
  }
  .profile-card.is-active:focus-visible {
    background: hsl(var(--state-surface));
    border-color: hsl(var(--state-border));
    color: hsl(var(--state-ink));
    outline: 2px solid hsl(var(--focus-ring));
    outline-offset: 2px;
  }

  .profile-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .profile-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: hsl(var(--foreground));
    overflow-wrap: anywhere;
    max-width: 100%;
  }

  .profile-sub {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    width: 100%;
    min-width: 0;
    font-size: var(--text-xs);
    line-height: 1.35;
    color: hsl(var(--muted-foreground));
  }
  .profile-position,
  .profile-gmail {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .profile-chevron {
    width: 16px;
    height: 16px;
    flex: none;
    margin-left: auto;
    color: hsl(var(--muted-foreground));
  }

  .profile-gmail {
    font-weight: 500;
    color: hsl(var(--muted-foreground));
  }
  .profile-gmail.is-linked { color: hsl(var(--st-ready)); }

  .sidebar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: 0;
    box-sizing: border-box;
    width: 100%;
  }

  .sidebar-actions .lang-switch { display: inline-flex; }
  .sidebar-actions .lang-btn { min-height: var(--space-8); min-width: 28px; padding: 0 var(--space-2); }

  .logout-btn {
    flex: 1 0 100%;
    justify-content: flex-start;
    min-height: 40px;
    margin-top: 2px;
    padding: var(--space-2);
    box-sizing: border-box;
    width: 100%;
    color: hsl(var(--muted-foreground));
  }
  .logout-label { display: inline; }

  @media (max-height: 640px) {
    .sidebar { padding: var(--space-2) var(--space-3); gap: var(--space-2); }
    .sidebar-brand { padding-bottom: var(--space-4); }
    .tab { min-height: 36px; padding: var(--space-1) var(--space-2); }
    .sidebar-section { margin-top: var(--space-2); padding-top: var(--space-2); }
    .sidebar-filter-btn { min-height: 28px; padding: var(--space-1) var(--space-2); }
    .sidebar-bottom { padding-top: var(--space-2); gap: var(--space-1); }
    .profile-card { min-height: 40px; padding: var(--space-1) var(--space-2); }
    .logout-btn { min-height: 36px; margin-top: 2px; padding: var(--space-1) var(--space-2); }
  }

  .main-content {
    flex: 1 1 0%;
    min-width: 0;
    padding: var(--space-6) var(--space-6) 40px;
    height: 100vh;
    overflow-y: auto;
  }

  .main-header {
    gap: var(--space-3);
    margin-bottom: var(--space-5);
  }

  .main-title {
    font-size: var(--text-2xl);
    letter-spacing: -0.025em;
    line-height: 1.2;
  }

  .quick-new-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 40px;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 600;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
  }
  .quick-new-btn:not(:disabled):hover {
    background: hsl(var(--primary) / 0.9);
    color: hsl(var(--primary-foreground));
  }
  .quick-new-btn:not(:disabled):active {
    background: hsl(var(--primary) / 0.82);
    color: hsl(var(--primary-foreground));
  }
  .quick-new-btn svg { width: 16px; height: 16px; }

  .filters { display: none; }

  .board-toolbar { justify-content: space-between; margin-bottom: var(--space-3); }
  .board-toolbar-title { display: inline-flex; }

  .order-list {
    display: grid;
    grid-template-columns: 8.25rem minmax(0, 1fr) 8.5rem 1.5rem;
    column-gap: var(--space-3);
    row-gap: var(--space-2);
    padding: 0 0 var(--space-6);
    container-type: inline-size;
  }

  .order-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    grid-template-areas: none;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    min-height: 48px;
  }
  @supports not (grid-template-columns: subgrid) {
    .order-row {
      grid-template-columns: 8.25rem minmax(0, 1fr) 8.5rem 1.5rem;
      column-gap: var(--space-3);
    }
  }
  .order-row > .row-ref { grid-area: auto; grid-column: 1; grid-row: 1; }
  .order-row > .row-name { grid-area: auto; grid-column: 2; grid-row: 1; margin-top: 0; font-size: var(--text-md); }
  .order-row > .pill { grid-area: auto; grid-column: 3; grid-row: 1; justify-self: start; }
  .order-row > .row-meta { grid-area: auto; grid-column: 2; grid-row: 2; margin-top: 2px; }
  .order-row > .card-mount-btn { grid-area: auto; grid-column: 3 / -1; grid-row: 2; margin-top: 0; justify-self: end; white-space: nowrap; }
  .row-go {
    grid-area: auto;
    position: static;
    transform: none;
    grid-column: 4;
    grid-row: 1;
    justify-self: center;
  }
  .order-row:not(:active):hover .row-go { color: hsl(var(--foreground)); transform: none; }
  .order-row:focus-visible .row-go { color: hsl(var(--foreground)); }

  @media (min-width: 1024px) {
    .order-list {
      grid-template-columns:
        clamp(136px, 8.5rem, 240px)
        minmax(0, 1.7fr)
        clamp(160px, 10rem, 220px)
        minmax(150px, 0.9fr)
        clamp(124px, 8rem, 176px)
        24px;
      column-gap: var(--space-3);
    }
    .order-row { padding: var(--space-2) var(--space-3); }
    @supports not (grid-template-columns: subgrid) {
      .order-row {
        grid-template-columns:
          clamp(136px, 8.5rem, 240px)
          minmax(0, 1.7fr)
          clamp(160px, 10rem, 220px)
          minmax(150px, 0.9fr)
          clamp(124px, 8rem, 176px)
          24px;
        column-gap: var(--space-3);
      }
    }
    .order-row > .row-meta { grid-area: auto; grid-column: 4; grid-row: 1; margin-top: 0; }
    .order-row > .card-mount-btn { grid-area: auto; grid-column: 5; grid-row: 1; margin-top: 0; justify-self: end; }
    .row-go { grid-column: 6; grid-row: 1; }
  }

  @container (max-width: 30em) {
    .order-row {
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-areas:
        "ref pill"
        "name name"
        "meta meta"
        "action action";
      padding: var(--space-3) 40px var(--space-3) var(--space-4);
      min-height: var(--tap);
    }
    .order-row > .row-ref { grid-area: ref; align-self: center; }
    .order-row > .row-name { grid-area: name; margin-top: var(--space-1); font-size: var(--text-lg); }
    .order-row > .pill { grid-area: pill; justify-self: start; }
    .order-row > .row-meta { grid-area: meta; margin-top: var(--space-1); }
    .order-row > .card-mount-btn { grid-area: action; margin-top: var(--space-3); justify-self: start; }
    .row-go {
      position: absolute;
      right: var(--space-3);
      top: 50%;
      transform: translateY(-50%);
      grid-column: auto;
      grid-row: auto;
      justify-self: auto;
    }
  }

  .card { margin: 0 0 var(--space-4); padding: var(--space-5); }

  .empty { min-height: 340px; margin: 0; }

  .toast {
    top: calc(var(--space-4) + env(safe-area-inset-top));
    right: var(--space-6);
    left: auto;
    bottom: auto;
    width: max-content;
    min-width: 220px;
    max-width: min(420px, calc(100vw - 48px));
  }

  .dialog { width: min(560px, calc(100vw - 64px)); }
  .import-dialog { width: min(720px, calc(100vw - 64px)); }
  .gmail-dialog { width: min(460px, calc(100vw - 64px)); }
  .dialog-head { padding: var(--space-6) var(--space-6) 0; }
  .dialog-body { padding: var(--space-4) var(--space-6) var(--space-6); }
  .dialog > .error { margin: 0 var(--space-6) var(--space-6); }

  .detail-head { padding: var(--space-5) var(--space-6); }
  .detail-customer {
    font-size: var(--text-2xl);
    letter-spacing: -0.025em;
    line-height: 1.2;
  }

  @media (min-width: 1024px) {
    .detail-facts {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
      column-gap: var(--space-8);
      row-gap: 0;
      margin-top: var(--space-5);
    }
    .fact { border-top: 0; padding: 0 0 var(--space-3); }
    .fact:nth-child(n + 3) { padding-bottom: 0; }
  }

  #pane-new form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-5);
    row-gap: var(--space-4);
  }

  #pane-new form > .field { margin-top: 0; }

  #pane-new form > .card-sub { grid-column: 1 / -1; }
  #pane-new form > .field:nth-of-type(1) { grid-column: 1; }
  #pane-new form > .field:nth-of-type(2) { grid-column: 2; }
  #pane-new form > .field:nth-of-type(3),
  #pane-new form > .row2,
  #pane-new form > .items-fieldset,
  #pane-new form > .file-field,
  #pane-new form > .error,
  #order-submit { grid-column: 1 / -1; }

  .main-header-actions .lang-switch { display: none; }

  #pane-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: var(--space-5);
    align-items: start;
  }

  #pane-detail > .detail-head { grid-column: 1 / -1; grid-row: 1; }
  #status-card { grid-column: 1; grid-row: 2; }
  #items-card { grid-column: 1; grid-row: 3; }
  #notes-card { grid-column: 2; grid-row: 2 / span 2; }
  #pane-detail > .detail-danger {
    grid-column: 1 / -1;
    grid-row: 4;
    justify-content: flex-end;
    margin-top: 0;
  }

  .status-buttons { grid-template-columns: repeat(2, minmax(0, 200px)); justify-content: start; }
  .status-buttons .primary { grid-column: auto; }
}

@media (pointer: coarse) {
  button:not([role="switch"]),
  input, select, textarea, .order-row, .btn-link {
    min-height: var(--tap);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .toast { transform: none !important; }
  button:not(:disabled):active { transform: none; }
  .order-row:not(:active):hover { transform: none; }
  .order-row:hover .row-go { transform: translateY(-50%); }
}
