/* =========================================================================
   Pelagic Order Form — styles
   Refined minimalist with a maritime/technical tone.
   ========================================================================= */

:root {
  /* Ink — Nautis navy */
  --ink: #0A1E2E;
  --ink-2: #1A1A1A;
  --ink-3: #3a4a5c;
  --ink-4: #6b7a88;
  --ink-5: #9aa7b5;
  /* Paper / surfaces */
  --paper: #FFFFFF;
  --paper-2: #F4F7F9;
  --paper-3: #E3E8EB;
  /* Lines */
  --line: #D9DEE2;
  --line-2: #B8C2CC;
  /* Brand — Nautis coral primary, ocean-blue secondary */
  --accent: #E94E3C;
  --accent-dark: #C5341E;
  --sea: #0077B6;
  --sea-light: #3AA0D4;
  --sea-dark: #005A8B;
  --gold: #D4C4A8;
  --gold-dark: #9f8f73;
  --green: #4a8d5a;
  --red: #C10230;
  /* Shadows — tinted navy, not neutral black */
  --shadow-sm: 0 1px 2px rgba(10,30,46,0.06), 0 0 0 1px rgba(10,30,46,0.05);
  --shadow-md: 0 4px 14px rgba(10,30,46,0.10), 0 0 0 1px rgba(10,30,46,0.06);
  --shadow-lg: 0 10px 30px rgba(10,30,46,0.14), 0 0 0 1px rgba(10,30,46,0.06);
  /* Radii */
  --radius: 4px;
  --radius-lg: 8px;
  --radius-pill: 100px;
  /* Category palette — one colour per keyword category for coloured meta pills */
  --cat-shirt: #0077B6;
  --cat-short: #E94E3C;
  --cat-pant: #1C4E7A;
  --cat-hoodie: #9f8f73;
  --cat-jacket: #4a8d5a;
  --cat-hat: #6b5bd1;
  --cat-footwear: #8c2a1f;
  --cat-other: #6b7a88;
  /* Marine gradient accent */
  --gradient-marine: linear-gradient(90deg, var(--ink) 0%, var(--sea-dark) 30%, var(--sea) 60%, var(--accent) 100%);
  /* Fonts — Anton display (Nautis), Archivo body (Pelagic), JetBrains mono */
  --font-display: 'Anton', 'Oswald', Impact, sans-serif;
  --font-body: 'Archivo', 'Ubuntu', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(0,119,182,0.06), transparent 60%),
    radial-gradient(800px 400px at 90% 110%, rgba(10,30,46,0.04), transparent 60%),
    var(--paper-2);
}

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }

/* =========================================================================
   LOGIN
   ========================================================================= */

.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 15% 20%, rgba(0,119,182,0.28), transparent 60%),
    radial-gradient(700px 500px at 85% 80%, rgba(233,78,60,0.18), transparent 65%),
    linear-gradient(180deg, #0A1E2E 0%, #0e2b42 100%);
}

.login-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background:
    repeating-linear-gradient(45deg, transparent 0 80px, rgba(255,255,255,0.025) 80px 81px),
    repeating-linear-gradient(-45deg, transparent 0 80px, rgba(255,255,255,0.02) 80px 81px);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow:
    0 30px 60px rgba(10,30,46,0.45),
    0 0 0 1px rgba(255,255,255,0.05);
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: var(--gradient-marine);
}

.login-card-inner {
  padding: 2.5rem 2.25rem 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
}

.brand-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--sea);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

/* Login-scoped brand treatment — larger, ocean-blue tile */
.login-card .brand-mark {
  width: 56px;
  height: 56px;
  font-size: 26px;
  background: var(--sea);
  border-radius: var(--radius-lg);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.14),
    0 8px 22px rgba(0,119,182,0.4);
}

.login-card .brand-title {
  font-size: 2.3rem;
  line-height: 0.95;
}

@media (max-width: 480px) {
  .login-wrap { padding: 1.25rem 0.9rem; }
  .login-card-inner { padding: 1.85rem 1.5rem 1.4rem; }
  .login-note { padding: 0.9rem 1.5rem 1.2rem; font-size: 0.68rem; }
  .login-card .brand-logo-text { height: 52px; max-width: 260px; }
  .brand { gap: 0.75rem; margin-bottom: 1.5rem; padding-bottom: 1.25rem; }
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

.brand-mark.small { width: 32px; height: 32px; font-size: 15px; }

/* Image-based brand marks (Nautis logo) */
.brand-mark-img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-brand-mark { width: 48px; height: 48px; }

.brand-logo-text {
  display: block;
  height: 34px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  margin-bottom: 0.3rem;
}

.login-card .brand-mark-img {
  width: 56px;
  height: 56px;
}

.login-card .brand-logo-text {
  height: 68px;
  max-width: 340px;
}

/* Wordmark-led brand layout: logo on top, supporting text below */
.brand-wordmark {
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}
.brand-wordmark .brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.brand-wordmark .brand-eyebrow { margin-bottom: 0; }

.header-version {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.2;
  margin-bottom: 2px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 0.95;
  color: var(--ink);
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-4);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 0.3rem;
}

.login-form { display: flex; flex-direction: column; gap: 1rem; }

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.login-form label > span {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  font-weight: 700;
}

.login-form input {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  transition: all 0.15s;
}

.login-form input::placeholder { color: var(--ink-5); }

.login-form input:hover { border-color: var(--ink-5); }

.login-form input:focus {
  outline: none;
  border-color: var(--sea);
  background: var(--paper);
  box-shadow: 0 0 0 3px rgba(0,119,182,0.18);
}

#login-btn {
  margin-top: 0.5rem;
  padding: 0.95rem 1.2rem;
  background: var(--ink);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(0,0,0,0.05) 100%);
  color: var(--paper);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: all 0.2s;
  box-shadow: 0 10px 24px rgba(10,30,46,0.25);
  border: none;
  cursor: pointer;
}

#login-btn:hover:not(:disabled) {
  background-color: var(--sea);
  box-shadow: 0 14px 30px rgba(0,119,182,0.4);
  transform: translateY(-1px);
}
#login-btn:active:not(:disabled) { transform: translateY(0); }
#login-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.link-btn {
  align-self: center;
  color: var(--ink-4);
  font-size: 0.78rem;
  font-family: inherit;
  text-decoration: none;
  padding: 0.35rem 0.25rem;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 0.25rem;
}
.link-btn:hover { color: var(--sea); border-bottom-color: var(--sea); }

.error-msg {
  color: var(--red);
  font-size: 0.82rem;
  min-height: 1em;
  padding: 0.1rem 0;
  font-weight: 500;
}
.error-msg:not(:empty) {
  padding: 0.6rem 0.75rem;
  background: rgba(193,2,48,0.08);
  border: 1px solid rgba(193,2,48,0.2);
  border-radius: var(--radius);
}

.login-note {
  padding: 1rem 2.25rem 1.3rem;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  font-size: 0.72rem;
  color: var(--ink-4);
  line-height: 1.5;
  text-align: center;
  letter-spacing: 0.01em;
}

/* =========================================================================
   APP HEADER
   ========================================================================= */

.app-top {
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: var(--ink);
  color: var(--paper);
  position: relative;
  box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

.app-header::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: var(--gradient-marine);
}

.header-left { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

.header-title { line-height: 1.15; }

.header-season {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--paper);
}

.header-user {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.04em;
}

.app-header .brand-mark {
  background: var(--sea);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 0 0 3px rgba(0,119,182,0.15);
}

.tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
}

.tab {
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
  transition: all 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
}

.tab:hover { color: var(--paper); background: rgba(255,255,255,0.08); }

.tab.active {
  background: var(--sea);
  color: var(--paper);
  border-color: var(--sea);
  box-shadow: 0 0 0 3px rgba(0,119,182,0.22);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.1rem 0.5rem;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  min-width: 1.5em;
  text-align: center;
}

.tab.active .tab-count { background: rgba(255,255,255,0.25); }

.header-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

.running-total {
  display: flex;
  gap: 0.75rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.05);
}

.total-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.total-label {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 3px;
}

.total-val {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1rem;
  color: var(--paper);
}

.total-stat:last-child .total-val { color: var(--accent); }

.running-total .total-stat + .total-stat {
  padding-left: 0.75rem;
  border-left: 1px solid rgba(255,255,255,0.12);
}

.primary-btn, .secondary-btn {
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.15s;
  white-space: nowrap;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.primary-btn {
  background: var(--accent);
  color: white;
}
.primary-btn:hover { background: var(--accent-dark); }
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.secondary-btn {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.secondary-btn:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* On the dark header, secondary buttons invert — white border, transparent fill */
.app-header .secondary-btn {
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.25);
}
.app-header .secondary-btn:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}

.primary-btn {
  background: var(--accent);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(0,0,0,0.06) 100%);
  background-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 4px 14px rgba(233,78,60,0.35);
}
.primary-btn:hover {
  background-color: var(--accent-dark);
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 6px 18px rgba(197,52,30,0.4);
}

/* =========================================================================
   TOOLBAR
   ========================================================================= */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border-bottom: 1px solid var(--line);
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 520px;
  min-width: 220px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  width: 17px;
  height: 17px;
  color: var(--ink-4);
  pointer-events: none;
  transition: color 0.15s;
}

#search {
  width: 100%;
  padding: 0.7rem 2.2rem 0.7rem 2.6rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(10,30,46,0.04);
  transition: all 0.15s;
}

#search::placeholder { color: var(--ink-4); font-weight: 400; }

#search:hover { border-color: var(--ink-5); }

#search:focus {
  outline: none;
  border-color: var(--sea);
  background: var(--paper);
  box-shadow: inset 0 1px 2px rgba(10,30,46,0.04), 0 0 0 4px rgba(0,119,182,0.14);
}

.search-wrap:focus-within .search-icon { color: var(--sea); }

#search::-webkit-search-cancel-button,
#search::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.search-clear {
  position: absolute;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--paper-3);
  color: var(--ink-3);
  font-size: 1.15rem;
  line-height: 1;
  transition: all 0.15s;
  cursor: pointer;
}
.search-clear:hover { background: var(--ink); color: var(--paper); transform: rotate(90deg); }

.toolbar-selects {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.select-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--ink-4);
  padding: 0.25rem 0.25rem 0.25rem 0.75rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  background: var(--paper);
  transition: border-color 0.15s;
}

.select-field:hover { border-color: var(--ink-5); }
.select-field:focus-within { border-color: var(--sea); box-shadow: 0 0 0 3px rgba(0,119,182,0.14); }

.select-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--ink-4);
}

#sort-select, #group-select, #size-filter {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0.4rem 2rem 0.4rem 0.6rem;
  border: none;
  border-radius: var(--radius-pill);
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7a88' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink);
}

#sort-select:focus, #group-select:focus, #size-filter:focus {
  outline: none;
}

.filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
}

.filters-toggle svg { width: 14px; height: 14px; }

.filters-toggle.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.filters-toggle:has(.filter-count:not(.hidden)) {
  border-color: var(--accent);
  color: var(--accent);
}
.filters-toggle.active:has(.filter-count:not(.hidden)) {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
}

.filters-toggle.active .filter-count { background: var(--paper); color: var(--ink); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--ink-3);
  cursor: pointer;
  user-select: none;
}

.toggle input { margin: 0; cursor: pointer; accent-color: var(--ink); }

.toolbar-status {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-4);
  padding: 0.3rem 0.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.toolbar-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(74,141,90,0.18);
}

/* ----- Filters panel ----- */

.toolbar-filters-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1.1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  position: relative;
  box-shadow: 0 8px 24px rgba(10,30,46,0.06);
  overflow: hidden;
}

.toolbar-filters-panel::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: var(--gradient-marine);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.filter-group-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filter-group-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  font-weight: 700;
}

.filter-group-inline .filter-group-label {
  color: var(--ink-4);
  min-width: 60px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-3);
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.12s;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.chip:hover { border-color: var(--ink-4); color: var(--ink); }

.chip.active {
  background: var(--sea);
  color: var(--paper);
  border-color: var(--sea);
  box-shadow: 0 0 0 2px rgba(0,119,182,0.18);
}

.chip-empty {
  font-size: 0.78rem;
  color: var(--ink-5);
  font-style: italic;
}

.range-inputs {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.range-inputs input {
  width: 72px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  -moz-appearance: textfield;
}
.range-inputs input::-webkit-outer-spin-button,
.range-inputs input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.range-inputs input:focus,
.qty-min-input:focus {
  outline: none; border-color: var(--sea); box-shadow: 0 0 0 2px rgba(0,119,182,0.15);
}

.range-sep { color: var(--ink-4); font-family: var(--font-mono); }

.qty-min-input {
  width: 80px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  -moz-appearance: textfield;
}
.qty-min-input::-webkit-outer-spin-button,
.qty-min-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.clear-filters-btn {
  position: absolute;
  top: 0.85rem;
  right: 1rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink-4);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.clear-filters-btn:hover { background: var(--red); color: var(--paper); border-color: var(--red); }

/* ----- Product list grouping ----- */

.product-list.grouped {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.product-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.product-group-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ink);
  position: relative;
}

.product-group-head::after {
  content: '';
  position: absolute;
  left: 0; bottom: -2px;
  width: 80px;
  height: 2px;
  background: var(--accent);
}

.product-group-label {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.35rem;
  color: var(--ink);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.product-group-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-4);
  padding: 0.1rem 0.45rem;
  background: var(--paper-3);
  border-radius: 10px;
}

.product-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* =========================================================================
   PRODUCT LIST
   ========================================================================= */

.product-list {
  flex: 1;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  align-content: start;
}

.product-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  position: relative;
}

.product-card:hover {
  border-color: var(--sea);
  box-shadow: 0 12px 28px rgba(10,30,46,0.12), 0 0 0 1px rgba(0,119,182,0.25);
  transform: translateY(-2px);
}

.product-card.has-order {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(233,78,60,0.15);
}

.product-card.has-order::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
  z-index: 2;
}

.product-image {
  aspect-ratio: 4 / 3;
  background: linear-gradient(180deg, var(--paper-3) 0%, var(--paper-2) 100%);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.product-image::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 38%;
  background: linear-gradient(180deg, transparent 0%, rgba(10,30,46,0.22) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.product-card:hover .product-image::after { opacity: 1; }

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--ink-4);
  font-size: 0.8rem;
  background:
    repeating-linear-gradient(45deg, transparent 0 14px, rgba(10,30,46,0.025) 14px 15px);
}

.product-image-placeholder svg {
  width: 36px; height: 36px; opacity: 0.3;
}

.product-colour-chip {
  position: absolute;
  z-index: 2;
  top: 0.625rem;
  left: 0.625rem;
  padding: 0.2rem 0.5rem;
  background: rgba(10,30,46,0.75);
  color: var(--paper);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  backdrop-filter: blur(4px);
}

.product-pelagic-link {
  position: absolute;
  z-index: 2;
  top: 0.625rem;
  right: 0.625rem;
  padding: 0.3rem 0.55rem;
  background: rgba(255,255,255,0.95);
  border-radius: var(--radius);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--line);
  transition: all 0.15s;
}

.product-pelagic-link:hover {
  background: var(--paper);
  border-color: var(--sea);
  color: var(--sea);
}

.product-body {
  padding: 0.9rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.product-head { display: flex; flex-direction: column; gap: 0.3rem; }

.product-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.005em;
  line-height: 1.25;
  color: var(--ink);
  margin: 0;
}

.product-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-4);
  line-height: 1.5;
}

.product-meta .meta-code { color: var(--ink-3); font-weight: 500; }
.product-meta .meta-sep { color: var(--ink-5); }
.product-meta .meta-tag {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 10px;
  color: var(--paper);
  background: var(--ink);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.colour-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.colour-swatch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-3);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.colour-swatch:hover { border-color: var(--ink-4); color: var(--ink); }

.colour-swatch.active {
  background: var(--sea);
  color: var(--paper);
  border-color: var(--sea);
  box-shadow: 0 0 0 2px rgba(0,119,182,0.22);
}

.swatch-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.colour-swatch.active .swatch-dot { background: var(--paper); }

.price-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.price-cell {
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  position: relative;
}

.price-cell::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--sea);
}
.price-cell:nth-child(2)::before { background: var(--gold-dark); }
.price-cell:nth-child(3)::before { background: var(--green); }
.price-cell:nth-child(3).margin-mid::before  { background: var(--gold-dark); }
.price-cell:nth-child(3).margin-low::before  { background: var(--ink-4); }
.price-cell:nth-child(3).margin-none::before { background: var(--line-2); }

.price-cell + .price-cell { border-left: 1px solid var(--line); }

.price-cell-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-4);
  font-weight: 600;
}

.price-cell-value {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.price-msrp-val { color: var(--ink-4); font-weight: 500; }

.price-margin.margin-high { color: var(--green); }
.price-margin.margin-mid  { color: var(--gold); }
.price-margin.margin-low  { color: var(--ink-3); }
.price-margin.margin-none { color: var(--ink-5); font-weight: 500; }

.size-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 0.3rem;
}

.size-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.size-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--ink-4);
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.size-input {
  width: 100%;
  padding: 0.3rem 0.1rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  color: var(--ink);
  transition: all 0.1s;
  -moz-appearance: textfield;
}

.size-input::-webkit-outer-spin-button,
.size-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.size-input:focus {
  outline: none;
  border-color: var(--sea);
  box-shadow: 0 0 0 2px rgba(0,119,182,0.15);
}

.size-input.filled {
  background: #f5ede0;
  border-color: var(--gold-dark);
  color: var(--ink);
  font-weight: 600;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  gap: 0.6rem;
}

.line-total {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  color: var(--ink-4);
}

.line-total .line-units {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.line-total .line-units-label { font-size: 0.7rem; }
.line-total .line-dollars {
  color: var(--ink-4);
  font-weight: 600;
  margin-left: 0.45rem;
  padding-left: 0.55rem;
  border-left: 1px solid var(--line);
}

.line-total.filled .line-units { color: var(--ink); }
.line-total.filled .line-dollars { color: var(--accent); }

.upload-image-btn {
  font-size: 0.7rem;
  color: var(--ink-4);
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: transparent;
  transition: all 0.15s;
  font-family: var(--font-body);
  white-space: nowrap;
}

.upload-image-btn:hover {
  color: var(--sea);
  border-color: var(--sea);
  background: var(--paper);
}

/* =========================================================================
   ORDER BASKET (right rail)
   ========================================================================= */

.app-body {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-height: 0;
}

.product-list { min-width: 0; }

.basket {
  width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.basket::-webkit-scrollbar { width: 8px; }
.basket::-webkit-scrollbar-track { background: var(--paper-2); }
.basket::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.basket-head {
  padding: 1.1rem 1rem 0.9rem;
  background: linear-gradient(180deg, var(--paper-2) 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.basket-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.basket-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1;
}

.basket-clear {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  background: var(--paper);
  color: var(--ink-4);
  font-family: inherit;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}
.basket-clear svg { width: 12px; height: 12px; }
.basket-clear:hover {
  background: var(--red);
  color: var(--paper);
  border-color: var(--red);
}

.basket-totals {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.basket-units { font-weight: 700; color: var(--ink); }
.basket-sep { color: var(--ink-5); }
.basket-dollars { font-weight: 700; color: var(--accent); }

.basket-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.7rem 1.2rem;
}

.basket-row {
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.basket-row:hover {
  border-color: var(--sea);
  box-shadow: 0 4px 12px rgba(0,119,182,0.08);
}

.basket-row-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.45rem;
}

.basket-row-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink);
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}

.basket-row-colour {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  padding: 0.12rem 0.45rem;
  border-radius: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.basket-row-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.basket-size {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: #f5ede0;
  color: var(--ink);
  border-radius: 10px;
  border: 1px solid var(--gold-dark);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.basket-size strong {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0;
}

.basket-row-foot {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-4);
  padding-top: 0.45rem;
  border-top: 1px dashed var(--line);
}

.basket-row-total { color: var(--ink); font-weight: 700; }

.basket-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ink-5);
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.5;
}

@media (max-width: 1200px) {
  .basket { display: none; }
}

/* =========================================================================
   LOADING / STATUS
   ========================================================================= */

.empty-state {
  grid-column: 1 / -1;
  padding: 4rem 1rem;
  text-align: center;
  color: var(--ink-4);
}

.empty-state h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  color: var(--ink);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.loading-state {
  grid-column: 1 / -1;
  padding: 4rem 1rem;
  text-align: center;
  color: var(--ink-4);
}

.export-status {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.875rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 100;
  max-width: 360px;
}

.export-status.success { background: var(--green); }
.export-status.error { background: var(--red); }

/* =========================================================================
   CONFIRM MODAL
   ========================================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,30,46,0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: modalFade 0.15s ease-out;
}

@keyframes modalFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  width: calc(100% - 2rem);
  max-width: 420px;
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-card::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: var(--gradient-marine);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

.modal-body {
  color: var(--ink-3);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

.modal-btn {
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.modal-btn-cancel {
  background: transparent;
  color: var(--ink-3);
  border-color: var(--line-2);
}
.modal-btn-cancel:hover { background: var(--paper-2); color: var(--ink); border-color: var(--ink-4); }

.modal-btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.modal-btn-primary:hover { background: var(--sea-dark); }

.modal-btn-destructive {
  background: var(--accent);
  color: var(--paper);
  box-shadow: 0 4px 14px rgba(233,78,60,0.3);
}
.modal-btn-destructive:hover { background: var(--accent-dark); }

/* =========================================================================
   HISTORY SCREEN
   ========================================================================= */

#history-screen { background: var(--paper-2); }

.history-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--ink);
  color: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 0 rgba(0,0,0,0.25);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.history-header::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: var(--gradient-marine);
}

.history-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem 0.5rem 0.65rem;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.08);
  color: var(--paper);
  border: 1px solid rgba(255,255,255,0.12);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.history-back:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.history-back svg { width: 16px; height: 16px; }

.history-header-title { flex: 1; min-width: 0; line-height: 1.15; }
.history-header-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.history-header-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.35rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
  color: var(--paper);
}

.history-header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.history-main { padding: 1.25rem 1.5rem 2rem; }

/* ----- List view ----- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 820px;
  margin: 0 auto;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: all 0.12s;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.history-row:hover,
.history-row:focus-visible {
  border-color: var(--sea);
  box-shadow: 0 8px 20px rgba(0,119,182,0.12);
  transform: translateY(-1px);
  outline: none;
}

.history-row-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }
.history-row-date { font-weight: 700; font-size: 0.95rem; color: var(--ink); }
.history-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-4);
  align-items: center;
}

.history-season {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.64rem;
}

.history-sep { color: var(--ink-5); }
.history-row-total { color: var(--accent); font-weight: 700; }

.history-row-chevron { color: var(--ink-5); flex-shrink: 0; transition: transform 0.15s, color 0.15s; }
.history-row-chevron svg { width: 20px; height: 20px; }
.history-row:hover .history-row-chevron { color: var(--sea); transform: translateX(2px); }

.history-loading,
.history-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ink-4);
  font-size: 0.95rem;
}

.history-empty h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.history-empty p { margin-bottom: 0.4rem; font-size: 0.88rem; }

/* ----- Detail view summary + tiles ----- */

.history-detail-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  max-width: 820px;
  margin: 0 auto 1.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.history-detail-summary::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: var(--gradient-marine);
}

.summary-stat {
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.summary-stat + .summary-stat { border-left: 1px solid var(--line); }
.summary-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-4);
  font-weight: 700;
}
.summary-val {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.summary-val.accent { color: var(--accent); }

.history-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* Read-only size pills for history tiles */
.size-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.size-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem 0.25rem 0.7rem;
  border: 1px solid var(--gold-dark);
  background: #f5ede0;
  color: var(--ink);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.size-pill-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  font-weight: 500;
}

.size-pill-qty {
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 10px;
  min-width: 1.8em;
  text-align: center;
}

.history-tile:hover {
  transform: none; /* history tiles aren't interactive */
  box-shadow: var(--shadow-md);
}

@media (max-width: 680px) {
  .history-header { padding: 0.7rem 0.85rem; gap: 0.5rem; }
  .history-header-name { font-size: 1.1rem; }
  .history-back span { display: none; }
  .history-back { width: 38px; height: 38px; padding: 0; justify-content: center; }
  .history-header-actions .primary-btn .btn-label { display: none; }
  .history-header-actions .primary-btn { padding: 0.5rem 0.85rem; }

  .history-main { padding: 1rem 0.85rem 2rem; }
  .history-detail-summary { grid-template-columns: repeat(2, 1fr); }
  .summary-stat + .summary-stat { border-left: none; }
  .summary-stat:nth-child(n+2) { border-top: 1px solid var(--line); }
  .summary-stat:nth-child(3), .summary-stat:nth-child(4) { border-top: 1px solid var(--line); }
  .summary-stat:nth-child(2), .summary-stat:nth-child(4) { border-left: 1px solid var(--line); }

  .history-tiles { grid-template-columns: 1fr; }
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 1100px) {
  .app-header { flex-wrap: wrap; gap: 0.75rem; padding: 0.7rem 1rem; }
  .app-header .tabs {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    padding: 0.5rem 0.2rem 0.4rem;
    margin: 0.25rem -0.2rem -0.2rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { scroll-snap-align: start; flex-shrink: 0; }
  .header-right { margin-left: auto; }
}

/* Mobile-only tabs bar inside the toolbar. On desktop this wrapper is hidden. */
.mobile-tabs-bar { display: none; }

.toolbar.mobile .mobile-tabs-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 -0.85rem;
  padding: 0.1rem 0.85rem 0.55rem;
  border-bottom: 1px solid var(--line);
}

.toolbar.mobile .mobile-tabs-bar .tabs {
  flex: 1;
  min-width: 0;
  width: auto;
  justify-content: flex-start;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding: 0.2rem 0 0.2rem;
  gap: 0.35rem;
}
.toolbar.mobile .mobile-tabs-bar .tabs::-webkit-scrollbar { display: none; }

.toolbar.mobile .mobile-tabs-bar .tab {
  color: var(--ink-3);
  padding: 0.4rem 0.85rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  background: var(--paper);
  border-color: var(--line);
  scroll-snap-align: start;
  flex-shrink: 0;
}
.toolbar.mobile .mobile-tabs-bar .tab:hover {
  background: var(--paper-3);
  color: var(--ink);
  border-color: var(--line-2);
}
.toolbar.mobile .mobile-tabs-bar .tab.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 0 4px 12px rgba(10,30,46,0.18);
}
.toolbar.mobile .mobile-tabs-bar .tab-count {
  background: var(--paper-3);
  color: var(--ink-4);
}
.toolbar.mobile .mobile-tabs-bar .tab.active .tab-count {
  background: rgba(255,255,255,0.18);
  color: var(--paper);
}

/* Search/filter toggle — circular pill with swapping search/close icons */
.mobile-search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line-2);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}
.mobile-search-toggle:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.mobile-search-toggle svg { width: 17px; height: 17px; }
.mobile-search-toggle .icon-close { display: none; }
.mobile-search-toggle[aria-expanded="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.mobile-search-toggle[aria-expanded="true"] .icon-search { display: none; }
.mobile-search-toggle[aria-expanded="true"] .icon-close { display: block; }

.toolbar.mobile .mobile-search-toggle { display: inline-flex; }

/* Collapsed state — only tabs bar visible, everything below hidden */
.toolbar.mobile.collapsed {
  padding-bottom: 0;
  gap: 0;
}
.toolbar.mobile.collapsed .toolbar-row,
.toolbar.mobile.collapsed .toolbar-filters-panel {
  display: none;
}
.toolbar.mobile.collapsed .mobile-tabs-bar {
  padding-bottom: 0.5rem;
  border-bottom: none;
  margin-bottom: 0;
}

@media (max-width: 680px) {
  .app-header {
    padding: 0.55rem 0.85rem;
    gap: 0.6rem;
  }
  .header-brand-mark { width: 40px; height: 40px; }
  .header-title { flex: 1; min-width: 0; overflow: hidden; }
  .header-version { font-size: 0.6rem; }
  .header-user { font-size: 0.62rem; }
  .header-right { gap: 0.4rem; }

  /* Export becomes icon-prominent short label; Sign-out becomes icon-only circle */
  #export-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
  }
  #export-btn .btn-label { display: none; }
  #export-btn .btn-icon { width: 16px; height: 16px; }

  #logout-btn, #history-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
  }
  #logout-btn .btn-label, #history-btn .btn-label { display: none; }
  #logout-btn .btn-icon, #history-btn .btn-icon { width: 16px; height: 16px; }

  .tabs { gap: 0.3rem; padding: 0.55rem 0.2rem 0.4rem; }
  .tab { padding: 0.4rem 0.85rem; font-size: 0.7rem; letter-spacing: 0.06em; }
  .tab-count { font-size: 0.62rem; padding: 0.08rem 0.4rem; }

  .toolbar { padding: 0.75rem 0.85rem; gap: 0.6rem; }
  .toolbar-row { gap: 0.5rem; }
  .search-wrap { max-width: 100%; min-width: 0; width: 100%; order: 1; }
  #search { padding: 0.6rem 2rem 0.6rem 2.4rem; font-size: 0.88rem; }
  .toolbar-selects { order: 2; width: 100%; flex-wrap: wrap; }
  .select-field { flex: 1; min-width: 0; padding: 0.2rem 0.2rem 0.2rem 0.6rem; }
  .select-field select { flex: 1; min-width: 0; }
  .filters-toggle { flex: 0 0 auto; padding: 0.5rem 0.85rem; }
  .filters-toggle span:not(.filter-count) { display: none; }
  .toolbar-status { order: 3; margin-left: 0; align-self: flex-start; font-size: 0.62rem; padding: 0.25rem 0.55rem; }

  .toolbar-filters-panel { padding: 1rem 0.85rem 0.85rem; gap: 0.85rem; }
  .clear-filters-btn { top: 0.7rem; right: 0.7rem; padding: 0.3rem 0.7rem; font-size: 0.62rem; }

  .product-list { padding: 0.75rem; grid-template-columns: 1fr; gap: 0.8rem; }
  .product-group-grid { grid-template-columns: 1fr; }
  .running-total { display: none; }
}
