/* Kupon. Native fonts, plain surfaces, one accent. */

:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --ink: #1b1f1d;
  --ink-2: #4a524e;
  --muted: #6a736e;
  --line: #dde1de;
  --accent: #17634a;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --bar: #2a8563;
  --bar-hover: #17634a;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --danger: #b3261e;
  --radius: 10px;
  --tab-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1b201e;
    --ink: #e8ece9;
    --ink-2: #c1c9c4;
    --muted: #97a19b;
    --line: #2f3633;
    --accent: #4cc293;
    --accent-ink: #0c1d16;
    --accent-soft: #1d3329;
    --bar: #3fa87e;
    --bar-hover: #6fd7ac;
    --warn: #f0b85a;
    --warn-soft: #3a2d14;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .4rem 0 .6rem; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .5rem; font-weight: 650; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; font-weight: 650; }
p { margin: .4rem 0; }
[hidden] { display: none !important; }

.ic { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.ic.tiny { width: 15px; height: 15px; color: var(--accent); vertical-align: -2px; }
.ic.ok { color: var(--accent); width: 24px; height: 24px; vertical-align: -5px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.center { text-align: center; }
.pad { padding: 1rem 0; }
.warn { color: var(--warn); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand img { border-radius: 6px; }
.langbtn {
  font: inherit; font-size: .85rem; font-weight: 600;
  background: none; color: var(--ink-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; min-height: 32px;
}

main { max-width: 640px; margin: 0 auto; padding: 8px 16px 0; }

.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--warn-soft); color: var(--ink); font-size: .9rem;
  border-bottom: 1px solid var(--line);
}

.notice {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px; margin: 8px 0; border-radius: var(--radius);
  background: var(--warn-soft); color: var(--ink); text-decoration: none; font-size: .92rem;
}
.notice .ic { color: var(--warn); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px;
  font: inherit; font-weight: 600; font-size: .95rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.danger[data-armed] { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.link { background: none; border: none; color: var(--accent); padding-left: 0; padding-right: 0; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .85rem; }
.btn.big { min-height: 52px; padding: 10px 22px; font-size: 1.05rem; }
.iconbtn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  background: none; border: none; color: var(--ink-2); border-radius: 50%; cursor: pointer;
}
.iconbtn:hover:not(:disabled) { background: var(--accent-soft); }
.iconbtn:disabled { opacity: .3; cursor: default; }

input, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
  min-height: 44px; padding: 8px 12px; width: 100%;
}
input:focus, select:focus, .btn:focus-visible, .iconbtn:focus-visible, .tabbar a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { font-size: .9rem; font-weight: 600; color: var(--ink-2); }

.row { display: flex; gap: 8px; align-items: center; }
.row.gap { margin: 12px 0; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; margin-top: 16px; }
.row input { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.stack > .btn { justify-content: flex-start; }
.msg { min-height: 1.4em; font-size: .92rem; }
.msg.err { color: var(--danger); }

/* ---------- overview ---------- */
.empty { padding: 32px 0; }
.empty p { color: var(--ink-2); }
.monthbar { display: flex; align-items: center; justify-content: space-between; margin: 4px -10px 0; }
.monthbar h1 { margin: 0; font-size: 1.15rem; }
.hero { margin: 10px 0 2px; }
.hero-num { font-size: 2.4rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.small-hero .hero-num { font-size: 1.9rem; }
.sub { color: var(--ink-2); font-size: .92rem; margin: 2px 0; }

.chart { position: relative; margin: 4px 0; }
.chart svg { display: block; }
.chart .bar { fill: var(--bar); }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit.on { fill: var(--ink); fill-opacity: .06; }
.chart .tip {
  position: absolute; top: -6px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: .8rem; white-space: nowrap;
  padding: 3px 8px; border-radius: 6px; pointer-events: none;
}

.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter { display: block; height: 4px; margin-top: 6px; background: var(--line); border-radius: 2px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--bar); border-radius: 2px; }

/* ---------- scan ---------- */
.viewfinder {
  position: relative; aspect-ratio: 1 / 1; max-height: 58vh; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  display: grid; place-items: center;
}
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.viewfinder .frame { display: none; position: absolute; inset: 18%; border: 3px solid #fff; border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
.viewfinder.live { background: #000; }
.viewfinder.live video, .viewfinder.live .frame { display: block; }
.viewfinder.live #cam-btn { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); }

/* ---------- lists ---------- */
input[type=search] { margin: 4px 0 8px; }
h2.group { display: flex; justify-content: space-between; font-size: .95rem; color: var(--ink-2); margin: 1.2rem 0 .4rem; }
.rlist { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); }
.rlist li { border-bottom: 1px solid var(--line); }
.rlist li:last-child { border-bottom: none; }
.rlist li > button:first-child {
  display: flex; width: 100%; gap: 12px; align-items: center; justify-content: space-between;
  padding: 11px 12px; background: none; border: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.rlist li > button:first-child:hover { background: var(--accent-soft); }
.rmain { display: flex; flex-direction: column; min-width: 0; }
.rname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ramt { font-weight: 600; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.ramt.small { font-weight: 500; }
.wlist li.soon { background: var(--warn-soft); }
.wlist .btn.link { margin: -6px 12px 4px; min-height: 34px; }

/* ---------- sheet ---------- */
dialog#sheet {
  border: none; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px;
  max-height: 92vh; overflow: auto;
  background: var(--bg); color: var(--ink);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--line);
}
@media (min-width: 600px) { dialog#sheet { margin: auto; border-radius: 16px; } }
dialog#sheet::backdrop { background: rgba(0, 0, 0, .45); }
#sheet-body:focus { outline: none; }
#sheet-body { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
#sheet-body h2 { margin-top: 0; font-size: 1.2rem; }
.kv { border-collapse: collapse; margin: 8px 0; font-size: .93rem; }
.kv th { text-align: left; font-weight: 500; color: var(--muted); padding: 2px 16px 2px 0; }
.kv td { font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.actions .btn { justify-content: flex-start; }
fieldset.warranty { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; background: var(--surface); }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; color: var(--ink); }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.check .ic { color: var(--accent); }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 10px 0; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; text-align: center; padding: 10px 6px; cursor: pointer; color: var(--ink-2); background: var(--surface); font-weight: 600; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }

.people { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.people li { display: flex; gap: 6px; align-items: center; }
.people .pname { flex: 1; min-width: 0; }
.people .pamt { width: 110px; flex: none; text-align: right; }
.people .pshare { width: 110px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.preview {
  white-space: pre-wrap; font: inherit; font-size: .9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin: 10px 0;
}

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.tabbar a .ic { width: 24px; height: 24px; }
.tabbar a[aria-current=page] { color: var(--accent); }
.tabbar .scan-tab .ic { width: 28px; height: 28px; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: .92rem;
  max-width: calc(100% - 32px);
}

/* ---------- tax portal, items, prices, split by item ---------- */
:root { --good: #17633f; }
@media (prefers-color-scheme: dark) { :root { --good: #6fd7ac; } }
.good { color: var(--good); }
.ic.tiny.warn { color: var(--warn); }
.ic.tiny.muted { color: var(--muted); }
.fstate { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-size: .92rem; }
.fstate .ic { margin-top: 1px; }
.fstate.ok { color: var(--good); font-weight: 600; }
.fstate.warn { color: var(--warn); }
.fmissing { background: var(--warn-soft); border-radius: var(--radius); padding: 4px 12px 10px; margin: 8px 0; }
.fmissing .fstate { color: var(--ink); }
.fmissing .fstate .ic { color: var(--warn); }
.spin { width: 16px; height: 16px; flex: none; margin-top: 2px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }
.tbl.items tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: none; }
.meter.over span { background: var(--warn); }
.grow { flex: 1; margin: 0; min-width: 0; }
.tbl.budgets td { vertical-align: middle; padding-top: 4px; padding-bottom: 4px; }
.tbl.budgets input { width: 120px; text-align: right; min-height: 38px; }
.tbl.budgets label { color: var(--ink); font-weight: 500; font-size: .93rem; }
.seg span { font-size: .88rem; line-height: 1.25; }
.seg .ic { width: 16px; height: 16px; vertical-align: -3px; }
.sitems { list-style: none; margin: 8px 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.sitems li { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sitems li:last-child { border-bottom: none; }
.row.between0 { justify-content: space-between; gap: 12px; }
.sitems .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font: inherit; font-size: .85rem; min-height: 34px; padding: 4px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 17px; background: var(--bg); color: var(--ink-2);
}
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
