/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-raised: #1c1c1c;
  --border: #2e2e2e;
  --border-strong: #454545;
  --text: #f5f5f3;
  --text-muted: #9a9a94;
  --text-dim: #6b6b66;
  --accent: #2dd4c4;
  --accent-dim: #1c7f76;
  --ok: #4caf6e;
  --err: #e5484d;

  --mono: 'SF Mono', 'JetBrains Mono', 'Roboto Mono', ui-monospace, Consolas, monospace;
  --sans: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --radius: 2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

.app {
  min-height: 100vh;
}

a { color: inherit; }

::selection {
  background: var(--accent);
  color: #0a0a0a;
}

/* Focus: always visible, never suppressed */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ==========================================================================
   Layout shell
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.topbar__brand-mark {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 3px 7px;
  border-radius: var(--radius);
}

.topbar__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar__account {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.topbar__account strong {
  color: var(--text);
  font-weight: 600;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover { color: var(--text); }

.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 28px 100px;
}

/* ==========================================================================
   Login screen
   ========================================================================== */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 36px 32px 32px;
  border-radius: var(--radius);
}

.login-card__eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}

.login-card__title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 28px;
  letter-spacing: -0.01em;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 11px 12px;
  font-size: 14px;
  transition: border-color 0.12s ease;
}

.field input:hover {
  border-color: #5c5c5c;
}

.field input:focus-visible {
  border-color: var(--accent);
}

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

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
  letter-spacing: 0.01em;
}

.btn-primary:hover { background: #45e0d1; }
.btn-primary:active { transform: scale(0.995); }

.btn-primary:disabled {
  background: var(--border-strong);
  color: var(--text-dim);
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  background: var(--surface-raised);
}

.btn-secondary--small {
  padding: 7px 12px;
  font-size: 12px;
}

.login-error {
  border: 1px solid var(--err);
  background: rgba(229, 72, 77, 0.08);
  color: #ff8b8e;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-family: var(--mono);
}

.login-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.7;
}

.login-hint code {
  color: var(--text-muted);
}

/* ==========================================================================
   Section headers
   ========================================================================== */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.section-head__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-head__meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   Catalog / product table
   ========================================================================== */
.catalog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.catalog-row {
  display: grid;
  grid-template-columns: 1fr 100px 120px 170px 130px;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.addr-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 8px;
  font-size: 12px;
  font-family: var(--mono);
}

.addr-select:hover { border-color: #5c5c5c; }
.addr-select:focus-visible { border-color: var(--accent); }
.addr-select:disabled { color: var(--text-dim); cursor: not-allowed; }

.catalog-row:last-child { border-bottom: none; }

.catalog-row--head {
  background: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 12px 18px;
}

.catalog-row__product {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.catalog-row__img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  flex-shrink: 0;
}

.discount-badge {
  display: inline-block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--bg);
  background: var(--accent);
  padding: 2px 6px;
  border-radius: var(--radius);
}

.catalog-row__title {
  font-weight: 600;
  font-size: 14px;
}

.catalog-row__sku {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}

.catalog-row__price {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
}

.catalog-row__unit {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.qty-control {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: fit-content;
}

.qty-control button {
  background: var(--surface-raised);
  border: none;
  color: var(--text);
  width: 30px;
  font-size: 15px;
  cursor: pointer;
  font-family: var(--mono);
}

.qty-control button:hover { background: var(--border-strong); }

.qty-control input {
  width: 52px;
  text-align: center;
  background: var(--bg);
  border: none;
  border-left: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-strong);
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 4px;
}

.btn-add {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-add:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
}

.btn-add.is-added {
  background: var(--ok);
  border-color: var(--ok);
  color: #0a0a0a;
}

.moq-note {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* ==========================================================================
   Cart drawer
   ========================================================================== */
.cart-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.12s ease;
  z-index: 40;
}

.cart-fab:hover { background: #45e0d1; }

.cart-fab__count {
  background: #0a0a0a;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  border-radius: 100px;
  padding: 1px 8px;
  min-width: 20px;
  text-align: center;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 51;
  display: flex;
  flex-direction: column;
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.drawer__title {
  font-size: 16px;
  font-weight: 700;
}

.drawer__close {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.drawer__close:hover { color: var(--text); border-color: var(--text-muted); }

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 22px;
}

.cart-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.cart-line__img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  flex-shrink: 0;
}

.cart-line__info { flex: 1; min-width: 0; }

.cart-line__title {
  font-size: 13px;
  font-weight: 600;
}

.cart-line__sku {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

.cart-line__price {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.cart-line__right {
  text-align: right;
  flex-shrink: 0;
}

.cart-line__total {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
}

.cart-line__remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  text-decoration: underline;
  cursor: pointer;
  margin-top: 8px;
  padding: 0;
}

.cart-line__remove:hover { color: var(--err); }

.cart-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
}

/* ---- Shipment grouping (cart drawer) ---- */
.shipment-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 14px 0;
  overflow: hidden;
}

.shipment-group__head {
  background: var(--bg);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.shipment-group__label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.shipment-group__addr {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

.shipment-group .cart-line {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.shipment-group__subtotal {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.split-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  background: rgba(45, 212, 196, 0.06);
  padding: 10px 12px;
  border-radius: var(--radius);
  margin: 14px 0;
  line-height: 1.6;
}

/* ---- Shipment blocks (order confirmation) ---- */
.shipment-block {
  margin-bottom: 28px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.shipment-block__head {
  margin-bottom: 14px;
}

.shipment-block__index {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.shipment-block__label {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-top: 4px;
}

.shipment-block__addr {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Address manager ---- */
.address-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface-raised);
}

.address-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.address-card__label {
  font-size: 13px;
  font-weight: 700;
}

.address-card__lines {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.address-form {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.drawer__footer {
  border-top: 1px solid var(--border);
  padding: 18px 22px 22px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--mono);
}

.summary-row--total {
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.terms-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 3px 7px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

/* ==========================================================================
   Order confirmation
   ========================================================================== */
.confirm-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 32px;
}

.confirm-card__status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 100%;
  background: var(--ok);
}

.confirm-card__id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.confirm-card__title {
  font-size: 20px;
  font-weight: 700;
  margin: 14px 0 24px;
}

.confirm-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.confirm-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 0 0 10px;
  border-bottom: 1px solid var(--border);
}

.confirm-table td {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.confirm-table td:last-child,
.confirm-table th:last-child {
  text-align: right;
  font-family: var(--mono);
}

.confirm-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.confirm-meta__item label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.confirm-meta__item div {
  font-size: 14px;
  font-weight: 600;
}

.confirm-actions {
  margin-top: 28px;
  display: flex;
  gap: 12px;
}

/* ==========================================================================
   Order history
   ========================================================================== */
.order-history {
  margin-top: 48px;
}

.history-row {
  display: grid;
  grid-template-columns: 140px 1fr 110px 130px;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
}

.history-row__id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.history-row__date {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.history-row__total {
  font-family: var(--mono);
  font-weight: 700;
  text-align: right;
}

.history-empty {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 20px 0;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 28px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--ok);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 720px) {
  .catalog-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .catalog-row--head { display: none; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .confirm-meta { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr; gap: 6px; }
  .drawer { width: 100%; }
}
