/* ===================== Tokens ===================== */
:root {
  --paper: #edf1f8;
  --surface: #ffffff;
  --surface-2: #f4f7fb;
  --ink: #0f1b2e;
  --ink-2: #33415a;
  --muted: #5d6a80;
  --line: #d6deea;
  --line-2: #e6ebf3;
  --primary: #1f4fd1;
  --primary-ink: #173c9f;
  --primary-wash: #e2eafd;
  --on-primary: #ffffff;
  --green: #0c7a54;
  --green-ink: #0a5f42;
  --green-wash: #def2e9;
  --blue: #1f4fd1;
  --blue-wash: #e2eafd;
  --red: #bf352b;
  --red-wash: #f9e5e2;
  --amber: #9a620a;
  --amber-wash: #f6ecd6;
  --violet: #5b39b8;
  --violet-wash: #ebe5f8;
  --teal: #0d6a7a;
  --teal-wash: #ddeff2;
  --slate: #4b5a72;
  --slate-wash: #e6ebf3;
  --note: #10295c;
  --note-ink: #e8eefc;
  --note-muted: #a8bbe8;
  --r: 14px;
  --r-s: 10px;
  --shadow: 0 1px 0 rgba(15, 27, 46, .04), 0 10px 28px -18px rgba(15, 27, 46, .30);
  --focus: 0 0 0 3px color-mix(in srgb, var(--primary) 26%, transparent);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0a1120; --surface: #101a2e; --surface-2: #15213a; --ink: #e3e9f5; --ink-2: #c1cbdc; --muted: #8a97ae;
    --line: #23314b; --line-2: #1a2640; --primary: #7ea2ff; --primary-ink: #a9c0ff; --primary-wash: #172a55; --on-primary: #08132e;
    --green: #3cc497; --green-ink: #7fe0bd; --green-wash: #10302a; --blue: #8fb0ff; --blue-wash: #172a55;
    --red: #ff8174; --red-wash: #3a1d1b; --amber: #efb34b; --amber-wash: #372b14; --violet: #b9a0ff; --violet-wash: #281f43;
    --teal: #5ec6d3; --teal-wash: #10303a; --slate: #a9b6cb; --slate-wash: #1e2a40;
    --note: #0e2250; --note-ink: #e6edfc; --note-muted: #93a9de;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 28px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0a1120; --surface: #101a2e; --surface-2: #15213a; --ink: #e3e9f5; --ink-2: #c1cbdc; --muted: #8a97ae;
  --line: #23314b; --line-2: #1a2640; --primary: #7ea2ff; --primary-ink: #a9c0ff; --primary-wash: #172a55; --on-primary: #08132e;
  --green: #3cc497; --green-ink: #7fe0bd; --green-wash: #10302a; --blue: #8fb0ff; --blue-wash: #172a55;
  --red: #ff8174; --red-wash: #3a1d1b; --amber: #efb34b; --amber-wash: #372b14; --violet: #b9a0ff; --violet-wash: #281f43;
  --teal: #5ec6d3; --teal-wash: #10303a; --slate: #a9b6cb; --slate-wash: #1e2a40;
  --note: #0e2250; --note-ink: #e6edfc; --note-muted: #93a9de;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 28px -18px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

.t-violet { --tc: var(--violet); --tw: var(--violet-wash); }
.t-teal { --tc: var(--teal); --tw: var(--teal-wash); }
.t-amber { --tc: var(--amber); --tw: var(--amber-wash); }
.t-blue { --tc: var(--blue); --tw: var(--blue-wash); }
.t-red { --tc: var(--red); --tw: var(--red-wash); }
.t-green { --tc: var(--green); --tw: var(--green-wash); }
.t-slate { --tc: var(--slate); --tw: var(--slate-wash); }

/* ===================== Base ===================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; font-weight: 400;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.zero { color: var(--muted); }
.outv { color: var(--ink-2); }
.owe-t { color: var(--blue); }
.due-t { color: var(--red); }
.muted { color: var(--muted); }
.ic { width: 20px; height: 20px; flex: none; }
.ic.sm { width: 15px; height: 15px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===================== Shell ===================== */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px;
  padding: 22px 16px; border-inline-end: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 8px; font-weight: 700; font-size: 19px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--note); color: var(--note-ink); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); }
.side-nav a:hover { background: var(--surface-2); }
.side-nav a.on { background: var(--primary-wash); color: var(--primary-ink); font-weight: 500; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.linkish { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 0; background: none; border-radius: 10px; color: var(--muted); text-align: start; }
.linkish:hover { background: var(--surface-2); color: var(--ink); }
#main { padding: 24px 32px 56px; max-width: 1180px; width: 100%; outline: none; }
.tabbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  #main { padding: 12px 14px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; inset-inline: 0; bottom: 0; z-index: 30; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 2px; font-size: 11.5px; color: var(--muted); }
  .tabbar a.on { color: var(--primary); font-weight: 500; }
  .tabbar .tab-add { align-self: center; justify-self: center; width: 56px; height: 56px; margin-top: -26px; border-radius: 18px; display: grid; place-items: center;
    background: var(--primary); color: var(--on-primary); box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--primary) 70%, transparent); padding: 0; }
  .tabbar .tab-add .ic { width: 28px; height: 28px; stroke-width: 2.2; }
  body.form-mode .tabbar { display: none; }
  body.form-mode #main { padding-bottom: 24px; }
  .hide-m { display: none !important; }
}

/* ===================== Page header ===================== */
.ph { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; min-height: 48px; }
.ph-t { flex: 1; min-width: 0; }
.ph h1 { font-size: 23px; line-height: 1.3; overflow-wrap: anywhere; }
.ph p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.ph-a { display: flex; gap: 8px; align-items: center; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.wa { color: #12925a; }
.icon-btn.back { border-color: transparent; background: transparent; }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-ink); border-color: var(--primary-ink); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger-t { color: var(--red); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.wa { color: #12925a; }
.lnk { color: var(--primary); font-size: 13.5px; font-weight: 500; }
.lnk:hover { text-decoration: underline; }
.add-main { height: 46px; }

/* ===================== Cards & lists ===================== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 16px; overflow: hidden; }
.card.pad { padding: 16px 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 10px; }
.card-h.flat { padding: 0 0 10px; }
.card-h h2 { font-size: 15.5px; }
.card .muted { font-size: 13.5px; margin-bottom: 12px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.col { min-width: 0; }
@media (max-width: 1080px) { .cols { grid-template-columns: minmax(0, 1fr); gap: 0; } }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border: 0; border-top: 1px solid var(--line-2);
  background: none; width: 100%; text-align: start; min-height: 58px;
}
.rows > .row:first-child { border-top: 0; }
a.row:hover, button.row:hover { background: var(--surface-2); }
.row-m { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-m b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-m small, .op-m small { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 12.5px; }
.row-d { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: end; }
.row-d small { color: var(--muted); font-size: 12px; }
.row-a { display: flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 4px; background: var(--cc); flex: none; }

.ops { display: flex; flex-direction: column; }
.op { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--line-2); }
.ops > .op:first-child { border-top: 0; }
.op:hover { background: var(--surface-2); }
.op-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tw); color: var(--tc); }
.op-m { display: flex; flex-direction: column; min-width: 0; }
.op-m b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-v { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-weight: 500; }
.op-v small { font-weight: 400; font-size: 12px; color: var(--muted); }
.muted-note { font-style: normal; }
.day h3 {
  display: flex; justify-content: space-between; padding: 14px 18px 6px; font-size: 13px; font-weight: 500; color: var(--muted);
  background: var(--surface-2); border-top: 1px solid var(--line-2);
}
.day:first-child h3 { border-top: 0; }
#ops-list .day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
#ops-list .day h3 { border-top: 0; }
.card .day h3 { background: transparent; }

.empty { padding: 28px 18px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading { display: flex; justify-content: center; gap: 6px; padding: 60px 0; }
.loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: blink 1s infinite ease-in-out; }
.loading span:nth-child(2) { animation-delay: .15s; }
.loading span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

.bd { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.bd.owe { background: var(--blue-wash); color: var(--blue); }
.bd.due { background: var(--red-wash); color: var(--red); }
.st { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.st.soon { background: var(--amber-wash); color: var(--amber); }
.st.exp { background: var(--red-wash); color: var(--red); }
.st.ok { background: var(--green-wash); color: var(--green-ink); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--tw); color: var(--tc); font-size: 12.5px; }

.warn-box { background: var(--amber-wash); color: var(--amber); border-radius: var(--r-s); padding: 10px 12px; font-size: 14px; }
.warn-box a { text-decoration: underline; font-weight: 500; }
.hint-box { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 13.5px; padding: 6px 4px; }
.info-line { background: var(--surface-2); border-radius: var(--r-s); padding: 10px 12px; font-size: 14px; }
.meta { color: var(--muted); font-size: 12.5px; margin: 6px 4px 20px; }
.sub-h { font-size: 14px; color: var(--muted); font-weight: 500; margin: 16px 0 8px; }
.ctx { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 14px; margin-bottom: 12px; font-size: 14px; display: flex; gap: 12px; flex-wrap: wrap; }
.tot { display: flex; justify-content: space-between; color: var(--muted); font-size: 13.5px; margin: 4px 4px 10px; }
.more-wrap { display: flex; justify-content: center; margin: 8px 0 20px; }
.danger-zone { display: flex; justify-content: center; margin: 10px 0 30px; }

/* ===================== The banknote (hero) ===================== */
.hero {
  position: relative; overflow: hidden; border-radius: 18px; color: var(--note-ink); background-color: var(--note);
  background-image:
    repeating-radial-gradient(circle at 12% 120%, transparent 0 13px, rgba(255, 255, 255, .045) 13px 14px),
    repeating-radial-gradient(circle at 92% -30%, transparent 0 9px, rgba(255, 255, 255, .04) 9px 10px);
  padding: 22px 24px 12px; margin-bottom: 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 24px;
}
.hero::after { content: ''; position: absolute; inset: 7px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 13px; pointer-events: none; }
.hero-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-l { color: var(--note-muted); font-size: 14px; }
.hero-v { font-size: 42px; line-height: 1.12; font-weight: 600; letter-spacing: -0.01em; }
.hero-v .num.pos, .hero-v .num.neg, .hero-v .num.zero, .hero .num { color: inherit; }
.hero-s { color: var(--note-muted); font-size: 13px; }
.hero-side { display: grid; grid-template-columns: repeat(2, minmax(110px, auto)); gap: 4px 22px; align-content: start; }
.hero-side div { display: flex; flex-direction: column; }
.hero-side span { color: var(--note-muted); font-size: 13px; }
.hero-side b { font-size: 20px; font-weight: 600; }
.hero-side small { color: var(--note-muted); font-size: 12px; }
.hero-chart { grid-column: 1 / -1; position: relative; z-index: 1; }
.hero .chart .b-pos { fill: rgba(232, 238, 252, .85); }
.hero .chart .b-neg { fill: #ffab9f; }
.hero .chart .ch-z { stroke: rgba(232, 238, 252, .25); }
.hero .chart .ch-t { fill: var(--note-muted); }
.hero .split { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; border-top: 1px solid rgba(255, 255, 255, .14); padding-top: 12px; }
.hero .split div { display: flex; flex-direction: column; }
.hero .split span, .hero .split small { color: var(--note-muted); font-size: 12.5px; }
.hero .split b { font-size: 17px; font-weight: 600; }
.hero.rep { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 700px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding: 18px 18px 8px; }
  .hero-v { font-size: 34px; }
  .hero .split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.chart .b-pos { fill: var(--primary); }
.chart .b-neg { fill: var(--red); }
.chart .ch-z { stroke: var(--line); }
.chart .ch-t { font-size: 11px; fill: var(--muted); font-family: inherit; }

/* ===================== KPIs, quick, stocks, wallets ===================== */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi.net { background: var(--primary-wash); border-color: transparent; }
.kpi.net b { color: var(--primary-ink); }
.card-sub { font-size: 13px; font-weight: 400; margin-inline-start: 6px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
a.kpi:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font-size: 20px; font-weight: 600; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.owe b { color: var(--blue); }
.kpi.due b { color: var(--red); }
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi.net { grid-column: span 3; } }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .kpi b { font-size: 17px; } .kpi.net { grid-column: 1 / -1; } }

.quick { display: flex; gap: 8px; margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.quick::-webkit-scrollbar { display: none; }
.qa { display: inline-flex; align-items: center; gap: 8px; padding: 0 14px 0 16px; height: 42px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; font-size: 14px; flex: none; }
.qa .ic { color: var(--tc); }
.qa:hover { background: var(--tw); border-color: transparent; }

.stocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 4px 18px 18px; }
.stock { border: 1px solid var(--line); border-inline-start: 4px solid var(--pc); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 0 6px; }
.stock:hover { background: var(--surface-2); }
.stock-n { grid-column: 1 / -1; font-weight: 500; }
.stock b { font-size: 26px; font-weight: 600; }
.stock-u { color: var(--muted); font-size: 13px; }
.stock small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 4px; }
.stock.low { background: var(--amber-wash); }
.stock.low small { color: var(--amber); }
.lowtag { display: inline-flex; align-items: center; gap: 3px; margin-inline-start: auto; font-weight: 500; }

.wallets { display: flex; gap: 10px; overflow-x: auto; padding: 4px 18px 18px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.card .wallets { flex-wrap: wrap; overflow: visible; }
.wallet {
  flex: 1 1 150px; min-width: 150px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: inset 0 3px 0 var(--ac);
}
.wallet:hover { background: var(--surface-2); }
.w-n { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet b { font-size: 18px; font-weight: 600; }
.wallet small { color: var(--muted); font-size: 12px; }
.wallets.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); padding: 0; margin-bottom: 14px; overflow: visible; }
.wallets.arch .wallet { opacity: .6; }
.wallet.big { margin-bottom: 14px; padding: 18px 20px; }
.wallet.big b { font-size: 30px; }
.totals { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.totals > div:first-child { display: flex; flex-direction: column; }
.totals span { color: var(--muted); font-size: 13px; }
.totals b { font-size: 24px; font-weight: 600; }
.cur-tot { display: flex; gap: 8px 16px; flex-wrap: wrap; font-weight: 500; }

.start { border: 1px dashed var(--primary); background: color-mix(in srgb, var(--primary-wash) 55%, var(--surface)); }
.start h2 { font-size: 17px; margin-bottom: 2px; }
.steps { margin: 4px 0 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 10px; }
.steps li::marker { color: var(--primary); font-weight: 600; }
.steps a { font-weight: 500; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.steps small { display: block; color: var(--muted); font-size: 13px; }

/* ===================== Filters, chips, tabs ===================== */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; height: 44px; color: var(--muted); }
.search input { flex: 1; border: 0; background: none; outline: none; height: 100%; color: var(--ink); min-width: 0; }
.search:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.sm .chip { height: 32px; font-size: 13px; padding: 0 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 14px; white-space: nowrap;
}
.chip:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .cnt { font-size: 12px; opacity: .75; }
.chips.actions { margin-bottom: 14px; }
@media (max-width: 700px) {
  .filters .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -14px; padding-inline: 14px; }
  .filters .chips::-webkit-scrollbar { display: none; }
  .filters .chip { flex: none; }
  .wallets.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wallets.grid .wallet { min-width: 0; }
  .wallet b { font-size: 16.5px; }
}
.chips.actions .chip .ic { color: var(--tc, var(--muted)); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--primary); font-weight: 500; }
.range { align-items: end; }

/* ===================== Forms ===================== */
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.fl { font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.fl .opt { color: var(--muted); font-weight: 400; }
.fh { font-size: 12.5px; color: var(--muted); }
.fld input:not([type=checkbox]):not([type=color]), .fld select, .fld textarea, .rate-r input, .plan-r input {
  width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface);
  outline: none; transition: border-color .12s;
}
.fld textarea { height: auto; padding: 10px 12px; resize: vertical; }
.fld select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8d85' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 12px center; background-size: 16px 16px; background-repeat: no-repeat; padding-inline-start: 12px; padding-inline-end: 36px; text-overflow: ellipsis; }
.fld input:focus, .fld select:focus, .fld textarea:focus, .rate-r input:focus, .plan-r input:focus { border-color: var(--primary); box-shadow: var(--focus); }
.fld input[readonly] { background: var(--surface-2); }
.fld input[type=date] { text-align: start; }
.fld input[type=color] { width: 100%; height: 46px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); }
.inp { position: relative; display: block; }
.inp input { padding-inline-end: 44px !important; }
.inp .sfx { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.inp.big input { height: 56px !important; font-size: 22px; font-weight: 600; }
.f-row { display: flex; gap: 12px; align-items: flex-start; }
.f-row > * { flex: 1; min-width: 0; }
.f-row.wrap { flex-wrap: wrap; }
.f-row.wrap > * { flex: 0 0 auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.chk { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; padding: 4px 0; }
.chk input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }

.chips.pickable .chip { height: auto; min-height: 44px; padding: 6px 16px; flex-direction: column; gap: 0; align-items: center; justify-content: center; line-height: 1.3; font-weight: 500; color: var(--ink); }
.chips.pickable .chip small { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.chips.pickable .chip.on { background: var(--cc, var(--ink)); border-color: var(--cc, var(--ink)); color: #fff; }
.chips.pickable .chip.on small { color: rgba(255, 255, 255, .8); }
:root[data-theme="dark"] .chips.pickable .chip.on:not([style]) { color: var(--paper); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; border-radius: 9px; height: 38px; font-size: 13.5px; color: var(--muted); padding: 0 6px; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.opform { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.f-body { display: flex; flex-direction: column; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; border-top: 3px solid var(--tc); }
.f-sum { position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.f-sum-l:empty { display: none; }
.f-sum-b { display: flex; gap: 8px; }
.f-sum-b .btn { flex: 1; }
.f-sum-b .btn.primary { flex: 1.4; height: 48px; font-size: 16px; }
.sl { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; font-size: 14px; color: var(--muted); }
.sl b { color: var(--ink); font-weight: 500; text-align: end; }
.sl.credit b { color: var(--blue); }
.sl.profit, .sl.key { border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 10px; color: var(--ink); font-weight: 500; }
.sl.profit b, .sl.key b { font-size: 22px; font-weight: 600; }
.sl em.ask { font-style: normal; color: var(--amber); font-weight: 500; }
@media (max-width: 900px) {
  .opform { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .f-body { padding: 14px; border-radius: var(--r) var(--r) 0 0; border-bottom: 0; gap: 14px; }
  .f-sum { position: sticky; bottom: 0; top: auto; border-radius: 0 0 var(--r) var(--r); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); gap: 8px; z-index: 5;
    box-shadow: 0 -10px 24px -18px rgba(0, 0, 0, .35); }
  .sl { padding: 2px 0; font-size: 13px; }
  .sl.profit b, .sl.key b { font-size: 19px; }
  .f-sum-b .btn.ghost { flex: 0 1 auto; font-size: 13px; padding: 0 10px; }
}

/* person picker */
.pk { position: relative; display: flex; align-items: center; }
.pk-ic { position: absolute; inset-inline-start: 12px; color: var(--muted); display: flex; }
.pk input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); padding-inline-start: 40px; padding-inline-end: 12px; outline: none; }
.fld .pk input:not([type=checkbox]):not([type=color]) { padding-inline-start: 40px; }
.pk input:focus { border-color: var(--primary); box-shadow: var(--focus); }
.pk-list { position: absolute; top: calc(100% + 4px); inset-inline: 0; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; padding: 4px; }
.pk-list button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; background: none; text-align: start; padding: 8px 10px; border-radius: 8px; }
.pk-list button:hover, .pk-list button:focus { background: var(--surface-2); }
.pk-list button small { display: flex; gap: 8px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.pk-list .pk-new { flex-direction: row; align-items: center; gap: 6px; color: var(--primary); font-weight: 500; border-top: 1px solid var(--line-2); border-radius: 0 0 8px 8px; }
.pk-empty { padding: 10px; color: var(--muted); font-size: 13.5px; }
.pk-sel { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px 10px; background: var(--surface-2); }
.pk-sel.new { border-style: dashed; }
.pk-av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-wash); color: var(--primary-ink); font-weight: 600; flex: none; }
.pk-i { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pk-i small { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; align-items: center; }

/* ===================== Picker of op types ===================== */
.pick-g { margin-bottom: 20px; }
.pick-g h2 { font-size: 14px; color: var(--muted); font-weight: 500; margin: 0 4px 8px; }
.picks, .more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); text-align: start; width: 100%; }
.pick:hover { border-color: var(--tc, var(--primary)); background: var(--surface-2); }
.pick-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--tw, var(--primary-wash)); color: var(--tc, var(--primary)); flex: none; }
.pick-t { display: flex; flex-direction: column; min-width: 0; }
.pick-t b { font-weight: 500; }
.pick-t small { color: var(--muted); font-size: 12.5px; }
@media (max-width: 600px) { .picks, .more-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; } .pick { padding: 12px; } }

/* ===================== Op detail, person ===================== */
.op-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 20px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.facts dd a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.person-top { margin-bottom: 12px; }
.contact { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.contact > .num { font-size: 17px; font-weight: 500; margin-inline-end: 6px; }
.balances { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.bal { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.bal span { color: var(--muted); font-size: 13px; }
.bal b { font-size: 20px; font-weight: 600; }
.bal small { color: var(--muted); font-size: 12px; }
.bal.owe { background: var(--blue-wash); border-color: transparent; }
.bal.owe b { color: var(--blue); }
.bal.due { background: var(--red-wash); border-color: transparent; }
.bal.due b { color: var(--red); }
.bal.zero b { font-size: 15px; font-weight: 500; }
.note { margin-top: 10px; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.sub .row-m { text-decoration: none; }
.sub { flex-wrap: wrap; }
@media (max-width: 600px) {
  .sub { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; }
  .sub .row-a { grid-column: 1 / -1; justify-content: flex-start; }
  .sub .st { justify-self: end; }
}

/* ===================== Tables ===================== */
.tbl-w { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: start; font-weight: 500; color: var(--muted); padding: 8px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 12.5px; }
.tbl td { padding: 9px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl a { color: var(--primary); }

/* settings */
.rates { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.rate-r { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 170px) minmax(0, 150px); align-items: center; gap: 12px; }
.rate-avg { color: var(--muted); font-size: 12.5px; }
.rate-r.head { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.rate-c { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.rate-c small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate-r input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); outline: none; font-variant-numeric: tabular-nums; }
.rate-r input::placeholder { color: var(--amber); }
@media (max-width: 600px) { .rate-r { grid-template-columns: 84px minmax(0, 1fr) minmax(0, 96px); gap: 10px; } .rate-c small { display: none; } .rate-avg { font-size: 11.5px; } }
.cost-mode { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.more-cur { margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.more-cur summary { cursor: pointer; }
.more-cur .chips { margin-top: 10px; }
.rate-tbl { padding: 0 18px 14px; }
.rt-h, .rt-r { display: grid; grid-template-columns: 92px 1fr 1fr; gap: 10px; align-items: center; }
.rt-h { font-size: 12.5px; color: var(--muted); padding-bottom: 4px; }
.rt-r { padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 15px; }
.rt-r em { font-style: normal; color: var(--amber); font-size: 13px; }
.pad-x { padding: 0 18px 10px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.card-h .linkbtn { text-decoration: none; font-size: 13.5px; }
.plan-h, .plan-r { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.plan-h { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.plans { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.plan-r.del { opacity: .4; text-decoration: line-through; }

/* ===================== Modal & toast ===================== */
body.modal-open { overflow: hidden; }
.mdl-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(9, 15, 12, .45); display: grid; place-items: center; padding: 16px; animation: fade .14s ease-out; }
.mdl { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .45); }
.mdl.wide { width: min(680px, 100%); }
.mdl-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.mdl-h h2 { font-size: 17px; }
.mdl-h .icon-btn { border: 0; }
.mdl-b { padding: 6px 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.mdl-f { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.mdl-msg { line-height: 1.7; }
@keyframes fade { from { opacity: 0; } }
@media (max-width: 600px) {
  .mdl-wrap { align-items: end; padding: 0; }
  .mdl, .mdl.wide { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
  .mdl-f .btn { flex: 1; }
}
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); z-index: 80; opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--paper);
  box-shadow: 0 16px 34px -14px rgba(0, 0, 0, .5); max-width: min(92vw, 460px); transition: opacity .18s, transform .18s; font-size: 14px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); color: #fff; }
#toast.ok .ic { color: #7fe0bd; }
@media (max-width: 900px) { #toast { bottom: calc(92px + env(safe-area-inset-bottom)); } body.form-mode #toast { bottom: calc(150px + env(safe-area-inset-bottom)); } }

/* ===================== Login ===================== */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.login-mark { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: var(--note); color: var(--note-ink); }
.login-mark .ic { width: 26px; height: 26px; }
.login-card h1 { font-size: 26px; }
.login-err { color: var(--red); font-size: 14px; min-height: 1.2em; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

/* number of codes */
.stepper { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; height: 46px; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; background: var(--surface); }
.stepper button { border: 0; background: var(--surface-2); font-size: 22px; line-height: 1; color: var(--ink-2); }
.stepper button:hover { background: var(--primary-wash); color: var(--primary); }
.stepper:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.fld .stepper input:not([type=checkbox]):not([type=color]) { height: 44px; border: 0; border-radius: 0; box-shadow: none; text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* rates of the day */
.rate-date { max-width: 220px; margin-bottom: 14px; }
.today-tag { color: var(--green-ink); font-weight: 500; }

/* opening balances */
.su-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.su-r { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px); gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.su-r.three { grid-template-columns: minmax(0, 1fr) minmax(0, 150px) minmax(0, 160px); }
.su-r:last-child { border-bottom: 0; }
.su-n { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.su-n small { color: var(--muted); font-size: 12.5px; }
.su-r input { width: 100%; height: 44px; padding: 0 12px; padding-inline-end: 54px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); outline: none; font-variant-numeric: tabular-nums; }
.su-r input:focus { border-color: var(--primary); box-shadow: var(--focus); }
.su-ppl { margin: 4px -18px 14px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.su-done { display: flex; justify-content: flex-end; margin: 6px 0 40px; }
.su-done .btn { height: 50px; padding: 0 24px; font-size: 16px; }
@media (max-width: 600px) {
  .su-r, .su-r.three { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .su-r.three .su-n { grid-column: 1 / -1; }
  .su-done .btn { width: 100%; }
}
.info-line .num { font-weight: 600; }
.bal b.num { font-size: 22px; }
/* keep the input boxes close to their names on wide screens */
.su-rows, .rates, .rate-r.head { max-width: 640px; }

.su-o .row-a { margin-inline-start: 4px; }
.su-o .row-a .icon-btn { width: 36px; height: 36px; }
.su-tot { color: var(--muted); font-size: 13.5px; margin: -6px 0 14px; }
@media (max-width: 600px) { .su-o { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; } .su-o .row-a { grid-column: 2 / -1; justify-content: flex-end; } }
