/* Bills & Cards: the shared Gins look (Plus Jakarta Sans, brand #0B6B4E, shared light and dark palette).
   Violet #6D28D9 is used only on the app tile and the avatar (set through Gins.init). */
:root {
  --bg: #F4F7F5; --card: #FFFFFF; --line: #E1E8E4; --line2: #EEF2F0; --fg: #0E1C17; --muted: #52625C;
  --brand: #0B6B4E; --brand-fg: #FFFFFF; --soft: #E3ECE7; --input: #C9D4CF; --sel: #EEF6F2;
  --ok-bg: #E3F2EA; --ok-fg: #0B6B4E; --warn-bg: #FFF1D6; --warn-fg: #7A4D00; --bad-bg: #FDECEC; --bad-fg: #9B1C1C;
  --info-bg: #E8EEFB; --info-fg: #1E3A8A; --dot-bad: #B42318; --dot-warn: #B7791F; --dot-ok: #0B6B4E; --dot-auto: #9AA9A3;
  --accent: #6D28D9; --shadow: 0 10px 30px rgba(7, 43, 32, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1310; --card: #121E19; --line: #23332C; --line2: #1A2822; --fg: #E6EFEA; --muted: #9DB2A9;
    --brand: #3CC58F; --brand-fg: #062117; --soft: #1C2B25; --input: #33463E; --sel: #16302A;
    --ok-bg: #12322A; --ok-fg: #3CC58F; --warn-bg: #3A2C0E; --warn-fg: #F3C969; --bad-bg: #3B1717; --bad-fg: #F5B4B4;
    --info-bg: #1A2440; --info-fg: #A9C1F5; --dot-bad: #F5B4B4; --dot-warn: #F3C969; --dot-ok: #3CC58F; --dot-auto: #6B8379;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1310; --card: #121E19; --line: #23332C; --line2: #1A2822; --fg: #E6EFEA; --muted: #9DB2A9;
  --brand: #3CC58F; --brand-fg: #062117; --soft: #1C2B25; --input: #33463E; --sel: #16302A;
  --ok-bg: #12322A; --ok-fg: #3CC58F; --warn-bg: #3A2C0E; --warn-fg: #F3C969; --bad-bg: #3B1717; --bad-fg: #F5B4B4;
  --info-bg: #1A2440; --info-fg: #A9C1F5; --dot-bad: #F5B4B4; --dot-warn: #F3C969; --dot-ok: #3CC58F; --dot-auto: #6B8379;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--fg); font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .center { text-align: center; }
.okc { color: var(--ok-fg); } .badc { color: var(--bad-fg); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
svg { width: 20px; height: 20px; flex: none; }

/* ---------- shell: bottom tabs (phone), icon rail (iPad), sidebar (desktop) ---------- */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px calc(100px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(8px + env(safe-area-inset-bottom)); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; min-height: 50px; color: var(--muted); font-size: 11px; font-weight: 700; text-decoration: none; border-radius: 12px; min-width: 0; }
.nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a[aria-current="page"] { color: var(--brand); }
.nav svg { width: 22px; height: 22px; }
.nav .brand, .wide-only { display: none !important; }
.narrow-only { display: inline-flex; }
@media (min-width: 600px) {
  .shell { flex-direction: row; }
  .nav { position: sticky; top: 0; height: 100vh; height: 100dvh; width: 88px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 8px 18px; border-top: 0; border-right: 1px solid var(--line); }
  .nav a { width: 76px; flex: none; font-size: 10.5px; letter-spacing: -.01em; }
  .nav a[aria-current="page"] { background: var(--soft); }
  .nav .brand { display: grid !important; margin-bottom: 12px; }
  .nav .brand > span:last-child { display: none; }
  .nav a.wide-only { display: flex !important; }
  .nav a.me { margin-top: auto; width: auto; }
  .nav a.me .me-t { display: none; }
  .main { padding: 28px 28px 40px; max-width: 980px; }
  .narrow-only { display: none !important; }
}
.appic { width: 44px; height: 44px; border-radius: 13px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13.5px; text-decoration: none; flex: none; }
@media (min-width: 1100px) {
  .nav { width: 240px; align-items: stretch; padding: 24px 14px; }
  .nav .brand { display: flex !important; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding: 0 8px 18px; margin: 0; }
  .nav .brand > span:last-child { display: inline; }
  .nav a { width: auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; min-height: 42px; font-size: 14.5px; letter-spacing: 0; color: var(--fg); }
  .nav a[aria-current="page"] { color: var(--brand); }
  .nav a.me { gap: 10px; padding: 8px; min-height: 56px; }
  .nav a.me .me-t { display: flex; flex-direction: column; min-width: 0; }
  .nav a.me small { color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav .owners { display: flex !important; flex-direction: column; gap: 2px; margin-top: 16px; }
  .owners .lbl { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
  .owners button { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; font-size: 14px; text-align: left; }
  .owners button i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); }
  .owners button[aria-pressed="true"] { background: var(--soft); }
  .owners button[aria-pressed="true"] i { border-color: var(--brand); background: var(--brand); }
  .main { max-width: 1240px; padding: 28px 32px 40px; }
  .cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .due-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
  .pane { position: sticky; top: 24px; padding: 20px; max-height: calc(100vh - 48px); overflow: auto; }
}
.cols { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------- header, buttons, chips ---------- */
.top { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.top .ttl { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.top h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; line-height: 1.2; }
.top .sub { font-size: 13px; color: var(--muted); }
.top-r { display: flex; gap: 6px; align-items: center; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; color: var(--fg); text-decoration: none; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1.5px solid transparent; font-weight: 700; font-size: 14px; white-space: nowrap; text-decoration: none; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.primary { background: var(--brand); color: var(--brand-fg); }
.btn.line { background: var(--card); color: var(--fg); border-color: var(--line); }
.btn svg { width: 17px; height: 17px; }
.linkbtn { font-size: 13px; font-weight: 700; color: var(--brand); text-decoration: none; background: none; border: 0; padding: 6px 0; min-height: 32px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--card); color: var(--fg); font-weight: 700; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--soft); }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; font-weight: 700; font-size: 13.5px; padding: 0 10px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-fg); }
.seg.sm button { min-height: 34px; font-size: 13px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.owner-sel select { min-height: 36px; padding: 0 12px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 13px; }
.pill { border-radius: 6px; padding: 3px 8px; font-size: 11.5px; font-weight: 800; white-space: nowrap; background: var(--soft); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); } .pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); } .pill.info { background: var(--info-bg); color: var(--info-fg); }
.pill.muted { background: var(--soft); color: var(--muted); font-weight: 700; }
.pill.owner { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 99px; font-weight: 700; }

/* ---------- banners ---------- */
.banner { border-radius: 14px; padding: 10px 14px; font-size: 13.5px; background: var(--warn-bg); color: var(--warn-fg); overflow-wrap: anywhere; }
.banner.info { background: var(--info-bg); color: var(--info-fg); } .banner.bad { background: var(--bad-bg); color: var(--bad-fg); }
.banner.soft { background: var(--soft); color: var(--muted); }
.banner .linkbtn { color: inherit; text-decoration: underline; padding: 0 0 0 6px; min-height: 0; }

/* ---------- cards and lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; min-width: 0; }
.card.empty, .empty { padding: 22px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.list { display: flex; flex-direction: column; overflow: hidden; }
.badline { border-color: var(--bad-fg); }
.grp { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.grp > h2 { margin: 6px 4px 0; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.grp > h2.bad { color: var(--bad-fg); }
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.totals > div { display: flex; flex-direction: column; gap: 2px; padding: 12px; min-width: 0; }
.totals > div + div { border-left: 1px solid var(--line); }
.totals small { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.totals b { font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--soft); color: var(--brand); display: grid; place-items: center; flex: none; }

/* Due rows */
.drow { border-top: 1px solid var(--line); padding: 4px 0 10px; }
.drow:first-child { border-top: 0; }
.drow.dim { opacity: .6; } .drow.sel { background: var(--sel); }
.drow-main { width: 100%; display: flex; gap: 12px; padding: 10px 14px 4px; border: 0; background: transparent; text-align: left; color: inherit; }
.drow .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.drow .l1, .drow .l2 { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.drow .nm { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.drow .amt { font-size: 15px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.drow .l2 { font-size: 12.5px; color: var(--muted); }
.drow .l2 > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.drow .when { white-space: nowrap; font-weight: 600; } .drow .when.late { color: var(--bad-fg); }
.drow-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 2px 14px 0 66px; }
.drow-chips .btn { margin-left: auto; }

/* detail */
.detail { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.detail .kicker { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.detail h2 { font-size: 20px; font-weight: 800; overflow-wrap: anywhere; }
.detail h3, .ccard-b h3, .totals2 h3 { font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 2px 0 6px; }
.kv4, .kv3, .kv2 { display: grid; gap: 10px; }
.kv4 { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; border-radius: 14px; background: var(--soft); }
.kv3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv4 > span, .kv3 > span, .kv2 > span { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.kv4 small, .kv3 small, .kv2 small { font-size: 12px; color: var(--muted); }
.kv2 b { font-size: 22px; }
.note { font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.hrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--line2); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; }
.check > span { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; min-width: 0; overflow-wrap: anywhere; }
.check small { color: var(--muted); font-size: 12.5px; }
.check.ok { background: var(--ok-bg); color: var(--ok-fg); } .check.warn { background: var(--warn-bg); color: var(--warn-fg); } .check.bad { background: var(--bad-bg); color: var(--bad-fg); }
.check small { color: inherit; opacity: .85; }

/* cards screen */
.cgrid { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 900px) { .cgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
@media (min-width: 1300px) { .cgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ccard { background: var(--card); border: 1px solid var(--line); border-radius: 16px; min-width: 0; }
.ccard.open { border-color: var(--brand); } .ccard.dim { opacity: .55; }
.ccard-h { width: 100%; display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 0; background: transparent; text-align: left; color: inherit; }
.cchip { width: 46px; height: 32px; border-radius: 6px; color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; flex: none; }
.ccard .txt, .arow .txt, .srow .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ccard .nm, .arow .nm, .srow .nm { font-size: 15px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.ccard .sub, .arow .sub, .srow .sub, .loan .sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.ccard .end, .arow .end, .srow .end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; text-align: right; }
.ccard-b { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.dashed { min-height: 44px; border-radius: 12px; border: 1.5px dashed var(--line); background: transparent; color: var(--muted); font-weight: 700; font-size: 13px; }
.mini { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line2); font-size: 13.5px; flex-wrap: wrap; }
.mini:first-child { border-top: 0; }
.mini .nm { flex: 1; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }

/* accounts */
.arow { width: 100%; display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border: 0; border-top: 1px solid var(--line2); background: transparent; color: inherit; text-align: left; white-space: normal; }
.list > .arow:first-child { border-top: 0; }
.arow.dim { opacity: .6; } .arow.static { cursor: default; }
.arow .emi { font-size: 12px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; }

/* loans */
.loan { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.loan.flat { flex-direction: row; justify-content: space-between; align-items: center; }
.loan.flat .txt { display: flex; flex-direction: column; min-width: 0; }
.loan-h { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.loan-h h2 { font-size: 16px; font-weight: 800; }
.big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; margin: 6px 0 4px; }
.bar i { display: block; height: 6px; background: var(--brand); }

/* subscriptions */
.totals2 { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.barrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; font-size: 13px; }
.barrow .bar { grid-column: 1 / -1; margin: 4px 0 2px; }
.srow { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-top: 1px solid var(--line2); }
.list > .srow:first-child { border-top: 0; }
.srow .chips { margin-top: 3px; }

/* calendar */
.cal { padding: 8px; }
.cal-h, .cal-g { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.cal-h { font-size: 11.5px; font-weight: 800; color: var(--muted); padding: 4px 0 6px; }
.cday { height: 52px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--fg); }
.cday.out { visibility: hidden; }
.cday.today { outline: 2px solid var(--brand); outline-offset: -2px; font-weight: 800; }
.cday.sel { background: var(--soft); }
.cday .dots { display: flex; gap: 3px; height: 6px; }
.cday .dots i, .legend i, .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: none; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; padding: 10px 6px 4px; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; } .legend i { width: 8px; height: 8px; }
i.bad { background: var(--dot-bad); } i.warn { background: var(--dot-warn); } i.ok { background: var(--dot-ok); } i.auto { background: var(--dot-auto); }

/* Mark paid sheet */
.pay-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; text-align: left; }
.field input { font-weight: 600; font-size: 16px; padding: 11px 12px; border-radius: 12px; border: 1.5px solid var(--input); background: var(--card); color: var(--fg); min-width: 0; width: 100%; }
.note-preview { border-radius: 12px; background: var(--soft); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 13.5px; }
.note-preview .lbl { font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.note-preview .hint { font-size: 12px; color: var(--muted); }
.undo-bar { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); transform: translateX(-50%); z-index: 1100; display: flex; align-items: center; gap: 14px;
  background: #0E1C17; color: #fff; padding: 10px 10px 10px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.undo-bar button { border: 0; background: #3CC58F; color: #062117; font-weight: 800; border-radius: 10px; min-height: 36px; padding: 0 14px; }
@media (min-width: 600px) { .undo-bar { bottom: 24px; } }
