/* APU order — Bridge Design System (bridge.apple.com) tokens + components. */

:root {
  color-scheme: light dark;

  /* Text */
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-interactive: #0066cc;
  --text-error: #e30000;
  --text-success: #008009;
  --text-warning: #bf4800;

  /* Surfaces */
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --surface-3: #f5f5f7;
  --seg-on: #ffffff;
  --bg-error: #fff2f4;
  --bg-success: #f6fff6;
  --bg-warning: #fff9f4;
  --code-bg: #1d1d1f;
  --code-fg: #f5f5f7;

  /* Borders */
  --border-primary: #8f8f94;
  --border-secondary: #d2d2d7;
  --border-tertiary: #e8e8ed;

  /* Typography */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Monaco, monospace;

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

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-seg: 0 1px 3px rgba(0, 0, 0, 0.1);
  --focus-ring: 0 0 0 3px rgba(0, 102, 204, 0.28);

  /* Motion */
  --transition-fast: 150ms cubic-bezier(0, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #f5f5f7;
    --text-secondary: #98989d;
    --text-tertiary: #86868b;
    --text-interactive: #2997ff;
    --text-error: #ff3037;
    --text-success: #30d158;
    --text-warning: #ff9f0a;

    --canvas: #000000;
    --surface: #1c1c1e;
    --surface-2: #161617;
    --surface-3: #2c2c2e;
    --seg-on: #48484a;
    --bg-error: #330000;
    --bg-success: #002b03;
    --bg-warning: #290d00;
    --code-bg: #0a0a0a;
    --code-fg: #f5f5f7;

    --border-primary: #5b5b5e;
    --border-secondary: #424245;
    --border-tertiary: #333336;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-seg: 0 1px 3px rgba(0, 0, 0, 0.5);
    --focus-ring: 0 0 0 3px rgba(41, 151, 255, 0.35);
  }
}

* { box-sizing: border-box; }
html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body:not(.is-admin) {
  padding: var(--space-6) max(var(--space-4), env(safe-area-inset-right)) calc(var(--space-12) + env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
}
::selection { background: rgba(0, 102, 204, 0.18); color: var(--text-primary); }
[hidden] { display: none !important; }

/* ───────────────────────── Layout ───────────────────────── */

.sheet {
  max-width: 34rem;
  margin: 0 auto;
}
body:not(.is-admin) .sheet {
  background: var(--surface);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6) var(--space-8);
  box-shadow: var(--shadow-md);
}
.is-admin .sheet {
  max-width: 66rem;
  padding: var(--space-8) var(--space-6) var(--space-12) calc(13rem + var(--space-8));
}
.is-admin .sheet:has(.orders-desk) {
  max-width: 94rem;
}

.mast {
  max-width: 34rem;
  margin: 0 auto var(--space-4);
  padding: 0 var(--space-1);
}
.wordmark {
  display: inline-block;
  color: var(--text-primary);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.wordmark span {
  margin-left: var(--space-1);
  font-weight: 400;
  color: var(--text-secondary);
}
.wordmark:hover { text-decoration: none; }

/* ─────────────────────── Typography ─────────────────────── */

h1, h2, .admin-h, .page-h, .desk-title {
  font-family: var(--font-display);
}
h1 {
  font-size: 27px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-2);
}
.admin-h {
  font-size: 34px;
  font-weight: 600;
  line-height: 1.125;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-6);
}
.page-h {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-2);
}
h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: var(--space-8) 0 var(--space-3);
}
.kicker, .eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 var(--space-2);
}
.lede {
  color: var(--text-secondary);
  margin: 0 0 var(--space-5);
  max-width: 55ch;
}
.quiet { color: var(--text-secondary); font-size: 15px; }
a { color: var(--text-interactive); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-secondary);
  word-break: break-all;
}

.quota-line {
  color: var(--text-secondary);
  font-size: 15px;
  margin: 0 0 var(--space-6);
}
.quota-line strong {
  display: block;
  font-family: var(--font-display);
  font-size: 43px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.125;
}
.banner-closed,
.banner-warn {
  border-radius: var(--radius);
  font-size: 15px;
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
}
.banner-closed {
  color: var(--text-error);
  background: var(--bg-error);
  border: 1px solid var(--text-error);
}
.banner-warn {
  color: var(--text-warning);
  background: var(--bg-warning);
  border: 1px solid var(--text-warning);
}

/* ───────────────────────── Forms ───────────────────────── */

.ticket-form label, .ticket-form fieldset {
  display: block;
  margin: 0 0 var(--space-4);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
fieldset { border: 0; padding: 0; }
legend {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  padding: 0;
}
.hint {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  margin: calc(var(--space-4) * -0.75) 0 var(--space-4);
}
legend + .hint { margin-top: var(--space-1); }
.field-warn { color: var(--text-error); }

.ticket-form input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
.ticket-form select,
.ticket-form textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: var(--space-2);
  font-family: inherit;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius);
  padding: 11px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.ticket-form textarea { min-height: 5.5rem; resize: vertical; }
.ticket-form input:focus-visible,
.ticket-form select:focus-visible,
.ticket-form textarea:focus-visible {
  outline: none;
  border-color: var(--text-interactive);
  box-shadow: var(--focus-ring);
}
.ticket-form input:disabled,
.ticket-form select:disabled,
.ticket-form textarea:disabled {
  background: var(--surface-3);
  color: var(--text-tertiary);
  cursor: not-allowed;
}
.ticket-form input[type="file"] {
  display: block;
  width: 100%;
  margin-top: var(--space-2);
  font-size: 15px;
}

.ticket-form select {
  -webkit-appearance: none;
  appearance: none;
  min-width: 100%;
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236e6e73' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.25 8 9.75l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px;
}

/* Custom select: trigger button + full-screen sheet (form.js). */
.pick { display: block; position: relative; width: 100%; }
.pick select {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  pointer-events: none;
}
button.pick-btn,
.is-admin button.pick-btn {
  display: block;
  width: 100%;
  max-width: none;
  min-height: 44px;
  margin-top: var(--space-2);
  font-family: inherit;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  color: var(--text-primary);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236e6e73' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.25 8 9.75l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius);
  padding: 11px var(--space-8) 11px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
button.pick-btn:hover:not(:disabled) { border-color: var(--border-primary); }
button.pick-btn:focus-visible {
  outline: none;
  border-color: var(--text-interactive);
  box-shadow: var(--focus-ring);
}
button.pick-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pick-sheet {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  z-index: 80;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.pick-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-tertiary);
}
.pick-sheet-head p {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
button.pick-close,
.is-admin button.pick-close {
  background: none;
  color: var(--text-interactive);
  padding: var(--space-2) 0;
  font-size: 17px;
  font-weight: 400;
  width: auto;
  min-height: 44px;
}
.pick-sheet-list {
  flex: 1;
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
button.pick-option,
.is-admin button.pick-option {
  display: block;
  width: 100%;
  max-width: none;
  min-height: 44px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.4;
  padding: var(--space-4);
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border-tertiary);
}
button.pick-option:hover:not(:disabled) { background: var(--surface-3); }
button.pick-option.is-on {
  font-weight: 500;
  color: var(--text-interactive);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%230066cc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 9.5 3.5 3.5 7.5-8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
}

/* Segmented control */
.seg {
  display: flex;
  gap: 2px;
  margin-top: var(--space-2);
  padding: 2px;
  background: var(--surface-3);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
}
.seg label {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  margin: 0 !important;
  padding: var(--space-2) var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-primary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}
.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg label:has(input:focus-visible) {
  outline: 2px solid var(--text-interactive);
  outline-offset: -1px;
}
.seg label:has(input:checked) {
  background: var(--seg-on);
  box-shadow: var(--shadow-seg);
  font-weight: 500;
}
.seg label:has(input:disabled) { color: var(--text-tertiary); cursor: not-allowed; }

.inline {
  display: inline-flex !important;
  align-items: center;
  gap: var(--space-2);
  min-height: 28px;
  margin: 0 var(--space-4) var(--space-1) 0;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 400;
}
.inline input {
  width: auto;
  display: inline;
  margin: 0;
  accent-color: var(--text-interactive);
  border: 0;
}

/* ──────────────────────── Buttons ──────────────────────── */

.primary, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  min-height: 36px;
  cursor: pointer;
  border: 0;
  background: var(--text-interactive);
  color: #ffffff;
  padding: 10px var(--space-5);
  border-radius: var(--radius);
  transition: filter var(--transition-fast), transform var(--transition-fast), background-color var(--transition-fast);
}
.primary:hover:not(:disabled), button:hover:not(:disabled) { filter: brightness(1.1); }
.primary:active:not(:disabled), button:active:not(:disabled) { filter: brightness(0.95); transform: scale(0.98); }
.primary:focus-visible, button:focus-visible {
  outline: 2px solid var(--text-interactive);
  outline-offset: 2px;
}
.primary:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }

.ticket-form .primary {
  margin-top: var(--space-2);
  width: 100%;
  min-height: 44px;
  font-size: 17px;
}
.is-admin .primary, .is-admin button:not(.linkish):not(.danger) {
  width: auto;
  min-height: 36px;
  font-size: 15px;
}
.is-admin .ticket-form .primary { margin-top: var(--space-2); }

.danger {
  background: transparent;
  color: var(--text-error);
  border: 1px solid var(--border-secondary);
}
.danger:hover:not(:disabled) {
  filter: none;
  background: var(--bg-error);
  border-color: var(--text-error);
}
.desk-remove { margin-top: var(--space-6); }

.linkish {
  background: none;
  color: var(--text-interactive);
  padding: var(--space-2) 0;
  min-height: 28px;
  font-weight: 400;
  border-radius: 0;
}
.linkish:hover:not(:disabled) { filter: none; text-decoration: underline; }

/* ──────────────────────── Feedback ─────────────────────── */

.flash {
  font-size: 15px;
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-5);
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.flash-bad {
  color: var(--text-error);
  background: var(--bg-error);
  border-color: var(--text-error);
}
.flash-ok {
  color: var(--text-success);
  background: var(--bg-success);
  border-color: var(--text-success);
}

/* ─────────────────────── YAML receipt ──────────────────── */

.yaml-card {
  margin: var(--space-5) 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.yaml-card pre {
  margin: 0;
  padding: var(--space-5);
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.yaml-card .primary,
.is-admin .yaml-card .primary {
  display: flex;
  width: 100%;
  min-height: 44px;
  border-radius: 0;
  margin: 0;
}
.yaml-card-admin pre { max-height: 17rem; }

/* ───────────────────── Admin sidebar ───────────────────── */

.rail {
  position: fixed;
  z-index: 2;
  inset: 0 auto 0 0;
  width: 13rem;
  padding: var(--space-5) var(--space-3);
  background: var(--surface-2);
  color: var(--text-primary);
  border-right: 1px solid var(--border-tertiary);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.rail-brand {
  display: block;
  padding: 0 var(--space-3);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
}
.rail-brand:hover { text-decoration: none; }
.rail-brand span { font-weight: 400; color: var(--text-secondary); }
.rail nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 400;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}
.rail a:hover { background: var(--surface-3); text-decoration: none; }
.rail a.is-on {
  background: var(--text-interactive);
  color: #ffffff;
  font-weight: 500;
}
.rail form { margin-top: auto; padding: 0 var(--space-3); }
.rail .linkish { color: var(--text-secondary); font-size: 15px; }
.rail .linkish:hover { color: var(--text-primary); }

/* ────────────────────────  Tables ──────────────────────── */

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--canvas);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-secondary);
}
.grid td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-tertiary);
  vertical-align: top;
}
.grid a { color: var(--text-interactive); }

.badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--text-secondary);
}
.badge-submitted { background: rgba(0, 102, 204, 0.12); color: var(--text-interactive); }
.badge-waiting_for_stock, .badge-ordered { background: var(--bg-warning); color: var(--text-warning); }
.badge-ready_for_pickup, .badge-shipped, .badge-delivered { background: var(--bg-success); color: var(--text-success); }
.badge-cancelled { background: var(--bg-error); color: var(--text-error); }

/* ─────────────────── Admin orders desk ─────────────────── */

.orders-desk { display: grid; gap: var(--space-6); }
.desk-empty {
  margin: 0;
  padding: var(--space-6);
  text-align: center;
  border: 1px dashed var(--border-secondary);
  border-radius: var(--radius-lg);
}
.desk-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--text-primary);
  margin: 0 0 var(--space-1);
}
.desk-meta { color: var(--text-secondary); font-size: 14px; margin: 0 0 var(--space-4); }
.desk-edit-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.grid tr.order-row { position: relative; transition: background-color var(--transition-fast); }
.grid tr.order-row td:first-child a {
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: none;
}
.grid tr.order-row td:first-child a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.grid tr.order-row:hover { background: var(--surface-3); }
.grid tr.order-row.is-on {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--text-interactive);
}

@media (min-width: 960px) {
  .orders-desk {
    grid-template-columns: minmax(16rem, 0.92fr) minmax(22rem, 1.08fr);
    align-items: start;
  }
  .desk-left {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    min-width: 0;
  }
  .desk-list {
    min-width: 0;
  }
  .desk-pane {
    position: sticky;
    top: var(--space-4);
    max-height: calc(100vh - var(--space-8));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-6);
    background: var(--surface);
    border: 1px solid var(--border-tertiary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }
}

/* ───────────────── Admin models & stores ───────────────── */

.generate-form { margin-bottom: var(--space-8); }
.generate-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 720px) {
  .generate-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.generate-form textarea { min-height: 7rem; }

.catalog-form { margin-top: var(--space-8); }
.catalog-save { width: auto; margin-top: var(--space-3); }
.catalog-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.catalog-filter {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.catalog-filter input {
  display: block;
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-primary);
  width: 18rem;
  max-width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-secondary);
  background: var(--surface);
  border-radius: var(--radius);
}
.catalog-filter input:focus-visible {
  outline: none;
  border-color: var(--text-interactive);
  box-shadow: var(--focus-ring);
}
.catalog-bulk { display: flex; gap: var(--space-2); }
.ghost, .is-admin button.ghost {
  background: transparent;
  color: var(--text-interactive);
  border: 1px solid var(--border-secondary);
}
.ghost:hover:not(:disabled), .is-admin button.ghost:hover:not(:disabled) {
  filter: none;
  background: var(--surface-3);
}
#catalog-count { margin: 0 0 var(--space-3); }
.catalog-note { margin: var(--space-3) 0 0; }

.row-form {
  display: grid;
  grid-template-columns: 2fr 1fr 5rem auto;
  gap: var(--space-2);
  align-items: center;
  margin: 0 0 var(--space-2);
}
.row-form input {
  font: inherit;
  font-size: 15px;
  color: var(--text-primary);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-secondary);
  background: var(--surface);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.row-form input:focus-visible {
  outline: none;
  border-color: var(--text-interactive);
  box-shadow: var(--focus-ring);
}

.quota-form {
  display: flex;
  gap: var(--space-3);
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.quota-form label { color: var(--text-primary); font-size: 14px; font-weight: 500; }
.quota-form input {
  font: inherit;
  font-size: 17px;
  color: var(--text-primary);
  padding: 10px var(--space-3);
  border: 1px solid var(--border-secondary);
  background: var(--surface);
  border-radius: var(--radius);
  display: block;
  margin-top: var(--space-2);
}
.quota-form input:focus-visible {
  outline: none;
  border-color: var(--text-interactive);
  box-shadow: var(--focus-ring);
}
.quota-form .form-switch {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  align-items: center;
}
.quota-form .form-switch legend {
  width: 100%;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}
.quota-form .form-switch label {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-weight: 400;
}

.counts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-3);
}
.counts li {
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
}
.counts a { color: var(--text-secondary); font-size: 14px; }
.counts strong {
  display: block;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* ───────────────────────── Export ──────────────────────── */

.export-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: var(--space-4);
  max-width: 46rem;
}
.export-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.export-h {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text-primary);
  margin: 0;
}
.export-card .quiet { margin: 0; flex: 1; }
.export-meta { margin: 0; font-size: 13px; color: var(--text-secondary); }
a.export-go {
  align-self: start;
  margin-top: var(--space-2);
  text-decoration: none;
}
a.export-go:hover { text-decoration: none; }

.yaml-apply { max-width: 38rem; margin: 0; }.yaml-apply textarea {
  min-height: 8rem;
  font-family: var(--font-mono) !important;
  font-size: 13px !important;
}
.yaml-apply .primary { width: auto; min-height: 36px; font-size: 15px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
}
.filters a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--surface-3);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.filters a:hover { color: var(--text-primary); text-decoration: none; }
.filters .is-on {
  background: var(--text-interactive);
  color: #ffffff;
}

/* ─────────────────────── Small screens ─────────────────── */

@media (max-width: 720px) {
  body:not(.is-admin) {
    padding: var(--space-3) 0 calc(var(--space-8) + env(safe-area-inset-bottom));
  }
  body:not(.is-admin) .sheet {
    max-width: none;
    padding: var(--space-5) var(--space-4) var(--space-6);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }
  body:not(.is-admin) .mast {
    max-width: none;
    padding: 0 var(--space-4);
  }
  .mast { margin-bottom: var(--space-3); }
  .page-h { font-size: 24px; }
  .admin-h { font-size: 27px; }
  .quota-line strong { font-size: 34px; }
  .seg label { font-size: 14px; padding: var(--space-2) var(--space-1); line-height: 1.25; }
  .yaml-card pre { font-size: 12px; padding: var(--space-4); }
  .is-admin .sheet {
    padding: calc(3.5rem + var(--space-6)) var(--space-4) calc(var(--space-8) + env(safe-area-inset-bottom));
  }
  .rail {
    width: 100%;
    height: auto;
    bottom: auto;
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) max(var(--space-3), env(safe-area-inset-right)) var(--space-2) max(var(--space-3), env(safe-area-inset-left));
    padding-top: max(var(--space-2), env(safe-area-inset-top));
    border-right: 0;
    border-bottom: 1px solid var(--border-tertiary);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .rail-brand { display: none; }
  .rail nav { flex-direction: row; flex-wrap: nowrap; gap: var(--space-1); }
  .rail a { white-space: nowrap; font-size: 14px; }
  .rail form { padding: 0; }
  .row-form { grid-template-columns: 1fr; }
  .desk-edit-top { grid-template-columns: 1fr; }
  .desk-pane { padding-top: var(--space-4); border-top: 1px solid var(--border-tertiary); }
  .grid-wrap, .grid {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .grid th { position: static; }
}

@media (max-width: 380px) {
  .seg label { font-size: 13px; }
}

/* Inline SVG glyphs cannot use CSS variables, so restate them for dark mode. */
@media (prefers-color-scheme: dark) {
  .ticket-form select,
  button.pick-btn,
  .is-admin button.pick-btn {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2398989d' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.25 8 9.75l3.5-3.5'/%3E%3C/svg%3E");
  }
  button.pick-option.is-on,
  .is-admin button.pick-option.is-on {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%232997ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 9.5 3.5 3.5 7.5-8'/%3E%3C/svg%3E");
  }
  .badge-submitted { background: rgba(41, 151, 255, 0.16); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .primary:active:not(:disabled), button:active:not(:disabled) { transform: none; }
}
