/* Plumbline - gunmetal + gold (see brand palette), light + dark, phone first. */
:root {
  --gun: #2A3439;
  --gold: #CF9C29;
  --gold-dark: #a87f1b;
  --gold-tint: #f3e0a8;
  --logo-gray: #808080;
  --bg: #ebe9e4;
  --card: #ffffff;
  --ink: #2A3439;
  --muted: #667177;
  --line: #d8d5ce;
  --field: #f7f6f3;
  --ok: #2c7a4b;
  --warn: #9a5b00;
  --warn-bg: #fff4de;
  --bad: #b3261e;
  --bad-bg: #fdeceb;
  --shadow: 0 1px 2px rgba(42, 52, 57, .08), 0 4px 14px rgba(42, 52, 57, .06);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14191c;
    --card: #1f272b;
    --ink: #e8ebed;
    --muted: #98a3a9;
    --line: #333f45;
    --field: #182024;
    --gold-tint: #4a3d1a;
    --ok: #62c58a;
    --warn: #f0b24a;
    --warn-bg: #3b2f14;
    --bad: #ff8b82;
    --bad-bg: #3d1f1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }

/* ── header ── */
.hero {
  background: var(--logo-gray); text-align: center;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
}
.logo { display: block; margin: 0 auto; width: min(240px, 62vw); height: auto; }
.hero-sub { color: #fdf6e3; font-weight: 600; font-size: 13px; letter-spacing: .02em; margin-top: 4px; }
.userbar { margin-top: 8px; font-size: 13px; color: #fdf6e3; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }
.userbar .link { color: #fff; }

/* ── tabs ── */
.tabs {
  position: sticky; top: 0; z-index: 5; display: flex; background: var(--gun); overflow-x: auto; scrollbar-width: none;
  padding: 0 4px; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.tab {
  flex: 1 0 auto; white-space: nowrap; padding-left: 14px; padding-right: 14px; border: 0; background: none; color: #c9d0d4; font: inherit; font-weight: 600; font-size: 14px;
  padding: 14px 14px 12px; min-height: 48px; border-bottom: 3px solid transparent; cursor: pointer;
}
.tab.active { color: #fff; border-bottom-color: var(--gold); }

main { max-width: 980px; margin: 0 auto; padding: 14px 14px 60px; }
.view > * + * { margin-top: 14px; }

/* ── cards ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.center { text-align: center; padding: 28px 18px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 17px; }
.card h2 { font-size: 20px; }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--gold); color: var(--gun); font-size: 13px; font-weight: 800; margin-right: 6px;
}
.step.ok { background: var(--ok); color: #fff; }
.muted { color: var(--muted); margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.stack > * + * { margin-top: 10px; }

/* ── form controls (16px+ stops iOS zooming on focus) ── */
.row { display: flex; gap: 10px; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }
.field { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.field + .field { margin-top: 10px; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  display: block; width: 100%; margin-top: 4px; min-height: 46px; padding: 10px 12px;
  font: inherit; font-size: 16px; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 10px;
}
textarea { resize: vertical; margin-bottom: 10px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--gold) 55%, transparent); outline-offset: 1px; border-color: var(--gold);
}
#year, #yeYear { width: 96px; }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 12px 18px; font: inherit; font-weight: 700; border: 0; border-radius: 12px; cursor: pointer;
}
.btn.wide { width: 100%; }
.btn.primary { background: var(--gold); color: var(--gun); }
.btn.primary:active { background: var(--gold-dark); }
.btn.secondary { background: var(--gun); color: #fff; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn[disabled] { opacity: .55; cursor: progress; }
.link { background: none; border: 0; padding: 4px; font: inherit; color: var(--gold-dark); text-decoration: underline; cursor: pointer; }
.file-btn { cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn:focus-within { outline: 3px solid color-mix(in srgb, var(--gold) 55%, transparent); }

/* ── messages ── */
.msg { margin: 10px 0 0; font-size: 14px; }
.msg.bad { color: var(--bad); } .msg.ok { color: var(--ok); }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 12px 0; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice b { font-weight: 700; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* ── lists ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { background: var(--field); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); }
.list > .item { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.list > .item:first-child { border-top: 0; }
.card.flush .list > .item { padding: 13px 16px; }
.item .main { min-width: 0; }
.item .title { font-weight: 700; overflow-wrap: anywhere; }
.item .sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.item .amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.item .amt.big { font-size: 19px; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }

/* owner rows: big tappable checkbox + amount */
.owners > label.item { cursor: pointer; }
.owners > label.item.off { opacity: .55; }
.owners input[type=checkbox] { width: 24px; height: 24px; flex: none; accent-color: var(--gold-dark); margin: 0; }
.owners .lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tag { display: inline-block; margin-top: 3px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--gold-tint); color: var(--gun); }
.tag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
@media (prefers-color-scheme: dark) { .tag { color: #f6e7bd; } }

.totals { background: var(--gold-tint); border-radius: 10px; padding: 10px 14px; margin-top: 8px; display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; }
.totals small { font-weight: 600; color: var(--muted); }
.check { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 4px; font-weight: 600; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--gold-dark); margin: 0; }
.check small { color: var(--muted); font-weight: 400; }
.actionbar { position: sticky; bottom: 0; padding: 10px 0 calc(6px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--card) 70%, transparent); margin-top: 6px; }
#view-settings > .actionbar { background: linear-gradient(to top, var(--bg) 70%, transparent); }

.settings-owner { display: grid; gap: 4px; }
.alias-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 480px) { .alias-row { grid-template-columns: 1fr; } }

/* ── dialog / toast / misc ── */
dialog { border: 0; border-radius: 16px; padding: 20px; width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, .4); }
dialog::backdrop { background: rgba(10, 14, 16, .6); }
dialog h3 { margin: 0 0 8px; }
.confirm-body { color: var(--muted); font-size: 15px; }
.confirm-body ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink); }
.dlg-actions { display: flex; gap: 10px; margin-top: 18px; }
.dlg-actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--gun); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 20; max-width: calc(100vw - 32px); box-shadow: var(--shadow); font-weight: 600; }
.spinner { width: 34px; height: 34px; margin: 0 auto 10px; border: 4px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.demo-badge { position: fixed; left: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); background: #b3261e; color: #fff; font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 8px; z-index: 30; letter-spacing: .04em; white-space: nowrap; opacity: .9; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
