/* ── Inter loaded via <link> in <head> ── */

/* ── Design tokens ── */
:root {
  /* Surfaces — dark first */
  --bg:         #0d1117;
  --surface:    #161c27;
  --surface-hi: #1d2535;
  --border:     #252f42;
  --border-hi:  #3b4a62;

  /* Text */
  --fg:     #e8edf5;
  --muted:  #6b7a94;
  --xmuted: #3a4558;

  /* Accent: blue */
  --blue:      #3b82f6;
  --blue-hi:   #60a5fa;
  --blue-soft: rgba(59, 130, 246, .14);

  /* Action: green (the add button) */
  --green:      #15803d;
  --green-hi:   #166534;
  --green-soft: rgba(21, 128, 61, .14);
  --green-text: #34d399;

  /* Danger: red */
  --red:      #b91c1c;
  --red-hi:   #991b1b;
  --red-soft: rgba(185, 28, 28, .14);
  --red-text: #f87171;

  /* Radius — sharp scale (4 / 6 / 8) */
  --r-sm:  4px;
  --r-md:  6px;
  --r-lg:  8px;
  --r-xl: 12px;

  /* Elevation */
  --sh:    0 1px 3px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.24);
  --sh-lg: 0 20px 60px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.3);

  /* Spacing scale: 4 8 12 16 24 32 48 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:         #f1f5f9;
    --surface:    #ffffff;
    --surface-hi: #f8fafc;
    --border:     #e2e8f0;
    --border-hi:  #cbd5e1;
    --fg:         #0f172a;
    --muted:      #64748b;
    --xmuted:     #cbd5e1;
    --blue:       #2563eb;
    --blue-hi:    #1d4ed8;
    --blue-soft:  rgba(37, 99, 235, .09);
    --green:      #15803d;
    --green-hi:   #166534;
    --green-soft: rgba(21, 128, 61, .09);
    --green-text: #15803d;
    --red:        #b91c1c;
    --red-hi:     #991b1b;
    --red-soft:   rgba(185, 28, 28, .09);
    --red-text:   #b91c1c;
    --sh:         0 1px 3px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.09);
    --sh-lg:      0 20px 60px rgba(0,0,0,.2), 0 4px 16px rgba(0,0,0,.1);
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -120px;
  left: var(--s4);
  z-index: 100;
  padding: 10px 18px;
  background: var(--blue);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--r-lg);
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus { top: var(--s4); outline: 2px solid var(--fg); outline-offset: 2px; }

/* ── Screen-reader only ── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ── Base ── */
html { color-scheme: dark light; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100dvh;
  padding: var(--s5) var(--s4) 80px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-shell { max-width: 860px; margin: 0 auto; }

/* ── App header ── */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--s4);
  margin-bottom: var(--s5);
}

.app-logo {
  width: 48px; height: 48px;
  flex-shrink: 0;
  background: var(--blue-soft);
  border: 1px solid rgba(59, 130, 246, .22);
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  color: var(--blue-hi);
}

h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.2;
}
.app-tagline {
  color: var(--muted);
  font-size: 14px;
  margin-top: 3px;
  line-height: 1.5;
}

h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.015em;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s6);
  margin-bottom: var(--s4);
  box-shadow: var(--sh);
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: var(--s5);
}

/* ── Three-step form ── */
.steps {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: start;
  gap: 0 var(--s3);
}

@media (max-width: 600px) {
  .steps {
    grid-template-columns: 1fr;
    gap: var(--s5) 0;
  }
  .step-sep { display: none; }
}

.step { min-width: 0; }

.step-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--xmuted);
  /* nudge down to sit at the vertical midpoint of the input */
  margin-top: 44px;
  flex-shrink: 0;
}

.step-hd {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
}

.step-num {
  width: 26px; height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-hi);
  border: 1.5px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s, color .18s, border-color .18s, transform .2s, box-shadow .2s;
}

.step:focus-within .step-num {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.step label {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: default;
  transition: color .18s;
}
.step:focus-within label { color: var(--blue-hi); }

.step-hint {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: var(--s2);
  line-height: 1.4;
}

/* ── Inputs ── */
input {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.01em;
  padding: 14px var(--s4);
  min-height: 58px;
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
input:disabled { opacity: .35; cursor: not-allowed; }
input.upper { text-transform: uppercase; }
input::placeholder {
  color: var(--muted);
  opacity: .55;
  font-weight: 400;
  font-size: 17px;
  letter-spacing: 0;
}

/* ── Buttons (base) ── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 11px var(--s5);
  min-height: 48px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
  transition: background .14s, transform .1s, box-shadow .14s, opacity .14s;
}
button:hover:not(:disabled) {
  background: var(--blue-hi);
  box-shadow: 0 2px 14px var(--blue-soft);
}
button:active:not(:disabled) { transform: scale(.97); }
button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

button.sec {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
button.sec:hover:not(:disabled) {
  background: var(--surface-hi);
  color: var(--fg);
  border-color: var(--border-hi);
  box-shadow: none;
}

button.danger {
  background: var(--red);
  color: #fff;
}
button.danger:hover:not(:disabled) {
  background: var(--red-hi);
  box-shadow: 0 2px 12px var(--red-soft);
}

button:disabled { opacity: .36; cursor: not-allowed; }

/* ── Add button (primary action) ── */
#add {
  width: 100%;
  margin-top: var(--s5);
  padding: 18px var(--s5);
  min-height: 60px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  background: var(--green);
}
#add:hover:not(:disabled) {
  background: var(--green-hi);
  box-shadow: 0 4px 22px var(--green-soft);
}
#add:focus-visible { outline-color: var(--green); }

/* ── Status ── */
#status {
  margin-top: var(--s3);
  min-height: 44px;
  padding: 10px var(--s4);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.5;
  transition: background .2s, color .2s;
}
#status.info {
  background: var(--green-soft);
  color: var(--green-text);
}
#status.err {
  background: var(--red-soft);
  color: var(--red-text);
}

/* ── Cart header ── */
.cart-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.cart-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

.count {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-hi);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px var(--s3);
  min-height: 36px;
  white-space: nowrap;
  transition: color .2s, border-color .2s, background .2s;
}
.count.full {
  color: var(--red-text);
  border-color: var(--red);
  background: var(--red-soft);
}

/* ── Progress bar ── */
.progress-wrap { margin-bottom: var(--s5); }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--s2);
}

.progress-bar {
  height: 6px;
  background: var(--surface-hi);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: var(--blue);
  border-radius: 3px;
  transition: width .4s cubic-bezier(.4,0,.2,1), background .3s;
}
.progress-bar__fill.full { background: var(--red); }

/* ── Table ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 420px;
}
th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: var(--s2) var(--s3) 10px;
  border-bottom: 1.5px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
td {
  padding: var(--s4) var(--s3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:not(.empty-row):hover td {
  background: var(--surface-hi);
  transition: background .12s;
}

/* Empty state */
.empty-row td {
  text-align: center;
  padding: var(--s7) var(--s5);
  color: var(--muted);
  font-size: 14px;
  border-bottom: none;
}
.empty-row td span {
  display: block;
  font-size: 32px;
  margin-bottom: var(--s3);
  opacity: .6;
}

/* Row action buttons */
td.acts { white-space: nowrap; text-align: right; }
td.acts button {
  padding: var(--s2) var(--s3);
  min-height: 40px;
  font-size: 13px;
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
td.acts button:hover:not(:disabled) {
  color: var(--fg);
  border-color: var(--border-hi);
  background: var(--surface-hi);
  box-shadow: none;
  transform: none;
}
td.acts button.del-btn:hover:not(:disabled) {
  color: var(--red-text);
  border-color: var(--red);
  background: var(--red-soft);
}
td.acts button + button { margin-left: var(--s2); }

/* ── Dialogs ── */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--fg);
  padding: var(--s6);
  width: min(440px, 93vw);
  box-shadow: var(--sh-lg);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
dialog::backdrop {
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(5px);
}
dialog h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--s5);
}
dialog label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: var(--s1) 0 var(--s2);
}
dialog input {
  font-size: 17px;
  min-height: 52px;
  margin-bottom: var(--s3);
}
dialog p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin-top: var(--s1);
}

.actions {
  display: flex;
  gap: var(--s2);
  justify-content: flex-end;
  margin-top: var(--s5);
}

/* ── Footer hint ── */
.hint {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: var(--s5);
  opacity: .7;
}
.hint kbd {
  display: inline-block;
  font-family: inherit;
  font-size: 11.5px;
  padding: 2px var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-hi);
  color: var(--fg);
  margin: 0 2px;
}
