:root {
  --bg: #f4f1ea; --card: #fffdf8; --ink: #1c1b18; --muted: #6d6a62; --line: #e4ded1;
  --green: #1f5f3f; --green-soft: #e3efe6; --red: #b3261e; --red-soft: #fbe9e6;
  --blue: #1d5a8f; --blue-soft: #e4eef8; --amber: #9a6100; --amber-soft: #fcf0d9;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151512; --card: #1e1d19; --ink: #efece4; --muted: #a29e93; --line: #34322b;
    --green: #5fbf8a; --green-soft: #1d3326; --red: #f08a7f; --red-soft: #3a1f1c;
    --blue: #86b8e6; --blue-soft: #1b2a38; --amber: #e4b25a; --amber-soft: #36291a; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0); }
button { font: inherit; cursor: pointer; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1120px; margin: 0 auto; padding: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 17px; }
.shop { display: block; font-size: 13px; color: var(--muted); }
.mark { width: 36px; height: 36px; border-radius: 10px; background: var(--green); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; }

/* ---------- tabs ---------- */

.tabs-nav { display: flex; gap: 4px; }
.tab-btn { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent;
  border-radius: 10px; padding: 8px 12px; color: var(--muted); font-weight: 600; font-size: 13px; }
.tab-btn svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.tab-btn.on { color: var(--green); background: var(--green-soft); }
.top-tabs { flex: none; }
.bottom-tabs { display: none; }

@media (max-width: 819px) {
  .top-tabs { display: none; }
  .bottom-tabs {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around; gap: 2px;
  }
  .bottom-tabs .tab-btn { flex-direction: column; gap: 2px; flex: 1; padding: 6px 4px; font-size: 11px; border-radius: 10px; }
  .app { padding-bottom: 64px; }
}

.fab-mic { position: fixed; right: 18px; bottom: 76px; z-index: 19; width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--green); color: #fff; box-shadow: 0 6px 18px rgba(31, 95, 63, .32); display: grid; place-items: center; }
.fab-mic svg { width: 26px; height: 26px; fill: currentColor; }
.fab-mic[hidden] { display: none; }
@media (min-width: 820px) { .fab-mic { bottom: 24px; } }

.grid { max-width: 1120px; margin: 0 auto; padding: 0 16px 16px; display: grid; gap: 16px; align-items: start; }
.tab-panel { display: grid; gap: 16px; }
.tab-panel[hidden] { display: none; }
#tab-talk.tab-panel { grid-template-columns: minmax(0, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

.talk { display: flex; flex-direction: column; gap: 14px; min-height: 460px; }
.howto summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.talk-head { display: flex; align-items: center; gap: 16px; }
.mic { width: 76px; height: 76px; flex: none; border-radius: 50%; border: 0; background: var(--green); color: #fff;
  display: grid; place-items: center; box-shadow: 0 6px 18px rgba(31, 95, 63, .28); transition: transform .15s; }
.mic svg { width: 34px; height: 34px; fill: currentColor; }
.mic:active { transform: scale(.96); }
.mic.live { background: var(--red); box-shadow: 0 0 0 0 rgba(179, 38, 30, .45); animation: pulse 1.6s infinite; }
.mic.hearing { animation-duration: .7s; }
.mic:disabled { opacity: .6; cursor: default; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(179, 38, 30, .45); } 70% { box-shadow: 0 0 0 16px rgba(179, 38, 30, 0); } 100% { box-shadow: 0 0 0 0 rgba(179, 38, 30, 0); } }
.mic-label { font-weight: 700; font-size: 18px; }
.status { color: var(--muted); font-size: 14px; }

.log { flex: 1; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 380px; min-height: 160px;
  padding: 4px 2px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 15px; }
.msg.you { align-self: flex-end; background: var(--green-soft); border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.partial { opacity: .6; }
.msg .who { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.log .empty { color: var(--muted); margin: auto; text-align: center; font-size: 14px; }

.draft { border: 2px solid var(--amber); background: var(--amber-soft); border-radius: 12px; padding: 12px 14px; }
.draft-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); margin-bottom: 6px; }
.draft table { width: 100%; border-collapse: collapse; font-size: 14px; }
.draft td { padding: 3px 0; }
.draft td.n { text-align: right; font-variant-numeric: tabular-nums; }
.draft tr.total td { border-top: 1px solid var(--line); font-weight: 700; padding-top: 6px; }
.draft .after { margin-top: 8px; font-weight: 600; }
.draft-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.primary { background: var(--green); color: #fff; border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 700; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; }
.ghost:disabled { opacity: .5; cursor: default; }
.small { font-size: 13px; padding: 6px 10px; }

.type { display: flex; gap: 8px; }
.type input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); }
.tries-label { font-size: 13px; color: var(--muted); margin-bottom: -6px; }
.tries { display: flex; flex-wrap: wrap; gap: 6px; }
.tries button { font-size: 13px; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 99px; padding: 5px 10px; }
.tries button:hover { color: var(--ink); border-color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat { border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; }
.stat.owe { background: var(--red-soft); color: var(--red); }
.stat.hold { background: var(--blue-soft); color: var(--blue); }
.customers, .receipts, .tools { list-style: none; margin: 0; padding: 0; }
.customers li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 4px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.customers li:first-child { border-top: 0; }
.customers li:hover { background: var(--bg); }
.customers li.flash { animation: flash 1.8s; }
@keyframes flash { 0%, 40% { background: var(--amber-soft); } 100% { background: transparent; } }
.amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.amt.owe { color: var(--red); }
.amt.hold { color: var(--blue); }
.amt.zero { color: var(--muted); font-weight: 400; }
.receipts li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.receipts li:first-child { border-top: 0; }
.receipts li.empty { color: var(--muted); cursor: default; }
.ref { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--green-soft); color: var(--green); font-weight: 600; }
details.card summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.tools li { font-size: 12px; font-family: ui-monospace, Consolas, monospace; padding: 6px 0; border-top: 1px solid var(--line); word-break: break-word; }
.tools li:first-child { margin-top: 8px; }
.tools .ok { color: var(--green); } .tools .err { color: var(--red); }

dialog.receipt { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
  width: min(420px, calc(100vw - 32px)); padding: 18px; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h3 { margin: 0 0 4px; }
dialog table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
dialog td { padding: 4px 0; border-bottom: 1px solid var(--line); }
dialog td.n { text-align: right; font-variant-numeric: tabular-nums; }
dialog form { margin-top: 12px; text-align: right; }

.real { max-width: 1120px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: 13px; }

.remind { border: 2px solid var(--green); background: var(--green-soft); border-radius: 12px; padding: 12px 14px; }
.remind .draft-title { color: var(--green); }
.remind p { margin: 4px 0 0; }
a.primary { text-decoration: none; display: inline-block; }

.stock li { cursor: default; }
.stock li.low .amt { color: var(--amber); }

/* ---------- dashboard / trades / business ---------- */

.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pill { font-size: 13px; border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 99px; padding: 7px 13px; font-weight: 600; }
.pill.on { background: var(--green); border-color: var(--green); color: #fff; }

.hero { text-align: center; padding: 8px 0 18px; }
.hero-label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.hero-num { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--green); margin-top: 4px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tiles.small .tile { padding: 10px; }
.tile { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.tile-num { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile-sub { font-size: 11px; color: var(--muted); }

.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--line); }
.rowlist li:first-child { border-top: 0; }
.rowlist li.empty { color: var(--muted); }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.tradelist { list-style: none; margin: 0; padding: 0; }
.tradelist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--line); cursor: pointer; flex-wrap: wrap; }
.tradelist li:first-child { border-top: 0; }
.tradelist li.empty { color: var(--muted); cursor: default; }
.tradelist .row-main b { display: block; font-size: 14px; }
.tradelist .row-main .hint { margin: 2px 0 0; }

.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.badge.paid { background: var(--green-soft); color: var(--green); }
.badge.credit { background: var(--red-soft); color: var(--red); }

.stat-line { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.stat-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.biz-panel .customers { margin-top: 0; }

/* Leave room at the very bottom so the floating mic never covers a button or link. */
.app.fab-on { padding-bottom: 88px; }
@media (max-width: 819px) {
  .app.fab-on { padding-bottom: calc(152px + env(safe-area-inset-bottom, 0px)); }
}

/* Gbam's memory of the last chat. */
.memnote { font-size: 13px; color: var(--muted); margin: 6px 0 4px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--green); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.msg.old { opacity: .55; }

.sharebtn { display: inline-block; text-decoration: none; padding: 10px 14px; border-radius: 10px; background: var(--green); color: #fff; font-weight: 700; }

#remindText { white-space: pre-line; }

.noisy-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 4px 0 6px; }
.noisy-row label { display: flex; align-items: center; gap: 8px; }
#micBtn, #fabMic { touch-action: manipulation; }

.mic.muted, #fabMic.muted { background: var(--muted); box-shadow: none; animation: none; }

#basketBody { max-height: 38vh; overflow-y: auto; }
#basketBody table { width: 100%; border-collapse: collapse; font-size: 14px; }
#basketBody td { padding: 3px 0; }
#basketBody .hint { font-size: 13px; opacity: .75; margin-top: 6px; }
