:root {
  --bg-main: #0b0b0b;
  --bg-card: #141414;
  --bg-elevated: #111111;
  --bg-hover: #1a1a1a;
  --border: #212121;
  --border-hi: #2c2c2c;
  --text-main: #ededed;
  --text-muted: #9a9a9a;
  --text-dim: #5a5a5a;

  --accent: oklch(0.48 0.22 25);
  --accent-dark: oklch(0.38 0.22 25);
  --accent-strong: oklch(0.55 0.22 25);
  --accent-soft: color-mix(in oklch, var(--accent) 25%, transparent);
  --accent-bg: color-mix(in oklch, var(--accent) 14%, transparent);
  --accent-text: #ff8a95;

  --green: oklch(0.7 0.15 150);
  --green-bg: color-mix(in oklch, var(--green) 16%, transparent);
  --yellow: oklch(0.78 0.16 85);
  --yellow-bg: color-mix(in oklch, var(--yellow) 16%, transparent);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.75);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(11, 11, 11, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1520px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-bg);
  border: 1px solid var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.1rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* Buttons & Interactive Pills */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.btn-sm {
  min-height: 32px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px var(--accent-dark), 0 1px 0 var(--accent-dark);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-hi);
}

.btn-secondary:hover,
.btn-secondary[aria-expanded="true"] {
  background: var(--bg-hover);
  border-color: #3a3a3a;
}

.btn-secondary[aria-expanded="true"] {
  border-color: var(--accent-soft);
  color: var(--accent-text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.btn-icon {
  min-width: 38px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
}

.filter-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
}

.cart-pill-total {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.28);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.toggle-pill,
.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.toggle-pill input,
.checkbox-pill input {
  accent-color: var(--accent-strong);
  width: 15px;
  height: 15px;
  margin: 0;
}

/* Main Container */
.container {
  max-width: 1520px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.alert-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  background: var(--yellow-bg);
  border: 1px solid color-mix(in oklch, var(--yellow) 35%, transparent);
  color: var(--yellow);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert-badge {
  background: var(--yellow);
  color: #0b0b0b;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Section Tabs (Wrapped cleanly on desktop — never clipped) */
.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border-hi);
  background: var(--bg-card);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.section-tab:hover {
  color: var(--text-main);
  background: var(--bg-hover);
  border-color: #3a3a3a;
}

.section-tab[aria-pressed="true"] {
  background: var(--accent-bg);
  color: var(--accent-text);
  border-color: var(--accent-soft);
}

.section-tab .tab-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  opacity: 0.85;
}

.mobile-section-select-wrap {
  display: none;
  margin-bottom: 0.85rem;
}

.full-width {
  width: 100%;
}

.section-note {
  padding: 0.6rem 0.95rem;
  border-radius: var(--radius-md);
  background: var(--accent-bg);
  border: 1px solid var(--accent-soft);
  color: var(--text-main);
  font-size: 0.83rem;
  margin-bottom: 0.9rem;
}

/* Filter Toolbar & Advanced Filters Panel */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
}

.search-wrap {
  width: 100%;
}

.search-wrap input {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hi);
  background: var(--bg-main);
  color: var(--text-main);
  font: inherit;
  font-size: 0.9rem;
}

.search-wrap input::placeholder {
  color: var(--text-dim);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}

.toolbar-selects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.toolbar-selects .filter-field select {
  width: 100%;
}

.toolbar-actions {
  align-items: center;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.filter-field select {
  min-height: 38px;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hi);
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.84rem;
}

.advanced-panel {
  padding: 0.9rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  margin-bottom: 0.9rem;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.advanced-grid .filter-field select {
  width: 100%;
}

/* Bulk Selection Bar */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  background: var(--accent-bg);
  border: 1px solid var(--accent-soft);
  margin-bottom: 0.85rem;
  font-weight: 600;
  font-size: 0.88rem;
}

.bulk-actions {
  display: flex;
  gap: 0.5rem;
}

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Desktop & Responsive Table */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(72vh, 800px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  container-type: inline-size;
}

table {
  width: 100%;
  min-inline-size: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
}

thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--bg-elevated);
}

th,
td {
  padding: 0.75rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

thead th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-hi);
  white-space: nowrap;
}

thead th:has(> button) {
  padding: 0;
}

thead th > button {
  width: 100%;
  min-height: 42px;
  padding: 0.65rem 0.8rem;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  cursor: pointer;
}

thead th > button:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

thead th[aria-sort] > button {
  color: var(--accent-text);
}

.sort-icon::after {
  content: "↕";
  opacity: 0.35;
}

th[aria-sort="ascending"] .sort-icon::after {
  content: "↑";
  opacity: 1;
}

th[aria-sort="descending"] .sort-icon::after {
  content: "↓";
  opacity: 1;
}

tbody tr {
  transition: background-color 0.12s ease;
}

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

tbody tr[hidden] {
  display: none;
}

.col-select {
  width: 44px;
  text-align: center;
}

.col-select input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

.col-qty {
  width: 72px;
}

.col-type {
  width: 130px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.col-grade {
  width: 96px;
}

.col-model {
  min-width: 220px;
}

.col-specs {
  min-width: 240px;
}

.col-section {
  width: 165px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.col-price {
  width: 112px;
  white-space: nowrap;
  text-align: right;
}

thead .col-price > button {
  justify-content: flex-end;
}

.col-action {
  width: 148px;
  text-align: right;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.qty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.78rem;
  background: var(--green-bg);
  color: var(--green);
  white-space: nowrap;
}

.qty-badge.out {
  background: rgba(90, 90, 90, 0.2);
  color: var(--text-dim);
}

.grade-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.74rem;
  background: var(--bg-main);
  border: 1px solid var(--border-hi);
  color: var(--text-main);
  white-space: nowrap;
}

.model-name {
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
}

.model-sub {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  line-height: 1.35;
}

.spec-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.spec-chip {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.35;
}

.price-now {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-text);
}

.price-was {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-dim);
  text-decoration: line-through;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  margin-top: 1rem;
}

/* Mobile Card Layout */
@container (width < 760px) {
  .table-wrapper {
    max-block-size: none;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  table {
    min-inline-size: 0;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "select model price"
      "meta meta meta"
      "specs specs specs"
      "action action action";
    gap: 0.5rem 0.75rem;
    padding: 0.9rem;
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
  }

  td {
    border: 0;
    padding: 0;
    width: auto !important;
    min-width: 0 !important;
  }

  .col-select {
    grid-area: select;
    align-self: start;
    padding-top: 0.15rem;
  }

  .col-select input {
    width: 20px;
    height: 20px;
  }

  .col-model {
    grid-area: model;
  }

  .col-price {
    grid-area: price;
    text-align: right;
  }

  .col-qty,
  .col-type,
  .col-grade,
  .col-section {
    display: inline-flex;
    align-items: center;
    margin-right: 0.45rem;
  }

  .col-qty { grid-row: 2; grid-column: 1 / -1; justify-self: start; }
  .col-type { grid-row: 2; grid-column: 1 / -1; justify-self: start; margin-left: 3.1rem; }
  .col-grade { grid-row: 2; grid-column: 1 / -1; justify-self: end; margin-right: 0; }
  .col-section { display: none; }

  .col-specs {
    grid-area: specs;
  }

  .col-action {
    grid-area: action;
    text-align: left;
    margin-top: 0.2rem;
  }

  .col-action .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 0.5rem;
  }

  .col-action .row-actions .btn {
    width: 100%;
    min-height: 40px;
  }
}

@media (max-width: 768px) {
  .topbar-inner {
    padding: 0.75rem 1rem;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .container {
    padding: 0.9rem 1rem 3rem;
  }

  .section-tabs {
    display: none;
  }

  .mobile-section-select-wrap {
    display: block;
  }

  .desktop-hint {
    display: none;
  }

  .toolbar {
    padding: 0.8rem;
  }

  .filter-group {
    width: 100%;
  }

  .filter-field {
    flex: 1 1 120px;
  }

  .filter-field select {
    width: 100%;
  }
}

/* Native Modal Dialogs */
dialog {
  width: min(880px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.dialog-header h1 {
  margin: 0;
  font-size: 1.1rem;
}

.dialog-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

.dialog-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* Cart Items */
.cart-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.9rem;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  margin-bottom: 0.7rem;
}

.cart-item-info {
  flex: 1 1 320px;
}

.cart-item-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.cart-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
}

.qty-stepper button {
  background: var(--bg-hover);
  color: var(--text-main);
  border: 0;
  width: 32px;
  height: 34px;
  cursor: pointer;
  font-weight: 700;
}

.qty-stepper input {
  width: 46px;
  height: 34px;
  border: 0;
  background: var(--bg-card);
  color: var(--text-main);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.order-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field-stack input {
  min-height: 38px;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hi);
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.88rem;
}

.cart-summary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cart-total-block strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--accent-text);
}

.cart-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.terms-list {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}
