/* Skullies palette (workspace CLAUDE.md): amber #e18f2e/#985b21, red-orange
   #d9471f/#852713, teal #0b7c7e/#005564, sage #919d67/#59724d, sand #cec09e/#918c68.
   iPad-first: big touch targets, generous type. */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --amber: #e18f2e; --amber-d: #985b21;
  --red: #d9471f; --red-d: #852713;
  --teal: #0b7c7e; --teal-d: #005564;
  --sage: #919d67; --sage-d: #59724d;
  --sand: #cec09e; --sand-d: #918c68;
  --bone: #f7f3ea; --card: #fffdf8; --ink: #2b2320; --muted: #7a6f66;
  --line: #e5dcc9;
}

html { font-size: 17px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bone); color: var(--ink);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px 14px; background: #fff; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: 14px 0 5px; }
label .req { color: var(--red); }

/* ---------- chrome ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--ink); color: var(--bone);
}
header.topbar h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: .04em; flex: 1; }
header.topbar .show-name { display: block; font-size: .7rem; font-weight: 400; color: var(--sand); }
.provisional-banner {
  background: var(--red); color: #fff; text-align: center;
  font-size: .8rem; font-weight: 700; padding: 5px; letter-spacing: .06em;
}
.net-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sage); }
.net-dot.offline { background: var(--sand-d); }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs[hidden] { display: none; }
nav.tabs .badge:empty { display: none; }
nav.tabs button {
  flex: 1; padding: 12px 0 10px; background: none; border: none;
  font-size: .8rem; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav.tabs button.active { color: var(--teal); }
nav.tabs .glyph { font-size: 1.35rem; line-height: 1; }
nav.tabs .badge {
  position: absolute; transform: translate(16px, -4px);
  background: var(--red); color: #fff; font-size: .65rem; font-weight: 700;
  border-radius: 9px; padding: 1px 6px;
}

main { padding: 16px 16px 90px; max-width: 1100px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; font-weight: 700;
  padding: 15px 22px; font-size: 1rem; min-height: 52px;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:active { background: var(--teal-d); }
.btn-amber { background: var(--amber); color: #fff; }
.btn-amber:active { background: var(--amber-d); }
.btn-ghost { background: none; border: 1.5px solid var(--line); color: var(--ink); }
.btn-danger { background: none; border: 1.5px solid var(--red); color: var(--red); }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: .45; }

/* ---------- login ---------- */
.login-wrap { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.login-wrap .logo { font-size: 2rem; font-weight: 800; letter-spacing: .08em; }
.login-wrap .card { text-align: left; margin-top: 24px; }
.auth-error { color: var(--red); font-size: .85rem; margin-top: 10px; }
.offline-note { margin-top: 16px; font-size: .85rem; color: var(--muted); }

/* ---------- catalog ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filters input[type="search"] { flex: 1; min-width: 200px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 20px;
  padding: 9px 16px; font-size: .85rem; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bone); }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.pcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
}
.pcard img { width: 100%; aspect-ratio: 5/4; object-fit: cover; background: #eee; }
.pcard .pbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.pcard .pname { font-weight: 700; font-size: .92rem; line-height: 1.25; }
.pcard .psku { font-size: .72rem; color: var(--muted); letter-spacing: .04em; }
.pcard .pprice { font-weight: 800; color: var(--teal-d); margin-top: auto; padding-top: 4px; }
.pcard .pref { font-size: .72rem; font-weight: 600; color: var(--muted); line-height: 1.5; }
.pcard .pref s { color: var(--sand-d); }
.min-warning {
  background: #fdf0e7; border: 1.5px solid var(--amber); border-radius: 10px;
  color: var(--amber-d); font-weight: 700; font-size: .9rem;
  padding: 12px 16px; margin-bottom: 12px; text-align: center;
}
.pricing-label {
  background: var(--sage); color: #fff; border-radius: 10px;
  padding: 8px 14px; font-size: .82rem; font-weight: 700; letter-spacing: .03em;
  margin-bottom: 12px; text-align: center;
}
.pcard .stepper { margin-top: 8px; }

.stepper { display: flex; align-items: center; gap: 0; }
.stepper button {
  width: 44px; height: 44px; border: none; border-radius: 10px;
  font-size: 1.4rem; font-weight: 700; background: var(--bone); color: var(--ink);
}
.stepper .add {
  flex: 1; background: var(--amber); color: #fff; font-size: .9rem; height: 44px;
}
.stepper .qty { flex: 1; text-align: center; font-weight: 800; font-size: 1.05rem; }
.stepper.in-cart button.minus { background: var(--sand); }
.stepper.in-cart button.plus { background: var(--amber); color: #fff; }

/* ---------- cards / lists ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; margin-bottom: 14px;
}
.card h2 { font-size: 1.05rem; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: .85rem; }

.lines { width: 100%; border-collapse: collapse; }
.lines td { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lines .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .total-row td { border: none; font-weight: 800; font-size: 1.1rem; }

.hist-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 4px; border-bottom: 1px solid var(--line);
}
.hist-item .who { font-weight: 700; }
.pill {
  font-size: .7rem; font-weight: 800; letter-spacing: .05em;
  padding: 4px 10px; border-radius: 20px; white-space: nowrap;
}
.pill.local { background: var(--sand); color: var(--ink); }
.pill.synced { background: var(--sage); color: #fff; }
.pill.error { background: var(--red); color: #fff; }

.sync-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.sync-row .status { flex: 1; font-size: .9rem; color: var(--muted); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.confirm-policy {
  background: var(--bone); border: 1px dashed var(--sand-d); border-radius: 10px;
  padding: 12px 14px; font-size: .85rem; margin: 14px 0;
}
.check-row { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0; }
.check-row input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--teal); flex-shrink: 0; }

.saved-splash { text-align: center; padding: 10vh 20px; }
.saved-splash .big { font-size: 3.2rem; }
.saved-splash h2 { margin: 12px 0 6px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--ink); color: var(--bone); border-radius: 12px;
  padding: 12px 22px; font-weight: 600; z-index: 50; max-width: 90vw; text-align: center;
}
