:root {
  --wow-bg: #0b0f1a;
  --wow-bg-elevated: #0f1524;
  --wow-surface: #111827;
  --wow-surface-hover: #1a2233;
  --wow-border: #1f2937;
  --wow-border-strong: #2d3748;
  --wow-text: #e5e7eb;
  --wow-text-strong: #f9fafb;
  --wow-text-muted: #9ca3af;
  --wow-text-subtle: #6b7280;
  --wow-text-inverse: #0b0f1a;
  --wow-accent: #38bdf8;
  --wow-accent-hover: #0ea5e9;
  --wow-accent-active: #0284c7;
  --wow-accent-soft: rgba(56, 189, 248, 0.12);
  --wow-accent-ring: rgba(56, 189, 248, 0.35);
  --wow-success: #10b981;
  --wow-success-soft: rgba(16, 185, 129, 0.12);
  --wow-warning: #f59e0b;
  --wow-warning-soft: rgba(245, 158, 11, 0.12);
  --wow-danger: #ef4444;
  --wow-danger-soft: rgba(239, 68, 68, 0.12);
  --wow-info: #6366f1;
  --wow-info-soft: rgba(99, 102, 241, 0.12);
  --wow-font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --wow-font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --wow-text-xs: 0.75rem;
  --wow-text-sm: 0.875rem;
  --wow-text-base: 1rem;
  --wow-text-lg: 1.125rem;
  --wow-text-2xl: 1.5rem;
  --wow-text-3xl: 1.875rem;
  --wow-weight-regular: 400;
  --wow-weight-medium: 500;
  --wow-weight-semibold: 600;
  --wow-weight-bold: 700;
  --wow-space-1: 0.25rem;
  --wow-space-2: 0.5rem;
  --wow-space-3: 0.75rem;
  --wow-space-4: 1rem;
  --wow-space-5: 1.25rem;
  --wow-space-6: 1.5rem;
  --wow-space-8: 2rem;
  --wow-radius-sm: 4px;
  --wow-radius-md: 6px;
  --wow-radius-lg: 8px;
  --wow-radius-full: 9999px;
  --wow-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --wow-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --wow-shadow-glow: 0 0 0 3px var(--wow-accent-ring);
  --wow-transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --wow-transition-base: 180ms cubic-bezier(0.4, 0, 0.2, 1);

  --bg: var(--wow-bg);
  --panel: var(--wow-surface);
  --panel-soft: var(--wow-bg-elevated);
  --ink: var(--wow-text);
  --muted: var(--wow-text-muted);
  --line: var(--wow-border);
  --teal: var(--wow-accent);
  --teal-soft: var(--wow-accent-soft);
  --gold: var(--wow-warning);
  --gold-soft: var(--wow-warning-soft);
  --green: var(--wow-success);
  --green-soft: var(--wow-success-soft);
  --red: var(--wow-danger);
  --red-soft: var(--wow-danger-soft);
  --blue: var(--wow-info);
  --blue-soft: var(--wow-info-soft);
  --shadow: var(--wow-shadow-sm);
  color-scheme: dark;
  font-family: var(--wow-font-sans);
}

html[data-theme="light"] {
  --wow-bg: #f3f6fa;
  --wow-bg-elevated: #f8fafc;
  --wow-surface: #ffffff;
  --wow-surface-hover: #f1f5f9;
  --wow-border: #e2e8f0;
  --wow-border-strong: #cbd5e1;
  --wow-text: #1e293b;
  --wow-text-strong: #0f172a;
  --wow-text-muted: #64748b;
  --wow-text-subtle: #94a3b8;
  --wow-text-inverse: #ffffff;
  --wow-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --wow-shadow-md: 0 4px 8px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --wow-shadow-glow: 0 0 0 3px var(--wow-accent-ring);
  --bg: var(--wow-bg);
  --panel: var(--wow-surface);
  --panel-soft: var(--wow-bg-elevated);
  --ink: var(--wow-text);
  --muted: var(--wow-text-muted);
  --line: var(--wow-border);
  --shadow: var(--wow-shadow-sm);
  color-scheme: light;
}

html[data-theme="light"] .section,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .record-card,
html[data-theme="light"] .stat-pill {
  border-color: #d7e0eb;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .sidebar,
html[data-theme="light"] .topbar {
  border-color: #d7e0eb;
}

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

html[data-theme="dark"] .primary-button {
  border-color: color-mix(in srgb, var(--wow-accent) 72%, #ffffff);
  background: var(--wow-accent);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .primary-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--wow-accent) 52%, #ffffff);
  background: color-mix(in srgb, var(--wow-accent) 82%, #ffffff);
  color: #ffffff;
}

html[data-theme="dark"] .secondary-button,
html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .sidebar-logout,
html[data-theme="dark"] .session-button,
html[data-theme="dark"] .session-logout {
  border-color: #334155;
  background: #111827;
  color: #e5e7eb;
}

html[data-theme="dark"] .secondary-button:hover:not(:disabled),
html[data-theme="dark"] .icon-button:hover,
html[data-theme="dark"] .sidebar-logout:hover,
html[data-theme="dark"] .session-button:hover,
html[data-theme="dark"] .session-logout:hover {
  border-color: #475569;
  background: #1e293b;
  color: #ffffff;
}

html[data-theme="dark"] .nav-button.is-active {
  background: rgba(56, 189, 248, 0.16);
  color: #f8fafc;
}

html[data-theme="dark"] .nav-button.is-active strong,
html[data-theme="dark"] .nav-button.is-active .nav-count,
html[data-theme="dark"] .header-theme__button.is-active {
  border-color: #475569;
  background: #020617;
  color: #ffffff;
}

html[data-theme="dark"] .header-theme {
  border-color: #334155;
  background: #0b1220;
}

html[data-theme="dark"] .header-theme__button {
  color: #cbd5e1;
}

html[data-theme="dark"] .brand-mark,
html[data-theme="dark"] .brand-preview__mark {
  border: 1px solid #334155;
  background: #111827;
  color: #e5e7eb;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .brand strong {
  color: #f8fafc;
}

html[data-theme="dark"] .brand small {
  color: #93a4ba;
}

html[data-theme="dark"] .production-stage {
  border-color: #334155;
  background: #111827;
  color: #e5e7eb;
}

html[data-theme="dark"] .production-stage:hover {
  border-color: #475569;
  background: #1e293b;
}

html[data-theme="dark"] .production-stage.is-active {
  border-color: color-mix(in srgb, var(--wow-accent) 58%, #ffffff);
  background: rgba(56, 189, 248, 0.16);
  color: #f8fafc;
}

html[data-theme="dark"] .production-stage.is-active span,
html[data-theme="dark"] .production-stage.is-active strong {
  color: #ffffff;
}

html[data-theme="dark"] .production-stage.is-active small {
  color: #cbd5e1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--wow-bg);
  color: var(--wow-text);
  font-family: var(--wow-font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

body.is-login .app-shell {
  display: block;
}

body.is-login .sidebar,
body.is-login .topbar {
  display: none;
}

body.is-login .main {
  min-height: 100vh;
}

body.is-login .view {
  min-height: 100vh;
  padding: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--wow-bg-elevated);
  border-right: 1px solid var(--wow-border);
  color: var(--wow-text);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--wow-space-3);
  min-height: 56px;
  padding: 0 var(--wow-space-3);
  border-bottom: 1px solid var(--wow-border);
  color: var(--wow-text-strong);
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  place-items: center;
  border-radius: var(--wow-radius-md);
  background: var(--wow-accent);
  color: var(--wow-text-inverse);
  font-weight: var(--wow-weight-bold);
}

.brand-mark img,
.brand-preview__mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: var(--wow-text-base);
  font-weight: var(--wow-weight-semibold);
}

.brand small {
  margin-top: 2px;
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: var(--wow-space-6);
  background: var(--wow-bg);
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: var(--wow-space-5);
  padding: var(--wow-space-6);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-surface);
  box-shadow: var(--wow-shadow-md);
}

.login-card--token-only {
  width: min(360px, 100%);
  gap: var(--wow-space-4);
  padding: var(--wow-space-5);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--wow-space-3);
}

.login-brand__mark {
  width: 44px;
  height: 44px;
}

.login-brand h1,
.login-brand p,
.login-copy h2,
.login-copy p {
  margin: 0;
}

.login-brand h1 {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-lg);
  font-weight: var(--wow-weight-bold);
}

.login-brand p,
.login-copy p {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-sm);
}

.login-copy {
  display: grid;
  gap: var(--wow-space-1);
}

.login-copy h2 {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
  font-weight: var(--wow-weight-semibold);
}

.login-submit {
  width: 100%;
  justify-content: center;
}

.client-portal {
  min-height: 100vh;
  background: var(--wow-bg);
}

.client-portal--login {
  display: grid;
  place-items: center;
  padding: var(--wow-space-6);
}

.client-login-card {
  width: min(440px, 100%);
}

.client-portal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wow-space-4);
  padding: var(--wow-space-4) var(--wow-space-6);
  border-bottom: 1px solid var(--wow-border);
  background: color-mix(in srgb, var(--wow-surface) 94%, transparent);
  backdrop-filter: blur(12px);
}

.client-portal-main {
  display: grid;
  gap: var(--wow-space-5);
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: var(--wow-space-6);
}

.client-order-list {
  display: grid;
  gap: var(--wow-space-4);
}

.client-order-card {
  display: grid;
  gap: var(--wow-space-4);
  padding: var(--wow-space-4);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-surface);
}

.client-order-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--wow-space-3);
}

.client-order-card__head h2 {
  margin: 0;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-lg);
}

.client-order-status {
  display: grid;
  justify-items: end;
  gap: var(--wow-space-1);
  min-width: 120px;
}

.client-order-status > span {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
  text-transform: uppercase;
}

.client-order-delivery {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--wow-space-1) var(--wow-space-2);
  padding: var(--wow-space-2) var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
}

.client-order-delivery span,
.client-order-delivery small {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.client-order-delivery span {
  font-weight: var(--wow-weight-semibold);
  text-transform: uppercase;
}

.client-order-delivery strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
}

.client-order-detail-strip {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(100px, 1fr));
  gap: var(--wow-space-2);
}

.client-order-detail-strip div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: var(--wow-space-2);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
}

.client-order-detail-strip span {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
  text-transform: uppercase;
}

.client-order-detail-strip strong {
  overflow: hidden;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-garment-stage-table {
  min-width: 560px;
}

.client-garment-stage-table th:nth-child(2),
.client-garment-stage-table td:nth-child(2) {
  width: 110px;
  text-align: center;
}

.client-garment-stages {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wow-space-1);
}

.client-garment-stage {
  width: fit-content;
  white-space: nowrap;
}

.client-order-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--wow-space-3);
}

.client-current-stage {
  display: grid;
  gap: 2px;
  padding: var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.client-current-stage span,
.client-current-stage small {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.client-current-stage span {
  font-weight: var(--wow-weight-semibold);
  text-transform: uppercase;
}

.client-current-stage strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-xl, 1.25rem);
}

.client-order-progressbar {
  height: 8px;
  overflow: hidden;
  border-radius: var(--wow-radius-full);
  background: var(--wow-border);
}

.client-order-progressbar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--wow-accent);
}

.client-order-facts {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--wow-space-2);
}

.client-order-facts div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: var(--wow-space-2);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
}

.client-order-facts span {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.client-order-facts strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-lg);
}

.client-stage-track {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--wow-space-2);
}

.client-stage-step {
  display: grid;
  gap: var(--wow-space-2);
  min-width: 0;
  padding: var(--wow-space-2);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
}

.client-stage-step__bar {
  height: 5px;
  overflow: hidden;
  border-radius: var(--wow-radius-full);
  background: var(--wow-border);
}

.client-stage-step__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--wow-accent);
}

.client-stage-step strong {
  display: block;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-xs);
}

.client-stage-step small {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.client-stage-step.is-active {
  border-color: var(--wow-accent);
  background: var(--wow-accent-soft);
}

.client-stage-step.is-done .client-stage-step__bar span {
  background: var(--wow-success);
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--wow-space-3);
  padding: var(--wow-space-3) var(--wow-space-2);
  overflow-y: auto;
}

.nav-group {
  display: grid;
  gap: 2px;
}

.nav-group + .nav-group {
  padding-top: var(--wow-space-3);
  border-top: 1px solid var(--wow-border);
}

.nav-group-title {
  padding: 0 var(--wow-space-3) var(--wow-space-1);
  color: var(--wow-text-subtle);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 36px;
  padding: var(--wow-space-2) var(--wow-space-3);
  border: 0;
  border-radius: var(--wow-radius-md);
  background: transparent;
  color: var(--wow-text-muted);
  font-size: var(--wow-text-sm);
  text-align: left;
  transition: background var(--wow-transition-fast), color var(--wow-transition-fast);
}

.nav-button span {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: var(--wow-space-3);
}

.nav-button strong {
  display: grid;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  place-items: center;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-sm);
  color: var(--wow-text-subtle);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
}

.nav-button strong svg,
.nav-button strong i[data-lucide] {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.nav-button:hover {
  background: var(--wow-surface-hover);
  color: var(--wow-text);
}

.nav-button.is-active {
  background: var(--wow-accent-soft);
  color: var(--wow-accent);
  font-weight: var(--wow-weight-medium);
}

.nav-button.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: var(--wow-radius-full);
  background: var(--wow-accent);
}

.nav-button.is-active strong {
  border-color: transparent;
  background: var(--wow-accent);
  color: var(--wow-text-inverse);
}

.nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--wow-space-2);
  border-radius: var(--wow-radius-full);
  background: var(--wow-surface-hover);
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-style: normal;
  font-weight: var(--wow-weight-semibold);
}

.nav-button.is-active .nav-count {
  background: var(--wow-accent);
  color: var(--wow-text-inverse);
}

.sidebar-footer {
  display: grid;
  gap: var(--wow-space-3);
  padding: var(--wow-space-2);
  border-top: 1px solid var(--wow-border);
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.sidebar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  gap: var(--wow-space-2);
  padding: 0 var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
  color: var(--wow-text);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-medium);
}

.sidebar-logout:hover {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
}

.sidebar-logout svg,
.sidebar-logout i[data-lucide] {
  width: 16px;
  height: 16px;
}

.ghost-button {
  min-height: 36px;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: transparent;
  color: var(--wow-text);
  transition: background var(--wow-transition-fast), border-color var(--wow-transition-fast);
}

.ghost-button:hover {
  background: var(--wow-surface-hover);
  border-color: var(--wow-border-strong);
}

.main {
  min-width: 0;
  background: var(--wow-bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  gap: var(--wow-space-4);
  padding: var(--wow-space-2) var(--wow-space-5);
  border-bottom: 1px solid var(--wow-border);
  background: var(--wow-surface);
  background: color-mix(in srgb, var(--wow-surface) 92%, transparent);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-xl, 1.25rem);
  font-weight: var(--wow-weight-bold);
  letter-spacing: 0;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-medium);
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--wow-space-2);
}

.session-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--wow-space-1);
}

.topbar .session-logout {
  display: none;
}

.session-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  gap: var(--wow-space-2);
  padding: 0 var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
  color: var(--wow-text);
  line-height: 1;
}

.session-button:hover {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
}

.session-button svg,
.session-button i[data-lucide] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--wow-accent);
}

.session-button span {
  display: grid;
  gap: 1px;
  text-align: left;
}

.session-button strong,
.session-button small {
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-button strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
}

.session-button small {
  color: var(--wow-text-muted);
  font-size: 0.68rem;
}

.session-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
  color: var(--wow-text-muted);
}

.session-logout:hover {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
  color: var(--wow-text);
}

.session-logout svg,
.session-logout i[data-lucide] {
  width: 16px;
  height: 16px;
}

.header-theme {
  display: inline-flex;
  align-items: center;
  gap: var(--wow-space-1);
  padding: 2px;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
}

.header-theme__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--wow-radius-md);
  background: transparent;
  color: var(--wow-text-muted);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-medium);
  line-height: 1;
  transition: background var(--wow-transition-fast), color var(--wow-transition-fast), border-color var(--wow-transition-fast);
}

.header-theme__button:hover {
  background: var(--wow-surface-hover);
  color: var(--wow-text);
}

.header-theme__button.is-active {
  border-color: var(--wow-accent);
  background: var(--wow-accent);
  color: var(--wow-text-inverse);
}

html[data-theme="light"] .header-theme__button.is-active {
  border-color: #0a0a0a;
  background: #0a0a0a;
  color: #ffffff;
}

.header-theme__button svg,
.header-theme__button i[data-lucide] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  min-width: auto;
  min-height: 34px;
  gap: var(--wow-space-2);
  padding: 0 var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
}

.stat-card strong {
  display: block;
  margin-top: var(--wow-space-1);
  color: var(--wow-text-strong);
  font-size: var(--wow-text-xl, 1.25rem);
  font-weight: var(--wow-weight-bold);
  line-height: 1.1;
}

.stat-card span {
  display: block;
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-medium);
  letter-spacing: 0;
  text-transform: uppercase;
}

.stat-pill strong {
  display: inline;
  margin: 0;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
  font-weight: var(--wow-weight-bold);
  line-height: 1;
}

.stat-pill span {
  display: inline;
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
  letter-spacing: 0;
  text-transform: uppercase;
}

.view {
  padding: var(--wow-space-6);
}

.grid {
  display: grid;
  gap: var(--wow-space-4);
}

.grid.two {
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.3fr);
  align-items: start;
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.section,
.stat-card,
.record-card {
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-surface);
  box-shadow: none;
}

.section {
  padding: var(--wow-space-5);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--wow-space-4);
  margin-bottom: var(--wow-space-4);
}

.section-header h2,
.section-header h3 {
  margin: 0;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
  font-weight: var(--wow-weight-semibold);
  letter-spacing: 0;
}

.section-header p {
  margin: 2px 0 0;
  color: var(--wow-text-muted);
  font-size: var(--wow-text-sm);
}

.stat-card {
  padding: var(--wow-space-5);
}

.stat-card strong {
  font-size: var(--wow-text-3xl);
}

.grid.three.costs-summary-grid {
  gap: var(--wow-space-3);
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.cost-stat-card {
  min-height: 72px;
  padding: var(--wow-space-3);
}

.cost-stat-card span {
  font-size: 0.66rem;
}

.cost-stat-card strong {
  margin-top: 2px;
  font-size: var(--wow-text-xl, 1.25rem);
  line-height: 1.1;
}

.record-list {
  display: grid;
  gap: var(--wow-space-3);
}

.record-card {
  padding: var(--wow-space-4);
  transition: background var(--wow-transition-fast), border-color var(--wow-transition-fast);
}

.record-list .record-card {
  padding: var(--wow-space-3);
}

.record-card:hover {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
}

.record-head {
  display: flex;
  justify-content: space-between;
  gap: var(--wow-space-3);
  margin-bottom: var(--wow-space-3);
}

.record-list .record-head {
  align-items: flex-start;
  margin-bottom: var(--wow-space-2);
}

.record-head__aside {
  display: flex;
  align-items: flex-start;
  gap: var(--wow-space-3);
}

.record-head h3 {
  margin: 0;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
  font-weight: var(--wow-weight-semibold);
}

.record-list .record-head h3 {
  font-size: var(--wow-text-sm);
  line-height: 1.2;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wow-space-2);
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.record-list .record-meta {
  gap: 6px;
  font-size: 0.72rem;
}

.batch-timer {
  display: grid;
  min-width: 132px;
  padding: 6px 10px;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
  color: var(--wow-text);
  text-align: right;
}

.batch-timer span {
  color: var(--wow-text-muted);
  font-size: 0.58rem;
  font-weight: var(--wow-weight-semibold);
  letter-spacing: 0;
  text-transform: uppercase;
}

.batch-timer strong {
  color: var(--wow-text-strong);
  font-family: var(--wow-font-mono);
  font-size: var(--wow-text-base);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.batch-timer small {
  color: var(--wow-text-muted);
  font-size: 0.62rem;
}

.record-list .table-wrap {
  border-radius: var(--wow-radius-md);
}

.record-list .compact-table th,
.record-list .compact-table td {
  padding: 8px var(--wow-space-3);
  line-height: 1.15;
}

.batch-finish-form {
  grid-template-columns: minmax(220px, 0.5fr) auto;
  align-items: end;
  gap: var(--wow-space-2);
  margin-top: var(--wow-space-2);
}

.batch-finish-form label {
  max-width: 420px;
}

.batch-finish-form input {
  min-height: 34px;
}

.batch-finish-form .button-row {
  align-self: end;
}

.batch-finish-form .primary-button {
  min-height: 36px;
  padding: 0 var(--wow-space-3);
}

.batch-timer.is-warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
}

.batch-timer.is-warning strong {
  color: #b45309;
}

.batch-timer.is-overdue {
  border-color: rgba(220, 38, 38, 0.45);
  background: rgba(220, 38, 38, 0.1);
}

.batch-timer.is-overdue strong {
  color: #dc2626;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--wow-space-3);
}

.form-grid--three {
  grid-template-columns: 1.3fr 0.7fr 1fr;
}

.load-user-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--wow-space-2);
  margin-bottom: var(--wow-space-2);
  padding: var(--wow-space-2) var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
}

.load-user-banner span {
  display: inline-flex;
  align-items: center;
  gap: var(--wow-space-2);
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
  text-transform: uppercase;
}

.load-user-banner strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-bold);
}

.load-user-banner small {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.load-user-banner svg,
.load-user-banner i[data-lucide] {
  width: 16px;
  height: 16px;
  color: var(--wow-accent);
}

.form-grid .full,
.full {
  grid-column: 1 / -1;
}

.form-subsection {
  margin-top: var(--wow-space-2);
  padding-top: var(--wow-space-2);
  border-top: 1px solid var(--wow-border);
}

.form-subsection:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.form-subsection h3 {
  margin: 0;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-semibold);
}

.form-subsection--action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wow-space-3);
}

.client-extra-contact-fields.is-hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

label {
  display: grid;
  gap: var(--wow-space-2);
  color: var(--wow-text);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-medium);
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 0 var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
  color: var(--wow-text);
  outline: none;
  transition: background var(--wow-transition-fast), border-color var(--wow-transition-fast), box-shadow var(--wow-transition-fast);
}

input::placeholder,
textarea::placeholder {
  color: var(--wow-text-subtle);
}

select {
  appearance: none;
  padding-right: var(--wow-space-8);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-position: right var(--wow-space-3) center;
  background-repeat: no-repeat;
}

textarea {
  min-height: 80px;
  padding: var(--wow-space-3);
  line-height: 1.5;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--wow-border-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--wow-accent);
  box-shadow: var(--wow-shadow-glow);
}

.search-field {
  position: relative;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 25;
  display: none;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
  box-shadow: var(--wow-shadow-md);
}

.search-field:focus-within .search-results {
  display: block;
}

.search-option {
  display: grid;
  width: 100%;
  gap: 2px;
  padding: var(--wow-space-3);
  border: 0;
  border-bottom: 1px solid var(--wow-border);
  background: transparent;
  color: var(--wow-text);
  text-align: left;
}

.search-option:hover,
.search-option:focus-visible {
  background: var(--wow-surface-hover);
  outline: none;
}

.search-option strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-sm);
}

.search-option span,
.search-empty {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.search-option.is-hidden,
.search-empty {
  display: none;
}

.search-empty.is-visible {
  display: block;
  padding: var(--wow-space-3);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wow-space-2);
  align-items: center;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wow-space-3);
  align-items: center;
}

.file-button {
  display: inline-flex;
  align-items: center;
  gap: var(--wow-space-2);
}

.file-button input {
  display: none;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 var(--wow-space-4);
  border: 1px solid transparent;
  border-radius: var(--wow-radius-md);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-medium);
  line-height: 1;
  white-space: nowrap;
  transition: background var(--wow-transition-fast), border-color var(--wow-transition-fast), color var(--wow-transition-fast), box-shadow var(--wow-transition-fast);
}

.primary-button {
  border-color: var(--wow-accent);
  background: var(--wow-accent);
  color: var(--wow-text-inverse);
}

.primary-button:hover:not(:disabled) {
  border-color: var(--wow-accent-hover);
  background: var(--wow-accent-hover);
}

.secondary-button {
  border-color: var(--wow-border);
  background: var(--wow-surface);
  color: var(--wow-text);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
}

.danger-button {
  border-color: var(--wow-danger);
  background: var(--wow-danger);
  color: #ffffff;
}

.danger-button:hover:not(:disabled) {
  border-color: #dc2626;
  background: #dc2626;
}

.icon-button {
  min-width: 36px;
  padding: 0;
  border-color: var(--wow-border);
  background: var(--wow-surface);
  color: var(--wow-text);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-surface);
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: var(--wow-surface);
  font-size: var(--wow-text-sm);
}

th,
td {
  padding: var(--wow-space-3) var(--wow-space-4);
  border-bottom: 1px solid var(--wow-border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--wow-bg-elevated);
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-medium);
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: var(--wow-text);
}

tbody tr {
  transition: background var(--wow-transition-fast);
}

tbody tr:hover {
  background: var(--wow-surface-hover);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wow-space-3);
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.pagination-controls,
.pagination-pages {
  display: flex;
  align-items: center;
  gap: var(--wow-space-2);
}

.pagination-button {
  min-height: 34px;
  padding: 0 var(--wow-space-3);
}

.pagination-page {
  min-width: 34px;
  height: 34px;
  padding: 0 var(--wow-space-2);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
  color: var(--wow-text);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-semibold);
}

.pagination-page:hover:not(:disabled) {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
}

.pagination-page.is-active {
  border-color: var(--wow-text-strong);
  background: var(--wow-text-strong);
  color: var(--wow-bg);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus-visible {
  outline: 2px solid var(--wow-accent-ring);
  outline-offset: -2px;
}

tr:last-child td {
  border-bottom: 0;
}

.actions-cell {
  width: 1%;
  white-space: nowrap;
}

.compact-table {
  min-width: 520px;
}

.qty-input {
  max-width: 110px;
  font-family: var(--wow-font-mono);
  font-variant-numeric: tabular-nums;
}

.qty-fill-control {
  display: inline-flex;
  align-items: center;
  gap: var(--wow-space-2);
}

.qty-fill-control .qty-input {
  width: 96px;
}

.production-load-modal .keypad-number-input {
  min-height: 34px;
  cursor: pointer;
  caret-color: transparent;
  user-select: none;
}

.production-load-modal .keypad-number-input[readonly] {
  background: var(--wow-surface);
}

.production-load-modal .keypad-number-input.is-keypad-active {
  border-color: var(--wow-accent);
  background: var(--wow-surface);
  box-shadow: inset 0 0 0 1px var(--wow-accent);
}

.production-load-modal .qty-input {
  text-align: center;
}

.production-load-modal .work-percent-input {
  text-align: left;
}

.qty-fill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 var(--wow-space-2);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
  color: var(--wow-text);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
}

.qty-fill-button:hover {
  border-color: var(--wow-accent);
  background: var(--wow-accent-soft);
  color: var(--wow-text-strong);
}

.qty-fill-button--group {
  min-height: 26px;
  padding: 0 var(--wow-space-2);
  white-space: nowrap;
}

.production-allocation-wrap {
  height: min(46vh, 420px);
  max-height: min(46vh, 420px);
  overflow: auto;
}

.production-load-modal.has-allocation-keypad .production-allocation-wrap {
  height: min(46vh, 420px);
  max-height: min(46vh, 420px);
}

.production-load-modal .production-allocation-table {
  min-width: 760px;
}

.production-load-modal .production-allocation-table th,
.production-load-modal .production-allocation-table td {
  padding: 3px var(--wow-space-3);
  line-height: 1.1;
}

.production-allocation-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

.production-allocation-table .production-order-group td {
  background: var(--wow-bg-elevated);
  color: var(--wow-text-strong);
  font-size: var(--wow-text-xs);
}

.production-allocation-table .production-order-group td:first-child,
.production-allocation-table .production-order-group td:nth-child(2) {
  white-space: nowrap;
}

.production-allocation-table .production-order-group td:nth-child(2) {
  min-width: 160px;
}

.production-allocation-table .production-order-group td:last-child {
  color: var(--wow-text-muted);
  font-weight: var(--wow-weight-medium);
  text-align: right;
}

.production-allocation-table .production-order-item.is-keypad-active td {
  background: var(--wow-surface-hover);
}

.production-allocation-table .production-order-item td {
  padding-top: 2px;
  padding-bottom: 2px;
}

.production-allocation-table .production-order-item td:first-child,
.production-allocation-table .production-order-item td:nth-child(2) {
  width: 1%;
  padding: 0;
}

.production-load-modal .production-order-item .qty-input {
  width: 68px;
  height: 28px;
  min-height: 28px;
}

.production-load-modal .production-order-item .qty-fill-button {
  height: 28px;
  min-height: 28px;
  padding: 0 var(--wow-space-2);
}

.allocation-keypad {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  align-content: start;
  gap: var(--wow-space-3);
  min-width: 260px;
  padding: var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
  box-shadow: var(--wow-shadow-sm);
}

.allocation-keypad.is-disabled {
  opacity: 0.58;
}

.allocation-keypad.is-disabled .allocation-key {
  pointer-events: none;
}

.allocation-keypad__display {
  display: grid;
  gap: 2px;
}

.allocation-keypad__display span {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
  text-transform: uppercase;
}

.allocation-keypad__display strong {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
  color: var(--wow-text-strong);
  font-family: var(--wow-font-mono);
  font-size: var(--wow-text-base);
  font-weight: var(--wow-weight-bold);
  font-variant-numeric: tabular-nums;
  padding: 0 var(--wow-space-3);
}

.allocation-keypad__keys {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--wow-space-1);
}

.allocation-key {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-surface);
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
  font-weight: var(--wow-weight-semibold);
  line-height: 1;
  transition: background var(--wow-transition-fast), border-color var(--wow-transition-fast), transform var(--wow-transition-fast);
  touch-action: manipulation;
}

.allocation-key:hover {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
}

.allocation-key:active {
  transform: translateY(1px);
}

.allocation-key svg,
.allocation-key i[data-lucide] {
  width: 18px;
  height: 18px;
}

.allocation-key--muted {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-sm);
}

.allocation-key--accent {
  border-color: var(--wow-accent);
  background: var(--wow-accent-soft);
  color: var(--wow-accent);
  font-size: var(--wow-text-sm);
}

.allocation-key--primary {
  border-color: var(--wow-accent);
  background: var(--wow-accent);
  color: var(--wow-text-inverse);
  font-size: var(--wow-text-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  gap: var(--wow-space-1);
  padding: 2px var(--wow-space-2);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-full);
  background: var(--wow-surface);
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-medium);
  line-height: 1.4;
  white-space: nowrap;
}

.badge.green {
  border-color: transparent;
  background: var(--wow-success-soft);
  color: var(--wow-success);
}

.badge.gold {
  border-color: transparent;
  background: var(--wow-warning-soft);
  color: var(--wow-warning);
}

.badge.blue {
  border-color: transparent;
  background: var(--wow-info-soft);
  color: var(--wow-info);
}

.badge.red {
  border-color: transparent;
  background: var(--wow-danger-soft);
  color: var(--wow-danger);
}

.badge.teal {
  border-color: transparent;
  background: var(--wow-accent-soft);
  color: var(--wow-accent);
}

.stack {
  display: grid;
  gap: var(--wow-space-3);
}

.small {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.total-line {
  display: flex;
  justify-content: space-between;
  gap: var(--wow-space-3);
  margin-top: var(--wow-space-3);
  padding-top: var(--wow-space-3);
  border-top: 1px solid var(--wow-border);
  color: var(--wow-text-strong);
  font-weight: var(--wow-weight-semibold);
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--wow-space-2);
}

.progress-step {
  min-height: 58px;
  padding: var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.progress-step strong {
  display: block;
  margin-top: var(--wow-space-1);
  color: var(--wow-text-strong);
  font-size: var(--wow-text-lg);
}

.progress-step span {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.production-stages {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: var(--wow-space-5);
  width: min(980px, calc(100% - 64px));
  margin: var(--wow-space-3) auto var(--wow-space-4);
}

.production-log-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: var(--wow-space-4);
  width: min(1080px, calc(100% - 64px));
  margin: var(--wow-space-3) auto var(--wow-space-5);
}

.production-log-table-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 0.8fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr) auto;
  align-items: end;
  gap: var(--wow-space-3);
  padding: var(--wow-space-4);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.production-log-table-tools .button-row {
  align-items: end;
  justify-content: flex-end;
  margin: 0;
}

.production-stage {
  display: grid;
  min-height: 68px;
  gap: 2px;
  padding: var(--wow-space-2) var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
  color: var(--wow-text);
  text-align: left;
  transition: background var(--wow-transition-fast), border-color var(--wow-transition-fast), color var(--wow-transition-fast);
}

.production-stage:hover {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
}

.production-stage.is-active {
  border-color: var(--wow-accent);
  background: var(--wow-accent-soft);
  color: var(--wow-accent);
}

.production-stage span,
.production-stage small {
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
  letter-spacing: 0;
}

.production-stage small {
  color: var(--wow-text-muted);
}

.production-stage strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-2xl);
  line-height: 1;
}

.empty {
  display: grid;
  min-height: 112px;
  place-items: center;
  border: 1px dashed var(--wow-border-strong);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
  color: var(--wow-text-muted);
  font-size: var(--wow-text-sm);
  text-align: center;
}

.toast {
  position: fixed;
  right: var(--wow-space-6);
  bottom: var(--wow-space-6);
  z-index: 30;
  max-width: min(420px, calc(100vw - 48px));
  padding: var(--wow-space-3) var(--wow-space-4);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-surface);
  color: var(--wow-text-strong);
  box-shadow: var(--wow-shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--wow-transition-base), transform var(--wow-transition-base);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .brand {
    min-height: 52px;
  }

  .nav {
    display: flex;
    flex-direction: column;
    flex: initial;
    gap: var(--wow-space-3);
    padding: var(--wow-space-2);
  }

  .nav-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-group-title {
    grid-column: 1 / -1;
    padding: var(--wow-space-1) var(--wow-space-2);
  }

  .nav-button.is-active::before {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: var(--wow-space-4);
  }

  .topbar-stats {
    width: 100%;
    justify-content: stretch;
  }

  .stat-pill {
    flex: 1 1 140px;
  }

  .view {
    padding: var(--wow-space-4);
  }

  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .production-stages {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(560px, calc(100% - var(--wow-space-4)));
  }

  .production-log-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(640px, calc(100% - var(--wow-space-4)));
  }

  .production-log-table-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .production-load-modal.has-allocation-keypad .production-allocation-wrap {
    max-height: min(34vh, 320px);
  }

  .production-load-workspace {
    grid-template-columns: 1fr;
  }

  .allocation-keypad {
    position: static;
    min-width: 0;
  }

  .allocation-keypad__keys {
    grid-template-columns: repeat(5, minmax(42px, 1fr));
  }

  .allocation-key {
    min-height: 42px;
  }
}

@media (max-width: 640px) {
  .production-stages {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .production-log-filters {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .production-log-table-tools {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .nav-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-button {
    min-height: 44px;
    padding: var(--wow-space-2);
  }

  .form-grid,
  .progress-steps {
    grid-template-columns: 1fr;
  }

  .load-user-banner {
    grid-template-columns: 1fr;
    gap: var(--wow-space-1);
  }

  .record-head,
  .section-header {
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    min-height: 44px;
  }

  .allocation-keypad__display {
    align-items: stretch;
    min-width: 0;
  }

  .allocation-keypad__display strong {
    width: 100%;
  }
}

/* HanezUI composition fixes for this app's generated markup. */
.section.wow-card {
  padding: 0;
  overflow: hidden;
}

.section > .section-header.wow-card__header {
  margin-bottom: 0;
}

.section > form,
.section > .table-wrap,
.section > .record-list,
.section > .grid,
.section > .empty,
.section > .progress-steps,
.section > .record-meta,
.section > .total-line,
.section > .pagination-bar {
  margin: var(--wow-space-5);
}

.section > form + .table-wrap,
.section > form + .record-meta,
.section > .grid + .table-wrap,
.section > .table-wrap + .total-line,
.section > .table-wrap + .pagination-bar,
.section > .record-list + .pagination-bar {
  margin-top: 0;
}

.section > .section-header + .empty {
  margin-top: var(--wow-space-5);
}

.stat-pill.wow-stat {
  min-width: auto;
  padding: 0 var(--wow-space-3);
}

.stat-pill .wow-stat__label,
.stat-pill .wow-stat__value {
  display: inline;
  margin: 0;
  line-height: 1;
}

.stat-pill .wow-stat__value {
  font-size: var(--wow-text-base);
}

.brand-preview {
  display: flex;
  align-items: center;
  gap: var(--wow-space-3);
  margin: 0 var(--wow-space-5) var(--wow-space-5);
  padding: var(--wow-space-4);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.brand-preview__mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  place-items: center;
  border-radius: var(--wow-radius-md);
  background: var(--wow-accent);
  color: var(--wow-text-inverse);
  font-weight: var(--wow-weight-bold);
}

.brand-preview strong,
.brand-preview small {
  display: block;
}

.brand-preview small {
  margin-top: 2px;
  color: var(--wow-text-muted);
}

.price-actions {
  margin: var(--wow-space-4) var(--wow-space-5) var(--wow-space-5);
}

.order-modal {
  width: min(1040px, calc(100vw - var(--wow-space-8)));
  max-width: none;
}

.wow-modal-overlay {
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: none;
}

.module-modal {
  width: min(920px, calc(100vw - var(--wow-space-8)));
  max-width: none;
}

.production-load-modal {
  width: min(1280px, calc(100vw - var(--wow-space-4)));
}

.production-load-modal .wow-modal__header {
  padding: var(--wow-space-3) var(--wow-space-4);
}

.production-load-modal .wow-modal__body {
  padding: var(--wow-space-3);
}

.production-load-modal .wow-modal__footer {
  padding: var(--wow-space-2) var(--wow-space-3);
}

.production-load-modal textarea {
  min-height: 38px;
  max-height: 58px;
}

.production-load-modal .form-grid {
  gap: var(--wow-space-2);
}

.production-load-modal label {
  gap: 5px;
  font-size: var(--wow-text-xs);
}

.production-load-modal input,
.production-load-modal select {
  min-height: 34px;
}

.production-load-modal .qty-fill-control .qty-input {
  width: 78px;
}

.production-load-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: var(--wow-space-3);
  align-items: start;
}

.production-load-main {
  min-width: 0;
  max-height: min(46vh, 420px);
  overflow: hidden;
}

.module-modal--sm {
  width: min(620px, calc(100vw - var(--wow-space-8)));
}

.client-modal {
  width: min(940px, calc(100vw - var(--wow-space-8)));
}

.client-modal .wow-modal__body {
  max-height: min(70vh, 720px);
  overflow: auto;
}

.client-modal .form-grid {
  gap: var(--wow-space-2) var(--wow-space-3);
}

.client-site-list {
  display: grid;
  gap: var(--wow-space-2);
}

.client-site-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(130px, 0.7fr) minmax(220px, 1.5fr);
  gap: var(--wow-space-2);
  padding: var(--wow-space-2);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
}

.client-site-row.has-remove {
  grid-template-columns: minmax(130px, 0.8fr) minmax(130px, 0.7fr) minmax(220px, 1.5fr) 36px;
}

.client-site-row label {
  min-width: 0;
}

.client-site-row__remove {
  align-self: end;
}

.token-modal {
  width: min(420px, calc(100vw - var(--wow-space-8)));
}

.production-log-modal {
  width: min(1120px, calc(100vw - var(--wow-space-8)));
}

.production-log-modal .wow-modal__body {
  display: grid;
  gap: var(--wow-space-4);
  max-height: min(72vh, 760px);
  overflow: auto;
}

.production-log-modal .detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--wow-space-3);
  margin-bottom: 0;
}

.production-log-modal .detail-panel {
  padding: var(--wow-space-3);
}

.production-log-modal .detail-panel dl {
  grid-template-columns: minmax(100px, 0.42fr) minmax(0, 1fr);
  gap: var(--wow-space-2);
}

.production-log-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--wow-space-3);
}

.production-log-summary-card {
  display: grid;
  gap: 3px;
  padding: var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.production-log-summary-card span {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
  font-weight: var(--wow-weight-semibold);
  text-transform: uppercase;
}

.production-log-summary-card strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
}

.production-log-summary-card small {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.production-overdue-modal {
  width: min(920px, calc(100vw - var(--wow-space-8)));
  max-width: none;
}

.production-overdue-list {
  display: grid;
  gap: var(--wow-space-3);
}

.production-overdue-card {
  display: grid;
  gap: var(--wow-space-3);
  padding: var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-left: 3px solid var(--wow-danger);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.production-overdue-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--wow-space-3);
}

.production-overdue-card__head strong,
.production-overdue-card__head span {
  display: block;
}

.production-overdue-card__head strong {
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
}

.production-overdue-card__head span {
  margin-top: 2px;
  color: var(--wow-text-muted);
  font-size: var(--wow-text-sm);
}

.production-overdue-card .table-wrap {
  max-height: 220px;
  overflow: auto;
}

.production-overdue-card__actions {
  justify-content: flex-end;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--wow-space-4);
  margin-bottom: var(--wow-space-4);
}

.detail-panel {
  padding: var(--wow-space-4);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.detail-panel h3 {
  margin: 0 0 var(--wow-space-3);
  color: var(--wow-text-strong);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-semibold);
}

.detail-panel dl {
  display: grid;
  grid-template-columns: minmax(90px, 0.45fr) minmax(0, 1fr);
  gap: var(--wow-space-2) var(--wow-space-3);
  margin: 0;
}

.detail-panel dl + dl {
  margin-top: var(--wow-space-4);
  padding-top: var(--wow-space-4);
  border-top: 1px solid var(--wow-border);
}

.detail-panel dt {
  color: var(--wow-text-muted);
  font-size: var(--wow-text-xs);
}

.detail-panel dd {
  min-width: 0;
  margin: 0;
  color: var(--wow-text);
  word-break: break-word;
}

.token-pad {
  display: grid;
  gap: var(--wow-space-4);
}

.token-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.token-display {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--wow-space-3);
  padding: var(--wow-space-4);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.token-dot {
  display: block;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2px solid var(--wow-border-strong);
  border-radius: 999px;
  background: transparent;
}

.token-dot.is-filled {
  border-color: var(--wow-accent);
  background: var(--wow-accent);
}

.token-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--wow-space-3);
}

.token-key {
  display: inline-flex;
  min-height: 68px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-md);
  background: var(--wow-bg-elevated);
  color: var(--wow-text-strong);
  font-size: var(--wow-text-2xl);
  font-weight: var(--wow-weight-bold);
  line-height: 1;
  transition: background var(--wow-transition-fast), border-color var(--wow-transition-fast), transform var(--wow-transition-fast);
}

.token-key:hover {
  border-color: var(--wow-border-strong);
  background: var(--wow-surface-hover);
}

.token-key:active {
  transform: translateY(1px);
}

.token-key--muted {
  color: var(--wow-text-muted);
}

.token-key svg {
  width: 24px;
  height: 24px;
}

.token-submit {
  min-width: 140px;
}

.order-modal .wow-modal__body,
.module-modal .wow-modal__body {
  max-height: min(68vh, 760px);
}

.order-modal {
  width: min(1180px, calc(100vw - var(--wow-space-8)));
}

.order-modal .wow-modal__header {
  padding: var(--wow-space-4) var(--wow-space-5);
}

.order-modal .wow-modal__body {
  max-height: none;
  overflow: visible;
  padding: var(--wow-space-4);
}

.order-modal .wow-modal__footer {
  padding: var(--wow-space-3) var(--wow-space-4);
}

.order-quick-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.85fr) minmax(460px, 1.15fr);
  gap: var(--wow-space-3);
  align-items: start;
}

.order-compact-panel {
  display: grid;
  gap: var(--wow-space-3);
  padding: var(--wow-space-3);
  border: 1px solid var(--wow-border);
  border-radius: var(--wow-radius-lg);
  background: var(--wow-bg-elevated);
}

.order-compact-panel__header,
.order-lines-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wow-space-3);
}

.order-compact-panel__header h3 {
  margin: 0;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-sm);
  font-weight: var(--wow-weight-semibold);
}

.order-details-grid,
.order-item-grid {
  display: grid;
  gap: var(--wow-space-2);
}

.order-details-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.order-item-grid {
  grid-template-columns: minmax(72px, 0.55fr) minmax(96px, 0.7fr) minmax(125px, 1fr) minmax(112px, 0.8fr);
  align-items: end;
}

.order-details-grid .full,
.order-item-garment {
  grid-column: 1 / -1;
}

.order-modal label {
  gap: 5px;
  font-size: var(--wow-text-xs);
}

.order-modal input,
.order-modal select {
  min-height: 36px;
}

.order-modal textarea {
  min-height: 56px;
  resize: vertical;
}

.order-add-line-button {
  min-height: 32px;
  padding: 0 var(--wow-space-3);
  white-space: nowrap;
}

.danger-icon {
  color: var(--wow-danger);
}

.order-lines-panel {
  display: grid;
  gap: var(--wow-space-3);
  padding-top: var(--wow-space-2);
}

.order-lines-panel--compact {
  margin-top: var(--wow-space-3);
  padding-top: 0;
}

.order-lines-panel--compact .empty {
  margin-top: 0 !important;
  padding: var(--wow-space-3);
}

.order-lines-panel--compact .table-wrap {
  margin-top: 0 !important;
}

.order-lines-panel--compact th,
.order-lines-panel--compact td {
  padding: 2px var(--wow-space-3);
  line-height: 1;
}

.order-lines-panel--compact table {
  font-size: var(--wow-text-xs);
}

.order-lines-panel--compact .icon-button {
  width: 22px;
  min-width: 22px;
  min-height: 22px;
  height: 22px;
  padding: 0;
  font-size: var(--wow-text-xs);
}

.order-lines-panel__header h3 {
  margin: 0;
  color: var(--wow-text-strong);
  font-size: var(--wow-text-base);
  font-weight: var(--wow-weight-semibold);
}

@media (max-width: 640px) {
  .order-modal,
  .module-modal,
  .module-modal--sm,
  .client-modal,
  .token-modal {
    width: 100%;
  }
}

/* Responsive pass across the operational shell, data grids and modals. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

input,
select,
textarea,
button {
  min-width: 0;
}

.topbar > div:first-child,
.topbar-stats,
.nav-button .wow-sidebar__item-label,
.section-header > div,
.record-head > div,
.order-compact-panel,
.production-load-main {
  min-width: 0;
}

.nav-button .wow-sidebar__item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .view {
    padding: var(--wow-space-5);
  }

  .topbar {
    gap: var(--wow-space-3);
    padding-inline: var(--wow-space-4);
  }

  .grid.two {
    grid-template-columns: minmax(0, 1fr);
  }

  .grid.three:not(.costs-summary-grid),
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.three.costs-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .client-stage-track {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .client-order-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .client-order-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .client-order-detail-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .production-stages {
    width: min(860px, calc(100% - var(--wow-space-4)));
    gap: var(--wow-space-3);
  }

  .production-log-filters {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .production-log-table-tools {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .production-log-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .production-log-table-tools .button-row {
    justify-content: flex-start;
  }

  .order-modal,
  .module-modal,
  .production-log-modal {
    width: min(1080px, calc(100vw - var(--wow-space-4)));
  }

  .production-load-modal {
    width: min(1180px, calc(100vw - var(--wow-space-4)));
  }

  .production-load-workspace {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .allocation-keypad {
    min-width: 240px;
  }
}

@media (max-width: 1120px) {
  .order-modal .wow-modal__body {
    max-height: min(72vh, 760px);
    overflow: auto;
  }

  .order-quick-layout {
    grid-template-columns: 1fr;
  }

  .order-item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--wow-border);
  }

  .brand {
    min-height: 50px;
  }

  .nav {
    flex: initial;
    padding: var(--wow-space-2);
  }

  .nav-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-group-title {
    grid-column: 1 / -1;
  }

  .nav-button {
    min-height: 42px;
  }

  .nav-button.is-active::before,
  .sidebar-footer {
    display: none;
  }

  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    padding: var(--wow-space-3) var(--wow-space-4);
  }

  .topbar-stats {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar .session-logout {
    display: inline-flex;
  }

  .stat-pill {
    flex: 1 1 150px;
    justify-content: space-between;
  }

  .view {
    padding: var(--wow-space-4);
  }

  .grid.two,
  .grid.three:not(.costs-summary-grid),
  .grid.four {
    grid-template-columns: 1fr;
  }

  .grid.three.costs-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .production-stages {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    margin-inline: 0;
  }

  .production-log-filters,
  .production-log-table-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    margin-inline: 0;
  }

  .production-log-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid--three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .production-load-modal.has-allocation-keypad .production-allocation-wrap {
    height: min(36vh, 340px);
    max-height: min(36vh, 340px);
  }

  .production-load-main {
    max-height: min(36vh, 340px);
  }

  .production-load-workspace {
    grid-template-columns: minmax(0, 1fr) 232px;
  }

  .allocation-keypad {
    position: sticky;
    top: 0;
    min-width: 0;
  }

  .allocation-keypad__keys {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .production-load-modal .production-allocation-table {
    min-width: 620px;
  }

  .allocation-key {
    min-height: 42px;
  }
}

@media (max-width: 760px) {
  .topbar-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-actions,
  .session-button,
  .header-theme {
    width: 100%;
  }

  .session-button {
    justify-content: flex-start;
  }

  .header-theme {
    justify-content: center;
  }

  .stat-pill {
    width: 100%;
  }

  .section > form,
  .section > .table-wrap,
  .section > .record-list,
  .section > .grid,
  .section > .empty,
  .section > .progress-steps,
  .section > .record-meta,
  .section > .total-line,
  .section > .pagination-bar {
    margin: var(--wow-space-4);
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-controls {
    justify-content: space-between;
    width: 100%;
  }

  .pagination-pages {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .section-header {
    gap: var(--wow-space-3);
  }

  .button-row {
    align-items: stretch;
  }

  .button-row > button,
  .button-row > .primary-button,
  .button-row > .secondary-button,
  .button-row > .danger-button,
  .button-row > .file-button {
    flex: 1 1 160px;
  }

  .detail-grid,
  .form-grid,
  .form-grid--three,
  .order-details-grid,
  .order-item-grid,
  .progress-steps {
    grid-template-columns: 1fr;
  }

  .client-site-row,
  .client-site-row.has-remove {
    grid-template-columns: 1fr;
  }

  .client-site-row__remove {
    justify-self: start;
  }

  .load-user-banner {
    grid-template-columns: 1fr;
    gap: var(--wow-space-1);
  }

  .production-load-modal,
  .order-modal,
  .module-modal,
  .module-modal--sm,
  .client-modal,
  .token-modal,
  .production-overdue-modal,
  .production-log-modal {
    width: min(100%, calc(100vw - var(--wow-space-3)));
  }

  .wow-modal__header,
  .order-modal .wow-modal__header,
  .production-load-modal .wow-modal__header {
    padding: var(--wow-space-3);
  }

  .wow-modal__body,
  .order-modal .wow-modal__body,
  .production-load-modal .wow-modal__body {
    max-height: calc(100vh - 156px);
    overflow: auto;
    padding: var(--wow-space-3);
  }

  .wow-modal__footer,
  .order-modal .wow-modal__footer,
  .production-load-modal .wow-modal__footer {
    padding: var(--wow-space-3);
  }

  .order-lines-panel__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .production-load-modal textarea {
    max-height: none;
  }

  .production-overdue-card__head,
  .production-overdue-card__actions {
    align-items: stretch;
    flex-direction: column;
  }

  .production-load-workspace {
    grid-template-columns: 1fr;
  }

  .allocation-keypad {
    position: static;
  }

  .allocation-keypad__keys {
    grid-template-columns: repeat(5, minmax(42px, 1fr));
  }
}

@media (max-width: 640px) {
  .login-view {
    padding: var(--wow-space-4);
  }

  .login-card,
  .login-card--token-only {
    padding: var(--wow-space-4);
  }

  .token-key {
    min-height: 56px;
    font-size: var(--wow-text-xl, 1.25rem);
  }

  .view {
    padding: var(--wow-space-3);
  }

  .brand {
    padding-inline: var(--wow-space-3);
  }

  .brand strong,
  .brand small {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-button {
    align-items: flex-start;
    min-height: 44px;
    padding: var(--wow-space-2);
  }

  .nav-button span {
    gap: var(--wow-space-2);
  }

  .topbar {
    padding: var(--wow-space-3);
  }

  .topbar h1 {
    font-size: var(--wow-text-lg);
  }

  .topbar-stats {
    grid-template-columns: 1fr;
  }

  .client-portal--login,
  .client-portal-main {
    padding: var(--wow-space-3);
  }

  .client-portal-header,
  .client-order-card__head {
    align-items: stretch;
    flex-direction: column;
  }

  .client-order-status {
    justify-items: start;
  }

  .client-order-overview {
    grid-template-columns: 1fr;
  }

  .client-stage-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-head__aside {
    align-items: stretch;
    justify-content: space-between;
    width: 100%;
  }

  .batch-timer {
    flex: 1;
    min-width: 0;
    text-align: left;
  }

  .batch-finish-form {
    grid-template-columns: 1fr;
  }

  .batch-finish-form label {
    max-width: none;
  }

  .client-order-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .client-order-detail-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-button span {
    min-width: 0;
  }

  .session-button strong,
  .session-button small {
    max-width: none;
  }

  .section {
    border-radius: var(--wow-radius-md);
  }

  .section > form,
  .section > .table-wrap,
  .section > .record-list,
  .section > .grid,
  .section > .empty,
  .section > .progress-steps,
  .section > .record-meta,
  .section > .total-line {
    margin: var(--wow-space-3);
  }

  .section-header,
  .record-head,
  .form-subsection--action {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    min-height: 42px;
  }

  th,
  td {
    padding: var(--wow-space-2) var(--wow-space-3);
  }

  table {
    min-width: 640px;
  }

  .compact-table {
    min-width: 480px;
  }

  .grid.three.costs-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cost-stat-card {
    min-height: 64px;
  }

  .production-stages,
  .production-log-filters,
  .production-log-table-tools {
    grid-template-columns: 1fr;
  }

  .production-log-summary-grid {
    grid-template-columns: 1fr;
  }

  .production-stage {
    min-height: 62px;
  }

  .production-load-modal .production-allocation-table {
    min-width: 620px;
  }

  .production-load-modal.has-allocation-keypad .production-allocation-wrap {
    height: min(34vh, 300px);
    max-height: min(34vh, 300px);
  }

  .production-load-main {
    max-height: min(34vh, 300px);
  }

  .qty-fill-control {
    gap: var(--wow-space-1);
  }

  .qty-fill-control .qty-input,
  .production-load-modal .qty-fill-control .qty-input {
    width: 72px;
  }

  .allocation-keypad {
    gap: var(--wow-space-2);
    padding: var(--wow-space-2);
  }

  .allocation-keypad__keys {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .allocation-key {
    min-height: 40px;
  }

  .wow-modal__footer,
  .order-modal .wow-modal__footer,
  .production-load-modal .wow-modal__footer {
    flex-wrap: wrap;
  }

  .wow-modal__footer button,
  .order-modal .wow-modal__footer button,
  .production-load-modal .wow-modal__footer button {
    flex: 1 1 140px;
  }

  .toast {
    right: var(--wow-space-3);
    bottom: var(--wow-space-3);
    max-width: calc(100vw - var(--wow-space-6));
  }
}

@media (max-width: 420px) {
  .nav-group {
    grid-template-columns: 1fr;
  }

  .brand strong,
  .brand small {
    max-width: 140px;
  }

  .header-theme__button,
  .session-logout {
    width: 32px;
    height: 32px;
  }

  .grid.three.costs-summary-grid {
    grid-template-columns: 1fr;
  }

  .client-stage-track {
    grid-template-columns: 1fr;
  }

  .client-order-facts {
    grid-template-columns: 1fr;
  }

  .client-order-detail-strip {
    grid-template-columns: 1fr;
  }

  .record-head__aside {
    flex-direction: column;
  }

  .batch-timer {
    width: 100%;
  }

  .token-display {
    gap: var(--wow-space-2);
    padding: var(--wow-space-3);
  }

  .token-keypad {
    gap: var(--wow-space-2);
  }

  .token-key {
    min-height: 50px;
  }
}
