/* =========================================================================
   B25 Fashion: design tokens
   ========================================================================= */
:root {
  --brand: #0f2747;
  --brand-2: #1d4ed8;
  --brand-soft: #e8efff;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --line-2: #d0d5dd;
  --ok: #067647;   --ok-bg: #e7f6ee;
  --warn: #b54708; --warn-bg: #fef3e2;
  --bad: #b42318;  --bad-bg: #fdecea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .16);
  --tabbar-h: 62px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.authed { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; line-height: 1.25; margin: 4px 0 10px; letter-spacing: -.2px; }
h2 { font-size: 15px; margin: 18px 0 8px; letter-spacing: -.1px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn-t { color: var(--warn); font-weight: 600; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 10px 12px 28px; }
.wrap > * { min-width: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.num, .tot, .money b, .pcost { font-variant-numeric: tabular-nums; }

/* =========================================================================
   App bar + navigation
   ========================================================================= */
.appbar { background: var(--brand); color: #fff; padding-top: env(safe-area-inset-top); }
.appbar-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 8px 12px; min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: #fff; }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #fff; color: var(--brand); font-weight: 900; font-size: 12px; letter-spacing: .3px; }
.logo.big { width: 52px; height: 52px; border-radius: 14px; font-size: 18px; background: var(--brand); color: #fff; }
.bname { font-weight: 700; font-size: 16px; letter-spacing: .1px; }
.topnav { display: none; }
.logout { margin: 0 0 0 auto; }
.iconbtn { display: inline-flex; align-items: center; gap: 6px; background: transparent; color: #cdd6e6; border: 1px solid rgba(255,255,255,.18); border-radius: 9px; padding: 6px 10px; min-height: 36px; font: inherit; font-size: 13px; cursor: pointer; }
.iconbtn:hover { color: #fff; border-color: rgba(255,255,255,.4); }
.iconbtn svg { width: 18px; height: 18px; }

/* bottom tab bar (phones / tablets) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(16,24,40,.06);
}
.tabbar > a, .tabmore > summary {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h); color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; list-style: none;
}
.tabbar > a:hover { text-decoration: none; }
.tabmore > summary::-webkit-details-marker { display: none; }
.tabbar > a.on, .tabmore.on > summary, .tabmore[open] > summary { color: var(--brand-2); }
.tabbar > a.on svg { stroke-width: 2.2; }
.tabmore { position: relative; }
.tabmore .sheet {
  position: absolute; right: 8px; bottom: calc(var(--tabbar-h) + 8px); min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
}
.tabmore .sheet a { display: block; padding: 12px 14px; border-radius: 9px; color: var(--ink); font-weight: 600; }
.tabmore .sheet a:hover, .tabmore .sheet a.on { background: var(--brand-soft); text-decoration: none; color: var(--brand-2); }

/* =========================================================================
   Controls
   ========================================================================= */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=date], input[type=password], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 16px; transition: border-color .12s, box-shadow .12s;
}
select { padding-right: 30px; }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(29,78,216,.16); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
::placeholder { color: #98a2b3; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: 0 1px 2px rgba(16,24,40,.05);
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--bad); border-color: #f4c7c3; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; color: var(--brand-2); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
button.link { background: none; border: 0; padding: 6px 4px; color: var(--brand-2); font-weight: 600; cursor: pointer; min-height: 34px; }
button.link.danger { color: var(--bad); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; box-shadow: var(--shadow); }
.form label { display: block; margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form label > input, .form label > select, .form label > textarea { margin-top: 5px; font-weight: 400; }
.form label .muted { font-weight: 400; }
.form label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.form label.check input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--brand-2); }
.form h2 { margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.head h1 { margin: 4px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; align-items: flex-end; }
.filters > input, .filters > select { flex: 1 1 150px; width: auto; }
.filters label { font-size: 12px; font-weight: 600; color: var(--muted); flex: 1 1 130px; }
.filters label input { margin-top: 3px; }
.flash { padding: 10px 12px; border-radius: var(--radius-sm); margin: 8px 0; background: var(--brand-soft); color: var(--brand); border: 1px solid #cfdcfb; font-weight: 500; }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: #f4c7c3; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: #b7e4cb; }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: #f8d9a8; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 460px); background: #101828; color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 60;
  box-shadow: var(--shadow-lg); font-weight: 500;
}
.toast.error { background: var(--bad); }
.toast[hidden] { display: none; }

/* badges */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: #eef0f3; color: var(--ink-2); white-space: nowrap; line-height: 1.6; }
.badge.s-open { background: var(--brand-soft); color: var(--brand-2); }
.badge.s-completed, .badge.st-bought { background: var(--ok-bg); color: var(--ok); }
.badge.s-cancelled { background: #eef0f3; color: var(--muted); }
.badge.s-warn, .badge.st-partial { background: var(--warn-bg); color: var(--warn); }
.badge.st-incomplete { background: var(--bad-bg); color: var(--bad); }
.badge.st-pending { background: #eef0f3; color: var(--muted); }

/* =========================================================================
   Generic lists (history, products, suppliers, expenses, export)
   ========================================================================= */
.list { display: flex; flex-direction: column; gap: 8px; }
h2.cat, .cat { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 16px 2px 2px; font-weight: 700; }
.prow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; color: inherit; box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s;
}
a.prow:hover { text-decoration: none; border-color: #b9c6e4; box-shadow: 0 2px 8px rgba(16,24,40,.08); }
.prow .ref { font-weight: 800; color: var(--brand); font-size: 13px; letter-spacing: .2px; }
.prow .pdate { color: var(--muted); font-size: 13px; }
.prow .psup { flex: 1 1 150px; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.prow .pmeta { color: var(--muted); font-size: 12.5px; flex: 1 1 100%; overflow-wrap: anywhere; order: 10; }
.prow .pcost { font-weight: 800; margin-left: auto; font-size: 15px; }
.arow {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 14px; overflow-wrap: anywhere; box-shadow: var(--shadow);
}
.arow form { margin: 0; display: inline; }
.rowact { display: inline-flex; gap: 6px; align-items: center; }
details.stk { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
details.stk summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 12px 14px; list-style: none; }
details.stk summary::-webkit-details-marker { display: none; }
details.stk .psup { flex: 1 1 160px; }
details.stk .pmeta { color: var(--muted); font-size: 12.5px; flex: 1 1 100%; order: 10; }
details.stk .pcost { margin-left: auto; font-weight: 800; }
.stkd { padding: 0 14px 12px; border-top: 1px solid var(--line); padding-top: 10px; }
table.mini { border-collapse: collapse; width: 100%; max-width: 460px; margin: 8px 0; }
table.mini th, table.mini td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
table.mini th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
.tiles.small { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.tiles.small .tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); min-width: 0; }
.tiles.small .tile span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.tiles.small .tile b { display: block; font-size: 17px; margin-top: 2px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* login */
.loginpage .wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.loginbox { width: 100%; max-width: 380px; }
.loginbrand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.loginbrand h1 { margin: 0; font-size: 22px; }
.loginbrand p { margin: 0; }
.loginbox .card { padding: 20px; }

/* =========================================================================
   Buy list: purchase header
   ========================================================================= */
.phead { margin: 2px 0 10px; }
.ptop { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ptitle { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.ptitle h1 { margin: 2px 0; font-size: 22px; }
.pdate { color: var(--muted); font-weight: 500; }
.savestate { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.savestate:empty { display: none; }
.savestate.saving { color: var(--warn); background: var(--warn-bg); }
.savestate.ok { color: var(--ok); background: var(--ok-bg); }
.savestate.error { color: #fff; background: var(--bad); }
.pctl { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 8px; margin: 8px 0; }
.selwrap { display: block; min-width: 0; }
.selwrap span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 3px; }
.selwrap select { min-height: 40px; font-size: 15px; }
.plinks { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 1px 12px; }
.plinks::-webkit-scrollbar { display: none; }
.plinks a { flex: 0 0 auto; white-space: nowrap; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.plinks a:hover { text-decoration: none; border-color: #b9c6e4; color: var(--brand-2); }
.plinks a.plnew { color: var(--brand-2); border-color: #cfdcfb; background: var(--brand-soft); }

/* money summary: sticks to the top while scrolling */
.money { position: sticky; top: 0; z-index: 30; margin: 0 -12px; padding: 6px 12px 8px; background: linear-gradient(var(--bg) 85%, rgba(243,244,247,0)); }
.mcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px 10px; }
.mtop { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.mstat { min-width: 0; }
.mstat.right { text-align: right; }
.mlab { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.mstat b { display: block; font-size: 24px; line-height: 1.15; font-weight: 800; letter-spacing: -.4px; overflow-wrap: anywhere; }
.mstat.spent b { color: var(--ink); }
.mstat.left b { color: var(--ok); }
.mstat.left.danger b { color: var(--bad); }
.bar { height: 8px; background: #e9edf3; border-radius: 999px; margin: 8px 0 7px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #2563eb, #1d4ed8); transition: width .3s; }
.bar.warn i { background: linear-gradient(90deg, #f59e0b, #d97706); }
.bar.over i { background: var(--bad); }
.mbot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.mbot b { color: var(--ink); font-weight: 700; }
.budget { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.budget input { width: 100px; min-height: 30px; padding: 2px 8px; font-size: 14px; font-weight: 700; border-radius: 7px; background: var(--surface-2); border-color: transparent; }
.budget input:hover { border-color: var(--line-2); }
.facts { display: inline-flex; flex-wrap: wrap; gap: 0 10px; }
.sumnote { margin-top: 7px; display: flex; flex-direction: column; gap: 4px; }
.sumnote:empty { display: none; }
.sumnote div { font-size: 12.5px; font-weight: 600; padding: 5px 9px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }
.sumnote div.bad { background: var(--bad-bg); color: var(--bad); }
.sumnote div.info { background: var(--surface-2); color: var(--ink-2); font-weight: 500; }

/* search + filter chips */
.tools { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 10px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 1px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 6px 13px; min-height: 36px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chip b { font-weight: 700; color: var(--muted); margin-left: 3px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.on b { color: #c7d2fe; }

/* =========================================================================
   Shopping list: mode switch, offline banner
   ========================================================================= */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #e6e9ef; border-radius: 12px; margin: 4px 0 6px; }
.modes button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; border: 0; border-radius: 9px;
  background: transparent; color: var(--ink-2); font-weight: 700; font-size: 14px; cursor: pointer;
}
.modes button svg { width: 18px; height: 18px; }
.modes button[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.offline { margin: 6px 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn); border: 1px solid #f8d9a8; font-weight: 600; font-size: 13px; }
.sumnote div.good { background: var(--ok-bg); color: var(--ok); }
.toolrow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.toolrow .chips { flex: 1 1 auto; min-width: 0; }
.toolrow .btn svg { width: 16px; height: 16px; }
.over { color: var(--bad); font-weight: 600; }
.under { color: var(--ok); font-weight: 600; }
.left { color: var(--warn); font-weight: 700; }

/* =========================================================================
   Market mode: checklist rows
   ========================================================================= */
.plist { display: flex; flex-direction: column; gap: 8px; }
.plist .cathead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 10px 2px 0; }
.plist .cathead h2 { margin: 0; font-size: 12.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--ink-2); }
.plist .cathead span { font-size: 12.5px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.plist > .empty { padding: 24px 14px; margin: 0; text-align: center; background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--line-2); }

.ck { min-width: 0;
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 10px 12px 12px; min-height: 64px; transition: border-color .12s, background .12s;
}
.ck:hover { border-color: #b9c6e4; }
.ck:active { background: var(--surface-2); }
.tick {
  flex: 0 0 auto; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--line-2); background: var(--surface); color: #fff;
}
.tick svg { width: 20px; height: 20px; stroke-width: 2.6; }
.ck.st-done .tick { background: #12b76a; border-color: #12b76a; }
.ck.st-partial .tick { background: #f79009; border-color: #f79009; }
.ck.st-skipped .tick { background: #98a2b3; border-color: #98a2b3; }
.ck.st-done { background: #f7fcf9; }
.ck.st-done .ckname > span:first-child, .ck.st-skipped .ckname > span:first-child { color: var(--muted); }
.ck.st-skipped { background: var(--surface-2); }
.ck.opt:not(.st-done) .tick { border-style: dashed; }
.ckbody { flex: 1 1 auto; min-width: 0; }
.ckname { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-weight: 700; font-size: 15px; line-height: 1.3; }
.ckname > span:first-child { overflow-wrap: anywhere; }
.ckline { font-size: 13px; color: var(--ink-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ckline b { font-weight: 700; }
.cknote { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ckwarn { display: inline-block; font-size: 12px; font-weight: 700; color: var(--bad); background: var(--bad-bg); border-radius: 6px; padding: 1px 7px; margin-top: 4px; }
.chev { flex: 0 0 auto; color: #98a2b3; display: flex; }
.chev svg { width: 18px; height: 18px; }

.fab {
  position: fixed; right: 14px; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); z-index: 35;
  display: inline-flex; align-items: center; gap: 6px; min-height: 50px; padding: 0 18px 0 14px; border: 0; border-radius: 999px;
  background: var(--brand-2); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: 0 8px 22px rgba(29,78,216,.35);
}
.fab svg { width: 20px; height: 20px; stroke-width: 2.4; }
.mode-plan .fab { display: none; }
.mode-market .plist { padding-bottom: 64px; }

/* =========================================================================
   Plan mode rows
   ========================================================================= */
.pl { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 12px 12px 14px; display: grid; gap: 10px; }
.pl.opt { background: #fcfcfd; }
.plhead { display: flex; align-items: center; gap: 8px; }
.plname { flex: 1 1 auto; min-width: 0; }
.plname b { display: block; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.plname span { display: block; font-size: 12px; overflow-wrap: anywhere; }
.seg { flex: 0 0 auto; display: inline-flex; background: #eceff3; border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 7px; padding: 5px 9px; min-height: 32px; font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.pl.opt .seg button[aria-pressed="true"] { color: var(--warn); }
.iconbtn2 { flex: 0 0 auto; display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.iconbtn2:hover { background: var(--surface-2); color: var(--bad); }
.iconbtn2 svg { width: 20px; height: 20px; }
.plgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.plgrid .num { text-align: right; font-size: 17px; font-weight: 700; }
.plest { text-align: right; padding-bottom: 9px; }
.plest span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.plest b { font-size: 16px; font-variant-numeric: tabular-nums; }
input.plnote { min-height: 38px; font-size: 14px; background: var(--surface-2); border-color: transparent; }
input.plnote:hover { border-color: var(--line-2); }

/* =========================================================================
   Bottom sheet (record a purchase / extra item)
   ========================================================================= */
dialog.sheet {
  margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; border: 0; box-shadow: var(--shadow-lg);
}
dialog.sheet::backdrop { background: rgba(16,24,40,.5); }
.shead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.shead h2 { margin: 2px 0 2px; font-size: 18px; }
.shead p { margin: 0; font-size: 13px; }
.snote { margin: 10px 0 0; padding: 8px 10px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 500; }
.stabs { display: flex; gap: 6px; overflow-x: auto; margin: 12px 0 0; scrollbar-width: none; }
.stabs::-webkit-scrollbar { display: none; }
.stabs button { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 6px 12px; font-weight: 700; font-size: 13px; cursor: pointer; }
.stabs button small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.stabs button[aria-pressed="true"] { border-color: var(--brand-2); background: var(--brand-soft); color: var(--brand); }
.sform { display: grid; gap: 12px; margin-top: 12px; }
.sform > p { margin: 0; }
.sgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fld { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); min-width: 0; }
.fld > input, .fld > select, .fld > textarea { margin-top: 4px; font-weight: 400; }
.num.big { min-height: 52px; font-size: 22px; font-weight: 800; text-align: right; }
.num.auto { background: var(--brand-soft); color: var(--brand); }
.chip.usetarget { justify-self: start; background: var(--ok-bg); border-color: #b7e4cb; color: var(--ok); }
.slive { min-height: 22px; font-size: 15px; font-variant-numeric: tabular-nums; }
.btn.big { min-height: 52px; font-size: 16px; }
.btn.big svg { width: 20px; height: 20px; stroke-width: 2.4; }
.sactions { display: flex; flex-wrap: wrap; gap: 8px; }
.sactions:empty { display: none; }
.sactions .btn { flex: 1 1 auto; }
.recv { display: flex; align-items: flex-end; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--line); }
.recv .fld { flex: 1 1 auto; }
.recv .num { text-align: right; }

/* size / colour boxes inside the sheet */
.bdrow { min-width: 0; }
.bdhead { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; min-height: 28px; }
.bdhead .bdtot { margin-left: auto; }
.bdlab { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.bdtot { font-size: 12px; font-weight: 700; color: var(--ok); font-variant-numeric: tabular-nums; }
.bdtot.bad { color: var(--bad); }
.bdgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.bdcell { display: flex; flex-direction: column; min-width: 0; }
.bdcell span { font-size: 11.5px; font-weight: 700; color: var(--ink-2); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }
.bdcell input.num { min-height: 44px; padding: 4px 2px; text-align: center; font-size: 18px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.bdcell input.num.filled { background: var(--brand-soft); border-color: #a9c0f5; color: var(--brand); }
input.bdmore { width: 76px; min-height: 28px; padding: 2px 6px; font-size: 12px; text-align: center; border-radius: 7px; border: 1px dashed var(--line-2); background: transparent; color: var(--muted); }

/* add product */
.addbar { margin-top: 14px; }
.addbar h2 { margin: 0 0 8px; }
.addrow { display: flex; gap: 8px; margin-bottom: 4px; }
.addrow select { flex: 1 1 auto; min-width: 0; }
.addbar .btn.ghost { padding-left: 4px; }

dialog { border: 0; border-radius: 16px; padding: 18px; width: min(92vw, 440px); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(16,24,40,.5); }

/* =========================================================================
   Larger screens
   ========================================================================= */
@media (min-width: 480px) {
  .mstat b { font-size: 28px; }
  .tools { flex-direction: row; align-items: center; }
  .search { flex: 1 1 260px; }
  .chips { flex: 0 1 auto; }
}
@media (min-width: 760px) {
  .wrap { padding: 16px 20px 32px; }
  h1 { font-size: 24px; }
  .money { margin: 0 -20px; padding-left: 20px; padding-right: 20px; }
  .phead { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 6px 20px; }
  .ptop { grid-column: 1 / -1; }
  .pctl { margin: 0; grid-template-columns: 260px 160px; }
  .plinks { justify-content: flex-end; align-self: end; margin: 0; padding: 1px; }
  .tiles.small .tile b { font-size: 20px; }
  .card.form { padding: 18px 20px; }
}
@media (min-width: 1000px) {
  body.authed { padding-bottom: 0; }
  .tabbar { display: none; }
  .toast { bottom: 20px; }
  .topnav { display: flex; gap: 2px; margin-left: 18px; }
  .topnav a { color: #c3cde0; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; }
  .topnav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
  .topnav a.on { color: #fff; background: rgba(255,255,255,.14); }
  .fab { bottom: 24px; right: 24px; }
  dialog.sheet { margin: auto; border-radius: 20px; }
  .plist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .plist .cathead, .plist > .empty { grid-column: 1 / -1; }
  .form.card { max-width: 720px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .appbar, .tabbar, .tools, .addbar, .toast, .fab, .modes, .plinks { display: none !important; } .money { position: static; } }
