:root {
  --bg: #f7f4ef;
  --bg-2: #f3eef6;
  --card: rgba(255, 255, 255, 0.94);
  --ink: #101828;
  --muted: #667085;
  --border: rgba(16, 24, 40, 0.10);
  --primary: #091225;
  --plum: #5d1f69;
  --purple-2: #8e35ff;
  --bronze: #c67b31;
  --gold: #f2b94b;
  --green: #067647;
  --orange: #b54708;
  --red: #b42318;
  --blue: #175cd3;
  --cyan: #2e90fa;
  --soft-red: #fef3f2;
  --shadow: 0 18px 50px rgba(17, 24, 39, .10);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  padding-bottom: 96px;
  background:
    radial-gradient(circle at 6% 0%, rgba(93, 31, 105, .15), transparent 32%),
    radial-gradient(circle at 100% 8%, rgba(198, 123, 49, .15), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, #fbfaf8 46%, var(--bg-2) 100%);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px 16px 16px;
  background: linear-gradient(135deg, #07101f 0%, #16213f 34%, #4b164c 100%);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: 0 14px 34px rgba(11, 17, 32, .24);
}
.brand-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 18px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, #ffd875, #f6a800 70%);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 14px 22px rgba(0,0,0,.2);
}
.brand-h {
  font-size: 26px; font-weight: 700; color: rgba(255,255,255,.96); letter-spacing: -.03em;
  text-shadow: 0 1px 0 rgba(0,0,0,.1);
}
.brand-copy { min-width: 0; }
.eyebrow {
  margin: 0 0 3px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: #d5c1df;
}
h1 {
  margin: 0;
  font-size: clamp(24px, 5.6vw, 31px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -.03em;
}
.brand-subtitle {
  margin: 2px 0 0;
  font-size: clamp(20px, 4.8vw, 26px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.03em;
}

.brand-tagline {
  margin: 5px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #d5c1df;
}

h2 { margin: 2px 0; font-size: 25px; font-weight: 300; letter-spacing: -.02em; }
h3 { margin: 0 0 12px; font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
main { padding: 14px; max-width: 980px; margin: 0 auto; }
.tab-section { display: none; }
.tab-section.active { display: block; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(255,255,255,.65), 0 12px 28px rgba(17, 24, 39, .06);
  backdrop-filter: blur(14px);
}
.month-panel {
  border-color: rgba(75,22,76,.16);
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(250,245,255,.90));
}
.month-panel label, label {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
  color: #344054;
  margin-bottom: 7px;
}
select, input {
  width: 100%;
  border: 1px solid #d7d0dc;
  border-radius: 15px;
  background: rgba(255,255,255,.96);
  padding: 12px 13px;
  font-family: var(--sans);
  font-size: 16px;
  outline: none;
  margin-top: 6px;
  color: var(--ink);
}
select:focus, input:focus { border-color: #7f4a88; box-shadow: 0 0 0 4px rgba(75, 22, 76, .12); }

.icon-badge {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border-radius: 14px; color: #fff; font-size: 17px; flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 10px 18px rgba(17,24,39,.14);
  border: 1px solid rgba(255,255,255,.28);
}
.icon-badge span { transform: translateY(-.5px); }
.icon-trend { background: linear-gradient(135deg, #7c3aed, #d946ef); }
.icon-rules { background: linear-gradient(135deg, #12b76a, #32d583); }
.icon-planner { background: linear-gradient(135deg, #3b82f6, #7c3aed); }
.icon-cards { background: linear-gradient(135deg, #6d28d9, #2563eb); }
.icon-average { background: linear-gradient(135deg, #f59e0b, #fb7185); }
.icon-fixed { background: linear-gradient(135deg, #0f766e, #22c55e); }
.icon-edit { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.icon-income { background: linear-gradient(135deg, #f59e0b, #d97706); }
.icon-inflows { background: linear-gradient(135deg, #14b8a6, #06b6d4); }
.icon-goals { background: linear-gradient(135deg, #ef4444, #f97316); }
.icon-backup { background: linear-gradient(135deg, #344054, #667085); }

.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi-grid.two { margin-bottom: 0; }
.kpi {
  position: relative; overflow: hidden; background: #fff; border: 1px solid var(--border);
  border-radius: 19px; padding: 15px; min-height: 104px;
}
.kpi::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 76px; height: 76px;
  border-radius: 28px; opacity: .14; background: var(--plum);
}
.kpi::before { position: absolute; right: 15px; top: 12px; z-index: 1; font-size: 20px; }
.kpi-inflow::before { content: "↙"; color: var(--green); }
.kpi-outflow::before { content: "↗"; color: var(--red); }
.kpi-fixed::before { content: "◆"; color: var(--bronze); }
.kpi-card::before { content: "▰"; color: var(--plum); }
.kpi-net::before { content: "∑"; color: var(--blue); }
.kpi span, .label {
  display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 0 0 7px;
}
.kpi strong, .insight-card strong {
  display: block; font-family: var(--mono); font-size: 22px; font-weight: 500; letter-spacing: -.04em;
}
.status-panel { display: grid; gap: 14px; }
.muted, .hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; line-height: 1.42; }
.hint { font-family: var(--mono); font-size: 12px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.snapshot-list { display: grid; gap: 10px; }
.snapshot-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 13px;
  background: #fff;
  display: grid;
  gap: 10px;
}
.snapshot-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.snapshot-head strong { font-family: var(--mono); font-weight: 500; font-size: 13px; }
.snapshot-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.snapshot-values div { background: #fafafa; border: 1px solid rgba(16,24,40,.06); border-radius: 14px; padding: 9px; min-width: 0; }
.snapshot-values span { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.snapshot-values strong { display: block; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-pill { font-family: var(--mono); font-size: 11px; padding: 5px 8px; border-radius: 999px; white-space: nowrap; }
.ok-pill { background: #ecfdf3; color: var(--green); }
.tight-pill { background: #fff6ed; color: var(--orange); }
.negative-pill { background: #fef3f2; color: var(--red); }
.amount-row { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 12px; flex-wrap: wrap; }
.ok { color: var(--green); }
.tight { color: var(--orange); }
.negative { color: var(--red); }
.rules-panel ol { margin: 0; padding-left: 18px; }
.rules-panel li { margin: 8px 0; line-height: 1.35; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--border); text-align: right; font-family: var(--mono); font-size: 13px; }
th:first-child, td:first-child { text-align: left; }
th { background: #fbfafc; color: #344054; position: sticky; top: 0; font-weight: 500; }
td input { min-width: 112px; font-family: var(--mono); font-size: 13px; }
.list { display: grid; gap: 10px; }
.list-item {
  border: 1px solid var(--border); border-radius: 18px; padding: 13px; display: grid; gap: 6px; background: #fff;
}
.list-item-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list-title-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.badge { font-family: var(--mono); font-size: 12px; padding: 5px 9px; border-radius: 999px; background: #f4edf7; color: var(--plum); white-space: nowrap; }
.form-grid { display: grid; gap: 10px; margin-top: 12px; }
.card-field { border: 1px solid var(--border); padding: 12px; border-radius: 18px; background: #fff; }
.field-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.card-name { font-weight: 600; }
.brand-chip {
  width: 42px; height: 42px; border-radius: 14px; display: inline-grid; place-items: center; flex: 0 0 auto;
  color: #fff; font-family: var(--sans); font-weight: 700; font-size: 11px; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 10px 16px rgba(17,24,39,.12);
}
.chip-core { display: inline-block; transform: translateY(-.5px); }
.brand-chip.rbl { background: linear-gradient(135deg, #cc2d4a, #f44f6b); }
.brand-chip.kotak { background: linear-gradient(135deg, #0050a0, #e61d2b); font-size: 18px; }
.brand-chip.slice { background: linear-gradient(135deg, #111827, #52525b); font-size: 18px; text-transform: lowercase; }
.brand-chip.yes { background: linear-gradient(135deg, #0033a0, #2e90fa); font-size: 10px; }
.brand-chip.neutral { background: linear-gradient(135deg, #667085, #98a2b3); }

.mini-3d {
  width: 34px; height: 34px; border-radius: 12px; display: inline-grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 8px 16px rgba(17,24,39,.1);
  border: 1px solid rgba(255,255,255,.35); font-size: 16px; flex: 0 0 auto;
}
.icon-mini-purple { background: linear-gradient(135deg, #ede9fe, #d8b4fe); }
.icon-mini-gold { background: linear-gradient(135deg, #fef3c7, #fdba74); }
.icon-mini-blue { background: linear-gradient(135deg, #dbeafe, #93c5fd); }
.icon-mini-cyan { background: linear-gradient(135deg, #cffafe, #67e8f9); }
.icon-mini-peach { background: linear-gradient(135deg, #ffedd5, #fdba74); }
.icon-mini-green { background: linear-gradient(135deg, #dcfce7, #86efac); }
.icon-mini-orange { background: linear-gradient(135deg, #fed7aa, #fb923c); }

.insight-grid { gap: 12px; }
.kpi-grid.three { grid-template-columns: 1fr; }
.insight-card {
  position: relative; background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 16px;
  min-height: 110px; overflow: hidden;
}
.insight-card::after {
  content: ""; position: absolute; right: -12px; top: -10px; width: 74px; height: 74px; opacity: .18; border-radius: 24px;
  background: linear-gradient(135deg, #d8b4fe, #fde68a);
}
.insight-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.insight-meta { margin: 8px 0 0; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.total-line { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; display: flex; justify-content: space-between; align-items: center; }
.total-line strong { font-family: var(--mono); font-weight: 500; }
.goal { border: 1px solid var(--border); border-radius: 18px; padding: 13px; margin-bottom: 10px; background: #fff; }
.goal span { display: inline-block; font-family: var(--mono); font-size: 12px; color: var(--plum); background: #f4edf7; padding: 4px 8px; border-radius: 999px; margin-bottom: 8px; }
.goal strong { display: block; font-weight: 600; }
.goal p { color: var(--muted); margin: 6px 0 0; font-size: 14px; }
.primary-btn, .ghost-btn, .danger-btn {
  border: 0; border-radius: 14px; padding: 11px 14px; font-family: var(--sans); font-weight: 600; cursor: pointer;
}
.primary-btn { background: linear-gradient(135deg, var(--primary), var(--plum)); color: #fff; }
.ghost-btn { background: #f2f4f7; color: #344054; }
.header-action {
  background: rgba(255,255,255,.10); color: #fff; border: 1px solid rgba(255,255,255,.18); white-space: nowrap;
  display: flex; gap: 6px; align-items: center;
}
.danger-btn { background: var(--soft-red); color: var(--red); }
.small { padding: 8px 11px; font-size: 13px; }
.button-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle-row input { width: auto; margin: 0; }
.hidden { display: none; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(6, 1fr);
  background: rgba(255,255,255,.95); backdrop-filter: blur(18px); border-top: 1px solid var(--border);
  padding: 8px 4px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -14px 34px rgba(17, 24, 39, .06);
}
.bottom-nav button {
  border: 0; background: transparent; color: #667085; font-family: var(--mono); font-size: 10px;
  padding: 7px 2px; border-radius: 18px; display: grid; place-items: center; gap: 4px;
}
.nav-badge {
  width: 28px; height: 28px; border-radius: 10px; display: grid; place-items: center; font-size: 14px;
  border: 1px solid rgba(255,255,255,.3); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 12px rgba(17,24,39,.1);
}
.nav-dashboard { background: linear-gradient(135deg, #c7d2fe, #a5b4fc); }
.nav-planner { background: linear-gradient(135deg, #dbeafe, #93c5fd); }
.nav-cards { background: linear-gradient(135deg, #f5d0fe, #c084fc); }
.nav-fixed { background: linear-gradient(135deg, #dcfce7, #86efac); }
.nav-inflows { background: linear-gradient(135deg, #cffafe, #67e8f9); }
.nav-goals { background: linear-gradient(135deg, #fed7aa, #fb923c); }
.bottom-nav button.active { background: #091225; color: #fff; }
.bottom-nav button.active .nav-badge { background: rgba(255,255,255,.12); color: #fff; box-shadow: none; border-color: rgba(255,255,255,.12); }
.danger-zone input { margin-bottom: 10px; }

@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  main { padding: 18px; }
  .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid.three.insight-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .app-header { align-items: flex-start; }
  .brand-mark { width: 46px; height: 46px; border-radius: 16px; }
  .header-action { padding: 9px 10px; font-size: 12px; }
  .kpi strong, .insight-card strong { font-size: 19px; }
  .bottom-nav button { font-size: 9px; }
}

.lock-rupee-badge, .lock-rupee-nav { position: relative; }
.lock-rupee-badge .lock-main, .lock-rupee-nav .lock-main { font-size: 15px; line-height: 1; }
.lock-rupee-badge .rupee-mini, .lock-rupee-nav .rupee-mini {
  position: absolute;
  right: 3px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #0f172a;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(16,24,40,.18);
}
.bottom-nav button.active .lock-rupee-nav .rupee-mini { background: #f8fafc; color: #0f172a; }

/* Final polish: confirmations, fixed sum and clearer status cards */
.neutral-pill { background: #f2f4f7; color: #475467; }
.snapshot-card .status-pill { background: #f2f4f7; color: #475467; }
.snapshot-values div { background: #fff; }
.snapshot-values div:not(:last-child) strong { color: var(--ink); }
.commitment-total-card {
  border: 1px solid rgba(16,24,40,.08);
  background: linear-gradient(135deg, #ffffff, #f7f2fb);
  border-radius: 18px;
  padding: 13px;
  margin: 12px 0 14px;
  display: grid;
  gap: 6px;
}
.commitment-total-card > div { display: flex; align-items: center; gap: 10px; }
.commitment-total-card strong { font-family: var(--mono); font-size: 24px; font-weight: 500; letter-spacing: -.04em; }
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(9,18,37,.54);
  display: grid;
  place-items: center;
  padding: 18px;
  backdrop-filter: blur(10px);
}
.confirm-overlay.hidden { display: none; }
.confirm-box {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 22px 60px rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.6);
}
.confirm-box h3 { margin-bottom: 8px; }
.confirm-actions { justify-content: flex-end; }

/* v46 clean dashboard */
.result-hero {
  display: grid;
  gap: 6px;
  border-radius: 26px;
  border-color: rgba(16,24,40,.08);
  background: linear-gradient(135deg, #ffffff 0%, #fff7f5 100%);
}
.result-hero h2 {
  font-family: var(--mono);
  font-size: clamp(28px, 7vw, 42px);
  font-weight: 500;
  letter-spacing: -.05em;
  margin: 0;
}
.result-hero.hero-ok { background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%); }
.result-hero.hero-tight { background: linear-gradient(135deg, #ffffff 0%, #fff7ed 100%); }
.result-hero.hero-negative { background: linear-gradient(135deg, #ffffff 0%, #fff1f1 100%); }
.clean-kpi-grid .kpi {
  min-height: 112px;
  padding: 16px 64px 16px 16px;
}
.clean-kpi-grid .kpi::after {
  right: -12px;
  top: -12px;
  width: 66px;
  height: 66px;
  border-radius: 24px;
}
.clean-kpi-grid .kpi::before { right: 17px; top: 16px; font-size: 19px; }
.kpi-fund::before { content: "₹"; color: var(--green); font-weight: 700; }
.kpi-shortfall::before { content: "!"; color: var(--red); font-weight: 700; }
.card-flow-panel { overflow: hidden; }
.flow-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 14px 0 12px;
}
.flow-head div {
  background: #fff;
  border: 1px solid rgba(16,24,40,.07);
  border-radius: 16px;
  padding: 11px;
  min-width: 0;
}
.flow-head span {
  display: block;
  font-family: var(--mono);
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 5px;
}
.flow-head strong {
  display: block;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-track {
  height: 16px;
  border-radius: 999px;
  background: #eef0f3;
  overflow: hidden;
  display: flex;
  border: 1px solid rgba(16,24,40,.06);
}
.flow-covered {
  width: 0%;
  background: linear-gradient(90deg, #16a34a, #86efac);
  transition: width .25s ease;
}
.flow-shortfall {
  width: 0%;
  background: linear-gradient(90deg, #fca5a5, #ef4444);
  transition: width .25s ease;
}
.card-flow-panel .panel-title-row h3 { margin-bottom: 0; }
@media (max-width: 420px) {
  .clean-kpi-grid { gap: 10px; }
  .clean-kpi-grid .kpi { min-height: 102px; padding: 14px 48px 14px 13px; }
  .clean-kpi-grid .kpi::after { width: 56px; height: 56px; border-radius: 21px; }
  .clean-kpi-grid .kpi::before { right: 14px; top: 14px; font-size: 17px; }
  .flow-head { grid-template-columns: 1fr; }
  .flow-head strong { font-size: 18px; }
}
