/* Phone first: big buttons, big text, one column. Colours are tokens so dark mode only swaps these. */
:root {
  --bg: #f7f4ee; --card: #ffffff; --ink: #1f2722; --muted: #5d6a63; --line: #e3ddd2;
  --brand: #2f6b5a; --brand-ink: #ffffff; --brand-soft: #e3efe9;
  --accent: #b5562f; --accent-soft: #f8e7de;
  --good: #2c7a4b; --warn: #a15c00; --warn-soft: #fff1d9; --bad: #b3261e; --bad-soft: #fde4e1;
  --blue: #1f5fa8; --blue-soft: #e2edf9; --purple: #6b3fa0; --purple-soft: #efe6f8; --grey-soft: #ecebe7;
  --bar: #2f6b5a; --bar-neg: #b3261e; --grid: #ebe6dc;
  --radius: 14px; --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1e2421; --ink: #ecf0ed; --muted: #a3b0a9; --line: #313a35;
    --brand: #5fb39a; --brand-ink: #0d1411; --brand-soft: #23352e;
    --accent: #e08a62; --accent-soft: #3a2a22;
    --good: #6cc792; --warn: #f0b45a; --warn-soft: #3a2f1c; --bad: #f2867c; --bad-soft: #3c2220;
    --blue: #8bb8ef; --blue-soft: #1f2c3d; --purple: #c3a2ec; --purple-soft: #2d2440; --grey-soft: #2a302d;
    --bar: #5fb39a; --bar-neg: #f2867c; --grid: #2a312d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
a { color: var(--brand); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }
h4 { margin: 18px 0 6px; }
section { margin: 26px 0; }
[hidden] { display: none !important; }

/* ---------- top bar and bottom tabs ---------- */
#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: var(--brand-ink);
}
#shop-name { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.gear { color: inherit; text-decoration: none; font-size: 1.6rem; line-height: 1; padding: 4px 8px; }
#main { max-width: 760px; margin: 0 auto; padding: 16px; }
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; font-size: .75rem; color: var(--muted); text-decoration: none; }
#nav a span { font-size: 1.35rem; line-height: 1.2; }
#nav a.on { color: var(--brand); font-weight: 700; }
#nav a.add span { background: var(--brand); color: var(--brand-ink); border-radius: 50%; width: 42px; height: 42px; display: grid; place-items: center; font-size: 1.6rem; margin-top: -14px; box-shadow: var(--shadow); }
body.signed-out #nav, body.signed-out .gear { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center;
}
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.light { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: .95rem; }
.btn.wide, .btn.huge { width: 100%; }
.btn.huge { min-height: 60px; font-size: 1.15rem; border-radius: 16px; }
.btn .ico { font-size: 1.5rem; }
.big-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.big-buttons .btn { flex-direction: column; min-height: 104px; }
.sticky-save { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }

/* ---------- layout bits ---------- */
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; gap: 12px; }
.row.end { justify-content: flex-end; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.right { text-align: right; }
.meta, .hint { color: var(--muted); font-size: .9rem; }
.warn-text { color: var(--warn); font-weight: 600; }
.empty-note { color: var(--muted); text-align: center; padding: 18px; margin: 0; }
.loading { color: var(--muted); text-align: center; padding: 40px; }
.banner { background: var(--bad-soft); color: var(--bad); padding: 12px 16px; border-radius: 12px; margin: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.list { padding: 0; overflow: hidden; }
.card.list > * + * { border-top: 1px solid var(--line); }
.line { padding: 12px 14px; gap: 12px; color: inherit; text-decoration: none; }
.page-head { margin-bottom: 14px; }
.back { display: inline-block; text-decoration: none; font-weight: 600; padding: 4px 0 8px; }
.more-link { display: inline-block; margin-top: 4px; font-weight: 600; }
.actions { margin-top: 28px; }

/* ---------- status chips ---------- */
.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.chip.big { font-size: .95rem; padding: 5px 12px; }
.chip.grey { background: var(--grey-soft); color: var(--muted); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.amber { background: var(--warn-soft); color: var(--warn); }
.chip.purple { background: var(--purple-soft); color: var(--purple); }
.chip.green { background: var(--brand-soft); color: var(--good); }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.45rem; font-weight: 750; overflow-wrap: anywhere; }
.tile.good .tile-value { color: var(--good); }
.tile.warn { background: var(--warn-soft); }

/* ---------- item lists ---------- */
.item-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: inherit; text-decoration: none; }
.thumb { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; flex: none; background: var(--grey-soft); }
.thumb.empty { display: grid; place-items: center; font-size: 1.6rem; }
.title { font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.go { color: var(--brand); font-weight: 700; white-space: nowrap; }
.search input, input[type=search] { width: 100%; }
.search { margin-bottom: 10px; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.filters a { flex: none; padding: 8px 14px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: .92rem; }
.filters a b { color: var(--muted); font-weight: 600; }
.filters a.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.filters a.on b { color: inherit; }

/* ---------- to post ---------- */
.post-card .row { gap: 12px; color: inherit; text-decoration: none; margin-bottom: 12px; }
.due { font-weight: 700; }
.due.soon { color: var(--warn); }
.due.late { color: var(--bad); }

/* ---------- item page ---------- */
.strip { display: flex; gap: 8px; overflow-x: auto; margin: 14px 0; scroll-snap-type: x mandatory; }
.shot { flex: none; padding: 0; border: 0; background: none; border-radius: 12px; overflow: hidden; scroll-snap-align: start; cursor: zoom-in; }
.shot img { display: block; width: 150px; height: 190px; object-fit: cover; }
.no-photos { display: block; margin: 14px 0; padding: 26px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; text-decoration: none; }
.next-step { margin: 16px 0; }
.big-profit { font-size: 1.3rem; }
.big-profit b { color: var(--good); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.breakdown { margin-top: 12px; }
.breakdown .row { padding: 3px 0; }
.breakdown .total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-size: 1.1rem; }
.breakdown .total b { color: var(--good); }

dialog.viewer { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; }
dialog.viewer img { width: 100%; height: 100%; object-fit: contain; }
dialog.viewer button { position: absolute; background: rgb(0 0 0 / 50%); color: #fff; border: 0; font-size: 2rem; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; }
dialog.viewer .close { top: calc(12px + env(safe-area-inset-top)); right: 12px; font-size: 1.4rem; }
dialog.viewer .prev { left: 8px; top: 50%; }
dialog.viewer .next { right: 8px; top: 50%; }

/* ---------- forms ---------- */
.form section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; }
.field { display: block; margin: 0 0 14px; }
.field .label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { display: block; margin-top: 4px; }
input, textarea, select {
  font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 48px; max-width: 100%;
}
input:not([type=checkbox]), textarea { width: 100%; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
textarea { resize: vertical; }
input[type=checkbox] { width: 24px; height: 24px; min-height: 0; accent-color: var(--brand); vertical-align: middle; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 14px; }
.money { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.money span { padding: 0 4px 0 12px; color: var(--muted); font-weight: 600; }
.money input { border: 0; padding-left: 4px; }
.money:focus-within { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.money input:focus { outline: none; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices button { min-height: 46px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.choices button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.choices button.on::before { content: '✓ '; }
.suggest { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; margin: -6px 0 14px; flex-wrap: wrap; }
.suggest b { font-size: 1.15rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 12px; }
.ph { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: var(--grey-soft); }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph-btn { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 99px; background: rgb(0 0 0 / 60%); color: #fff; min-width: 32px; height: 32px; padding: 0 8px; font: inherit; font-size: .85rem; cursor: pointer; }
.ph-btn.left { right: auto; left: 4px; }

/* ---------- hangers ---------- */
.hanger-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin: 14px 0; }
.hanger { display: flex; flex-direction: column; gap: 2px; min-height: 84px; padding: 8px; border-radius: 12px; text-decoration: none; font-size: .78rem; line-height: 1.25; overflow: hidden; border: 1px solid var(--line); }
.hanger b { font-size: 1.25rem; }
.hanger.free { background: var(--card); color: var(--muted); border-style: dashed; }
.hanger.free.next { background: var(--brand-soft); color: var(--good); border: 2px solid var(--brand); font-weight: 700; }
.hanger.used { background: var(--blue-soft); color: var(--ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.hanger.used b { display: block; color: var(--blue); }
.hanger.sold { background: var(--warn-soft); }
.hanger.sold b { color: var(--warn); }
.hanger.double { border: 2px solid var(--bad); }

/* ---------- reports ---------- */
.period { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.period select { width: 100%; font-weight: 600; }
.custom-dates label { flex: 1; min-width: 140px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
tbody tr + tr td { border-top: 1px solid var(--line); }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
table.rules td, table.rules th { text-align: center; }
table.rules th:first-child { text-align: left; }
table.rules input[type=number] { width: 84px; min-height: 40px; padding: 6px 8px; }
.chart-box { position: relative; }
.chart-title { font-weight: 600; margin-bottom: 4px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; }
.chart .bar { fill: var(--bar); }
.chart .bar.neg { fill: var(--bar-neg); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover { fill: rgb(127 127 127 / 8%); }
.chart-tip { position: absolute; top: 34px; background: var(--ink); color: var(--bg); padding: 8px 10px; border-radius: 10px; font-size: .85rem; pointer-events: none; box-shadow: var(--shadow); }
.meter { height: 12px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.meter.over span { background: var(--warn); }

/* ---------- settings ---------- */
.chips-edit { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.chip-edit { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-soft); border-radius: 99px; padding: 4px 4px 4px 12px; font-weight: 600; }
.chip-edit button { border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font: inherit; }
.card .row.gap { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0 12px; }
.example p { margin: 6px 0; }
.rule-form { border: 2px solid var(--brand); }

/* ---------- pop-ups ---------- */
dialog.ask { border: 0; border-radius: 18px; padding: 20px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgb(0 0 0 / 30%); }
dialog::backdrop { background: rgb(0 0 0 / 45%); }
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 20; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); font-weight: 600;
}
#toast .btn { color: var(--bg); border-color: var(--bg); }

/* ---------- sign in ---------- */
.login { max-width: 380px; margin: 40px auto; text-align: center; }
.login .logo { font-size: 3.5rem; }
.login .field { text-align: left; margin-top: 20px; }
