/* Label Circle -- app.css
   Mobile first. Everything is sized for a thumb: 44px minimum touch targets,
   bottom tab bar, no hover-only affordances. */

:root {
  --ivory: #f3ece1;
  --ivory-2: #faf6f0;
  --ink: #241f1c;
  --ink-soft: #6b615b;
  --ink-faint: #a49a93;
  --gold: #c0a063;
  --gold-soft: #e4d6b8;
  --line: rgba(36, 31, 28, 0.14);
  --white: #fff;
  --ok: #2f7d50;
  --warn: #9a6a12;
  --danger: #a8352b;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(36, 31, 28, 0.08);
  --tabh: 62px;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom, 0px)); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--ink); }

.tracked {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .68rem;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ---------- app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-top, 0px));
  background: rgba(243, 236, 225, .96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar .mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  border: 1px solid var(--ink); border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 15px; font-weight: 600; letter-spacing: -.02em;
}
.appbar .mark i { font-style: normal; color: var(--gold); }
.appbar .title { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.appbar .who { margin-left: auto; font-size: .72rem; color: var(--ink-soft); text-align: right; }

/* ---------- layout ---------- */
main { padding: 14px; max-width: 760px; margin: 0 auto; }
.view[hidden] { display: none !important; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--ink-soft); }
.tiny { font-size: .76rem; }
.center { text-align: center; }

.card {
  background: var(--ivory-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; background: transparent; }
.hair { height: 1px; background: var(--line); margin: 6px 0; border: 0; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 10px; }
label.field > span {
  display: block; margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .12em;
  font-size: .66rem; font-weight: 600; color: var(--ink-soft);
}
input, select, textarea, button { font-family: inherit; font-size: 16px; }
input[type=text], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 11px 12px;
  background: var(--white);
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink);
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-soft); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ---------- buttons ---------- */
button {
  min-height: 44px; padding: 11px 16px;
  border: 1px solid var(--ink); border-radius: 10px;
  background: var(--ink); color: var(--ivory);
  font-weight: 600; letter-spacing: .02em; cursor: pointer;
}
button.ghost { background: transparent; color: var(--ink); }
button.gold { background: var(--gold); border-color: var(--gold); color: #24201c; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.small { min-height: 36px; padding: 7px 11px; font-size: .82rem; }
button.link { border: 0; background: none; color: var(--ink-soft); text-decoration: underline; padding: 6px; min-height: 36px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.wide { width: 100%; }

/* Destructive actions sit in their own box so a thumb reaching for Sell now
   does not land on Delete. */
.danger-zone { margin-top: 14px; border-color: rgba(168, 53, 43, .3); }
.danger-zone .tracked { color: var(--danger); }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-soft); background: var(--white);
}
.chip.on { background: var(--ink); color: var(--ivory); border-color: var(--ink); }
.badge { font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; letter-spacing: .08em; text-transform: uppercase; }
.badge.ok { background: rgba(47,125,80,.13); color: var(--ok); }
.badge.warn { background: rgba(154,106,18,.14); color: var(--warn); }
.badge.out { background: rgba(168,53,43,.12); color: var(--danger); }

/* ---------- tabs ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { white-space: nowrap; cursor: pointer; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabh) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(243,236,225,.97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
nav.tabs.tabs5 { grid-template-columns: repeat(5, 1fr); }
nav.tabs.tabs6 { grid-template-columns: repeat(6, 1fr); }
nav.tabs.tabs6 button { font-size: .58rem; letter-spacing: .06em; }
nav.tabs.tabs6 button .ic { font-size: 1.05rem; }
nav.tabs button {
  border: 0; background: none; color: var(--ink-soft);
  min-height: 0; border-radius: 0;
  display: grid; place-items: center; gap: 2px;
  font-size: .64rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 600;
}
nav.tabs button .ic { font-size: 1.15rem; line-height: 1; }
nav.tabs button[aria-current=true] { color: var(--ink); }
nav.tabs button .dot {
  position: absolute; transform: translate(18px, -12px);
  background: var(--danger); color: #fff; border-radius: 99px;
  font-size: .6rem; padding: 1px 5px; letter-spacing: 0;
}

/* ---------- wizard ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 12px; }
.steps div { flex: 1; height: 3px; background: var(--line); border-radius: 2px; }
.steps div.on { background: var(--gold); }
.steplabel { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }

.drop {
  border: 1.5px dashed rgba(36,31,28,.3); border-radius: var(--radius);
  padding: 22px 14px; text-align: center; color: var(--ink-soft);
  background: rgba(255,255,255,.5);
}
.drop strong { color: var(--ink); display: block; font-size: .95rem; }

/* ---------- crop ---------- */
.cropwrap { position: relative; touch-action: none; user-select: none; background: #2a2622; border-radius: var(--radius); overflow: hidden; }
.cropwrap img { display: block; width: 100%; height: auto; pointer-events: none; }
.cropbox { position: absolute; border: 2px solid var(--gold); box-shadow: 0 0 0 9999px rgba(20,18,16,.55); cursor: move; }
.cropbox .h { position: absolute; width: 26px; height: 26px; background: var(--gold); border-radius: 50%; }
.cropbox .h.tl { left: -13px; top: -13px; cursor: nwse-resize; }
.cropbox .h.tr { right: -13px; top: -13px; cursor: nesw-resize; }
.cropbox .h.bl { left: -13px; bottom: -13px; cursor: nesw-resize; }
.cropbox .h.br { right: -13px; bottom: -13px; cursor: nwse-resize; }

/* ---------- alert ---------- */
.alert {
  border: 1px solid rgba(154, 106, 18, .45);
  background: rgba(154, 106, 18, .10);
  color: #6b4a08;
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: .8rem;
  line-height: 1.5;
}
.alert strong { display: block; margin-bottom: 2px; color: #5a3e06; }
.alert[hidden] { display: none; }

/* ---------- candidates ---------- */
.cands { display: grid; gap: 10px; }
.cand {
  display: grid; grid-template-columns: 76px 1fr; gap: 11px;
  border: 1px solid var(--line); border-radius: 12px; padding: 9px;
  background: var(--white); text-align: left; cursor: pointer;
  min-height: 0; color: var(--ink); font-weight: 400; align-items: center;
}
.cand.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.cand img { width: 76px; height: 76px; object-fit: contain; background: #fff; border-radius: 8px; }
.cand .t { font-size: .84rem; line-height: 1.35; max-height: 3.6em; overflow: hidden; }
.cand .s { font-size: .7rem; color: var(--ink-soft); margin-top: 3px; }
.cand .p { font-weight: 700; font-size: .9rem; }

/* ---------- slots ---------- */
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.slot {
  position: relative; aspect-ratio: 1; border-radius: 12px;
  border: 1.5px dashed rgba(36,31,28,.28); background: rgba(255,255,255,.6);
  display: grid; place-items: center; overflow: hidden; cursor: pointer;
  padding: 0; min-height: 0; color: var(--ink-soft); font-weight: 600;
}
.slot canvas, .slot img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.slot .cap {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(36,31,28,.72); color: #fff;
  font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; padding: 3px;
}
.slot.filled { border-style: solid; border-color: var(--line); }
.slot .warnflag { position: absolute; top: 5px; right: 5px; background: var(--warn); color: #fff; border-radius: 99px; width: 20px; height: 20px; display: grid; place-items: center; font-size: .7rem; }
.slot .x { position: absolute; top: 4px; left: 4px; background: rgba(36,31,28,.8); color: #fff; border: 0; border-radius: 99px; width: 22px; height: 22px; min-height: 0; padding: 0; font-size: .8rem; line-height: 1; }

/* ---------- reference images from the listing page ---------- */
.refstrip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.refstrip::-webkit-scrollbar { display: none; }
.refstrip .r {
  position: relative; flex: 0 0 96px; width: 96px; height: 96px;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #fff; padding: 0; min-height: 0; cursor: pointer;
}
.refstrip .r img { width: 100%; height: 100%; object-fit: contain; }
.refstrip .r .use {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(36,31,28,.78); color: #fff;
  font-size: .55rem; letter-spacing: .08em; text-transform: uppercase; padding: 3px;
}
.refstrip .r.borrowed { border-color: var(--warn); box-shadow: 0 0 0 2px rgba(154,106,18,.22); }
.slot .borrowflag {
  position: absolute; top: 5px; right: 5px; background: var(--warn); color: #fff;
  border-radius: 4px; font-size: .5rem; letter-spacing: .06em; padding: 2px 4px;
}

/* ---------- preview ---------- */
.preview { background: var(--white); border-radius: var(--radius); padding: 10px; border: 1px solid var(--line); }
.preview canvas { width: 100%; height: auto; display: block; border-radius: 8px; }
pre.caption {
  white-space: pre-wrap; word-break: break-word;
  background: var(--white); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px; font-family: var(--sans); font-size: .82rem; margin: 0; line-height: 1.5;
}

/* ---------- stock list ---------- */
.item {
  display: grid; grid-template-columns: 66px 1fr auto; gap: 11px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 9px;
  background: var(--ivory-2);
}
.item > img, .item > .ph {
  width: 66px; height: 66px; border-radius: 8px; object-fit: contain;
  background: #fff; border: 1px solid var(--line);
}
.item .ph { display: grid; place-items: center; color: var(--ink-faint); font-size: 1.2rem; }
.item .n { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.item .m { font-size: .72rem; color: var(--ink-soft); margin-top: 2px; }
.item .pr { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; text-align: right; white-space: nowrap; }

/* ---------- sold ---------- */
.soldtot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.soldtot div {
  background: var(--ivory-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 8px; text-align: center;
}
.soldtot .v { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; white-space: nowrap; }
.soldtot .l { font-size: .55rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.soldtot .out .v { color: var(--danger); }

.sale {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 9px;
  background: var(--ivory-2); width: 100%; text-align: left;
  min-height: 0; color: var(--ink); font-weight: 400; cursor: pointer;
}
.sale > img, .sale > .ph {
  width: 62px; height: 62px; border-radius: 8px; object-fit: contain;
  background: #fff; border: 1px solid var(--line); display: grid; place-items: center;
  color: var(--ink-faint); font-size: 1.1rem;
}
.sale .n { font-weight: 600; font-size: .86rem; line-height: 1.25; }
.sale .m { font-size: .68rem; color: var(--ink-soft); margin-top: 2px; line-height: 1.45; }
.sale .r { text-align: right; white-space: nowrap; }
.sale .r .tot { font-family: var(--serif); font-size: 1.02rem; font-weight: 600; }
.sale .r .badge { margin-top: 3px; display: inline-block; }
.sale.unpaid { border-left: 3px solid var(--danger); }
.sale.part { border-left: 3px solid var(--warn); }
.sale.paid { border-left: 3px solid var(--ok); }

/* ---------- money ---------- */
.balances { display: grid; gap: 9px; margin-bottom: 12px; }
.bal {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
  background: var(--ivory-2);
}
.bal .who { font-weight: 600; font-size: .92rem; }
.bal .brk { font-size: .68rem; color: var(--ink-soft); margin-top: 3px; line-height: 1.5; }
.bal .amt { font-family: var(--serif); font-size: 1.18rem; font-weight: 600; text-align: right; white-space: nowrap; }
.bal .amt small { display: block; font-family: var(--sans); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; margin-top: 2px; }
.bal.owed { border-left: 3px solid var(--ok); }
.bal.owes { border-left: 3px solid var(--danger); }
.bal.owed .amt { color: var(--ok); }
.bal.owes .amt { color: var(--danger); }
.bal.flagged { box-shadow: 0 0 0 2px rgba(154,106,18,.25); }

.move {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .84rem;
}
.move:last-child { border-bottom: 0; }
.move .amt { font-weight: 700; white-space: nowrap; }
.move.draw { color: var(--ink-soft); }

.led { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line); width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left;
  min-height: 0; color: var(--ink); font-weight: 400; border-radius: 0; }
.led:last-child { border-bottom: 0; }
.led .tag { font-size: .55rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  padding: 3px 6px; border-radius: 4px; white-space: nowrap; }
.led .tag.in  { background: rgba(47,125,80,.14); color: var(--ok); }
.led .tag.out { background: rgba(168,53,43,.12); color: var(--danger); }
.led .tag.exp { background: rgba(154,106,18,.14); color: var(--warn); }
.led .d { font-size: .8rem; line-height: 1.3; min-width: 0; }
.led .d span { display: block; font-size: .66rem; color: var(--ink-soft); }
.led .v { font-weight: 600; white-space: nowrap; font-size: .86rem; }
.led.void { opacity: .45; }
.led.void .v { text-decoration: line-through; }

.pick { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; margin: 8px 0; }
.pickrow {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff;
  text-align: left; min-height: 0; color: var(--ink); font-weight: 400; cursor: pointer;
}
.pickrow.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.pickrow img, .pickrow .ph { width: 56px; height: 56px; border-radius: 8px; object-fit: contain;
  background: #fff; border: 1px solid var(--line); display: grid; place-items: center;
  color: var(--ink-faint); }
.pickrow .n { font-size: .8rem; font-weight: 600; line-height: 1.25; }
.pickrow .m { font-size: .66rem; color: var(--ink-soft); margin-top: 2px; }
.pickrow .o { font-weight: 700; font-size: .82rem; white-space: nowrap; }
.pickrow .o small { display: block; font-weight: 400; font-size: .58rem; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .08em; }

.revlist { font-size: .74rem; }
.revlist .r { padding: 7px 0; border-bottom: 1px solid var(--line); }
.revlist .r:last-child { border-bottom: 0; }
.revlist .r b { text-transform: uppercase; letter-spacing: .08em; font-size: .62rem; }
.revlist .r code { font-size: .68rem; color: var(--ink-soft); word-break: break-word; }

/* ---------- sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20,18,16,.5);
  display: grid; align-items: end;
}
.sheet[hidden] { display: none; }
.sheet > .panel {
  background: var(--ivory); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 90vh; overflow: auto;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 3px; background: var(--ink-faint); margin: 0 auto 12px; }

/* ---------- toast ---------- */
#toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabh) + 14px); z-index: 70; display: grid; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--ivory);
  padding: 11px 13px; border-radius: 10px; font-size: .84rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); line-height: 1.4;
}
.toast.bad { background: var(--danger); }
.toast.good { background: var(--ok); }

.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -2px; }
button.ghost .spin { border-color: rgba(36,31,28,.25); border-top-color: var(--ink); }
@keyframes sp { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 34px 16px; color: var(--ink-soft); }
.empty .big { font-size: 2rem; opacity: .35; }

@media (min-width: 620px) {
  .slots { grid-template-columns: repeat(6, 1fr); }
}
