/* Ascent Select - UI
   Soft-grey canvas, white cards, Ascent blue accent, Inter. Compact + professional.
   Aesthetic aligned with the Ascent console design system. */

:root {
  --bg:         #fafafa;
  --surface:    #ffffff;
  --soft:       #fafafa;
  --text:       #1a1a1a;
  --head:       #111827;
  --muted:      #6b7280;
  --muted-2:    #9ca3af;
  --line:       #e5e7eb;
  --line-2:     #d1d5db;
  --brand:      #005bea;
  --brand-ink:  #0050cf;
  --brand-soft: #eaf1ff;
  --ok:         #0a7d33;
  --ok-bg:      #e7f6ec;
  --warn:       #8a6d00;
  --warn-bg:    #fbf3d8;
  --err:        #b42318;
  --err-bg:     #fdecea;
  --radius:     8px;
  --radius-sm:  6px;
  --sidebar-w:  224px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; color: var(--head); margin: 0; }
h1 { font-size: 18px; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

/* ---------------------------------------------------------------- Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 0.5px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.brand-wrap { padding: 18px 18px 14px; border-bottom: 0.5px solid var(--line); }
.brand { display: block; }
.brand img { width: 132px; max-width: 100%; height: auto; display: block; }
.brand-sub { margin: 10px 2px 0; font-size: 11.5px; color: var(--muted-2); }

.nav { padding: 10px; flex: 1; overflow-y: auto; }
.nav .sec {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted-2); padding: 12px 10px 5px;
}
.nav .sec:first-child { padding-top: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: #374151; font-size: 13.5px; margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--soft); color: var(--head); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav-link svg { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.nav-link .badge { margin-left: auto; }
.nav-link.signout:hover { background: var(--err-bg); color: var(--err); }

.sidebar-foot { border-top: 0.5px solid var(--line); padding: 12px 18px 14px; }
.acct-line { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.acct-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.acct-email { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.powered { display: block; }
.powered img { height: 30px; width: auto; display: block; opacity: 1; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1 1 auto; min-width: 0;
  padding: 24px 28px 56px;
  max-width: 1180px;
}

/* --------------------------------------------------------------- Topbar */
.topbar {
  display: none;
  position: sticky; top: 0;
  align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--line);
  z-index: 50;
}
.topbar-logo { display: inline-flex; }
.topbar-logo img { width: 112px; height: auto; display: block; }
.menu-toggle {
  width: 36px; height: 32px; border: 0.5px solid var(--line-2);
  border-radius: var(--radius-sm); background: var(--surface);
  display: inline-flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 4px; cursor: pointer; padding: 0;
}
.menu-toggle span { width: 16px; height: 1.6px; background: var(--text); display: block; }

/* ------------------------------------------------------------- Headings */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { margin-bottom: 3px; }
.lede { margin: 0; color: var(--muted); font-size: 13px; max-width: 60ch; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Cards */
.card {
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-h {
  padding: 13px 16px; border-bottom: 0.5px solid var(--line);
  font-weight: 500; font-size: 13.5px; color: var(--head);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.card-b { padding: 16px; }
.table-card { padding: 0; overflow: hidden; }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty p { margin: 0 0 16px; }

/* --------------------------------------------------------------- Tables */
.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
.grid thead th {
  text-align: left; font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted);
  padding: 11px 16px; border-bottom: 0.5px solid var(--line);
  background: var(--soft); white-space: nowrap;
}
.grid tbody td { padding: 11px 16px; border-bottom: 0.5px solid var(--line); vertical-align: middle; font-size: 13px; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: #fcfcfd; }

.col-price, .col-total, .col-qty { white-space: nowrap; }
.col-action { width: 1%; white-space: nowrap; }
.col-desc { color: var(--muted); max-width: 380px; }

.sku { font-size: 12px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.name { display: block; font-weight: 500; color: var(--head); }
.col-name .sku { display: block; margin-top: 2px; }
.price { font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; margin-top: 4px;
  font-size: 10.5px; color: var(--muted); background: var(--soft);
  border: 0.5px solid var(--line); border-radius: 999px; padding: 1px 8px;
}

/* --------------------------------------------------------------- Badges */
.badge {
  display: inline-flex; align-items: center; min-width: 18px; justify-content: center;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  color: #fff; background: var(--brand); line-height: 1.6;
}
.pill {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; border: 0.5px solid var(--line-2);
  color: var(--muted); background: var(--surface); line-height: 1.6;
}
.pill.green { color: var(--ok); background: var(--ok-bg); border-color: #bfe6cb; }
.pill.blue  { color: var(--brand); background: var(--brand-soft); border-color: #c9dcff; }
.pill.amber { color: var(--warn); background: var(--warn-bg); border-color: #ecdca0; }
.pill.red   { color: var(--err); background: var(--err-bg); border-color: #f0c4bf; }
.pill.grey  { color: var(--muted); background: var(--soft); }

.row-actions { display: flex; gap: 14px; }
.row-actions a { color: var(--brand); font-size: 13px; }
.link-remove {
  background: none; border: none; color: var(--muted-2);
  font: inherit; font-size: 12.5px; cursor: pointer; padding: 0;
}
.link-remove:hover { color: var(--err); }

/* ------------------------------------------------------------- Stepper */
.add-row { display: flex; align-items: center; gap: 10px; }
.stepper {
  display: inline-flex; align-items: center;
  border: 0.5px solid var(--line-2); border-radius: var(--radius-sm);
  overflow: hidden; height: 32px; background: var(--surface);
}
.step {
  width: 30px; height: 30px; border: none; background: var(--surface);
  color: var(--text); font-size: 15px; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.step:hover { background: var(--soft); }
.step-qty {
  width: 34px; height: 30px; border: none; text-align: center;
  font: inherit; font-size: 13px; color: var(--text);
  font-variant-numeric: tabular-nums; background: transparent;
  border-left: 0.5px solid var(--line-2); border-right: 0.5px solid var(--line-2);
}
.step-qty:focus { outline: none; }

/* --------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 0.5px solid var(--line-2); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover { background: var(--soft); text-decoration: none; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--soft); }
.btn-add { padding: 8px 18px; }
.btn-block { display: flex; width: 100%; margin-top: 14px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ------------------------------------------------------------- Summary */
.cart-layout, .checkout-layout, .confirm-layout {
  display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start;
}
.summary h2 { margin-bottom: 16px; }
.sum-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 0; font-size: 13.5px; color: var(--muted);
}
.sum-row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.sum-total {
  margin-top: 6px; padding-top: 12px; border-top: 0.5px solid var(--line);
  font-size: 15px; font-weight: 600; color: var(--head);
}
.sum-total span:last-child { font-weight: 600; }
.sum-items { list-style: none; margin: 0 0 8px; padding: 0 0 8px; border-bottom: 0.5px solid var(--line); }
.sum-items li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13px; }
.sum-items .sum-name { color: var(--text); }
.sum-items em { color: var(--muted-2); font-style: normal; }
.fine { margin: 10px 0 0; font-size: 11.5px; color: var(--muted-2); text-align: center; }

/* --------------------------------------------------------------- Forms */
.form-card h2 { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span { font-size: 12.5px; color: #374151; font-weight: 500; }
.field em { color: var(--muted-2); font-style: normal; font-weight: 400; }
.field input, .field textarea, .field select {
  font: inherit; font-size: 13px; color: var(--text);
  padding: 8px 11px; border: 0.5px solid var(--line-2);
  border-radius: var(--radius-sm); background: var(--surface); width: 100%;
}
.field select { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field input[readonly] { background: var(--soft); color: var(--muted); }
.field textarea { resize: vertical; min-height: 70px; }
.check { display: flex; align-items: center; gap: 9px; margin: 16px 0 4px; font-size: 13px; color: var(--muted); }
.check input { width: 15px; height: 15px; accent-color: var(--brand); }
.checkout-note {
  font-size: 13px; color: var(--muted); background: var(--soft);
  border: 0.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 0 0 16px;
}
.checkout-note a { color: var(--brand); }
.pay-intro { font-size: 13.5px; color: var(--muted); margin: 0 0 18px; line-height: 1.5; }
.pay-note { font-size: 12px; color: var(--muted-2); margin: 14px 0 0; }

/* --------------------------------------------------------------- Auth */
.auth-wrap { max-width: 400px; margin: 6vh auto 0; }
.auth-card { padding: 30px 28px; border-radius: 12px; }
.auth-card h1 { font-size: 17px; margin-bottom: 6px; }
.auth-card .lede { margin-bottom: 20px; }
.auth-card .field { margin-bottom: 14px; }
.otp-input { letter-spacing: 8px; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.resend { margin-top: 14px; text-align: center; }
.link-plain { background: none; border: none; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; }

/* --------------------------------------------------------------- Confirm */
.confirm-banner {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
  border: 0.5px solid #bfe6cb; background: var(--ok-bg);
}
.confirm-banner .tick {
  width: 34px; height: 34px; border-radius: 50%; background: var(--ok);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; flex: none;
}
.confirm-ref { font-size: 15px; color: var(--head); font-weight: 600; }
.confirm-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* --------------------------------------------------------------- Flash */
.flash { border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 13px; border: 0.5px solid; }
.flash-success { background: var(--ok-bg); border-color: #bfe6cb; color: var(--ok); }
.flash-error   { background: var(--err-bg); border-color: #f0c4bf; color: var(--err); }
.flash-info    { background: var(--brand-soft); border-color: #c9dcff; color: var(--brand); }

/* --------------------------------------------------------------- Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--head); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.show-cart { display: none; }

/* ---------------------------------------------------------- Policy pages */
.policy { max-width: 820px; line-height: 1.6; }
.policy h2 { font-size: 15px; margin: 26px 0 8px; color: var(--head); }
.policy h2:first-child { margin-top: 0; }
.policy h3 { font-size: 13.5px; margin: 18px 0 6px; color: var(--head); }
.policy p { margin: 0 0 12px; color: #374151; font-size: 14px; }
.policy ul, .policy ol { margin: 0 0 14px; padding-left: 20px; color: #374151; font-size: 14px; }
.policy li { margin: 4px 0; }
.policy a { color: var(--brand); }
.policy .policy-address { line-height: 1.7; }
.policy .policy-eff { color: var(--muted-2); font-size: 12.5px; margin-top: 14px; }
.policy .policy-legend { font-size: 12.5px; color: var(--muted-2); }
.policy-table-wrap { overflow-x: auto; margin: 0 0 16px; }
.policy-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 460px; }
.policy-table th, .policy-table td { border: 0.5px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.policy-table th { background: var(--soft); font-weight: 500; color: var(--head); }
.policy-table td { color: #374151; }

/* ------------------------------------------------- Site footer (policies) */
.site-footer { margin-top: 44px; padding-top: 20px; border-top: 0.5px solid var(--line); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.footer-links a { font-size: 12.5px; color: var(--muted); }
.footer-links a:hover { color: var(--head); }
.footer-meta { font-size: 12px; color: var(--muted-2); }

/* ============================================================== Responsive */
.overlay { display: none; position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 35; }
@media (max-width: 860px) {
  .topbar { display: flex; }
  .main { margin-left: 0; padding: 16px 14px 48px; max-width: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 12px 40px rgba(0,0,0,.14); width: 250px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open + .overlay { display: block; }

  .page-head { flex-direction: column; gap: 12px; }
  .cart-layout, .checkout-layout, .confirm-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .show-cart { display: inline-flex; }

  /* Tables become stacked cards */
  table[data-cards] thead { display: none; }
  table[data-cards], table[data-cards] tbody { display: block; }
  table[data-cards] tr {
    display: block; background: var(--surface);
    border: 0.5px solid var(--line); border-radius: var(--radius);
    padding: 6px 4px; margin: 0 0 10px;
  }
  table[data-cards] tr:hover { background: var(--surface); }
  table[data-cards] td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 9px 14px; border-bottom: 0.5px solid var(--line) !important;
  }
  table[data-cards] td:last-child { border-bottom: 0 !important; }
  table[data-cards] td::before {
    content: attr(data-label); font-size: 11px; letter-spacing: 0.03em;
    text-transform: uppercase; color: var(--muted); font-weight: 500; flex: 0 0 auto;
  }
  table[data-cards] td[data-label=""]::before { display: none; }
  table[data-cards] .col-name { flex-direction: column; align-items: flex-start; gap: 2px; }
  table[data-cards] .col-name::before { order: -1; }
  table[data-cards] .col-desc { color: var(--muted); font-size: 13px; }
  table[data-cards] .col-action { display: block; }
  table[data-cards] .col-action::before { display: block; margin-bottom: 8px; }
  table[data-cards] .add-row { justify-content: space-between; }
  table[data-cards] .row-actions { justify-content: flex-end; }
  .col-desc { max-width: none; }
}
@media (max-width: 420px) {
  table[data-cards] .add-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .btn-add { width: 100%; }
}

/* Accessibility */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
