/* ============ TIRECALC #480 — Costco.com visual language ============ */
:root {
  --blue: #005daa;        /* Costco blue */
  --blue-dk: #00477e;
  --blue-tint: #e8f1fa;
  --red: #e31837;         /* Costco red — savings only */
  --red-dk: #c11030;
  --red-tint: #fdecef;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #22292f;
  --mut: #667085;
  --line: #e3e7eb;
  --ok: #1d7a3a;
  --shadow: 0 1px 3px rgba(16,24,40,.09), 0 1px 2px rgba(16,24,40,.05);
  --shadow-lg: 0 4px 14px rgba(16,24,40,.10);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
          Helvetica, Arial, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }  /* beats any display: set by a class */
html { font-size: 16px; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
input, textarea, button { font-family: var(--sans); }

/* red accent bar (replaces old tread stripe) */
.tread { height: 4px; background: var(--red); }

/* ============ HEADER ============ */
header {
  background: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 10;
}
.hd-store {
  padding: 14px 18px 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--blue);
}
.hd-store b { color: var(--red); font-weight: 800; }
.hd-sub {
  padding: 1px 18px 12px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--red);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.hd-name {
  color: var(--blue);
  letter-spacing: .08em;
}

/* ============ LAYOUT ============ */
main {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
}
.fld-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mut);
  margin: 20px 4px 8px;
}
.fld-label:first-child { margin-top: 2px; }

/* ============ PRICE INPUT ============ */
.price-row {
  display: flex;
  align-items: stretch;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.price-row:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0,93,170,.14);
}
.price-cur {
  display: flex; align-items: center;
  padding: 0 2px 0 16px;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--mut);
}
#price {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  padding: 14px 8px;
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text);
  background: transparent;
  font-variant-numeric: tabular-nums;
}
#price::placeholder { color: #c3cbd4; font-weight: 600; }
.price-clear {
  width: 56px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  font-size: 1.7rem;
  color: var(--mut);
  cursor: pointer;
}
.price-clear:active { color: var(--red); background: var(--bg); }

/* ============ CHIPS ============ */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1.5px solid #cdd5dd;
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 700;
  padding: 8px 16px;
  min-height: 48px;
  cursor: pointer;
  text-align: center;
  transition: background .12s, border-color .12s, transform .06s;
  box-shadow: var(--shadow);
}
.chip small {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: var(--red);
}
.chip:active { transform: scale(.97); }
.chip.on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.chip.on small { color: #ffd3da; }

/* ============ TOTALS ============ */
.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.tcard {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.tcard-promo { border-color: #f3c1ca; }
.tcard-promo.idle { border-style: dashed; border-color: var(--line); box-shadow: none; }
.tcard-tag {
  align-self: flex-start;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 4px 10px;
  border-radius: 999px;
}
.tcard-promo .tcard-tag { background: var(--red-tint); color: var(--red); }
.tcard-promo.idle .tcard-tag { background: var(--bg); color: var(--mut); }
.tcard-plain .tcard-tag { background: var(--blue-tint); color: var(--blue); }
.tcard-amt {
  font-size: clamp(1.3rem, 6.4vw, 1.85rem);
  font-weight: 800;
  line-height: 1.05;
  margin: 8px 0 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;   /* a total never wraps mid-number... */
  color: var(--text);
}
.tcard-amt.amt-long {    /* ...it shrinks to fit instead */
  font-size: clamp(1.05rem, 5.1vw, 1.5rem);
  letter-spacing: -.02em;
}
.tcard-promo .tcard-amt { color: var(--red); }
.tcard-promo.idle .tcard-amt { color: #c3cbd4; }
.tcard-amt.pop { animation: pop .22s ease; }
@keyframes pop {
  0% { transform: scale(.95); opacity: .5; }
  100% { transform: scale(1); opacity: 1; }
}
.tcard-sub {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--mut);
  text-transform: uppercase;
}
.tcard-promo .tcard-sub { color: var(--red); }
.tcard-promo.idle .tcard-sub { color: var(--mut); }

/* ============ RECEIPT ============ */
#receipt-wrap { margin-top: 22px; }
.rc-head {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mut);
  margin: 0 4px 8px;
}
.rc-head span { color: var(--red); }
.receipt {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.receipt td {
  padding: 11px 14px;
  border-bottom: 1px solid #eef1f4;
  font-size: .95rem;
}
.receipt .rc-amt {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.receipt .rc-lbl small { color: var(--mut); font-size: .78rem; font-weight: 400; }
.receipt .rc-promo td { color: var(--red); font-weight: 700; }
.receipt .rc-sub td { background: #fafbfc; font-weight: 700; }
.receipt .rc-total td {
  background: var(--blue);
  color: #fff;
  border-bottom: 0;
  font-weight: 800;
  font-size: 1.02rem;
}
.rc-note {
  margin: 9px 4px 0;
  font-size: .8rem;
  color: var(--mut);
}
.rc-note b { color: var(--red); }

/* ============ BUTTONS ============ */
.btn-red, .btn-ink, .btn-ghost {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 14px;
  cursor: pointer;
  transition: background .12s, transform .06s;
}
.btn-red { background: var(--blue); color: #fff; }
.btn-red:active { background: var(--blue-dk); transform: scale(.99); }
.btn-ink { background: var(--blue); color: #fff; }
.btn-ink:active { background: var(--blue-dk); transform: scale(.99); }
.btn-ghost {
  background: var(--card);
  color: var(--blue);
  border: 1.5px solid #cdd5dd;
}
.btn-ghost:active { background: var(--bg); }

/* ============ LOOKUP ============ */
.search-row input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  padding: 13px 18px;
  font-size: 1.05rem;
  outline: none;
  box-shadow: var(--shadow);
  -webkit-appearance: none;
}
.search-row input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0,93,170,.14);
}
.lk-count {
  font-size: .75rem;
  font-weight: 600;
  color: var(--mut);
  margin: 9px 6px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.lk-list { margin-bottom: 14px; }
.lk-row {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-bottom-width: 0;
  padding: 11px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.lk-row:first-child { border-radius: 14px 14px 0 0; }
.lk-row:last-child { border-bottom-width: 1.5px; border-radius: 0 0 14px 14px; box-shadow: var(--shadow); }
.lk-row:only-child { border-radius: 14px; }
.lk-ids {
  flex: 0 0 auto;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.lk-ids .lk-item { color: var(--blue); }
.lk-ids .lk-mspn { color: var(--mut); font-weight: 600; }
.lk-desc { flex: 1; font-size: .93rem; line-height: 1.35; }
.lk-del {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--mut);
  font-size: 1.4rem;
  padding: 6px 8px;
  cursor: pointer;
}
.lk-del:active { color: var(--red); }
.lk-empty {
  background: var(--card);
  border: 1.5px dashed #cdd5dd;
  border-radius: 14px;
  color: var(--mut);
  text-align: center;
  padding: 28px 16px;
  font-size: .93rem;
  line-height: 1.5;
}

/* add form */
.lk-form {
  margin-top: 14px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lk-form-head {
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue);
}
.lk-form input, .lk-form textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
  resize: vertical;
  -webkit-appearance: none;
}
.lk-form input:focus, .lk-form textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,93,170,.12);
}
.live-msg {
  font-size: .85rem;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.live-msg.ok { border-color: #bfe0c8; background: #f0f9f2; }
.live-msg.err { border-color: #f3c1ca; background: var(--red-tint); }
.live-msg button {
  display: block;
  margin-top: 6px;
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 700;
  font-size: .85rem;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
}
.lk-form-btns { display: flex; gap: 10px; }
.lk-form-btns .btn-ghost { flex: 1; }
.lk-form-btns .btn-red { flex: 1.4; }

/* ============ SETTINGS ============ */
.set-group {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  padding: 6px 16px 10px;
}
.set-head {
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue);
  padding: 12px 0 4px;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eef1f4;
}
.set-row:last-child { border-bottom: 0; }
.set-row label { font-size: .97rem; font-weight: 500; }
.set-num {
  width: 118px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1.02rem;
  font-weight: 700;
  text-align: right;
  outline: none;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
}
.set-num:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,93,170,.12); }
/* switch — iOS style */
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 52px;
  height: 32px;
  border-radius: 999px;
  background: #d3dae1;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16,24,40,.25);
  transition: transform .15s ease;
}
.switch:checked { background: var(--blue); }
.switch:checked::after { transform: translateX(20px); }
/* promo rows */
.promo-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eef1f4;
}
.promo-row input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .97rem;
  outline: none;
}
.promo-row .p-off {
  width: 84px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.promo-row input:focus { border-color: var(--blue); }
.promo-del {
  border: 0; background: none;
  font-size: 1.4rem; color: var(--mut);
  padding: 4px 6px; cursor: pointer;
}
#s-promo-add { margin: 10px 0 8px; font-size: .9rem; padding: 11px; }
.btn-save { position: sticky; bottom: calc(86px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); }
.set-ver {
  text-align: center;
  font-size: .72rem;
  color: var(--mut);
  margin-top: 14px;
}

/* ============ SIZE FINDER ============ */
.size-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#sz-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  outline: none;
  box-shadow: var(--shadow);
  -webkit-appearance: none;
}
#sz-input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,93,170,.14); }
.sz-chips { display: flex; gap: 5px; flex: 0 0 auto; }
.sz-chip {
  min-width: 38px;
  height: 38px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1.5px solid #cdd5dd;
  background: var(--card);
  color: var(--text);
  font-size: .72rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.sz-chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.sz-hint {
  margin: 10px 4px 0;
  font-size: .85rem;
  color: var(--mut);
  line-height: 1.45;
}
.sz-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 8px;
  box-shadow: var(--shadow);
}
.sz-badge {
  flex: 0 0 auto;
  min-width: 34px;
  text-align: center;
  padding: 5px 4px;
  border-radius: 8px;
  background: var(--blue-tint);
  color: var(--blue);
  font-size: .7rem;
  font-weight: 800;
}
.sz-desc { flex: 1; font-size: .92rem; line-height: 1.3; }
.sz-item {
  flex: 0 0 auto;
  font-size: .8rem;
  font-weight: 700;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}
.sz-add {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
}
.sz-add:disabled { background: var(--ok); }
.sz-ai { margin-top: 12px; font-size: .82rem; letter-spacing: .03em; }
.sz-off .sz-badge { background: var(--paper-2, #eef3f8); color: var(--mut); }
.sz-off .sz-desc { color: var(--mut); }
.sz-tag { font-size: .72rem; font-style: normal; color: var(--mut); }
.sz-specs {
  margin: 12px 4px 2px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.sz-cat {
  flex: 0 0 auto;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .05em;
  color: var(--mut);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
}
.sz-hintrow { cursor: pointer; }
.sz-hintrow:active { background: var(--blue-tint); }

/* knowledge-base editor + stored photos */
.sz-hintbox { max-height: 296px; overflow-y: auto; }  /* ~5 rows visible, scroll to 7 */
.set-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  padding: 12px 0;
}
.set-count {
  font-size: .68rem;
  color: var(--mut);
  letter-spacing: .06em;
}
.chev { margin-left: auto; color: var(--mut); font-size: .9rem; }
.cat-scroll { max-height: 320px; overflow-y: auto; }
.cat-legend {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mut);
  padding: 4px 0 2px;
}
.cat-row {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #eef1f4;
}
.cat-row select {
  flex: 0 0 auto;
  width: 58px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 8px 2px;
  font-size: .78rem;
  font-weight: 800;
  background: #fff;
  text-align: center;
}
.cat-row input {
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: .82rem;
}
.cat-row input[data-k="model"] { flex: 1; }
.c-cat { width: 70px; flex: 0 0 auto; font-size: .72rem !important; }
.c-rim { width: 36px; flex: 0 0 auto; text-align: center; font-variant-numeric: tabular-nums; }
#s-cat-add { margin: 10px 0 8px; font-size: .9rem; padding: 11px; }
.f-photo-view {
  max-width: 100%;
  max-height: 170px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  object-fit: contain;
  align-self: flex-start;
}
.lk-cam { font-size: .8rem; }

/* ============ TAB BAR ============ */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(16,24,40,.06);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.tabbar button {
  flex: 1;
  border: 0;
  background: none;
  color: #98a2b3;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  padding: 9px 0 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
}
.tabbar button::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 40px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: transparent;
}
.tabbar button.on::before { background: var(--red); }
.tabbar svg { width: 23px; height: 23px; fill: currentColor; }
.tabbar button.on { color: var(--blue); }

/* ============ LOGIN ============ */
.login {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 0 24px 26px;
  overflow: hidden;
}
.login-card .tread { margin: 0 -24px 20px; }
.login-brand {
  font-size: .95rem;
  font-weight: 700;
  color: var(--mut);
}
.login-brand b { color: var(--red); }
.login-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.05;
  color: var(--red);
  margin: 4px 0 20px;
}
.login-title span {
  display: block;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .3em;
  color: var(--blue);
  margin-top: 4px;
}
#login-pw {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1.15rem;
  outline: none;
  margin-bottom: 12px;
  -webkit-appearance: none;
}
#login-pw:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,93,170,.14); }
.login-err {
  color: var(--red);
  font-weight: 600;
  font-size: .9rem;
  margin: 0 0 10px;
  min-height: 1.2em;
}
.login-diag {
  margin-top: 12px;
  font-size: .72rem;
  color: var(--mut);
  text-align: center;
}

/* ============ TOAST ============ */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1d2939;
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
