:root {
  --ink: #1E1E1C;
  --navy: #14342E;
  --navy-soft: #1D473F;
  --brass: #C08A3E;
  --brass-light: #E0AF63;
  --teal: #2F6F5E;
  --bg: #F6F4EF;
  --card: #FFFFFF;
  --line: #E4DFD3;
  --muted: #6B6A63;
  --danger: #B4432F;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 52, 46, 0.06), 0 1px 2px rgba(20, 52, 46, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Roboto Slab', serif;
  color: var(--navy);
  margin: 0 0 0.3em;
}

a { color: var(--teal); }

.page { max-width: 980px; margin: 0 auto; padding: 20px 16px 64px; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--navy);
  border-bottom: 3px solid var(--brass);
}
.topbar-inner {
  max-width: 980px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; }
.brand-word { color: #fff; font-family: 'Roboto Slab', serif; font-weight: 700; letter-spacing: 0.03em; font-size: 1.05rem; }
.brand-word em { font-style: normal; color: var(--brass-light); font-weight: 500; }
.topnav a { color: #E9E5D8; text-decoration: none; margin-left: 18px; font-size: 0.92rem; font-weight: 500; }
.topnav a:hover { color: var(--brass-light); }

/* ---------- Flash ---------- */
.flash-stack { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 8px; }
.flash-error { background: #FBE7E2; color: var(--danger); }
.flash-success { background: #E5F1EC; color: var(--teal); }

/* ---------- Auth cards ---------- */
.auth-shell { display: flex; justify-content: center; padding-top: 24px; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 28px; width: 100%; max-width: 400px;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem;
  color: var(--brass); font-weight: 700; margin: 0 0 8px;
}
.muted { color: var(--muted); font-size: 0.92rem; }

.stacked-form { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.stacked-form label { font-size: 0.82rem; font-weight: 600; color: var(--navy); margin-top: 10px; }
.stacked-form input, .stacked-form select, .stacked-form textarea {
  font-family: inherit; font-size: 1rem; padding: 11px 12px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
}
.stacked-form input:focus, .stacked-form select:focus, .stacked-form textarea:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(47,111,94,0.15);
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }

.mobile-input { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.mobile-input .prefix { background: #F0EEE6; padding: 11px 12px; font-weight: 600; color: var(--muted); }
.mobile-input input { border: none; flex: 1; border-radius: 0; }
.mobile-input input:focus { box-shadow: none; }

.otp-input { letter-spacing: 0.5em; font-size: 1.4rem; text-align: center; font-family: 'Roboto Mono', monospace; }

.demo-banner {
  background: #FBF2E2; border: 1px dashed var(--brass); border-radius: 10px;
  padding: 12px 14px; font-size: 0.85rem; margin-top: 16px; color: #7A5620;
}
.demo-code { display: block; font-family: 'Roboto Mono', monospace; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.3em; color: var(--navy); margin-top: 4px; }

.btn {
  display: inline-block; text-align: center; font-weight: 700; border: none;
  border-radius: 10px; padding: 13px 18px; font-size: 1rem; cursor: pointer;
  text-decoration: none; font-family: inherit; transition: transform .08s ease, opacity .15s ease;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-soft); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary { background: var(--brass); color: #2B1D06; }
.btn:active { transform: scale(0.98); }
.text-link { display: inline-block; margin-top: 16px; font-size: 0.85rem; color: var(--muted); text-decoration: underline; }

/* ---------- Builder ---------- */
.builder-head { margin: 8px 0 24px; }
.builder-head h1 { font-size: 1.6rem; }

.pick-section { margin-bottom: 30px; }
.pick-section h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.step-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--brass);
  color: #2B1D06; font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 0.85rem;
}

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 14px; }

.pick-card {
  position: relative; display: block; background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 14px; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease;
}
.pick-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.pick-card:hover { border-color: var(--brass-light); }
.pick-card:has(input:checked) { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(47,111,94,0.12); }
.pick-check {
  position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); background: #fff;
}
.pick-card:has(input:checked) .pick-check { border-color: var(--teal); background: var(--teal); }
.pick-card:has(input:checked) .pick-check::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

.pick-photo { width: 100%; height: 120px; border-radius: 10px; overflow: hidden; background: #F0EEE6; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.pick-photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder { color: var(--brass); opacity: 0.6; }

.pick-body h3 { font-size: 0.98rem; margin-bottom: 4px; }
.pick-body p { font-size: 0.82rem; color: var(--muted); margin: 0 0 6px; line-height: 1.4; }
.pick-price { font-family: 'Roboto Mono', monospace; font-weight: 700; color: var(--navy); font-size: 0.95rem !important; }

.size-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--navy); margin-top: 8px; }
.needs-size-flag { display: none; font-weight: 500; color: var(--danger); text-transform: none; letter-spacing: 0; }
.pick-card.selected-needs-size .needs-size-flag { display: inline; }
.pick-card.selected-needs-size .size-select { border-color: var(--danger); animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180,67,47,0.0); }
  50% { box-shadow: 0 0 0 4px rgba(180,67,47,0.15); }
}
.size-select { width: 100%; margin-top: 4px; padding: 8px; border-radius: 8px; border: 1.5px solid var(--line); font-family: inherit; }
.size-select:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Reveal popup ---------- */
.reveal-overlay {
  position: fixed; inset: 0; background: rgba(10, 24, 21, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
.reveal-overlay.is-open { opacity: 1; pointer-events: auto; }

.reveal-card {
  background: var(--navy); border-radius: var(--radius); padding: 30px 24px 24px;
  color: #fff; box-shadow: 0 20px 60px rgba(0,0,0,0.35); width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  transform: translateY(18px) scale(0.97); transition: transform .28s cubic-bezier(.2,.85,.25,1);
}
.reveal-overlay.is-open .reveal-card { transform: translateY(0) scale(1); }

.reveal-dismiss { color: #C9D6D1 !important; font-size: 0.8rem; margin-top: -6px; }

.recall-pill {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  background: var(--brass); color: #2B1D06; border: none; border-radius: 999px;
  padding: 12px 20px; font-weight: 700; font-size: 0.9rem; box-shadow: var(--shadow);
  cursor: pointer; font-family: inherit;
}

.gauge-wrap { position: relative; width: 200px; }
.gauge { width: 100%; overflow: visible; }
.gauge-track { fill: none; stroke: rgba(255,255,255,0.15); stroke-width: 14; stroke-linecap: round; }
.gauge-fill { fill: none; stroke: var(--brass-light); stroke-width: 14; stroke-linecap: round;
  stroke-dasharray: 251.2; stroke-dashoffset: 251.2; transition: stroke-dashoffset 1.1s cubic-bezier(.2,.8,.2,1); }
.gauge-needle { stroke: #fff; stroke-width: 3; stroke-linecap: round; transform-origin: 100px 110px;
  transform: rotate(-90deg); transition: transform 1.2s cubic-bezier(.2,.85,.15,1); }
.gauge-hub { fill: #fff; }
.gauge-readout { position: absolute; left: 0; right: 0; bottom: -6px; text-align: center; }
.gauge-pct { font-family: 'Roboto Mono', monospace; font-size: 2.1rem; font-weight: 700; color: var(--brass-light); }
.gauge-pct-sign { font-family: 'Roboto Mono', monospace; font-size: 1.2rem; color: var(--brass-light); }
.gauge-label { display: block; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: #C9D6D1; margin-top: 2px; }

.reveal-items { width: 100%; max-width: 340px; border-top: 1px solid rgba(255,255,255,0.12); border-bottom: 1px solid rgba(255,255,255,0.12); padding: 4px 0; max-height: 140px; overflow-y: auto; }
.reveal-item-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 0.82rem; color: #D9E2DE; }
.reveal-item-row .item-name { flex: 1; }
.reveal-item-row .item-size { color: #9FB3AC; }
.reveal-item-row .item-price { font-family: 'Roboto Mono', monospace; }

.price-rows { width: 100%; max-width: 340px; }
.price-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.9rem; }
.muted-row { color: #B9C5C0; }
.final-row { border-top: 1px solid rgba(255,255,255,0.18); margin-top: 6px; padding-top: 10px; font-size: 1.3rem; font-weight: 700; }
.odometer { font-family: 'Roboto Mono', monospace; color: var(--brass-light); }

#submit-form { width: 100%; max-width: 340px; }

/* ---------- Order success ---------- */
.success-card { text-align: center; }
.success-tick { color: var(--teal); margin-bottom: 8px; }
.summary-box { background: #F0EEE6; border-radius: 10px; padding: 14px 16px; margin: 18px 0; text-align: left; }
.summary-line { display: flex; justify-content: space-between; font-size: 0.88rem; padding: 5px 0; color: var(--ink); }
.summary-line.total { font-weight: 700; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; color: var(--navy); }
.summary-line.saved { color: var(--teal); font-weight: 600; }

/* ---------- Admin ---------- */
.admin-shell { display: grid; grid-template-columns: 190px 1fr; gap: 26px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a {
  padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--ink);
  font-weight: 500; font-size: 0.9rem;
}
.admin-nav a.active, .admin-nav a:hover { background: var(--navy); color: #fff; }
.admin-nav .admin-logout { margin-top: 14px; color: var(--danger); }
.admin-content { min-width: 0; }

.admin-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0 26px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat-value { display: block; font-family: 'Roboto Slab', serif; font-size: 1.5rem; color: var(--navy); font-weight: 700; }
.stat-label { font-size: 0.78rem; color: var(--muted); }

.data-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; font-size: 0.86rem; }
.data-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.empty-row { text-align: center; color: var(--muted); padding: 20px; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.thumb-preview { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; margin-top: 6px; }
.row-actions { display: flex; gap: 10px; align-items: center; }
.row-actions form { display: inline; }
.link-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.86rem; text-decoration: underline; padding: 0; font-family: inherit; }

.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 20px; }
.inline-form select, .inline-form input { padding: 9px 10px; border-radius: 8px; border: 1.5px solid var(--line); font-family: inherit; }

.admin-form { max-width: 480px; }

@media (max-width: 720px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .gauge-fill, .gauge-needle { transition: none; }
}
