:root {
  color-scheme: light;
  --bg: #EEF1F4;
  --surface: #FFFFFF;
  --sunk: #E3E8ED;
  --ink: #16202B;
  --muted: #5B6B7B;
  --line: #D5DCE3;
  --accent: #0F6E78;
  --accent-ink: #FFFFFF;
  --pos: #17804A;
  --neg: #B3261E;
  --credit: #8A5A00;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0F1720;
    --surface: #17222E;
    --sunk: #1F2C3A;
    --ink: #E6EDF3;
    --muted: #93A4B5;
    --line: #2A3A4B;
    --accent: #3BB0BB;
    --accent-ink: #0B1A1D;
    --pos: #45C485;
    --neg: #F2766B;
    --credit: #E0A43A;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body {
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  font-size: 16px; line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px 96px; }

/* top bar */
.bar { display: flex; align-items: center; gap: 8px; padding: 14px 0 10px; }
.bar h1 { font-size: 20px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -0.01em; }
.iconbtn { border: 0; background: transparent; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--accent); font-weight: 600; }
.iconbtn:active { background: var(--sunk); }
.tag { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--credit); color: var(--surface); }

/* forms */
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=tel], input[type=search] {
  width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 17px;
}
.primary {
  width: 100%; border: 0; border-radius: var(--radius-sm); padding: 15px; margin-top: 18px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px;
}
.primary:disabled { opacity: .55; }
.ghost { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin-top: 10px; background: transparent; font-weight: 600; }
.err { color: var(--neg); font-size: 15px; margin-top: 12px; min-height: 1.4em; }

/* login */
.login { padding-top: 12vh; }
.login h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -0.02em; }

/* search */
.search { display: flex; gap: 8px; margin-top: 6px; }
.search input { flex: 1; }
.search button { border: 0; border-radius: var(--radius-sm); padding: 0 20px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.list { margin: 8px 0 0; padding: 0; list-style: none; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; background: transparent; text-align: left; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 13px; color: var(--muted); }
.row .right { text-align: right; font-weight: 600; }
h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 26px 4px 4px; }
.empty { padding: 22px 16px; color: var(--muted); background: var(--surface); border-radius: var(--radius-lg); margin-top: 8px; }

/* account header: the one bold element */
.acct { background: var(--surface); border-radius: var(--radius-lg); padding: 18px 18px 14px; }
.acct .who { font-size: 14px; color: var(--muted); }
.acct .who b { color: var(--ink); font-size: 17px; display: block; }
.equity { font-size: 44px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin: 14px 0 2px; }
.equity-label { font-size: 13px; color: var(--muted); }
.figs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.figs div span { display: block; font-size: 13px; color: var(--muted); }
.figs div b { font-size: 17px; }

/* actions */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.act { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 14px 12px; font-weight: 700; text-align: left; display: flex; align-items: center; gap: 10px; }
.act i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.act.deposit i { background: var(--pos); }
.act.withdraw i { background: var(--neg); }
.act.credit_in i, .act.credit_out i { background: var(--credit); }
.act:active { background: var(--sunk); }

/* segmented tabs */
.seg { display: flex; background: var(--sunk); padding: 4px; border-radius: 12px; margin-top: 22px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 4px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected=true] { background: var(--surface); color: var(--ink); }
.filters { display: flex; gap: 8px; margin-top: 10px; }
.filters button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.filters button[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.totalline { display: flex; justify-content: space-between; padding: 12px 4px 0; font-size: 15px; }

/* bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav div { display: flex; max-width: 560px; width: 100%; }
.nav button { flex: 1; border: 0; background: transparent; padding: 14px 0 12px; font-weight: 600; color: var(--muted); }
.nav button[aria-current=page] { color: var(--accent); }

/* bottom sheet */
dialog#sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; background: var(--surface); color: var(--ink); border-radius: 20px 20px 0 0; max-height: 92vh; }
dialog#sheet::backdrop { background: rgba(8, 14, 20, .45); }
dialog#sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet { padding: 20px 18px calc(22px + env(safe-area-inset-bottom, 0px)); }
.sheet h3 { margin: 0; font-size: 20px; }
.amount { font-size: 34px !important; font-weight: 700; padding: 12px 14px !important; }
.change { margin: 18px 0 4px; background: var(--sunk); border-radius: var(--radius-sm); padding: 16px; }
.change .line { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; }
.change .big { font-size: 26px; font-weight: 700; }
.confirm-deposit, .confirm-credit_in { background: var(--pos) !important; }
.confirm-withdraw, .confirm-credit_out { background: var(--neg) !important; }
.confirm-deposit, .confirm-credit_in, .confirm-withdraw, .confirm-credit_out { color: #fff !important; }
.done-mark { font-size: 15px; font-weight: 700; color: var(--pos); }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s .8s linear infinite; vertical-align: -3px; }
@keyframes s { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.subhead { margin: 4px 0 0; }
.mt12 { margin-top: 12px; }
.mt6 { margin-top: 6px; }
.ink { color: var(--ink); }

.setlist { margin-top: 12px; }
.setlist .title { font-size: 16px; }
.link { color: var(--accent); font-weight: 600; font-size: 15px; }
.select { width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: 17px; -webkit-appearance: none; appearance: none; }
.sel { -webkit-user-select: all; user-select: all; }
.change .line b, .change .line span { overflow-wrap: anywhere; text-align: right; }
.change .line > span:first-child { text-align: left; flex: none; margin-right: 12px; }
