/* ==========================================================================
   RealTimeBudget — styles.css  (v2, mobile-first)
   No web fonts (nothing blocks first paint). System stack only.
   Color is reserved for budget STATUS: emerald ahead / indigo on-track /
   amber watch / rose over. Nothing else competes for those hues.
   ========================================================================== */

:root {
  --brand:        #4f46e5;
  --brand-600:    #4338ca;
  --brand-700:    #3730a3;
  --brand-soft:   #eef2ff;

  --ok:           #047857;
  --ok-soft:      #ecfdf5;
  --track:        #4338ca;
  --track-soft:   #eef2ff;
  --warn:         #b45309;
  --warn-soft:    #fffbeb;
  --over:         #be123c;
  --over-soft:    #fff1f2;

  --bg:           #f5f6fa;
  --surface:      #ffffff;
  --surface-2:    #fafbfd;
  --line:         #e5e7f0;
  --line-strong:  #d3d7e6;
  --text:         #161a2b;
  --text-2:       #565c74;
  --text-3:       #868ca2;

  --radius:       14px;
  --radius-lg:    20px;
  --shadow-sm:    0 1px 2px rgba(20,24,45,.06), 0 1px 3px rgba(20,24,45,.05);
  --shadow-md:    0 4px 16px rgba(20,24,45,.07), 0 1px 3px rgba(20,24,45,.05);
  --shadow-lg:    0 -6px 30px rgba(20,24,45,.16);
  --maxw:         1040px;
  --navh:         62px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --brand:        #818cf8;
  --brand-600:    #6366f1;
  --brand-700:    #4f46e5;
  --brand-soft:   #1f1c46;

  --ok:           #34d399;
  --ok-soft:      #062a20;
  --track:        #a5b4fc;
  --track-soft:   #1f1c46;
  --warn:         #fbbf24;
  --warn-soft:    #2c2006;
  --over:         #fb7185;
  --over-soft:    #2e0d17;

  --bg:           #0c0f1e;
  --surface:      #141930;
  --surface-2:    #191f3a;
  --line:         #252c48;
  --line-strong:  #333b5e;
  --text:         #eceff8;
  --text-2:       #a2a9c3;
  --text-3:       #7b8299;
  --shadow-lg:    0 -6px 30px rgba(0,0,0,.55);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
h2 { font-size: 1rem; }
p  { margin: 0 0 10px; }

.muted-sm { color: var(--text-3); font-size: .78rem; }
.hint { color: var(--text-2); font-size: .84rem; margin: 12px 0 0; line-height: 1.55; }
.lead { color: var(--text-2); font-size: .88rem; margin-bottom: 14px; max-width: 60ch; }

/* --------------------------- System warning bar ------------------------ */
.sysbar {
  background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font-size: .82rem; padding: 10px 16px; text-align: center;
}

/* ============================== SETUP GATE ============================= */
.setup {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 28px 18px calc(28px + env(safe-area-inset-bottom));
  background:
    radial-gradient(1100px 460px at 50% -12%, var(--brand-soft), transparent 70%),
    var(--bg);
}
.setup[hidden] { display: none; }
.setup-inner { width: 100%; max-width: 430px; }
.setup-step[hidden] { display: none; }
.setup-logo { color: var(--brand); margin-bottom: 16px; }
.setup h1 { font-size: 1.72rem; line-height: 1.18; margin-bottom: 10px; letter-spacing: -.03em; }
.setup-lead { color: var(--text-2); font-size: .92rem; margin-bottom: 22px; }
.setup-kicker { font-size: .78rem; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }
.setup-number {
  font-size: clamp(3.2rem, 17vw, 4.4rem); font-weight: 770; letter-spacing: -.045em;
  line-height: 1.02; color: var(--brand); font-variant-numeric: tabular-nums; margin-bottom: 6px;
}
.setup-sub { color: var(--text-2); font-size: .92rem; margin-bottom: 20px; }
.setup-error { color: var(--over); font-size: .84rem; font-weight: 600; margin: 4px 0 10px; }
.setup-error[hidden] { display: none; }

.bank-card {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px;
}
.bank-card h2 { font-size: .98rem; margin-bottom: 8px; }
.bank-card p { font-size: .88rem; color: var(--text-2); }

.privacy-line {
  font-size: .78rem; color: var(--text-3); text-align: center;
  margin: 18px 0 0; line-height: 1.5;
}
.privacy-inline { text-align: left; margin: 12px 2px 0; }

.quickdates { display: flex; gap: 8px; margin: -4px 0 14px; flex-wrap: wrap; }

/* ================================ TOPBAR =============================== */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 54px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 1rem; letter-spacing: -.02em; }
.brand-mark { color: var(--brand); display: flex; }
.brand-text { font-weight: 450; }
.brand-text strong { font-weight: 750; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.chip {
  font-size: .72rem; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 11px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
}

/* ================================ VIEWS ================================ */
main { padding-top: 16px; padding-bottom: calc(var(--navh) + 34px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.is-active { display: block; animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

/* ============================== ALERTS ================================= */
.alert-zone { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.alert-zone:empty { margin-bottom: 0; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  border-radius: var(--radius); padding: 13px 14px;
  font-size: .88rem; line-height: 1.45; border: 1px solid transparent;
  animation: slideIn .28s cubic-bezier(.2,.8,.3,1);
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.alert-body { flex: 1; min-width: 0; }
.alert-body strong { display: block; margin-bottom: 2px; font-size: .92rem; }
.alert-x {
  background: none; border: 0; cursor: pointer; color: inherit; opacity: .55;
  font-size: 1.2rem; line-height: 1; padding: 4px 6px; margin: -4px -4px 0 0; border-radius: 8px;
}
.alert-x:hover { opacity: 1; }
.alert-info  { background: var(--brand-soft); color: var(--brand-700); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.alert-ok    { background: var(--ok-soft);    color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-warn  { background: var(--warn-soft);  color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.alert-over  { background: var(--over-soft);  color: var(--over);  border-color: color-mix(in srgb, var(--over) 32%, transparent); }
html[data-theme="dark"] .alert-info { color: var(--text); }

/* ============================== GLANCE ================================= */
.glance {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 20px 18px 18px;
  box-shadow: var(--shadow-md); border-top: 4px solid var(--track);
  transition: border-color .3s ease;
}
.glance[data-status="ahead"] { border-top-color: var(--ok); }
.glance[data-status="watch"] { border-top-color: var(--warn); }
.glance[data-status="over"]  { border-top-color: var(--over); }
.glance[data-status="ended"] { border-top-color: var(--text-3); }

.glance-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.glance-label { font-size: .74rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.status-pill {
  font-size: .74rem; font-weight: 750; padding: 5px 11px; border-radius: 999px;
  background: var(--track-soft); color: var(--track); white-space: nowrap;
}
.status-pill[data-status="ahead"] { background: var(--ok-soft);   color: var(--ok); }
.status-pill[data-status="watch"] { background: var(--warn-soft); color: var(--warn); }
.status-pill[data-status="over"]  { background: var(--over-soft); color: var(--over); }
.status-pill[data-status="ended"] { background: var(--surface-2); color: var(--text-3); }

.glance-number {
  font-size: clamp(3rem, 15vw, 4.6rem); font-weight: 770; letter-spacing: -.045em;
  line-height: 1.02; margin: 6px 0 2px; font-variant-numeric: tabular-nums;
  color: var(--text); transition: color .3s ease;
}
.glance[data-status="ahead"] .glance-number { color: var(--ok); }
.glance[data-status="watch"] .glance-number { color: var(--warn); }
.glance[data-status="over"]  .glance-number { color: var(--over); }
.glance[data-status="ended"] .glance-number { color: var(--text-3); }
.glance-number.pulse { animation: pulse .45s cubic-bezier(.2,.8,.3,1); }
@keyframes pulse { 0% { transform: scale(1); } 38% { transform: scale(1.045); } 100% { transform: scale(1); } }

.glance-sub { color: var(--text-2); font-size: .88rem; margin-bottom: 16px; }

.meter { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; height: 100%; background: var(--track); border-radius: 999px; transition: width .45s cubic-bezier(.2,.8,.3,1), background .3s ease; }
.glance[data-status="ahead"] .meter-fill { background: var(--ok); }
.glance[data-status="watch"] .meter-fill { background: var(--warn); }
.glance[data-status="over"]  .meter-fill { background: var(--over); }
.meter-pace { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); opacity: .5; border-radius: 2px; transition: left .4s ease; }

.glance-stats {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 10px;
  margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px;
}
.gstat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gstat-label { font-size: .72rem; color: var(--text-3); }
.gstat-value { font-size: 1rem; font-weight: 660; font-variant-numeric: tabular-nums; }

.pace-note {
  margin-top: 14px; padding: 11px 13px; border-radius: 11px;
  font-size: .85rem; font-weight: 600; line-height: 1.45;
  background: var(--warn-soft); color: var(--warn);
}
.pace-note[hidden] { display: none; }
.pace-note.is-ok { background: var(--ok-soft); color: var(--ok); }

/* ================================= ADS ================================= */
.ad-slot { margin: 18px 0; text-align: center; }
.ad-tag { display: block; font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.ad-box {
  min-height: 100px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-3);
  font-size: .78rem; padding: 12px; overflow: hidden;
}

/* ================================ CARDS ================================ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 16px 18px;
  box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.accent-card { border-left: 3px solid var(--brand); }
.notif-card { border-left: 3px solid var(--brand); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 1fr; gap: 0; }

.seg-nav { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.seg-nav::-webkit-scrollbar { display: none; }
.seg {
  font-size: .82rem; font-weight: 620; text-decoration: none; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 999px; white-space: nowrap;
}

/* ================================ FORMS ================================ */
.grid-form { display: grid; grid-template-columns: 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin-bottom: 12px; }
.field > span { font-size: .78rem; font-weight: 620; color: var(--text-2); }

input[type="text"], input[type="number"], input[type="date"], input[type="file"], select {
  font: inherit; font-size: 16px; /* 16px stops iOS zoom-on-focus */
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: 11px;
  padding: 12px 12px; width: 100%; min-width: 0; min-height: 46px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }

.input-with-prefix { display: flex; gap: 8px; }
.prefix-select { width: 108px; flex: 0 0 auto; }
.select-sm { font-size: .84rem; padding: 8px 10px; min-height: 40px; width: auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: .9rem; font-weight: 650; cursor: pointer;
  border-radius: 12px; padding: 11px 16px; border: 1px solid transparent;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-quiet { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.btn-danger { background: var(--over-soft); color: var(--over); border-color: color-mix(in srgb, var(--over) 35%, transparent); }
.btn-lg { font-size: 1rem; padding: 15px 20px; min-height: 52px; border-radius: 14px; }
.btn-sm { padding: 8px 12px; font-size: .8rem; min-height: 38px; }
.btn-block { width: 100%; margin-bottom: 10px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.chip-btn {
  font: inherit; font-size: .82rem; font-weight: 620; cursor: pointer;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 9px 14px; min-height: 40px;
  white-space: nowrap; flex: 0 0 auto;
}
.chip-btn.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ============================== DATA ROWS ============================== */
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .87rem; }
.kv:last-of-type { border-bottom: 0; }
.kv span { color: var(--text-2); }
.kv b { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; }
.kv-total { border-top: 1px solid var(--line); border-bottom: 0; margin-top: 4px; padding-top: 10px; }
.kv-total b { color: var(--brand); }

.totals-row {
  display: flex; gap: 20px; flex-wrap: wrap;
  padding: 12px 13px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.totals-row > div { display: flex; flex-direction: column; gap: 1px; }
.totals-row span { font-size: .7rem; color: var(--text-3); }
.totals-row b { font-size: 1rem; font-variant-numeric: tabular-nums; }

.txn-list { display: flex; flex-direction: column; }
.txn { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.txn:last-child { border-bottom: 0; }
.txn-main { flex: 1; min-width: 0; }
.txn-title { font-size: .92rem; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-meta { font-size: .75rem; color: var(--text-3); display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.txn-amt { font-variant-numeric: tabular-nums; font-weight: 680; font-size: .95rem; white-space: nowrap; }
.txn-amt.is-cashout { color: var(--brand); }
.txn-del { background: none; border: 0; cursor: pointer; color: var(--text-3); font-size: 1.3rem; line-height: 1; width: 40px; height: 40px; border-radius: 9px; flex: 0 0 auto; }

.tag { font-size: .66rem; font-weight: 680; padding: 2px 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.tag.tag-muted { background: var(--surface-2); color: var(--text-3); }
.tag.tag-warn  { background: var(--warn-soft); color: var(--warn); }

.empty { padding: 20px 4px; color: var(--text-3); font-size: .86rem; text-align: center; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 104px 1fr 76px; gap: 9px; align-items: center; font-size: .82rem; }
.bar-track { height: 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 999px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 620; }

.streak { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.streak-num { font-size: 2.4rem; font-weight: 770; letter-spacing: -.04em; color: var(--brand); line-height: 1; }
.streak-cap { font-size: .8rem; color: var(--text-2); }

.history-list { display: flex; flex-direction: column; gap: 9px; }
.hrow { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.hrow-date { font-size: .83rem; font-weight: 620; }
.hrow-bar { grid-column: 1 / -1; }
.hrow-amt { font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--text-2); }
.hrow-badge { font-size: .7rem; font-weight: 720; padding: 4px 9px; border-radius: 999px; }
.hrow-badge.ok { background: var(--ok-soft); color: var(--ok); }
.hrow-badge.over { background: var(--over-soft); color: var(--over); }

.callout {
  margin-top: 12px; padding: 13px 15px; border-radius: var(--radius);
  background: var(--brand-soft); color: var(--brand-700);
  font-size: .88rem; font-weight: 570; line-height: 1.5;
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}
html[data-theme="dark"] .callout { color: var(--text); }

.footer { padding: 16px 2px 4px; font-size: .78rem; color: var(--text-3); text-align: center; }
.footer-links { display: flex; gap: 14px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.footer-links a, .hint a, .lead a { color: var(--brand); text-decoration: none; }
.footer-links a:hover, .hint a:hover, .lead a:hover { text-decoration: underline; }

/* ========================== MONEY MOVES / OFFERS ======================= */
.signal-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.signal {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 12px;
}
.signal-label { font-size: .7rem; color: var(--text-3); }
.signal-value { font-size: .95rem; font-weight: 660; font-variant-numeric: tabular-nums; }

.offer-card { border-left: 3px solid var(--brand); }
.offer-why { font-size: .88rem; color: var(--text-2); line-height: 1.55; margin-bottom: 14px; }
.risk-note {
  font-size: .82rem; font-weight: 600; line-height: 1.5;
  background: var(--warn-soft); color: var(--warn);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.offer-empty {
  font-size: .82rem; color: var(--text-3); line-height: 1.55;
  border: 1px dashed var(--line-strong); border-radius: 11px;
  padding: 12px 13px; background: var(--surface-2);
}
.offer-empty strong { color: var(--text-2); }
.offer-row {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.offer-main { min-width: 0; }
.offer-title-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.offer-name { font-size: .95rem; font-weight: 660; }
.offer-blurb { font-size: .85rem; color: var(--text-2); margin-bottom: 6px; line-height: 1.5; }
.offer-note { font-size: .74rem; color: var(--text-3); margin-bottom: 6px; }
.offer-cta { align-self: flex-start; text-decoration: none; }
.disclosure-card { background: var(--surface-2); }

.import-preview { margin: 12px 0; max-height: 340px; overflow-y: auto; }

/* ============================ CONTENT PAGES =========================== */
.page { max-width: 720px; margin: 0 auto; padding: 26px 18px 60px; }
.page h1 { font-size: 1.9rem; line-height: 1.18; letter-spacing: -.03em; margin-bottom: 10px; }
.page h2 { font-size: 1.18rem; margin: 30px 0 10px; }
.page h3 { font-size: 1rem; margin: 22px 0 8px; }
.page p, .page li { font-size: 1rem; line-height: 1.68; color: var(--text-2); }
.page p { margin-bottom: 16px; }
.page ul, .page ol { padding-left: 22px; margin-bottom: 16px; }
.page li { margin-bottom: 8px; }
.page strong { color: var(--text); }
.page a { color: var(--brand); }
.page hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
.page-kicker { font-size: .74rem; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); margin-bottom: 8px; }
.page-meta { font-size: .82rem; color: var(--text-3); margin-bottom: 28px; }
.page blockquote {
  margin: 0 0 18px; padding: 14px 18px; border-left: 3px solid var(--brand);
  background: var(--surface); border-radius: 0 12px 12px 0;
}
.page blockquote p { margin: 0; font-size: .95rem; }

.sitebar { background: var(--surface); border-bottom: 1px solid var(--line); }
.sitebar-inner { max-width: 720px; margin: 0 auto; padding: 0 18px; height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sitebar a { text-decoration: none; }
.sitebar-links { display: flex; gap: 14px; font-size: .85rem; font-weight: 600; }
.sitebar-links a { color: var(--text-2); }
.sitebar-links a:hover { color: var(--brand); }

.post-list { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.post-item {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .06s;
}
.post-item:hover { border-color: var(--brand); }
.post-item:active { transform: translateY(1px); }
.post-item h2 { font-size: 1.08rem; margin: 0 0 6px; color: var(--text); }
.post-item p { font-size: .88rem; color: var(--text-2); margin: 0 0 8px; line-height: 1.55; }
.post-date { font-size: .74rem; color: var(--text-3); }

.cta-band {
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
  border-radius: var(--radius); padding: 20px 22px; margin: 30px 0;
}
.cta-band h2 { margin-top: 0; }
.cta-band p { margin-bottom: 14px; }

/* ============================== ASSISTANT ============================= */
.asst-fab {
  position: fixed; right: 14px; z-index: 45;
  bottom: calc(var(--navh) + 16px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: .82rem; font-weight: 680; cursor: pointer;
  background: var(--surface); color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
  border-radius: 999px; padding: 10px 15px 10px 12px; min-height: 44px;
  box-shadow: 0 6px 20px rgba(20,24,45,.16);
}
.asst-fab svg { width: 19px; height: 19px; }
.asst-fab.is-open { background: var(--brand); color: #fff; border-color: var(--brand); }

.asst-panel {
  position: fixed; z-index: 55;
  left: 10px; right: 10px;
  bottom: calc(var(--navh) + 16px + env(safe-area-inset-bottom));
  max-height: min(76vh, 620px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: 0 20px 60px rgba(20,24,45,.28);
  overflow: hidden;
  animation: asstIn .2s cubic-bezier(.2,.8,.3,1);
}
.asst-panel[hidden] { display: none; }
@keyframes asstIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.asst-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.asst-title { display: flex; align-items: center; gap: 8px; font-size: .92rem; font-weight: 700; }
.asst-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.asst-close {
  background: none; border: 0; cursor: pointer; color: var(--text-3);
  font-size: 1.5rem; line-height: 1; width: 40px; height: 40px; border-radius: 10px;
}
.asst-close:hover { background: var(--surface-2); color: var(--text); }

.asst-log { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.asst-msg { max-width: 88%; border-radius: 15px; padding: 10px 13px; font-size: .87rem; line-height: 1.55; }
.asst-msg p { margin: 0 0 9px; white-space: pre-line; }
.asst-msg p:last-child { margin-bottom: 0; }
.asst-bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-bottom-left-radius: 5px; }
.asst-me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.asst-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.asst-action {
  font: inherit; font-size: .78rem; font-weight: 650; cursor: pointer;
  background: var(--brand); color: #fff; border: 0;
  border-radius: 999px; padding: 8px 13px; min-height: 36px;
}

.asst-chips {
  display: flex; gap: 7px; padding: 0 14px 10px; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none; flex: 0 0 auto;
}
.asst-chips::-webkit-scrollbar { display: none; }
.asst-chips:empty { display: none; }
.asst-chip {
  font: inherit; font-size: .78rem; font-weight: 620; cursor: pointer;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 8px 13px; min-height: 36px; white-space: nowrap; flex: 0 0 auto;
}
.asst-chip:hover { border-color: var(--brand); color: var(--brand); }

.asst-form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); flex: 0 0 auto; }
.asst-form input { flex: 1; min-height: 44px; border-radius: 12px; }
.asst-send {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  background: var(--brand); color: #fff; border: 0;
  display: flex; align-items: center; justify-content: center;
}
.asst-send svg { width: 20px; height: 20px; }
.asst-foot { font-size: .68rem; color: var(--text-3); text-align: center; margin: 0; padding: 0 14px 11px; line-height: 1.45; }

@media (min-width: 760px) {
  .asst-fab { right: 24px; bottom: calc(var(--navh) + 24px); }
  .asst-panel { left: auto; right: 24px; width: 400px; bottom: calc(var(--navh) + 24px); }
}

.inline-disclosure {
  font-size: .78rem; color: var(--text-3); line-height: 1.55;
  border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 13px; background: var(--surface-2); margin-bottom: 24px;
}

/* =========================== BOTTOM NAV + FAB ========================== */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--navh) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.bnav {
  background: none; border: 0; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); height: var(--navh); padding: 0; min-width: 44px;
}
.bnav svg { width: 22px; height: 22px; }
.bnav span { font-size: .66rem; font-weight: 620; letter-spacing: .01em; }
.bnav.is-active { color: var(--brand); }

.fab {
  justify-self: center;
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 45%, transparent);
  margin-top: -22px; transition: transform .1s;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.94); }

/* ============================== ADD SHEET ============================== */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10,13,26,.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeBg .18s ease;
}
.sheet-backdrop[hidden] { display: none; }
@keyframes fadeBg { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%; max-width: 480px;
  background: var(--surface); color: var(--text);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom));
  max-height: 94vh; max-height: 94dvh; overflow-y: auto;
  animation: sheetUp .26s cubic-bezier(.2,.8,.3,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grab { width: 40px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 4px auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sheet-title { font-size: .9rem; font-weight: 680; }

.amount-display {
  display: flex; align-items: baseline; justify-content: center; gap: 3px;
  padding: 12px 0 2px; font-variant-numeric: tabular-nums;
}
.amount-cur { font-size: 1.6rem; font-weight: 620; color: var(--text-3); }
.amount-val { font-size: 3.1rem; font-weight: 760; letter-spacing: -.04em; line-height: 1; }
.amount-left { text-align: center; font-size: .8rem; color: var(--text-3); margin-bottom: 12px; min-height: 18px; }
.amount-left.is-over { color: var(--over); font-weight: 650; }

.chip-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.chip-row:empty { display: none; }
.chip-row-scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip-row-scroll::-webkit-scrollbar { display: none; }
.sheet-field { margin-bottom: 10px; }
.sheet-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.seg-toggle { display: flex; gap: 6px; }
.segbtn {
  font: inherit; font-size: .8rem; font-weight: 620; cursor: pointer;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 9px 13px; min-height: 42px; white-space: nowrap;
}
.segbtn.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.date-inline { flex: 1; min-height: 42px; padding: 8px 10px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.keypad button {
  font: inherit; font-size: 1.5rem; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 13px;
  height: 56px; display: flex; align-items: center; justify-content: center;
}
.keypad button:active { background: var(--brand-soft); border-color: var(--brand); }

/* ================================ TOAST ================================ */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--navh) + 18px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg);
  padding: 11px 12px 11px 18px; border-radius: 999px;
  font-size: .86rem; font-weight: 620; z-index: 70;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.28); max-width: 92vw;
}
.toast[hidden] { display: none; }
.toast-undo {
  font: inherit; font-size: .82rem; font-weight: 750; cursor: pointer;
  background: color-mix(in srgb, var(--bg) 22%, transparent); color: var(--bg);
  border: 0; border-radius: 999px; padding: 7px 13px; min-height: 34px;
}
.toast-undo[hidden] { display: none; }

/* ============================== DESKTOP =============================== */
@media (min-width: 760px) {
  .wrap { padding: 0 24px; }
  main { padding-top: 22px; padding-bottom: calc(var(--navh) + 44px); }
  .topbar-inner { height: 60px; }
  .glance { padding: 26px 26px 22px; }
  .glance-stats { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .cols { grid-template-columns: 1fr 1fr; gap: 14px; }
  .grid-form { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
  .field { margin-bottom: 0; }
  .card { padding: 18px 20px 20px; }
  .bar-row { grid-template-columns: 150px 1fr 90px; }
  .signal-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .offer-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 20px; }
  .offer-cta { align-self: center; flex: 0 0 auto; }
  .page h1 { font-size: 2.3rem; }
  .hrow { grid-template-columns: 160px 1fr 130px 96px; }
  .hrow-bar { grid-column: auto; }
  .hrow-amt { text-align: right; }

  /* On desktop the bottom bar becomes a slim top-anchored rail at the bottom
     of the viewport; the FAB stays, because it is the primary action. */
  .bottombar { max-width: var(--maxw); left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; border: 1px solid var(--line); border-bottom: 0; }
  .toast { bottom: calc(var(--navh) + 22px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
