:root {
  --bg: #f5f6fa; --surface: #ffffff; --text: #1b1d29; --muted: #6b7083; --line: #e3e5ee;
  --brand: #4f46e5; --brand-ink: #ffffff; --brand-soft: #eceafd;
  --pos: #12805c; --neg: #c0392b; --warn-bg: #fff6df; --warn-ink: #7a5600;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,22,40,.06), 0 4px 14px rgba(20,22,40,.06);
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131a; --surface: #1c1e2a; --text: #eef0f8; --muted: #9aa0b8; --line: #2b2e3f;
    --brand: #8b85ff; --brand-ink: #11122a; --brand-soft: #2a2850; --pos: #4cd6a0; --neg: #ff8a7a;
    --warn-bg: #3a2f10; --warn-ink: #ffd88a; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; margin: 1.2rem 0 .6rem; }
a { color: var(--brand); }
p { margin: .5rem 0; }
.muted { color: var(--muted); } .small { font-size: .8rem; } .strong { font-weight: 650; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.boot, .empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }
[hidden] { display: none !important; }

/* layout */
.shell { min-height: 100dvh; padding-bottom: calc(68px + var(--safe-bottom)); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: calc(.6rem + var(--safe-top)) 1rem .6rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-title { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.topbar-user { font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; max-width: 55%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tabbar { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
.tabbar a { flex: 1; text-align: center; padding: .85rem .25rem; text-decoration: none; color: var(--muted); font-size: .85rem; font-weight: 600; }
.tabbar a.active { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.content { max-width: 760px; margin: 0 auto; padding: 1rem; }
.page { display: flex; flex-direction: column; gap: .9rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .3rem; }
.back { text-decoration: none; font-weight: 600; }
@media (min-width: 900px) {
  .shell { padding-bottom: 0; }
  .tabbar { position: sticky; top: 52px; bottom: auto; justify-content: center; border-top: 0; border-bottom: 1px solid var(--line); padding-bottom: 0; }
  .tabbar a { flex: 0 0 auto; padding: .8rem 1.4rem; }
  .tabbar a.active { box-shadow: inset 0 -3px 0 var(--brand); }
}

/* cards & lists */
.card, .balance-card, .stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.balance-card { background: linear-gradient(135deg, var(--brand), #7c3aed); color: #fff; text-align: center; padding: 1.4rem 1rem; }
.balance-label { opacity: .85; font-size: .9rem; } .balance-value { font-size: 3.4rem; font-weight: 800; line-height: 1.1; } .balance-sub { opacity: .85; font-size: .9rem; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; } .row-main.link { text-decoration: none; color: inherit; }
.row-title { font-weight: 650; overflow-wrap: anywhere; } .row-sub { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; } .row-meta { color: var(--muted); font-size: .78rem; margin-top: .15rem; overflow-wrap: anywhere; }
.row-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex-shrink: 0; }
.button-col { gap: .35rem; }
.pts { font-weight: 750; font-size: 1.05rem; } .pts.pos { color: var(--pos); } .pts.neg { color: var(--neg); }
.struck .row-title, .struck .row-sub { text-decoration: line-through; opacity: .65; }
.row input[type=checkbox], .select-all input { width: 1.25rem; height: 1.25rem; accent-color: var(--brand); }
.select-all, .check { display: flex; align-items: center; gap: .5rem; padding: .3rem .2rem; color: var(--muted); font-size: .9rem; }
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .75rem; font-weight: 650; }
.chip.pending { background: var(--warn-bg); color: var(--warn-ink); } .chip.completed { background: #dcf5ea; color: #0b6b4a; } .chip.cancelled { background: #f6e0dd; color: #9a2a1d; } .chip.strong { background: var(--brand); color: var(--brand-ink); }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: .75rem 1rem; border-radius: var(--radius); }
.kv { display: grid; grid-template-columns: 7rem 1fr; gap: .4rem .75rem; margin: 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.stat-value { font-size: 1.8rem; font-weight: 800; } .stat-label { color: var(--muted); font-size: .85rem; }

/* forms & buttons */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; } .field label { font-weight: 600; font-size: .9rem; } .field small { color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: .7rem .8rem; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn { display: inline-block; font: inherit; font-weight: 650; padding: .7rem 1.1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-align: center; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); } .btn.danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn.ghost { background: transparent; } .btn.small { padding: .35rem .7rem; font-size: .85rem; } .btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; } .toolbar > * { flex: 1 1 200px; }
.inline-form { display: flex; gap: .5rem; } .inline-form input { flex: 1; }
.subnav { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; }
.subnav a { white-space: nowrap; padding: .4rem .8rem; border-radius: 999px; background: var(--surface); text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); }
.subnav a.active { background: var(--brand); color: var(--brand-ink); }
.action-bar { position: fixed; z-index: 7; left: 0; right: 0; bottom: calc(60px + var(--safe-bottom)); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: center; padding: .7rem 1rem; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.12); }
@media (min-width: 900px) { .action-bar { bottom: 0; } }
.plain { list-style: none; padding: 0; margin: .5rem 0; } .scroll { max-height: 14rem; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: .4rem .7rem; }
.secret { display: block; font-size: 1.4rem; letter-spacing: .05em; text-align: center; padding: 1rem; background: var(--bg); border-radius: 10px; user-select: all; }

/* auth */
.auth { max-width: 420px; margin: 0 auto; padding: calc(1.5rem + var(--safe-top)) 1rem 2rem; display: flex; flex-direction: column; gap: 1rem; }
.brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.tabs { display: flex; background: var(--surface); border-radius: 12px; padding: .25rem; box-shadow: var(--shadow); }
.tabs button { flex: 1; padding: .6rem; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; }
.tabs button.active { background: var(--brand); color: var(--brand-ink); }

/* modal & toast */
dialog.modal { width: min(92vw, 460px); border: 0; border-radius: var(--radius); padding: 1.2rem; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.modal::backdrop { background: rgba(10,12,24,.55); }
.modal h2 { margin-bottom: .6rem; } .modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
#toast { position: fixed; z-index: 100; left: 0; right: 0; top: calc(.6rem + var(--safe-top)); display: flex; justify-content: center; pointer-events: none; }
.toast { max-width: min(92vw, 520px); padding: .75rem 1rem; border-radius: 12px; background: #23263a; color: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.toast.error { background: #b3261e; } .toast.success { background: #11755a; }

.lang-corner { display: flex; justify-content: flex-end; } .lang-corner select { width: auto; padding: .35rem .6rem; }
.kv select { width: auto; padding: .3rem .6rem; }
