/* ==========================================================================
   Inventory Manager UI. Uses ONLY the tokens in resources/views/partials/theme.blade.php.
   No colour values live in this file.
   ========================================================================== */

/* ---------- Fonts (self-hosted, variable) ---------- */
@font-face { font-family: "Inter"; font-weight: 100 900; font-display: swap; src: url(../fonts/inter-latin-wght-normal.woff2) format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 200 800; font-display: swap; src: url(../fonts/plus-jakarta-sans-latin-wght-normal.woff2) format("woff2"); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-ui); font-size: 15px; line-height: 1.6;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; text-decoration-thickness: 1.5px; transition: text-decoration-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { font-family: var(--font-display); color: var(--primary-strong); margin: 0 0 var(--s-2); line-height: 1.2; }
h1 { font-size: clamp(1.625rem, 1.2rem + 1.4vw, 2.125rem); font-weight: 700; letter-spacing: -.025em; line-height: 1.12; }
h2 { font-size: 1.1875rem; font-weight: 650; letter-spacing: -.012em; }
h3 { font-size: 1rem; font-weight: 600; letter-spacing: -.005em; }
p { margin: var(--s-1) 0 var(--s-3); }
small, .muted { color: var(--text-muted); }
b, strong { font-weight: 600; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--ring-solid); outline-offset: 2px; border-radius: 4px; }
.icon { flex: 0 0 auto; vertical-align: -3px; }
.mono, .num, .stat .num, .stamp { font-variant-numeric: tabular-nums; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-pill); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); }
::-webkit-scrollbar-track { background: transparent; }

/* High-contrast attached notch, with status colour confined to the icon and edge. */
#notch-toaster-root {
  --foreground: var(--toast-bg); --background: var(--toast-text); --muted-foreground: var(--toast-muted);
  font-family: var(--font-ui);
}
#notch-toaster-root .nt-shell {
  --toast-status: var(--toast-info);
  background: var(--toast-bg); color: var(--toast-text);
  box-shadow: inset 0 0 0 1px var(--toast-border), inset 0 -3px 0 var(--toast-status), var(--toast-shadow);
}
#notch-toaster-root .nt-shell:has(.nt-icon-success) { --toast-status: var(--toast-success); }
#notch-toaster-root .nt-shell:has(.nt-icon-error) { --toast-status: var(--toast-error); }
#notch-toaster-root .nt-shell:has(.nt-icon-warning) { --toast-status: var(--toast-warning); }
#notch-toaster-root .nt-viewport { align-items: flex-start; }
#notch-toaster-root .nt-content {
  min-width: min(320px, calc(100vw - 32px)); max-width: min(600px, calc(100vw - 32px));
  min-height: 72px; gap: 12px; padding: 12px 16px 16px;
}
#notch-toaster-root .nt-icon {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--toast-status) 16%, var(--toast-bg)); color: var(--toast-status);
}
#notch-toaster-root .nt-check, #notch-toaster-root .nt-alert-icon { width: 20px; height: 20px; }
#notch-toaster-root .nt-spinner { width: 20px; height: 20px; }
#notch-toaster-root .nt-label {
  flex: 1; min-width: 0; height: auto; white-space: normal;
  font-family: var(--font-ui); font-size: 15px; font-weight: 500; line-height: 1.5; letter-spacing: 0;
}
#notch-toaster-root .nt-label-sizer, #notch-toaster-root .nt-label-slide { white-space: normal; overflow-wrap: anywhere; }
#notch-toaster-root .nt-dismiss, #notch-toaster-root .nt-action {
  flex-shrink: 0; min-height: 44px; border-radius: var(--r-sm);
  background: var(--toast-control); color: var(--toast-text);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
#notch-toaster-root .nt-dismiss { flex: 0 0 44px; width: 44px; height: 44px; padding: 12px; }
#notch-toaster-root .nt-close { width: 16px; height: 16px; }
#notch-toaster-root .nt-action { max-width: 128px; padding: 8px 12px; font-size: 13px; overflow-wrap: anywhere; }
#notch-toaster-root .nt-dismiss:hover, #notch-toaster-root .nt-action:hover { background: var(--toast-control-hover); color: var(--toast-text); }
#notch-toaster-root .nt-dismiss:focus-visible, #notch-toaster-root .nt-action:focus-visible { outline: 2px solid var(--toast-status); outline-offset: 2px; }
@media (max-width: 480px) {
  #notch-toaster-root .nt-content { padding-inline: 12px; gap: 8px; }
}
@media print { #notch-toaster-root { display: none; } }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
@media (min-width: 1024px) { .shell { background: linear-gradient(90deg, var(--side-bg) var(--sidebar-w), transparent 0); } }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--side-bg); color: var(--on-dark);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  border-right: 1px solid var(--side-border); z-index: 40;
}
.brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-4); color: var(--on-dark); font-family: var(--font-display); font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; }
.brand .mark { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-accent); flex: 0 0 auto; }
.brand img { height: 40px; width: auto; max-width: 96px; object-fit: contain; border-radius: var(--r-sm); background: var(--logo-bg); padding: 2px; }
.brand small { display: block; font-family: var(--font-ui); font-weight: 500; font-size: .75rem; color: var(--on-dark-muted); letter-spacing: 0; }
.nav { list-style: none; margin: 0; padding: var(--s-2) var(--s-3) var(--s-6); }
.nav .group { font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--on-dark-muted); padding: var(--s-5) var(--s-3) var(--s-2); }
.nav a {
  position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md); color: var(--on-dark-muted); text-decoration: none; font-weight: 500; font-size: .9375rem;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav a:hover { background: var(--side-hover); color: var(--on-dark); }
.nav a.active { background: var(--side-active); color: var(--on-dark); }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a.active .icon { color: var(--accent); }
.nav a:focus-visible { outline-color: var(--accent); }
.nav .count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 var(--s-2); display: inline-grid; place-items: center; border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 700; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s-3);
  min-height: 64px; padding: var(--s-3) var(--s-8);
  background: var(--header-bg); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-family: var(--font-display); font-weight: 650; color: var(--primary-strong); display: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .crumb { color: var(--text-muted); font-size: .875rem; }
.topbar .spacer { flex: 1; }
.topbar form { margin: 0; }
.who { display: flex; align-items: center; gap: var(--s-3); }
.who .avatar { width: 36px; height: 36px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-strong); font-weight: 650; font-size: .8125rem; }
.who .meta { line-height: 1.25; font-size: .875rem; }
.who .meta small { display: block; font-size: .75rem; }
.menu-toggle { display: none !important; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s-8) var(--s-8) var(--s-16); }

/* Page-load: gentle fade and rise of the main blocks */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.content > * { animation: rise var(--t-slow) var(--ease) both; }
.content > *:nth-child(2) { animation-delay: 40ms; }
.content > *:nth-child(3) { animation-delay: 80ms; }
.content > *:nth-child(4) { animation-delay: 120ms; }
.content > *:nth-child(n+5) { animation-delay: 160ms; }

/* Off-canvas sidebar below 1024px */
.scrim { display: none; }
@media (max-width: 1023px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform var(--t-slow) var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--backdrop); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity var(--t-slow) var(--ease); }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .menu-toggle { display: inline-flex !important; }
  .topbar { padding: var(--s-2) var(--s-4); min-height: 60px; }
  .topbar .title { display: block; }
  .content { padding: var(--s-6) var(--s-4) var(--s-12); }
}
@media (max-width: 640px) {
  .who .meta { display: none; }
  .topbar .btn-label { display: none; }
}

/* ---------- Layout helpers ---------- */
.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
@media (min-width: 1024px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.grid > .card, .grid > section.card { margin-bottom: 0; }
.grid + .grid, .grid + .card, .card + .grid, .grid + section { margin-top: var(--s-5); }
.grid { margin-bottom: var(--s-5); }
.row { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: flex-start; }
/* Labels line up across a row even when one field has a hint under it; buttons and checks sit level with the inputs. */
.row > .btn, .row > .check, .row > .btn-link, .row > form, .row > .hint, .row > span { align-self: flex-end; }
.row:has(> .field:not(.mb0)) > .btn, .row:has(> .field:not(.mb0)) > .check, .row:has(> .field:not(.mb0)) > form { margin-bottom: var(--s-5); }
.row > .field.check { align-self: flex-end; }
.row:has(> .field:not(.mb0)) { row-gap: 0; }
:not(.row):not(.actions):not(.sticky-actions) > .btn + .btn, :not(.row):not(.actions):not(.sticky-actions) > .btn + a.btn { margin-left: var(--s-2); }
.row > * { flex: 0 1 auto; }
.row .grow { flex: 1 1 220px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-bottom: var(--s-6); }
.page-head h1 { margin: 0; flex: 1 1 320px; }
.page-head.tight { margin-bottom: var(--s-4); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-4); }
.section-head h2 { flex: 1; margin: 0; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.mt { margin-top: var(--s-6); } .mb0 { margin-bottom: 0 !important; } .hidden { display: none !important; }
/* Page forms fill the same content width as the surrounding tables and cards. */
.form-narrow, .form-medium, .form-wide { width: 100%; max-width: none; }
.w-qty { width: 140px; } .w-batch { width: 140px; } .min-w-product { min-width: 260px; }
.inline-form { display: inline; }
.pre-line { white-space: pre-line; }
.pre { white-space: pre-wrap; font-family: var(--font-mono); font-size: .8125rem; background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-4); overflow-x: auto; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-6); margin-bottom: var(--s-5); box-shadow: var(--shadow-sm);
}
.card > h2:first-child, .card > .section-head:first-child { margin-top: 0; }
.card h2 { margin-bottom: var(--s-4); }
.card.flush { padding: 0; overflow: hidden; }
.card .pad { padding: var(--s-6); }
a.card, .card.interactive { display: block; color: inherit; text-decoration: none; transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease); }
a.card:hover, .card.interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-soft); }
a.card h2 { color: var(--primary-strong); }
a.card p { color: var(--text-muted); margin-bottom: 0; }

.stat {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6); box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat .lbl { color: var(--text-muted); font-size: .8125rem; font-weight: 500; order: -1; }
.stat .num { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; color: var(--primary-strong); margin-top: var(--s-2); }
.stat { display: flex; flex-direction: column; }
.stat.lead { background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%); }
.stat.lead::before { content: ""; position: absolute; left: var(--s-6); right: var(--s-6); top: 0; height: 3px; border-radius: 0 0 3px 3px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }

/* ---------- Buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-5); border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9375rem; font-weight: 600; line-height: 1;
  text-decoration: none; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-xs); user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn:active { transform: translateY(1px) scale(.98); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); border-color: var(--ring-solid); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%); border-color: var(--accent-strong);
  color: var(--on-accent); box-shadow: var(--shadow-accent);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--accent-strong) 0%, var(--accent-strong) 100%); border-color: var(--accent-strong); filter: saturate(1.05); }
.btn-primary:focus-visible { box-shadow: var(--shadow-accent), 0 0 0 4px var(--ring); }
.btn-danger { background: var(--bad-solid); border-color: var(--bad-solid); color: var(--on-bad); }
.btn-danger:hover { background: var(--bad-solid); border-color: var(--bad-text); filter: brightness(.92); }
.btn-dark { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.btn-dark:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { min-height: 36px; padding: 0 var(--s-3); font-size: .875rem; border-radius: var(--r-sm); }
.btn-icon { width: 44px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-link { border: none; background: none; color: var(--primary); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; padding: var(--s-2) 0; min-height: 44px; font: inherit; font-weight: 500; cursor: pointer; transition: text-decoration-color var(--t-fast) var(--ease); }
.btn-link:hover { text-decoration-color: currentColor; }
.btn-link.danger { color: var(--bad-text); }
/* Submit feedback: a soft shimmer bar instead of a spinner */
.btn.is-loading { pointer-events: none; color: transparent !important; }
.btn.is-loading::after { content: ""; position: absolute; left: 22%; right: 22%; top: calc(50% - 2px); height: 4px; border-radius: var(--r-pill); background: currentColor; background: var(--skeleton); background-size: 200% 100%; animation: shimmer 1s linear infinite; }
.btn-primary.is-loading::after { background: linear-gradient(90deg, rgba(15,23,42,.25), rgba(15,23,42,.6), rgba(15,23,42,.25)); background-size: 200% 100%; }

/* Theme toggle */
.theme-toggle .icon { transition: transform var(--t-slow) var(--ease), opacity var(--t) var(--ease); }
.theme-toggle .sun, .theme-toggle .moon { position: absolute; }
.theme-toggle .moon { opacity: 0; transform: rotate(-90deg) scale(.6); }
.theme-toggle.is-dark .sun { opacity: 0; transform: rotate(90deg) scale(.6); }
.theme-toggle.is-dark .moon { opacity: 1; transform: none; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 550; font-size: .875rem; margin-bottom: var(--s-2); color: var(--text); }
.field { margin-bottom: var(--s-5); }
.hint { font-size: .8125rem; color: var(--text-muted); font-weight: 400; margin-top: var(--s-1); }
label .hint { margin: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=time], input[type=search], input[type=file], select, textarea {
  width: 100%; font: inherit; font-size: .9375rem; min-height: 44px; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs); appearance: none; -webkit-appearance: none;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ring-solid); box-shadow: 0 0 0 4px var(--ring); }
input[disabled], select[disabled], textarea[disabled] { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
select {
  padding-right: var(--s-10); cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
input[type=file] { padding: var(--s-2); }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); margin-right: var(--s-3); cursor: pointer; }
textarea { min-height: 104px; resize: vertical; line-height: 1.55; padding: var(--s-3); }
input[type=date], input[type=month], input[type=time] { min-width: 160px; }
::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: var(--s-3); font-weight: 500; font-size: .9375rem; min-height: 44px; cursor: pointer; margin: 0; }
.check input { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 0; flex: 0 0 22px; border: 1.5px solid var(--text-muted); border-radius: var(--r-xs); background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.check input[type=radio] { border-radius: 50%; }
.check input::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--surface); border-top: 0; border-right: 0; transform: rotate(-45deg) scale(0); margin-top: -2px; transition: transform var(--t-fast) var(--ease); }
.check input[type=radio]::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--surface); margin: 0; transform: scale(0); }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { transform: rotate(-45deg) scale(1); }
.check input[type=radio]:checked::after { transform: scale(1); }
.check input:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
fieldset.plain { border: 0; padding: 0; margin: 0 0 var(--s-5); min-width: 0; }
fieldset.plain legend { font-weight: 550; font-size: .875rem; margin-bottom: var(--s-1); padding: 0; }
.error-text { display: flex; align-items: center; gap: var(--s-1); color: var(--bad-text); font-size: .8125rem; margin-top: var(--s-1); font-weight: 550; text-align: left; }
.is-invalid { background: var(--bad-bg) !important; border-color: var(--bad-solid) !important; }
.is-invalid:focus { box-shadow: 0 0 0 4px var(--bad-bg) !important; }
input:user-invalid:not(:focus):not(.qty-cell) { border-color: var(--bad-solid); }
.logo-preview { max-height: 72px; border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-2); background: var(--surface); }

/* ---------- Alerts, toasts ---------- */
.alert { display: flex; gap: var(--s-3); align-items: flex-start; border-radius: var(--r-md); padding: var(--s-4); margin-bottom: var(--s-5); border: 1px solid; font-weight: 500; line-height: 1.5; }
.alert > .icon { margin-top: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-solid); }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-solid); }
.alert-bad { background: var(--bad-bg); color: var(--bad-text); border-color: var(--bad-solid); }
.alert-info { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.alert ul { margin: var(--s-2) 0 0 var(--s-5); padding: 0; }
.alert li + li { margin-top: var(--s-1); }
.toasts { position: fixed; z-index: 70; top: var(--s-4); right: var(--s-4); left: var(--s-4); display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s-3); width: min(420px, 100%);
  padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-weight: 500; position: relative; overflow: hidden;
  animation: toast-in var(--t-slow) var(--ease) both;
}
.toast .icon.ok { color: var(--ok-solid); margin-top: 1px; }
.toast .close { margin: -8px -8px -8px auto; }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--ok-solid); animation: toast-timer 6s linear forwards; }
.toast.leaving { animation: toast-out var(--t) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes toast-timer { from { width: 100%; } to { width: 0; } }

/* ---------- Modal (confirm) ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: var(--s-4); }
.modal[hidden] { display: none; }
.modal .backdrop { position: absolute; inset: 0; background: var(--backdrop); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade var(--t) var(--ease) both; }
.modal .dialog { position: relative; width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: var(--s-6); animation: pop var(--t-slow) var(--ease) both; }
.modal .dialog h2 { margin-bottom: var(--s-2); }
.modal .dialog p { color: var(--text-muted); margin-bottom: var(--s-6); }
.modal .actions { display: flex; justify-content: flex-end; gap: var(--s-3); flex-wrap: wrap; }
.modal .badge-icon { width: 44px; height: 44px; border-radius: var(--r-pill); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); margin-bottom: var(--s-4); }
.modal.danger .badge-icon { background: var(--bad-bg); color: var(--bad-text); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.96); } }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.table-wrap.flush { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
.table-wrap.tall { max-height: 72vh; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9375rem; }
table.t th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-muted); text-align: left;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: var(--s-3) var(--s-4);
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
table.t td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tbody tr { transition: background-color var(--t-fast) var(--ease); }
table.t tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t .num { text-align: right; }
table.t tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
table.t tr.group-start td { border-top: 1px solid var(--border); }
table.t tbody tr.group-start:first-child td { border-top: 0; }
table.t a { font-weight: 500; }
table.compact td { padding: var(--s-2) var(--s-3); font-size: .875rem; }
table.compact th { padding: var(--s-2) var(--s-3); }
/* SSR: keep the product column visible while scrolling days */
table.ssr th:first-child, table.ssr td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
table.ssr th:first-child { z-index: 3; background: var(--surface-2); }
table.ssr tbody tr:hover td:first-child, table.ssr tfoot td:first-child { background: var(--surface-2); }
table.ssr th.day { text-align: center; letter-spacing: 0; }
table.ssr th.day small { display: block; font-weight: 500; text-transform: none; opacity: .8; }

/* ---------- Badges, stamps, pills ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--s-1); padding: 2px 10px 2px 8px; border-radius: var(--r-pill); font-size: .8125rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 1.5; }
.badge .ic { font-weight: 700; font-size: .75rem; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); border-color: color-mix(in srgb, var(--ok-solid) 35%, transparent); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); border-color: color-mix(in srgb, var(--warn-solid) 35%, transparent); }
.badge-bad { background: var(--bad-bg); color: var(--bad-text); border-color: color-mix(in srgb, var(--bad-solid) 35%, transparent); }
.badge-neutral { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.stamp { font-family: var(--font-mono); font-size: .8125rem; font-weight: 600; letter-spacing: .02em; padding: 2px 8px; border: 1px dashed var(--text-muted); border-radius: var(--r-xs); background: var(--surface); color: var(--primary-strong); white-space: nowrap; }
.pill-tabs { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-bottom: var(--s-5); padding: var(--s-1); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); width: fit-content; max-width: 100%; }
.pill-tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s-4); border-radius: var(--r-sm); color: var(--text-muted); text-decoration: none; font-weight: 550; font-size: .875rem; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.pill-tabs a:hover { color: var(--text); }
.pill-tabs a.active { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow-sm); }

/* ---------- Dispatch sheet ---------- */
input.qty-cell, .qty-cell {
  width: 112px; min-height: 44px; font-family: var(--font-ui); font-size: 1.0625rem; font-weight: 500; text-align: right;
  padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--shadow-xs) inset; font-variant-numeric: tabular-nums;
}
.qty-cell { -moz-appearance: textfield; appearance: textfield; }
.qty-cell::-webkit-inner-spin-button, .qty-cell::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qty-cell:focus { border-color: var(--ring-solid); box-shadow: 0 0 0 4px var(--ring); }
.qty-cell.filled { font-weight: 700; border-color: var(--primary); background: var(--primary-soft); }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center;
  padding: var(--s-4) var(--s-6); background: var(--header-bg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.sticky-actions .spacer { flex: 1; }
.sticky-actions.standalone { border-radius: var(--r-lg); border: 1px solid var(--border); box-shadow: var(--shadow-md); margin-top: var(--s-5); }
details { border-radius: var(--r-md); }
details summary { list-style: none; cursor: pointer; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; gap: var(--s-2); color: var(--primary); padding: 0 var(--s-3); margin-left: calc(-1 * var(--s-3)); border-radius: var(--r-md); transition: background-color var(--t-fast) var(--ease); }
details summary::-webkit-details-marker { display: none; }
details summary:hover { background: var(--surface-2); }
details[open] summary { margin-bottom: var(--s-2); }
details.paste { margin-top: var(--s-4); padding: var(--s-1) var(--s-4) var(--s-4); background: var(--surface-2); border: 1px dashed var(--border); }
details.paste:not([open]) { padding-bottom: var(--s-1); }

/* ---------- Content blocks ---------- */
.insight { white-space: pre-wrap; font-size: .9375rem; line-height: 1.7; color: var(--text); }
.insight-meta { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text-muted); font-size: .8125rem; margin-bottom: var(--s-3); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-3) var(--s-6); margin: 0; }
dl.kv dt { color: var(--text-muted); font-size: .875rem; font-weight: 500; }
dl.kv dd { margin: 0; font-weight: 500; }
.pagination { display: flex; gap: var(--s-1); flex-wrap: wrap; margin: var(--s-5) 0 0; list-style: none; padding: 0; }
.pagination a, .pagination span { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); text-decoration: none; color: var(--text); padding: 0 var(--s-3); font-weight: 550; font-size: .875rem; transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.pagination a:hover { background: var(--surface-2); border-color: var(--text-muted); }
.pagination .active span { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.pagination [aria-disabled] { opacity: .45; }

/* Empty states */
.empty { padding: var(--s-10) var(--s-4); text-align: center; color: var(--text-muted); font-size: .9375rem; }
p.empty::before, td.empty::before {
  content: ""; display: block; width: 28px; height: 28px; margin: 0 auto var(--s-3);
  background-color: var(--text-muted); opacity: .7;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Skeleton loaders */
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton { border-radius: var(--r-sm); background: var(--skeleton); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton-rows { display: grid; gap: var(--s-2); margin-top: var(--s-3); }
.skeleton-rows .skeleton { height: 44px; }
.skeleton-rows .skeleton:nth-child(2) { width: 86%; }
.skeleton-rows .skeleton:nth-child(3) { width: 72%; }

/* Dashboard density polish using the existing design system (unslop by Damir Sokolovsky, CC BY 4.0). */
body:has(.dashboard) .topbar { min-height: 80px; }
.content:has(> .dashboard) { max-width: 1560px; padding: var(--s-12) var(--s-16) var(--s-16); }
.dashboard { display: flex; flex-direction: column; gap: var(--s-6); }
.dashboard .grid { gap: var(--s-6); margin: 0; }
.dashboard > .page-head { margin: 0; align-items: center; }
.dashboard-heading { flex: 1 1 320px; }
.dashboard-heading h1 { font-size: 2rem; margin: 0; }
.dashboard-heading p { margin: var(--s-1) 0 0; font-size: .9375rem; }
.dashboard .card { padding: var(--s-6); margin: 0; min-width: 0; }
.dashboard .card h2 { font-size: 1.0625rem; margin-bottom: var(--s-5); }
.dashboard .card h3 { font-size: .9375rem; margin-bottom: var(--s-3); }
.dashboard .section-head { margin-bottom: var(--s-5); align-items: center; }
.dashboard .section-head h2 { margin-bottom: 0; }
.dashboard .section-head > .muted { font-size: .875rem; }
.dashboard .stat { padding: var(--s-6); min-height: 128px; justify-content: center; }
.dashboard .stat.lead { background: var(--surface); }
.dashboard .stat.lead::before { right: auto; width: 56px; background: var(--accent); }
.dashboard .stat-expired .num { color: var(--bad-solid); }
.dashboard .dashboard-pair { grid-template-columns: minmax(0, 1.42fr) minmax(0, 1fr); align-items: stretch; }
.dashboard-pair > .card { display: flex; flex-direction: column; }
.dashboard-daily > .card { min-height: 328px; }
.dashboard-stock > .card { min-height: 492px; }
.dashboard .dashboard-runway { min-height: 408px; display: flex; flex-direction: column; }
.dashboard-runway .runway-wrap { margin-top: auto; }
.dashboard .dashboard-insight-head { margin-bottom: var(--s-2); }
.dashboard-insight-head form { margin: 0; }
.dashboard-insight > .muted { font-size: .8125rem; margin: 0 0 var(--s-3); }
.dashboard .card .mt { margin-top: var(--s-4); }
.dashboard .empty { padding: var(--s-4); }
.dashboard-pair .empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0; }
.dashboard .widget-scroll { max-height: 288px; overflow: auto; overscroll-behavior: auto; scrollbar-gutter: stable; }
.dashboard .widget-scroll > .table-wrap { overflow: visible; }
.dashboard table.compact td { height: 48px; padding: var(--s-2) var(--s-4); }
.dashboard table.compact th { height: 40px; padding: var(--s-2) var(--s-4); }
.dashboard-stock .widget-scroll { max-height: 296px; }
.dashboard .widget-scroll-insight { max-height: 184px; padding-right: var(--s-2); line-height: 1.7; font-size: .875rem; }
.dashboard .dashboard-sheet-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s-2); max-height: 80px; overflow: auto; margin-top: auto; padding-top: var(--s-4); border-top: 1px solid var(--border); font-size: .875rem; }
.dashboard .dashboard-sheet-links > span:last-child { text-align: right; }
.dashboard-stock > .card > .mt { margin: auto 0 0; padding-top: var(--s-4); }
.dashboard-stock h2 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.dashboard .stamp { background: var(--surface-2); border-color: transparent; }
.dashboard .dashboard-signals > .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.dashboard .dashboard-signals { min-height: 256px; }
.dashboard .dashboard-expiring { min-height: 416px; }
.dashboard-expiring .empty { min-height: 128px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0; border: 1px dashed var(--border); border-radius: var(--r-md); }
.dashboard-signals > .grid > div + div { border-left: 1px solid var(--border); padding-left: var(--s-6); }
.dashboard .signal-row { flex-wrap: wrap; column-gap: var(--s-3); row-gap: var(--s-1); }
.dashboard .signal-row .muted { font-size: .8125rem; }
.dashboard .runway { height: 224px; padding-top: var(--s-5); }
.dashboard .runway .bar { background: var(--chart); }
.dashboard .runway .col.bad .bar { background: var(--bad-solid); }
.dashboard .runway .col.bad .val { color: var(--bad-solid); }
.dashboard .runway .col.warn .bar { background: var(--warn-solid); }
.dashboard .runway .col.zero .bar { background: var(--border); }
.dashboard .legend { margin-top: var(--s-6); }
.dashboard .legend .hover-hint { margin-left: auto; }
@media (max-width: 1279px) {
  body:has(.dashboard) .topbar { min-height: 64px; }
  .content:has(> .dashboard) { padding: var(--s-8); }
  .dashboard .dashboard-pair { grid-template-columns: 1fr; }
  .dashboard-daily > .card, .dashboard-stock > .card { min-height: 0; }
  .dashboard .dashboard-runway { min-height: 0; }
  .dashboard .dashboard-signals, .dashboard .dashboard-expiring { min-height: 0; }
  .dashboard-pair .empty { min-height: 160px; }
  .dashboard-stock > .card > .mt { margin-top: var(--s-4); padding-top: 0; }
}
@media (max-width: 640px) {
  .content:has(> .dashboard) { padding: var(--s-6) var(--s-4) var(--s-12); }
  .dashboard { gap: var(--s-4); }
  .dashboard .grid { gap: var(--s-4); }
  .dashboard-heading h1 { font-size: 1.5rem; }
  .dashboard .card { padding: var(--s-4); }
  .dashboard .stat { padding: var(--s-4); }
  .dashboard .widget-scroll { max-height: 240px; }
  .dashboard .widget-scroll-insight { max-height: 160px; }
  .dashboard .dashboard-signals > .grid { grid-template-columns: 1fr; }
  .dashboard-signals > .grid > div + div { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: var(--s-4); }
}

/* ---------- Dashboard: expiry runway ---------- */
.runway-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--s-2)); padding: 0 var(--s-2); }
.runway-wrap > div { min-width: 760px; }
.runway { display: flex; align-items: flex-end; gap: var(--s-1); height: 232px; padding-top: var(--s-8); }
.runway .col { flex: 1 0 40px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; border-radius: var(--r-sm); cursor: default; transition: background-color var(--t-fast) var(--ease); }
.runway .col:hover { background: var(--surface-2); }
.runway .val { font-size: .75rem; font-weight: 600; color: var(--text-muted); margin-bottom: var(--s-1); font-variant-numeric: tabular-nums; }
.runway .bar { width: 100%; max-width: 40px; height: var(--h, 2px); border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, color-mix(in srgb, var(--chart) 82%, var(--surface)) 0%, var(--chart) 100%); transition: filter var(--t-fast) var(--ease), transform var(--t) var(--ease); transform-origin: bottom; animation: grow 600ms var(--ease) both; }
.runway .col:hover .bar { filter: brightness(1.12); }
.runway .col.zero .bar { background: var(--border); }
.runway .col.warn .bar { background: linear-gradient(180deg, color-mix(in srgb, var(--warn-solid) 75%, var(--surface)) 0%, var(--warn-solid) 100%); }
.runway .col.bad .bar { background: linear-gradient(180deg, color-mix(in srgb, var(--bad-solid) 75%, var(--surface)) 0%, var(--bad-solid) 100%); }
@keyframes grow { from { transform: scaleY(0); } }
.runway-axis { display: flex; gap: var(--s-1); border-top: 1px solid var(--border); padding-top: var(--s-2); }
.runway-axis span { flex: 1 0 40px; text-align: center; font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.runway-axis span.now { color: var(--primary-strong); font-weight: 650; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); font-size: .8125rem; color: var(--text-muted); margin-top: var(--s-4); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: var(--s-2); vertical-align: -1px; }
.dot-bad { background: var(--bad-solid); } .dot-warn { background: var(--warn-solid); } .dot-ok { background: var(--chart); }
@media (max-width: 1023px) { .legend .hover-hint { display: none; } }

/* ---------- Settings ---------- */
.settings-intro { margin: calc(-1 * var(--s-4)) 0 var(--s-6); }
.settings-section header p { margin: 0; font-size: .875rem; }
.settings-section header h2 { margin-bottom: var(--s-1); }
.settings-section header { margin-bottom: var(--s-5); }
@media (min-width: 1024px) {
  .settings-section { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: var(--s-8); }
  .settings-section header { margin-bottom: 0; }
}
.settings-body { min-width: 0; }
.settings-section, [id] { scroll-margin-top: 88px; }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); margin-bottom: var(--s-3); }
.input-suffix { display: flex; align-items: center; gap: var(--s-3); }
.input-suffix input { flex: 0 1 160px; }
.input-suffix span { color: var(--text-muted); font-size: .875rem; white-space: nowrap; }
.note { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-2); color: var(--text-muted); font-size: .875rem; }
.note .icon { margin-top: 3px; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.switch-row { display: flex; align-items: flex-start; gap: var(--s-4); padding: var(--s-3) 0; margin-bottom: var(--s-3); cursor: pointer; font-weight: 400; }
.switch-row b { display: block; font-weight: 600; }
.switch-row small { display: block; font-size: .8125rem; margin-top: 2px; }
.switch { position: relative; flex: 0 0 48px; width: 48px; height: 28px; margin-top: 2px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: var(--r-pill); background: color-mix(in srgb, var(--text-muted) 55%, var(--surface)); transition: background-color var(--t) var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--t) var(--ease); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--ring); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: var(--s-1); padding: var(--s-1); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.segmented label { margin: 0; position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s-4); border-radius: var(--r-sm); font-weight: 550; font-size: .875rem; color: var(--text-muted); transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.segmented input:checked + span { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 4px var(--ring); }

@media (max-width: 640px) { .settings .sticky-actions .muted { display: none; } .settings .sticky-actions .btn { flex: 1; } }

/* ---------- Courier returns ---------- */
[x-cloak] { display: none !important; }
.courier-stats { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.courier-stat { display: flex; flex-direction: column; gap: 2px; padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); color: inherit; text-decoration: none; transition: border-color var(--t-fast) var(--ease), transform var(--t) var(--ease); }
.courier-stat:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.courier-stat .name { font-weight: 600; }
.courier-stat .num { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; color: var(--primary-strong); }
.courier-stat .muted { font-size: .8125rem; }
.qty-cell.damaged.filled { border-color: var(--bad-solid); background: var(--bad-bg); }
.return-totals { display: inline-flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); color: var(--text-muted); font-size: .9375rem; }
.return-totals b { color: var(--primary-strong); font-size: 1.0625rem; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .hide-sm { display: none; } }
.chip-list { list-style: none; margin: 0 0 var(--s-4); padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { display: inline-flex; align-items: center; gap: var(--s-1); min-height: 36px; padding: 0 var(--s-1) 0 var(--s-3); border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface-2); font-weight: 550; font-size: .875rem; animation: rise var(--t) var(--ease) both; }
.chip-x { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.chip-x:hover { background: var(--bad-bg); color: var(--bad-text); }
.chip-x:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* Courier returns: parcel rows */
.courier-picker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: var(--s-1) 0 var(--s-4); }
.picker-label { font-weight: 550; font-size: .875rem; margin-right: var(--s-2); }
.courier-chip { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-4); border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .9375rem; cursor: pointer; transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.courier-chip:hover { border-color: var(--text-muted); }
.courier-chip:active { transform: scale(.97); }
.courier-chip:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.courier-chip.on { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.courier-chip .n { min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--r-pill); display: inline-grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 700; }
.parcels { border-top: 1px solid var(--border); }
.parcel { display: grid; grid-template-columns: 32px minmax(120px, 1fr) minmax(130px, 1fr) minmax(180px, 2fr) minmax(170px, 1.6fr) 112px 112px 36px; gap: var(--s-2) var(--s-3); align-items: center; padding: var(--s-2) var(--s-6); border-bottom: 1px solid var(--border); transition: background-color var(--t-fast) var(--ease); }
.parcel:hover { background: var(--surface-2); }
.parcel.has-error { background: var(--bad-bg); }
.parcel-head { position: sticky; top: 64px; z-index: 3; background: var(--surface-2); color: var(--text-muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding-top: var(--s-3); padding-bottom: var(--s-3); }
.parcel-head:hover { background: var(--surface-2); }
.parcel-head .num { text-align: right; }
.parcel .idx { color: var(--text-muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.parcel .cell { margin: 0; min-width: 0; font-weight: 400; }
.parcel .cell select, .parcel .cell input { width: 100%; }
.parcel .c-ok, .parcel .c-bad { justify-self: end; }
.parcel .c-ok input, .parcel .c-bad input { width: 112px; }
.parcel .row-error { grid-column: 2 / -1; margin-top: 0; }
.parcel:not(.filled) select, .parcel:not(.filled) input { opacity: .85; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.parcel-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding-top: var(--s-4); padding-bottom: var(--s-4); }
.courier-summary { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); }
.courier-summary span { padding: 2px 10px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); font-size: .8125rem; font-weight: 600; }
table.t tr.subtotal td { background: var(--surface-2); font-weight: 600; color: var(--text-muted); }
@media (max-width: 1023px) {
  .parcel-head { display: none; }
  .parcel { grid-template-columns: 1fr 1fr; padding: var(--s-3) var(--s-4); position: relative; }
  .parcel .idx { position: absolute; top: var(--s-3); right: var(--s-4); }
  .parcel .c-courier { grid-column: 1; } .parcel .c-ref { grid-column: 2; padding-right: var(--s-8); }
  .parcel .c-product, .parcel .c-batch { grid-column: 1 / -1; }
  .parcel .c-ok, .parcel .c-bad { justify-self: stretch; }
  .parcel .c-ok input, .parcel .c-bad input { width: 100%; }
  .parcel .c-ok .sr, .parcel .c-bad .sr { position: static; width: auto; height: auto; clip: auto; font-size: .75rem; color: var(--text-muted); display: block; margin-bottom: 2px; }
  .parcel .c-x { grid-column: 1 / -1; justify-self: end; }
  .parcel .row-error { grid-column: 1 / -1; }
}

/* Website listings */
.link-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.link-form select { flex: 1 1 200px; min-width: 0; }
.signal-row { display: flex; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-size: .9375rem; }
.signal-row:last-child { border-bottom: 0; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: var(--s-4);
  background: radial-gradient(60rem 40rem at 85% -10%, var(--accent-soft), transparent 60%), radial-gradient(50rem 40rem at -10% 110%, rgba(148, 163, 184, .16), transparent 60%), var(--side-bg);
}
.login { width: 100%; max-width: 420px; padding: var(--s-8); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); }
.login .brand { padding: 0 0 var(--s-6); color: var(--text); }
.login .brand small { color: var(--text-muted); }
.login h1 { font-size: 1.5rem; margin-bottom: var(--s-1); }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
@media print { .no-print, .sidebar, .topbar, .toasts { display: none !important; } }
