/* style.css — mobile-first. Colours live in the variables below; dark mode just swaps them. */
:root {
  --bg: #f5f7fb; --card: #ffffff; --text: #1b2333; --muted: #667085; --border: #e3e8f0;
  --accent: #2f55d4; --accent-text: #ffffff; --pos: #13803f; --neg: #c62828; --warn-bg: #fff6df; --warn-text: #6b4e00;
  --nav-h: 58px; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f1420; --card: #181f2e; --text: #e8ecf5; --muted: #98a2b8; --border: #2a3347; --accent: #6f8fff; --accent-text: #0f1420; --pos: #4cd08a; --neg: #ff7a74; --warn-bg: #3a3017; --warn-text: #f2d98a; }
}
:root[data-theme="dark"] { --bg: #0f1420; --card: #181f2e; --text: #e8ecf5; --muted: #98a2b8; --border: #2a3347; --accent: #6f8fff; --accent-text: #0f1420; --pos: #4cd08a; --neg: #ff7a74; --warn-bg: #3a3017; --warn-text: #f2d98a; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.5rem; margin: .2em 0 .1em; } h2 { font-size: 1.1rem; margin: 1.2em 0 .5em; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .82rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; }

/* Navigation: bottom bar on phones */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--border); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; text-decoration: none; color: var(--muted); }
.nav a .ico { font-size: 1.2rem; line-height: 1; }
.nav a.active { color: var(--accent); font-weight: 600; }

.view { padding: 12px 16px calc(var(--nav-h) + 40px); max-width: 1000px; margin: 0 auto; }
.foot { text-align: center; padding: 0 16px 80px; }

/* On phones the secondary tabs hide behind "More"; on desktop all tabs show and "More" is hidden. */
.nav a.more-item { display: none; }
.more-link { display: block; padding: 14px 4px; border-bottom: 1px solid var(--border); text-decoration: none; font-size: 1.05rem; }
.seg { display: flex; gap: 4px; } .grow { flex: 1; min-width: 180px; } .grow select { margin: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

/* Desktop: sidebar */
@media (min-width: 800px) {
  body { padding-left: 200px; }
  .nav { top: 0; bottom: auto; right: auto; width: 200px; height: 100vh; flex-direction: column; justify-content: flex-start; padding: 70px 10px 0; border-top: 0; border-right: 1px solid var(--border); }
  .nav a.more-item { display: flex; } .nav a.more-tab { display: none; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: .95rem; }
  .nav a.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .topbar { margin-left: -200px; padding-left: 216px; }
  .view { padding-bottom: 40px; } .foot { padding-bottom: 20px; }
}

/* Cards and grids */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.grid { display: grid; gap: 10px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid .card, .grid .stat { margin: 0; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stat-label { font-size: .78rem; color: var(--muted); }
.stat-value { font-size: 1.25rem; font-weight: 650; margin: 2px 0; word-break: break-word; }
.stat-note { font-size: .74rem; color: var(--muted); }
.cat-card { display: block; text-decoration: none; color: inherit; border-left: 5px solid var(--accent); }
.cat-head { border-left: 5px solid var(--accent); padding-left: 10px; display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.cat-head h2 { margin: 0 0 6px; }
.chart-box { height: 320px; position: relative; }
.note { background: var(--warn-bg); color: var(--warn-text); padding: 10px 12px; border-radius: 8px; }
.empty { text-align: center; padding: 30px 14px; }
.back { display: inline-block; margin-top: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .74rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.name { font-weight: 600; }
table.edit input, table.edit select { min-width: 90px; padding: 5px; }
table.edit td:nth-child(4) input { min-width: 160px; }
tr.dup { opacity: .65; } tr.bad { background: color-mix(in srgb, var(--neg) 10%, transparent); }

/* Buttons and forms */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.row.between { justify-content: space-between; }
.btn { display: inline-block; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--neg); border-color: var(--neg); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.form label { display: block; margin: 10px 0; font-size: .85rem; color: var(--muted); }
input, select, textarea { width: 100%; padding: 9px; margin-top: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
input[type=checkbox] { width: auto; }
.topbar select { width: auto; margin: 0; padding: 5px; }
.txn-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.txn-row input { margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; }

/* MF import */
.raw { white-space: pre-wrap; font-size: .75rem; background: var(--bg); padding: 10px; border-radius: 8px; overflow-x: auto; }
tr.flag { background: color-mix(in srgb, #e0a800 18%, transparent); }
.card.off { opacity: .55; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 10px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); }

/* Phase 3 */
.bar { height: 10px; background: var(--border); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .78rem; font-weight: 600; }
.badge.ok { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.badge.no { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }
.chart-box.short { height: 260px; }
.checks label { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: var(--text); }

.catchup { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 4px; } .catchup h3 { margin: 10px 0 4px; font-size: 1rem; }

.btn.block { display: block; width: 100%; text-align: left; margin: 4px 0; } h3 { font-size: 1rem; margin: 14px 0 6px; }

.gauge { margin: 10px 0; } .gauge-head { margin-bottom: 4px; } .bar.tall { height: 16px; border-radius: 8px; }

/* Phase 4 */
.gauge.click { cursor: pointer; border-radius: 8px; padding: 4px 6px; } .gauge.click:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.eat { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--border); margin: 6px 0; }
.eat .keep { background: #2bb673; } .eat .lose { background: #d9534f; }
details.card > summary { cursor: pointer; font-weight: 600; }

/* Overview hero: headline + journey start on the left, a small trend line in the corner */
.hero { display: flex; gap: 14px; flex-wrap: wrap; align-items: stretch; background: linear-gradient(135deg, #1f3a8a, #2f55d4); color: #fff; border: 0; }
.hero .hero-text { flex: 1 1 260px; }
.hero .hero-label { font-size: .8rem; opacity: .8; }
.hero .hero-value { font-size: 2rem; font-weight: 700; margin: 2px 0 6px; }
.hero .hero-since { font-size: .95rem; opacity: .95; } .hero .hero-since b { font-weight: 650; }
.hero .hero-chart-wrap { flex: 1 1 340px; max-width: 460px; min-width: 240px; align-self: center; margin-left: auto; }
.hero .hero-chart-title { font-size: .74rem; opacity: .8; margin-bottom: 2px; }
.hero .hero-chart { height: 150px; position: relative; }
.hero .hero-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.hero .chip { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; background: #ffffff1c; padding: 2px 9px; border-radius: 999px; }
.hero .chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.hero .chip.gain { background: #4ade8040; font-weight: 650; } .hero .chip.gain.neg { background: #ff6b6b55; }
.hero .hero-btns { margin-top: 10px; }
.hero .btn { background: #ffffff22; color: #fff; border-color: #ffffff55; }

/* Snapshot (export image) dialog */
.modal { position: fixed; inset: 0; z-index: 60; background: #000a; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 20px 12px; }
.modal .sheet { background: var(--card); border-radius: var(--radius); padding: 14px; max-width: 520px; width: 100%; }
.modal img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); display: block; }

/* small print under overview totals */
.parts { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 3px; font-size: .72rem; color: var(--muted); } .parts .dot { width: 7px; height: 7px; margin-right: 4px; }

/* tables that fit the window instead of scrolling */
.fit { padding: 8px; } .fit table { table-layout: fixed; font-size: .82rem; } .fit th { white-space: normal; vertical-align: bottom; } .fit td, .fit th { padding: 6px 4px; overflow-wrap: anywhere; } .fit td.num, .fit th.num { white-space: normal; }
.fit.names th:first-child, .fit.names td:first-child { width: 40%; } .fit.years th:first-child, .fit.years td:first-child { width: 14%; } .fit td .name { font-size: .8rem; }
.garden { padding: 12px; } .garden .muted { padding-top: 6px; }

/* Phase 5: statement drop zone, import result, people chips */
.dropzone { display: block; text-align: center; padding: 26px 14px; border: 2px dashed var(--border); border-radius: var(--radius); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.dz-title { font-weight: 650; font-size: 1.05rem; margin-bottom: 4px; }
.result { border-left: 5px solid var(--pos); }
.res-list { margin-top: 8px; } .res-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.res-notes { margin: 8px 0 0; padding-left: 18px; font-size: .82rem; color: var(--muted); }
#profile-switch { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
.combine-row { flex-basis: 100%; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-top: 2px; }
.chip-btn.small { padding: 2px 9px; font-size: .78rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip-btn { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; }
.chip-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip-btn.add { color: var(--muted); border-style: dashed; }
.gear { text-decoration: none; font-size: 1.2rem; color: var(--muted); }

/* allocation card: soft finance backdrop (coins and a rising line) instead of plain white */
.alloc { background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='400' viewBox='0 0 900 400'><g fill='none' stroke='%232f55d4' stroke-opacity='.10' stroke-width='3' stroke-linecap='round'><path d='M20 350 L140 300 L230 320 L350 230 L450 255 L580 160 L690 185 L880 60'/></g><g fill='%23e0a800' fill-opacity='.16' stroke='%23c99700' stroke-opacity='.25' stroke-width='2'><circle cx='90' cy='70' r='34'/><circle cx='810' cy='330' r='42'/><circle cx='770' cy='90' r='22'/><circle cx='150' cy='330' r='24'/></g><g fill='%23b8860b' fill-opacity='.35' font-family='Georgia,serif' font-weight='700' text-anchor='middle'><text x='90' y='80' font-size='30'>₹</text><text x='810' y='344' font-size='36'>₹</text><text x='770' y='98' font-size='19'>₹</text><text x='150' y='339' font-size='21'>₹</text></g></svg>") center/cover no-repeat, linear-gradient(135deg, #f1f7ff 0%, #eef9f1 55%, #fff8e6 100%); border-color: #dbe6f3; }
:root[data-theme="dark"] .alloc { background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='400' viewBox='0 0 900 400'><g fill='none' stroke='%232f55d4' stroke-opacity='.10' stroke-width='3' stroke-linecap='round'><path d='M20 350 L140 300 L230 320 L350 230 L450 255 L580 160 L690 185 L880 60'/></g><g fill='%23e0a800' fill-opacity='.16' stroke='%23c99700' stroke-opacity='.25' stroke-width='2'><circle cx='90' cy='70' r='34'/><circle cx='810' cy='330' r='42'/><circle cx='770' cy='90' r='22'/><circle cx='150' cy='330' r='24'/></g><g fill='%23b8860b' fill-opacity='.35' font-family='Georgia,serif' font-weight='700' text-anchor='middle'><text x='90' y='80' font-size='30'>₹</text><text x='810' y='344' font-size='36'>₹</text><text x='770' y='98' font-size='19'>₹</text><text x='150' y='339' font-size='21'>₹</text></g></svg>") center/cover no-repeat, linear-gradient(135deg, #1a2540 0%, #16302b 60%, #2c2a1a 100%); border-color: var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .alloc { background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='400' viewBox='0 0 900 400'><g fill='none' stroke='%232f55d4' stroke-opacity='.10' stroke-width='3' stroke-linecap='round'><path d='M20 350 L140 300 L230 320 L350 230 L450 255 L580 160 L690 185 L880 60'/></g><g fill='%23e0a800' fill-opacity='.16' stroke='%23c99700' stroke-opacity='.25' stroke-width='2'><circle cx='90' cy='70' r='34'/><circle cx='810' cy='330' r='42'/><circle cx='770' cy='90' r='22'/><circle cx='150' cy='330' r='24'/></g><g fill='%23b8860b' fill-opacity='.35' font-family='Georgia,serif' font-weight='700' text-anchor='middle'><text x='90' y='80' font-size='30'>₹</text><text x='810' y='344' font-size='36'>₹</text><text x='770' y='98' font-size='19'>₹</text><text x='150' y='339' font-size='21'>₹</text></g></svg>") center/cover no-repeat, linear-gradient(135deg, #1a2540 0%, #16302b 60%, #2c2a1a 100%); border-color: var(--border); } }

/* intro + privacy note under the top bar */
.about { max-width: 1000px; margin: 0 auto; padding: 10px 16px 0; font-size: .82rem; color: var(--muted); }
.about p { margin: 0 0 4px; }
.about b { color: var(--text); }
.about .safe { background: color-mix(in srgb, var(--pos) 10%, transparent); border: 1px solid color-mix(in srgb, var(--pos) 28%, transparent); border-radius: 10px; padding: 6px 10px; }
.about + .view { padding-top: 6px; }
.topbar { gap: 10px; } .topbar .brand { white-space: nowrap; } .topbar #profile-switch { flex: 1 1 0; min-width: 0; }

/* ---- app chrome in the app's own colours (instead of plain white) ---- */
.topbar { background: linear-gradient(110deg, #1b3689 0%, #2f55d4 60%, #4f7cff 100%); border-bottom: 0; color: #fff; box-shadow: 0 2px 10px #1b36892e; }
.topbar .brand { display: flex; align-items: center; gap: 9px; color: #fff; letter-spacing: .2px; font-size: 1.05rem; }
.topbar .brand::before { content: '₹'; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe27a, #d9a21b); color: #7a5600; font: 700 16px Georgia, serif; box-shadow: 0 0 0 3px #ffffff30; }
.topbar .chip-btn { background: #ffffff1f; color: #fff; border-color: #ffffff47; }
.topbar .chip-btn:hover { background: #ffffff33; }
.topbar .chip-btn.on { background: #fff; color: #1b3689; border-color: #fff; font-weight: 650; }
.topbar .chip-btn.add { background: transparent; color: #ffffffd0; border-style: dashed; }
.topbar .combine-row .muted { color: #ffffffb8; }
.topbar .gear { color: #fff; opacity: .9; }
.nav { background: linear-gradient(180deg, #eaf1ff 0%, #e9f6ef 100%); border-color: #d6e2f3; }
.nav a.active { color: var(--accent); }
@media (min-width: 800px) {
  .nav a.active { background: #fff; box-shadow: 0 1px 6px #2f55d426; }
  .nav a:hover:not(.active) { background: #ffffff80; }
}
:root[data-theme="dark"] .topbar { background: linear-gradient(110deg, #101c45 0%, #1c2f7a 60%, #2a46b4 100%); box-shadow: 0 2px 10px #0006; }
:root[data-theme="dark"] .nav { background: linear-gradient(180deg, #131d3b 0%, #12262b 100%); border-color: var(--border); }
:root[data-theme="dark"] .nav a.active { background: #ffffff14; box-shadow: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar { background: linear-gradient(110deg, #101c45 0%, #1c2f7a 60%, #2a46b4 100%); box-shadow: 0 2px 10px #0006; }
  :root:not([data-theme="light"]) .nav { background: linear-gradient(180deg, #131d3b 0%, #12262b 100%); border-color: var(--border); }
}
@media (min-width: 800px) and (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav a.active { background: #ffffff14; box-shadow: none; } }

/* ---- phones ---- */
.lg { display: inline; } .sm { display: none; }
.about details.safe { padding: 6px 10px; } .about details.safe summary { cursor: pointer; list-style-position: inside; } .about details.safe p { margin: 6px 0 2px; }
@media (max-width: 600px) {
  .lg { display: none; } .sm { display: inline; } .hide-sm { display: none; }
  .topbar { position: relative; flex-wrap: wrap; padding: 10px 12px 8px; gap: 6px 8px; }
  .topbar #profile-switch { flex: 1 1 100%; order: 3; flex-wrap: nowrap; justify-content: flex-start; }
  .topbar .chips { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; padding-bottom: 2px; }
  .topbar .chips::-webkit-scrollbar { display: none; }
  .topbar .chip-btn { flex: none; white-space: nowrap; }
  .topbar .gear { position: absolute; right: 14px; top: 11px; font-size: 1.3rem; }
  .topbar .combine-row { justify-content: flex-start; }
  .view { padding-left: 12px; padding-right: 12px; } .about { padding-left: 12px; padding-right: 12px; }
  .grid.stats { grid-template-columns: 1fr 1fr; } .stat-value { font-size: 1.1rem; }
  .fit td, .fit th { padding: 6px 3px; } .fit table { font-size: .78rem; }
  h1 { font-size: 1.35rem; }
}
@media (max-width: 600px) { .fit.names th:first-child, .fit.names td:first-child { width: 58%; } .fit td .name { font-size: .82rem; line-height: 1.25; } .fit .muted.small { font-size: .7rem; } }
@media (max-width: 600px) {
  .topbar #profile-switch { flex-wrap: wrap; }
  .topbar .chips { flex: 1 1 100%; }
  .topbar .combine-row { flex: 1 1 100%; }
}
