:root{
  --bg:#f4f6f9; --card:#ffffff; --card2:#f1f4f8; --line:#dfe4ec;
  --text:#151a22; --dim:#66707f;
  /* Gold has to work twice: as a button fill (dark ink on top) and as text on
     white. Those need different values or one of them fails contrast. */
  --accent:#d9a52e; --accent-ink:#8a5d00;
  --gold:#8a5d00; --silver:#5f6875;
  --ok:#1a7f47; --err:#b3261e;
  --shadow:0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --tap:48px; --r:14px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
/* The `hidden` attribute is only a default of display:none, so ANY display rule
   beats it. `.row` is display:flex, so a filtered-out row stayed on screen while
   reporting itself hidden — search looked broken while the counter said 2 of 172.
   One global rule, because per-class patches only fix the classes you remember:
   `.sheet[hidden]` and `.toast[hidden]` were two earlier rounds of this. */
[hidden]{display:none !important}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;background:var(--bg);color:var(--text);
  font:16px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
}
a{color:inherit;text-decoration:none}

/* ---- app bar ---- */
.bar{
  position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:10px;
  padding:calc(10px + env(safe-area-inset-top)) 14px 10px;
  background:rgba(255,255,255,.94);backdrop-filter:blur(8px);
  border-bottom:1px solid var(--line);
}
.bar h1{font-size:17px;margin:0;font-weight:650;flex:1;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* ---- account menu ---- */
.acct{position:relative;flex:none}
.acct>summary{list-style:none;cursor:pointer;
  width:var(--tap);height:var(--tap);display:flex;align-items:center;justify-content:center;
  border-radius:50%}
.acct>summary::-webkit-details-marker{display:none}
.acct>summary::marker{content:""}
.acct>summary:focus-visible{outline:2px solid var(--accent-ink);outline-offset:2px}
.acct[open]>summary{background:var(--card2)}
.acct .menu{position:absolute;right:0;top:calc(100% + 8px);z-index:40;
  min-width:230px;background:var(--card);border:1px solid var(--line);
  border-radius:14px;overflow:hidden;
  box-shadow:0 10px 28px rgba(16,24,40,.18)}
.menu-head{display:flex;align-items:center;gap:10px;padding:12px 14px;background:var(--card2)}
.menu-id{display:flex;flex-direction:column;min-width:0}
.menu-id b{font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.menu-id small{font-size:12px;color:var(--dim)}
.menu-item{display:flex;align-items:center;gap:10px;min-height:50px;padding:0 14px;
  border-top:1px solid var(--line);font-size:15px;font-weight:600}
.menu-item:active{background:var(--card2)}
.menu-item.danger{color:var(--err)}
.menu-item .mi{font-size:17px;width:20px;text-align:center;flex:none}
.menu-foot{padding:8px 14px 12px;font-size:12px;color:var(--dim);
  border-top:1px solid var(--line);background:var(--card2)}
.face.sm{width:38px;height:38px;font-size:14px}
.back{font-size:26px;line-height:1;margin-left:-8px;width:var(--tap);min-height:var(--tap);
  display:flex;align-items:center;justify-content:center;flex:none}

/* Single bottom clearance, never stacked with a body padding: the nav is 57px,
   and where a FAB is present it reaches 142px up from the viewport bottom. */
main.wrap{padding:14px 14px calc(78px + env(safe-area-inset-bottom));max-width:820px;margin:0 auto}
body:has(.fab) main.wrap{padding-bottom:calc(152px + env(safe-area-inset-bottom))}

/* Visible only to screen readers — labels for controls whose purpose is otherwise
   carried by a placeholder, which vanishes as soon as you type. */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip:rect(0 0 0 0);white-space:nowrap;border:0}

/* ---- cards ---- */
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--r);
  padding:14px;margin-bottom:12px;box-shadow:var(--shadow)}
.card h2{margin:0 0 10px;font-size:14px;letter-spacing:.04em;
  text-transform:uppercase;color:var(--dim);font-weight:600}
.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.grid.g3{grid-template-columns:repeat(3,minmax(0,1fr))}
@media(max-width:360px){.grid.g3{grid-template-columns:repeat(2,1fr)}}

.stat{background:var(--card2);border-radius:12px;padding:12px;min-width:0}
.stat .k{font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--dim)}
.stat .v{font-size:clamp(13px,4.4vw,20px);font-weight:700;margin-top:4px;
  white-space:nowrap;letter-spacing:-.01em;font-variant-numeric:tabular-nums}
.stat.hero .v{font-size:clamp(15px,5.4vw,26px);color:var(--gold)}
.grid.g3 .stat .v{font-size:clamp(13px,4vw,18px)}

/* ---- lists ---- */
.list{display:flex;flex-direction:column;gap:10px}
.row{display:flex;align-items:center;gap:12px;background:var(--card);
  border:1px solid var(--line);border-radius:var(--r);padding:12px;min-height:var(--tap);
  box-shadow:var(--shadow)}
.row:active{background:var(--card2)}
.card .row{box-shadow:none;background:var(--card2);border-color:transparent}
.card .row:active{background:var(--line)}
.row .main{flex:1;min-width:0}
/* These MUST be block: text-overflow:ellipsis, overflow and margin-top are all
   inert on an inline box, and an inline box also reports a bogus client rect
   that spans its line fragments. */
.row .t{display:block;font-weight:650;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row .s{display:block;font-size:13px;color:var(--dim);margin-top:2px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row .s.multiline{white-space:normal;overflow:visible}
.row .r{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.row .r b{display:block}
.chip{display:inline-block;font-size:11px;padding:2px 8px;border-radius:999px;
  border:1px solid var(--line);color:var(--dim);background:var(--card)}
.chip.gold{color:var(--gold);border-color:#e6d3a3;background:#fdf6e6}
.chip.silver{color:var(--silver)}
.chip.low{color:var(--err);border-color:#f2c2bf;background:#fdeceb}
.dot{width:10px;height:10px;border-radius:50%;flex:none;background:var(--accent)}
.dot.silver{background:#9aa3b2}
.empty{text-align:center;color:var(--dim);padding:32px 12px}

/* ---- forms ---- */
label{display:block;font-size:12px;text-transform:uppercase;letter-spacing:.04em;
  color:var(--dim);margin:0 0 6px}
.field{margin-bottom:14px}
input,select,textarea,button{font:inherit;font-size:16px}
input,select,textarea{
  width:100%;min-height:var(--tap);padding:11px 12px;color:var(--text);
  background:var(--card);border:1px solid var(--line);border-radius:12px;
  appearance:none;outline:none}
input::placeholder,textarea::placeholder{color:#9aa3b2}
/* appearance:none above would blank out a checkbox or radio entirely — opt them
   back in. A radio must also shed the shared border, padding and 48px min-height,
   or what renders is not an oversized dot but a blank 26px rounded box. */
input[type="checkbox"]{appearance:auto;-webkit-appearance:checkbox;
  width:22px;height:22px;min-height:22px;padding:0;box-shadow:none;
  accent-color:var(--accent-ink)}
input[type="radio"]{appearance:auto;-webkit-appearance:radio;
  width:18px;height:18px;min-height:0;padding:0;border:0;box-shadow:none;
  accent-color:var(--accent-ink)}
input[type="checkbox"]:focus,input[type="radio"]:focus{box-shadow:none}
input:focus,select:focus,textarea:focus{
  border-color:var(--accent-ink);box-shadow:0 0 0 3px rgba(217,165,46,.22)}
select{background-image:linear-gradient(45deg,transparent 50%,var(--dim) 50%),
  linear-gradient(135deg,var(--dim) 50%,transparent 50%);
  background-position:calc(100% - 20px) 22px,calc(100% - 14px) 22px;
  background-size:6px 6px;background-repeat:no-repeat;padding-right:38px}
.two{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.hint{font-size:12px;color:var(--dim);margin-top:6px}

.btn{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;
  min-height:var(--tap);padding:12px;border:0;border-radius:12px;font-weight:700;
  background:var(--accent);color:#231800;cursor:pointer;box-shadow:var(--shadow)}
.btn:active{filter:brightness(.94)}
.btn.sec{background:var(--card);color:var(--text);border:1px solid var(--line)}
.btn.danger{background:var(--card);color:var(--err);border:1px solid #f2c2bf}
.btn.sm{width:auto;min-height:44px;padding:10px 14px;font-size:14px}
.btnrow{display:flex;gap:10px;margin-top:6px}

/* ---- flash ---- */
.flash{padding:12px 14px;border-radius:12px;margin-bottom:12px;font-size:14px}
.flash.ok{background:#e8f6ee;color:#12572f;border:1px solid #b3ddc4}
.flash.error{background:#fdeceb;color:#8c1d18;border:1px solid #f2c2bf}

/* ---- bottom nav ---- */
.nav{position:fixed;left:0;right:0;bottom:0;z-index:30;display:flex;
  background:rgba(255,255,255,.97);backdrop-filter:blur(10px);
  border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom);
  box-shadow:0 -1px 3px rgba(16,24,40,.06)}
.nav a{flex:1;min-height:var(--tap);padding:8px 2px 10px;text-align:center;
  font-size:11px;color:var(--dim);display:flex;flex-direction:column;
  align-items:center;justify-content:center;gap:3px}
.nav a .i{font-size:19px;line-height:1}
.nav a.on{color:var(--accent-ink);font-weight:650}
.fab{position:fixed;right:16px;bottom:calc(84px + env(safe-area-inset-bottom));z-index:29;
  width:58px;height:58px;border-radius:50%;background:var(--accent);color:#231800;
  display:flex;align-items:center;justify-content:center;font-size:30px;font-weight:600;
  box-shadow:0 6px 18px rgba(16,24,40,.22)}

/* ---- login ---- */
.login{min-height:100dvh;display:flex;flex-direction:column;align-items:center;
  justify-content:center;padding:24px;gap:18px}
.login .logo{font-size:30px;font-weight:800;letter-spacing:.02em;color:var(--accent-ink)}
.pin{display:flex;gap:10px;justify-content:center;margin:6px 0 2px;
  min-height:14px;align-items:center}
.pin i{width:14px;height:14px;border-radius:50%;background:var(--card);
  border:1px solid var(--line)}
.pin i.f{background:var(--accent-ink);border-color:var(--accent-ink)}
.pad{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;width:min(320px,100%)}
.pad button{min-height:64px;border-radius:16px;background:var(--card);
  border:1px solid var(--line);color:var(--text);font-size:24px;font-weight:600;
  box-shadow:var(--shadow)}
.pad button:active{background:var(--card2)}
.pad button.alt{font-size:16px;color:var(--dim)}

table{width:100%;border-collapse:collapse;font-size:14px}
th,td{text-align:left;padding:8px 6px;border-bottom:1px solid var(--line)}
td a{display:flex;align-items:center;min-height:44px;min-width:44px;margin:-8px 0;
  color:var(--accent-ink);font-weight:650}
th{font-size:11px;text-transform:uppercase;color:var(--dim);font-weight:600}
td.n,th.n{text-align:right;font-variant-numeric:tabular-nums}
.scroll{overflow-x:auto;-webkit-overflow-scrolling:touch}

/* ---- who-are-you picker ---- */
.people{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;width:min(360px,100%)}
@media(max-width:340px){.people{grid-template-columns:repeat(2,1fr)}}
.person{display:flex;flex-direction:column;align-items:center;gap:6px;
  padding:14px 6px;border-radius:16px;background:var(--card);
  border:1px solid var(--line);min-height:var(--tap);box-shadow:var(--shadow)}
.person:active{background:var(--card2)}
.person.solo{flex-direction:row;gap:12px;width:min(320px,100%);padding:12px 14px;
  align-items:center;text-align:left}
.person.solo .pname,.person.solo .prole{text-align:left;max-width:none}
.face{width:52px;height:52px;border-radius:50%;display:flex;align-items:center;
  justify-content:center;font-weight:800;font-size:19px;color:#fff;flex:none}
.pname{font-size:13px;font-weight:650;text-align:center;line-height:1.2;
  max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.prole{font-size:11px;color:var(--dim);text-transform:uppercase;letter-spacing:.04em}
.person.solo .main{flex:1}

/* Staff rows carry a name, a role and two controls. Below ~360px that squeezes
   the name to a stub, so give it a floor and let the controls wrap under it. */
.row.person-row .main{min-width:150px}

/* ---- manage hub: each tool is a destination, not a chip ---- */
.tiles{display:flex;flex-direction:column;gap:12px}
.tile{display:flex;align-items:flex-start;gap:12px;padding:14px;
  background:var(--card);border:1px solid var(--line);border-radius:var(--r);
  box-shadow:var(--shadow);min-height:var(--tap)}
.tile:active{background:var(--card2)}
.tile-ico{width:44px;height:44px;border-radius:12px;flex:none;
  display:flex;align-items:center;justify-content:center;font-size:20px;font-weight:700}
.tile-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}
.tile-t{font-size:17px;font-weight:700;line-height:1.2}
.tile-d{font-size:13px;color:var(--dim);line-height:1.35}
.tile-s{font-size:12px;font-weight:650;color:var(--accent-ink);
  background:var(--card2);border-radius:8px;padding:5px 8px;align-self:flex-start;
  max-width:100%}
.tile-s.warn{color:var(--err);background:#fdeceb}
.tile-go{align-self:center;font-size:24px;color:var(--dim);flex:none;
  width:24px;text-align:center}

/* ---- install prompt (bottom sheet) ---- */
.sheet{position:fixed;inset:0;z-index:60;display:flex;align-items:flex-end;
  background:rgba(16,24,40,.35);backdrop-filter:blur(2px);
  animation:sheetIn .18s ease-out}
.sheet-card{width:100%;background:var(--card);border-radius:18px 18px 0 0;
  padding:18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow:0 -8px 30px rgba(16,24,40,.25);
  display:grid;grid-template-columns:auto 1fr;gap:12px 14px;align-items:start;
  max-width:520px;margin:0 auto}
.sheet-ico{border-radius:12px;grid-row:span 2}
.sheet-body{display:flex;flex-direction:column;gap:4px;min-width:0}
.sheet-body b{font-size:17px}
.sheet-body span{font-size:13px;color:var(--dim);line-height:1.35}
.sheet-acts{grid-column:1 / -1;display:flex;gap:10px;align-items:center}
.sheet-acts .btn{flex:1}
.sheet-acts .btn.sec{flex:0 0 auto}
@keyframes sheetIn{from{opacity:0}to{opacity:1}}

/* ---- new-build toast ---- */
.toast{position:fixed;left:12px;right:12px;z-index:55;
  bottom:calc(78px + env(safe-area-inset-bottom));
  display:flex;align-items:center;gap:12px;
  background:var(--text);color:#fff;border-radius:14px;padding:12px 14px;
  font-size:14px;box-shadow:0 8px 24px rgba(16,24,40,.3);
  max-width:520px;margin:0 auto}
.toast span{flex:1;line-height:1.3}
.toast .btn{width:auto;flex:0 0 auto;min-height:40px;padding:8px 14px}

/* ---- restock alert ----
   A short showcase is the one thing the owner must act on, so it gets the only
   red panel in the app and sits above everything else on the page. */
.alert{background:#fdeceb;border:1px solid #f2c2bf;border-radius:var(--r);
  padding:12px 14px;margin-bottom:12px;color:#8c1d18}
.alert-t{font-size:13px;font-weight:700;letter-spacing:.02em;
  text-transform:uppercase;margin-bottom:6px}
.alert-r{display:block;font-size:14px;line-height:1.4;padding:4px 0;
  border-top:1px solid #f7d6d3}
.alert-r:first-of-type{border-top:0}
.alert .btn.sm{margin-top:10px;background:var(--card);color:#8c1d18;
  border:1px solid #f2c2bf}
.row.short{border-left:3px solid var(--err)}
.row .s.warn-t{color:var(--err);font-weight:650}

/* ---- searchable pickers (transfer screen)
   Over 100 boxes in a <select> is unusable on a phone, and hiding an <option>
   is ignored by Safari on iOS. So these are lists of radio rows: selection is
   native (works with no JS), and search only hides rows. */
.pick{max-height:246px;overflow-y:auto;-webkit-overflow-scrolling:touch;
  border:1px solid var(--line);border-radius:12px;padding:6px;background:var(--card2)}
.pick .pick-row{background:var(--card);box-shadow:none;border:1px solid transparent;
  margin-bottom:6px;cursor:pointer}
.pick .pick-row:last-child{margin-bottom:0}
.pick .pick-row:has(.pick-r:checked){border-color:var(--accent);background:#fdf6e6}
/* Sizing and appearance live on input[type=radio] above; the row is the tap
   target, so the dot only has to hold its column. */
.pick-r{flex:0 0 auto;margin:0}

/* ---- metal toggle
   Gold and silver are separate books, so the browse lists show one at a time.
   Two tabs rather than a dropdown: the current metal is readable without
   opening anything, and switching is one tap instead of three. */
.seg{display:flex;gap:8px}
.seg-b{flex:1;min-height:var(--tap);display:flex;align-items:center;justify-content:center;
  border:1px solid var(--line);border-radius:12px;background:var(--card2);
  font-size:15px;font-weight:650;color:var(--dim)}
.seg-b.on{background:#fdf6e6;border-color:#e6d3a3;color:var(--accent-ink)}
.seg-b:active{background:var(--line)}

/* ---- purity picker (price calculator)
   Four choices in a 2x2 grid: at 320px four side by side leave no room for the
   labels. The radio itself is hidden — the whole pill is the control, and the
   selected state is carried by colour plus aria-checked on the input. */
.pill{display:flex;flex-direction:column;justify-content:center;gap:2px;
  min-height:var(--tap);padding:10px 12px;border:1px solid var(--line);
  border-radius:12px;background:var(--card2);cursor:pointer}
.pill.on{background:#fdf6e6;border-color:#e6d3a3}
.pill input{position:absolute;opacity:0;width:0;height:0;pointer-events:none}
.pill-t{font-size:15px;font-weight:700}
.pill.on .pill-t{color:var(--accent-ink)}
.pill-s{font-size:12px;color:var(--dim)}
