:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --text: #1a1f1c;
  --muted: #66706a;
  --border: #e1e5e0;
  --accent: #0f766e;
  --accent-soft: #d6efeb;
  --good: #15803d;
  --good-soft: #dcf2e3;
  --bad: #b42318;
  --bad-soft: #fde4e1;
  --warn: #a15c07;
  --warn-soft: #fdf0d5;
  --info-soft: #e5ecfb;
  --info: #2948a8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --on-accent: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #13916a;
  --save: #6250d6;
  --save-soft: #ebe8fb;
  --scrim: rgba(0,0,0,.45);
  --toast-bg: #1a1f1c;
  --toast-fg: #f5f6f4;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1110;
    --surface: #171b19;
    --surface-2: #1f2421;
    --text: #e8ece9;
    --muted: #98a29c;
    --border: #2a302d;
    --accent: #2dd4bf;
    --accent-soft: #123a35;
    --on-accent: #062b27;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #2fb487;
    --save: #9085e9;
    --save-soft: #25213f;
    --good: #4ade80;
    --good-soft: #14321f;
    --bad: #f87171;
    --bad-soft: #3a1714;
    --warn: #fbbf24;
    --warn-soft: #3a2c0d;
    --info-soft: #1a2442;
    --info: #93b0ff;
    --shadow: none;
    --scrim: rgba(0,0,0,.6);
    --toast-bg: #e8ece9;
    --toast-fg: #0e1110;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.row-gap { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

/* Brand */
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 800; }

/* Cards, buttons, inputs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .55rem .95rem; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .8rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.error { color: var(--bad); background: var(--bad-soft); padding: .5rem .7rem; border-radius: 8px; font-size: .9rem; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; padding: 1.5rem; }
.auth-card .brand { margin-bottom: 1.2rem; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: .3rem; }

/* Top bar */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .7rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.tabs { display: flex; gap: .2rem; overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: .5rem .8rem; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabs button.active { background: var(--accent-soft); color: var(--accent); }
.content { max-width: 920px; margin: 0 auto; padding-block: 1.2rem 5rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; gap: .5rem; padding-block: .6rem; }
  .tabs { margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding: 0 max(16px, env(safe-area-inset-left, 0px)); scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; padding: .45rem .7rem; font-size: .88rem; }
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin: 1.2rem 0 .8rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* Periods */
.period { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .9rem; box-shadow: var(--shadow); overflow: hidden; }
.period.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.period-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .9rem 1rem; background: var(--surface-2); flex-wrap: wrap; }
.period-head .title { font-weight: 700; }
.period-head .dates { font-size: .85rem; color: var(--muted); }
.period-nums { display: flex; gap: 1.1rem; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .period-head { flex-direction: column; gap: .6rem; }
  .period-nums { display: grid; width: 100%; gap: .4rem; text-align: left; }
  .period-nums.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .period-nums.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .period-nums.cols-5 { grid-template-columns: repeat(5, 1fr); }
  .period-nums div strong { font-size: .95rem; }
}
.period-nums div span { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.period-nums div strong { font-size: 1.05rem; }
.meter { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; }
.meter.over > i { background: var(--bad); }
.meter.save > i { background: var(--save); }
.period > .meter { border-radius: 0; }
.item .meter, .occ .meter, .calc .meter { margin: .35rem 0 .25rem; }
.period-empty { padding: .9rem 1rem; color: var(--muted); font-size: .9rem; }

/* Rows */
.occ { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; border-top: 1px solid var(--border); }
.occ:first-child { border-top: 0; }
.occ .date { width: 48px; text-align: center; flex-shrink: 0; }
.occ .date b { display: block; font-size: 1.05rem; line-height: 1.1; }
.occ .date span { font-size: .7rem; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.occ .main { flex: 1; min-width: 0; }
.occ .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.occ .amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.occ.paid .name, .occ.paid .amt { color: var(--muted); }
.occ.paid .name { text-decoration: line-through; }
.occ .actions { display: flex; gap: .3rem; }

.badges { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .2rem; }
.badge { font-size: .7rem; font-weight: 700; padding: .12rem .45rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); letter-spacing: .01em; }
.badge.auto { background: var(--info-soft); color: var(--info); }
.badge.sub { background: var(--accent-soft); color: var(--accent); }
.badge.var { background: var(--warn-soft); color: var(--warn); }
.badge.paid { background: var(--good-soft); color: var(--good); }
.badge.late { background: var(--bad-soft); color: var(--bad); }
.badge.want { background: var(--surface-2); color: var(--muted); }

.list .item { display: flex; align-items: center; gap: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; margin-bottom: .55rem; box-shadow: var(--shadow); cursor: pointer; }
.list .item:hover { border-color: var(--accent); }
.list .item.inactive { opacity: .55; }
.list .item .main { flex: 1; min-width: 0; }
.list .item .meta { font-size: .82rem; color: var(--muted); }
.list .item .right { text-align: right; font-variant-numeric: tabular-nums; }
.list .item .right strong { display: block; }

.alert { border: 1px solid var(--bad); background: var(--bad-soft); border-radius: var(--radius); margin: 1rem 0 0; overflow: hidden; }
.alert .alert-head { padding: .7rem 1rem; font-weight: 700; color: var(--bad); }
.alert .occ { background: var(--surface); }

.filters { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .6rem; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: .3rem .75rem; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .btn { margin-top: .8rem; }

/* Modal */
.modal-wrap { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; overflow: hidden; overscroll-behavior: contain; }
.modal { position: relative; width: 100%; max-width: 520px; padding: 1.4rem; max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* Close stays reachable while the dialog scrolls */
.modal .close { position: sticky; top: -.8rem; float: right; margin: -.8rem -.6rem 0 .5rem; width: 2.4rem; height: 2.4rem; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); font-size: 1.6rem; color: var(--muted); cursor: pointer; line-height: 1; z-index: 3; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: 1rem; }
.choice button { padding: 1.2rem .8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.choice button:hover { border-color: var(--accent); }
.choice button strong { display: block; font-size: 1.05rem; margin-bottom: .2rem; }
.choice button span { font-size: .82rem; color: var(--muted); }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.toggle { display: flex; align-items: flex-start; gap: .55rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 10px; margin: 0; cursor: pointer; color: var(--text); font-weight: 600; }
.toggle input { width: auto; margin: .15rem 0 0; accent-color: var(--accent); }
.toggle small { display: block; font-weight: 400; color: var(--muted); font-size: .76rem; }
.modal-actions { display: flex; justify-content: space-between; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: .3rem 0 1rem; }
.seg button { border: 0; background: var(--surface); padding: .45rem .9rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--accent); color: var(--on-accent); }
details summary { cursor: pointer; font-weight: 600; color: var(--muted); margin-bottom: .8rem; }

.toast { position: fixed; bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-fg); padding: .6rem 1rem; border-radius: 10px; font-weight: 600; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

/* Variable bills: tappable amount, estimate labels, amount entry */
.amt-btn { background: none; border: 1px dashed transparent; border-radius: 8px; padding: .2rem .4rem; font: inherit; font-weight: 700; color: var(--text); cursor: pointer; text-align: right; font-variant-numeric: tabular-nums; }
.amt-btn small { display: block; font-size: .68rem; font-weight: 600; color: var(--muted); }
.amt-btn.est { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.amt-btn.est small { color: var(--warn); }
.amt-btn:hover { border-color: var(--accent); }
.period-foot { display: flex; flex-direction: column; gap: .3rem; border-top: 1px solid var(--border); }
.est-note { color: var(--warn); }
.calc { border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.calc > div { display: flex; justify-content: space-between; align-items: baseline; }
.calc-input { margin: 0; }
.calc-total { border-top: 1px solid var(--border); padding-top: .6rem; font-size: 1.05rem; }
.hint { font-size: .8rem; color: var(--muted); margin: -.2rem 0 0; }
.hint.est { color: var(--warn); }
label small.muted { display: block; font-weight: 400; margin-top: .3rem; line-height: 1.35; }
.history { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; margin-bottom: 1rem; font-size: .85rem; }
.history-head { display: flex; justify-content: space-between; gap: .5rem; color: var(--muted); font-weight: 600; margin-bottom: .4rem; flex-wrap: wrap; }
.history-grid { display: grid; grid-template-columns: 1fr auto 1fr auto; column-gap: 1rem; gap: .2rem .6rem; }
.history-grid .num { text-align: right; }
.toggle.spaced { margin-bottom: 1rem; }

/* ---------- planning features ---------- */
.lead { margin: -.4rem 0 .8rem; max-width: 65ch; }
.badge.extra { background: var(--good-soft); color: var(--good); vertical-align: 2px; margin-left: .3rem; }
.badge.save { background: var(--save-soft); color: var(--save); }
.amt small { display: block; font-size: .68rem; font-weight: 600; color: var(--muted); }
.amt small.neg { color: var(--bad); }
.sub-head { padding: .5rem 1rem .3rem; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-top: 1px solid var(--border); background: var(--surface-2); }
.save-row .date span, .save-row .date b { color: var(--save); }
.save-row .date b { font-size: .8rem; }
.budget-row .main { padding-left: .1rem; }
.callout { display: flex; flex-direction: column; gap: .2rem; border: 1px solid var(--good); background: var(--good-soft); border-radius: var(--radius); padding: .8rem 1rem; margin-top: 1rem; }
.callout strong { color: var(--good); }
.callout a { font-weight: 600; font-size: .9rem; }
.alert-inline { padding: .7rem .9rem; border-radius: 10px; background: var(--bad-soft); font-weight: 600; }

.stats-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1rem; }
.label { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.review-head { display: flex; gap: 2rem; flex-wrap: wrap; margin-bottom: .6rem; }
.review-head strong { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.review .sub-head, .extra-card .sub-head { margin: .4rem -1rem 0; }
.review-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .65rem 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.review-row .main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 12rem; }
.review-row > .num { flex-shrink: 0; }
.review-row .meta { font-size: .82rem; color: var(--muted); }

.budget-item { align-items: center; }
.spend-list { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 1rem; max-height: 220px; overflow-y: auto; }
.spend { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; border-top: 1px solid var(--border); font-size: .9rem; }
.spend:first-child { border-top: 0; }
.spend > span:first-child { width: 3.6rem; color: var(--muted); flex-shrink: 0; }
.spend .main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.debt-plan h3 { margin-top: 1.2rem; }
.debt-plan .stats-3 { margin-top: .6rem; }
.payoff-order { margin: 0; padding-left: 1.3rem; }
.payoff-order li { padding: .25rem 0; }
.payoff-order li span:last-child { float: right; font-variant-numeric: tabular-nums; }

.members { display: flex; flex-direction: column; margin-bottom: .8rem; }
.member { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.member:first-child { border-top: 0; }
#member-form { margin-top: .6rem; }

/* ---------- reports & charts ---------- */
.report h3 { margin-bottom: .3rem; }
.report > .muted { margin-top: 0; }
.chart { position: relative; margin-top: .6rem; min-height: 230px; }
.chart svg { display: block; max-width: 100%; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .faded-text { opacity: .6; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.series-1 { stroke: var(--series-1); }
.chart .line.series-2 { stroke: var(--series-2); }
.chart .line.series-3 { stroke: var(--series-3); stroke-dasharray: 2 4; stroke-linecap: round; }
.chart .line.dashed { stroke-dasharray: 5 4; }
.chart .bar.series-1 { fill: var(--series-1); }
.chart .bar.series-2 { fill: var(--series-2); }
.chart .bar.faded { opacity: .4; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit.on { fill: var(--text); fill-opacity: .05; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.tip { position: absolute; top: 2rem; background: var(--toast-bg); color: var(--toast-fg); font-size: .8rem; font-weight: 600; padding: .35rem .55rem; border-radius: 8px; pointer-events: none; white-space: nowrap; z-index: 2; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.sw.series-1 { background: var(--series-1); }
.sw.series-2 { background: var(--series-2); }
.sw.series-3 { background: var(--series-3); }
.sw.dashed { background: linear-gradient(90deg, var(--series-2) 50%, transparent 50%) 0 50% / 6px 3px repeat-x; height: 3px; }
.sw.faded-key { background: var(--muted); opacity: .4; }

.hbars { display: flex; flex-direction: column; gap: .7rem; margin-top: .6rem; }
.hbar-label { display: flex; justify-content: space-between; gap: .8rem; font-size: .9rem; margin-bottom: .25rem; flex-wrap: wrap; }
.hbar-track { position: relative; height: 10px; background: var(--surface-2); border-radius: 999px; }
.hbar-track > i { display: block; height: 100%; width: 0; border-radius: 999px; }
.hbar-track > i.series-1 { background: var(--series-1); }
.hbar-track > i.over { background: var(--bad); }
.hbar-track .marker { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }

.table-wrap { overflow-x: auto; margin-top: .5rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: .4rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tr.muted td { color: var(--muted); }
.report details { margin-top: .6rem; }
ul.plain { margin: .4rem 0 0; padding-left: 1.1rem; }
ul.plain li { padding: .15rem 0; }

/* ---------- polish ---------- */
.badge { white-space: nowrap; }
.period-nums strong { white-space: nowrap; }
@media (max-width: 640px) { .period-nums.cols-5 div strong { font-size: .86rem; } .period-nums.cols-5 div span { font-size: .66rem; } }
@media (max-width: 520px) { .stats-3 { grid-template-columns: 1fr; } }
.save-row .name { white-space: normal; }
.chart .cross { opacity: 0; }
.chart.hovering .cross { opacity: 1; }

/* ---------- transactions & import ---------- */
.modal.wide { max-width: 760px; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-row input { flex: 1 1 14rem; min-width: 0; margin: 0; }
.search-row select { width: auto; margin: 0; }
.callout.info { border-color: var(--info); background: var(--info-soft); }
.callout.info strong { color: var(--info); }
.import-help { text-align: left; }
.import-help p { max-width: 60ch; }
.txn-list { margin-top: .4rem; }
.txn-date { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: .8rem 0 .3rem; }
.txn { display: flex; gap: .8rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .65rem .9rem; margin-bottom: .4rem; }
.txn.ignored { opacity: .55; }
.txn .main { flex: 1; min-width: 0; }
.txn .name { font-weight: 600; }
.txn .meta { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; flex-shrink: 0; max-width: 48%; }
.txn-side select { margin: 0; padding: .3rem .5rem; font-size: .82rem; width: auto; max-width: 100%; }
.rules, .batches { display: flex; flex-direction: column; margin: .4rem 0 .8rem; }
.rule, .batch { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--border); }
.batch .meta { display: block; font-size: .8rem; color: var(--muted); }
.rule-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.rule-form input { flex: 2 1 12rem; margin: 0; }
.rule-form select { flex: 1 1 10rem; margin: 0; }
.rule-form .error { flex-basis: 100%; }
details.card > summary { margin: 0; }
details.card[open] > summary { margin-bottom: .6rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; }
.mapping { border: 1px solid var(--border); border-radius: 12px; padding: .7rem .9rem .2rem; margin: 0 0 1rem; }
.mapping legend { font-weight: 700; padding: 0 .3rem; }
.import-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; margin-bottom: .8rem; }
.import-stats div { background: var(--surface-2); border-radius: 10px; padding: .5rem .6rem; }
.import-stats strong { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.import-stats span { font-size: .75rem; color: var(--muted); }
@media (max-width: 560px) { .import-stats { gap: .3rem; } .import-stats div { padding: .4rem; } .import-stats strong { font-size: 1rem; } .import-stats span { font-size: .68rem; } }
.review-list { border: 1px solid var(--border); border-radius: 12px; margin-bottom: .8rem; }
.review-txn { padding: .55rem .8rem; border-top: 1px solid var(--border); }
.review-txn:first-child { border-top: 0; }
.rt-top { display: flex; gap: .6rem; align-items: baseline; font-size: .9rem; }
.rt-top > span:first-child { width: 3.4rem; flex-shrink: 0; }
.rt-desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-bottom { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .3rem; padding-left: 4rem; }
.rt-bottom select { width: auto; max-width: 100%; margin: 0; padding: .3rem .5rem; font-size: .85rem; }
.always { display: inline-flex; gap: .3rem; align-items: center; font-size: .8rem; margin: 0; color: var(--text); font-weight: 500; }
.always input { width: auto; margin: 0; }
@media (max-width: 560px) { .rt-bottom { padding-left: 0; } }

.modal.wide .modal-actions { position: sticky; bottom: -1.4rem; background: var(--surface); margin: 0 -1.4rem -1.4rem; padding: .8rem 1.4rem 1rem; border-top: 1px solid var(--border); align-items: center; }
.stats-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1rem; }
@media (max-width: 520px) {
  .stats-compact { gap: .4rem; }
  .stats-compact .stat { padding: .6rem .7rem; }
  .stats-compact .value { font-size: 1.1rem; }
  .stats-compact .label, .stats-compact .sub { font-size: .72rem; }
}

/* ---------- import freshness ---------- */
.fresh-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: .35rem; vertical-align: 2px; flex-shrink: 0; }
.stat .fresh-dot, .fresh-chip .fresh-dot { margin: 0 .4rem 0 0; width: 10px; height: 10px; vertical-align: 1px; }
.fresh-dot.fresh { background: var(--good); }
.fresh-dot.aging { background: var(--warn); }
.fresh-dot.stale { background: var(--bad); }
.level-fresh { color: var(--good); }
.level-aging { color: var(--warn); }
.level-stale { color: var(--bad); }
.freshness, .fresh-legend { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin: -.4rem 0 1rem; }
.fresh-legend { margin: 0 0 .9rem; }
.fresh-chip { display: inline-flex; align-items: center; gap: .1rem; font-size: .82rem; padding: .3rem .65rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); white-space: nowrap; }
.fresh-chip strong { margin-right: .3rem; }
.fresh-chip.aging { border-color: var(--warn); background: var(--warn-soft); }
.fresh-chip.stale { border-color: var(--bad); background: var(--bad-soft); }
.callout.stale { border-color: var(--bad); background: var(--bad-soft); }
.callout.stale strong { color: var(--bad); }
.unit-input { display: flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 500; }
.unit-input input { width: 6rem; }

/* ---------- dialogs on phones: page frozen behind, one scroll area, bottom sheet ---------- */
body.modal-open { position: fixed; left: 0; right: 0; overflow: hidden; }
@media (max-width: 560px) {
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 92vh; max-height: 92dvh; border-radius: 18px 18px 0 0; margin: 0; padding-bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px)); }
  .modal.wide { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; padding-top: calc(1.4rem + env(safe-area-inset-top, 0px)); }
  .modal.wide .modal-actions { padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); bottom: calc(-1.4rem - env(safe-area-inset-bottom, 0px)); margin-bottom: calc(-1.4rem - env(safe-area-inset-bottom, 0px)); }
}

.list-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; min-height: 2rem; }

/* possible recurring payments */
.recur-card summary { cursor: pointer; }
.recur { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .6rem 0; border-top: 1px solid var(--border); }
.recur .main { min-width: 0; }
.recur .name { font-weight: 600; }
.recur .meta { font-size: .8rem; color: var(--muted); }
.recur-link { margin: 0; width: auto; max-width: 11rem; padding: .3rem .5rem; font-size: .85rem; }
.recur-acts { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; max-width: 55%; }
@media (max-width: 600px) { .recur { flex-direction: column; align-items: stretch; } .recur-acts { max-width: none; justify-content: flex-start; } }

/* bills: expandable row with linked transactions */
.bill-wrap { margin-bottom: .55rem; }
.list .bill-wrap .item { margin-bottom: 0; }
.bill-wrap.open .item { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-color: transparent; }
.chev { width: .55rem; height: .55rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: 0 .2rem .2rem .2rem; flex-shrink: 0; transition: transform .15s; }
.bill-wrap.open .chev { transform: rotate(225deg); margin-top: .3rem; margin-bottom: 0; }
.bill-detail { background: var(--surface); border: 1px solid var(--border); border-top: 1px dashed var(--border); border-radius: 0 0 12px 12px; padding: .7rem 1rem .8rem; box-shadow: var(--shadow); }
.bill-detail-head { display: flex; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: .4rem; flex-wrap: wrap; }
.bill-txn { display: grid; grid-template-columns: 6.2rem 1fr auto 4.6rem; gap: .6rem; align-items: center; padding: .45rem 0; border-top: 1px solid var(--border); font-size: .88rem; }
.bill-txn .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.bill-txn .what { min-width: 0; display: flex; flex-direction: column; }
.bill-txn .desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-txn .meta { font-size: .76rem; color: var(--muted); }
.bill-txn .btn { justify-self: end; }
.bill-txn .m-when { display: none; }
@media (max-width: 600px) {
  .bill-txn { grid-template-columns: 1fr auto; grid-template-areas: "what amt" "what un"; row-gap: .2rem; }
  .bill-txn .what { grid-area: what; } .bill-txn strong { grid-area: amt; text-align: right; }
  .bill-txn .when { display: none; } .bill-txn .m-when { display: inline; }
  .bill-txn .btn, .bill-txn .unlink-gap { grid-area: un; }
}

/* debt: move-your-extra suggestion */
.debt-tip { background: var(--save-soft); border-color: transparent; box-shadow: none; margin: .7rem 0 .2rem; }
.debt-tip p { margin: .3rem 0 .6rem; }
#pay-mode-seg { margin: .6rem 0 .2rem; }
#pay-total { align-self: end; margin-bottom: .9rem; }

/* bills: custom "every N days/weeks/months" */
.custom-every { display: flex; align-items: center; gap: .5rem; margin: -.2rem 0 .8rem; }
.custom-every input, .custom-every select { width: auto; margin: 0; }
.custom-every input { width: 5rem; }

/* transactions: collapsible list */
.txn-section { margin-top: .4rem; }
.txn-section > summary { list-style: none; display: flex; align-items: center; gap: .6rem; color: var(--text); padding: .6rem .2rem; margin: 0 0 .4rem;
  border-bottom: 1px solid var(--border); }
.txn-section > summary::-webkit-details-marker { display: none; }
.txn-section-title { font-size: 1.05rem; font-weight: 700; }
.txn-section > summary .chev { margin-left: auto; }
.txn-section[open] > summary .chev { transform: rotate(225deg); margin-top: .3rem; margin-bottom: 0; }
.txn-section:not([open]) > summary { margin-bottom: 1rem; }
.rule-form #rule-amount { flex: 0 1 8.5rem; }
.rule.editing { background: var(--accent-soft); border-radius: 8px; }
.rule .row-gap { flex-wrap: nowrap; flex-shrink: 0; gap: .2rem; }

/* "Create a rule?" prompt after sorting by hand */
.prompt-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: center; max-width: min(36rem, calc(100vw - 2rem)); z-index: 61; font-weight: 500; }
.prompt-bar .btn.ghost { color: var(--toast-fg); }
.prompt-bar { min-width: min(26rem, calc(100vw - 2rem)); }
@media (max-width: 600px) { .prompt-bar { left: 1rem; right: 1rem; transform: none; min-width: 0; max-width: none; justify-content: space-between; } }

/* security */
.callout.danger { border-color: var(--bad); background: var(--bad-soft); }
.callout.danger strong { color: var(--bad); }
.sec-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; margin-left: .35rem; vertical-align: middle; background: var(--warn); }
.sec-dot.alert { background: var(--bad); }
.sec-summary { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: .6rem .8rem; border-radius: 10px; background: var(--good-soft); }
.sec-summary.warn { background: var(--warn-soft); } .sec-summary.danger { background: var(--bad-soft); }
.sec-summary.danger strong { color: var(--bad); }
#security h4 { margin: 1.1rem 0 .4rem; font-size: .95rem; }
.session, .audit-row { display: flex; gap: .6rem; align-items: center; padding: .5rem 0; border-top: 1px solid var(--border); }
.session .main, .audit-row .main { flex: 1; min-width: 0; }
.session .meta, .audit-row .meta { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.audit-row { align-items: flex-start; font-size: .9rem; }
.audit-row .sev { width: .55rem; height: .55rem; border-radius: 50%; margin-top: .4rem; flex-shrink: 0; background: var(--border); }
.audit-row.sev-warn .sev { background: var(--warn); }
.audit-row.sev-alert .sev { background: var(--bad); }
.audit-row.sev-alert .main > div:first-child { color: var(--bad); font-weight: 600; }
.audit-list { max-height: 28rem; overflow-y: auto; margin-bottom: .6rem; }
#revoke-others { margin-top: .5rem; }
