/* munimji-ledger.css — v3 "Direction C"
   Full pivot from the leather-ledger concept to a dark, glowing, modern
   direction (CRED/Jupiter-inspired) after confirming the look on sample
   pages. Landscape shell, vertical icon+label rail, glass cards, radial
   gauges, glow progress bars, real Munimji artwork. Every navigation swaps
   fresh DOM content, so entrance animations replay on every click for free
   — no restart-trick JS needed. */

:root {
  --ml-bg:        #08080b;
  --ml-panel:     rgba(20,18,24,0.6);
  --ml-glass:     rgba(255,255,255,0.035);
  --ml-glass-brd: rgba(255,255,255,0.08);
  --ml-text:      #f2f0eb;
  --ml-text-dim:  rgba(242,240,235,0.55);
  --ml-text-faint:rgba(242,240,235,0.4);
  --ml-gold-1:    #ffb74d;
  --ml-gold-2:    #ff8a65;
  --ml-violet:    #8b5cf6;
  --ml-good:      #6ee7a8;
  --ml-good-2:    #34d399;
  --ml-bad:       #ff6b7a;
  --ml-bad-2:     #ff4d5e;
  --ml-font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

#munimjiLedgerRoot {
  position: fixed; inset: 0; z-index: 998500;
  background: radial-gradient(ellipse at center, rgba(10,8,14,0.9), rgba(3,2,4,0.97));
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  font-family: var(--ml-font);
  color: var(--ml-text);
}

.ml-glow-blob { position: absolute; border-radius: 50%; filter: blur(90px); pointer-events: none; z-index: 0; }
.ml-glow-blob.gold   { width: 380px; height: 380px; top: -140px; left: -90px; background: radial-gradient(circle, rgba(255,183,77,0.28), transparent 70%); }
.ml-glow-blob.violet { width: 340px; height: 340px; bottom: -120px; right: -70px; background: radial-gradient(circle, rgba(139,92,246,0.22), transparent 70%); }

/* ── LANDSCAPE shell ─────────────────────────────────────────────────── */
#munimjiLedgerBook {
  position: relative; z-index: 1;
  width: min(94vw, 920px); height: min(88vh, 480px);
  display: flex;
  background: var(--ml-panel);
  backdrop-filter: blur(24px);
  border: 1px solid var(--ml-glass-brd);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
}

/* Positioning only — look now comes from the shared global .modal-close-x
   class (index.html), for one consistent close button across every modal.
   This one used to have no flex centering at all (just width/height/
   border-radius:50% on a default <button> box), which is exactly the class
   of bug that let the ✕ glyph sit off-center inside its circle. */
#mlCloseBtn {
  position: absolute; top: 12px; right: 14px; z-index: 8;
  opacity: 0.8; transition: opacity 0.15s;
}
#mlCloseBtn:hover { opacity: 1; }

/* ── Left rail — vertical icon+label nav, glow accent bar on active ─── */
#mlTabRail {
  width: 78px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0; gap: 4px; overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.06);
  scrollbar-width: none;
}
#mlTabRail::-webkit-scrollbar { display: none; }
.ml-tab {
  width: 62px; padding: 8px 4px 7px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 17px; color: var(--ml-text-faint); cursor: pointer;
  position: relative; flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}
.ml-tab .ml-tab-label {
  font-size: 8.5px; font-weight: 500; letter-spacing: 0.4px;
  text-transform: uppercase; opacity: 0.8; color: inherit;
}
.ml-tab.active { background: rgba(255,183,77,0.08); color: var(--ml-gold-1); }
.ml-tab.active::before {
  content: ''; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 3px;
  background: linear-gradient(180deg, var(--ml-gold-1), var(--ml-gold-2));
  box-shadow: 0 0 10px rgba(255,183,77,0.7);
}
.ml-tab.active .ml-tab-icon { filter: drop-shadow(0 0 6px rgba(255,183,77,0.55)); }
.ml-tab:not(.active):hover { background: rgba(255,255,255,0.05); color: rgba(242,240,235,0.68); }

/* ── Main column ─────────────────────────────────────────────────────── */
#mlMain { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

#mlTopbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 40px 6px 20px; flex-shrink: 0; }
#mlBrand { font-size: 14px; font-weight: 700; letter-spacing: 0.8px; color: var(--ml-text-dim); text-transform: uppercase; }
#mlBrand b { color: var(--ml-gold-1); font-weight: 800; }
#mlYearPill { justify-self: center; }
#mlShareBtn {
  justify-self: end; background: rgba(255,255,255,0.06); border: none;
  color: var(--ml-text-dim); width: 30px; height: 30px; border-radius: 50%;
  font-size: 13px; cursor: pointer; opacity: 0.8; transition: opacity 0.15s, color 0.15s;
}
#mlShareBtn:hover { opacity: 1; color: var(--ml-gold-1); }

#mlYearPill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--ml-glass-brd);
  border-radius: 999px; padding: 4px 6px;
}
.ml-year-btn { width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(255,255,255,0.08); color: var(--ml-text); font-size: 11px; cursor: pointer; }
.ml-year-btn:disabled { opacity: 0.25; cursor: default; }
.ml-year-btn:not(:disabled):hover { background: rgba(255,255,255,0.14); }
#mlYearLabel {
  font-weight: 800; font-size: 12.5px; padding: 0 2px; min-width: 34px; text-align: center;
  background: linear-gradient(135deg, var(--ml-gold-1), var(--ml-gold-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

/* ── Page content — this is what gets replaced on every navigation.
   overflow-y here is the "graceful growth" answer: hero elements stay put,
   this scrolls if a page's content genuinely exceeds the panel height. ── */
#mlPage { flex: 1; overflow-y: auto; padding: 6px 22px 18px; }
#mlPage::-webkit-scrollbar { width: 5px; }
#mlPage::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

/* ── Entrance choreography — plays fresh every single navigation because
   the elements are brand new each render. No restart JS needed. ── */
@keyframes mlFadeUp { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }
.ml-s1 { animation: mlFadeUp 0.55s ease 0.05s backwards; }
.ml-s2 { animation: mlFadeUp 0.55s ease 0.2s backwards; }
.ml-s3 { animation: mlFadeUp 0.55s ease 0.35s backwards; }
.ml-s4 { animation: mlFadeUp 0.55s ease 0.5s backwards; }

@keyframes mlMunimjiIn { from { opacity:0; transform: translateY(16px) scale(0.97); } to { opacity:1; transform: translateY(0) scale(1); } }
.ml-munimji-reveal { animation: mlMunimjiIn 0.55s cubic-bezier(.2,.8,.2,1) 0.35s backwards; }

.ml-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--ml-text-faint); margin: 0 0 3px; }
h1.ml-title { font-size: 22px; font-weight: 800; margin: 0 0 12px; letter-spacing: -0.5px; line-height: 1.15; }
h2.ml-title { font-size: 19px; font-weight: 800; margin: 0 0 12px; letter-spacing: -0.4px; }

/* ── Glass card ───────────────────────────────────────────────────────── */
.ml-glass { background: var(--ml-glass); backdrop-filter: blur(20px); border: 1px solid var(--ml-glass-brd); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; }

/* ── Hero stat cards ──────────────────────────────────────────────────── */
.ml-hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.ml-hero { padding: 12px 13px; border-radius: 14px; position: relative; overflow: hidden; background: var(--ml-glass); border: 1px solid var(--ml-glass-brd); }
.ml-hero::before { content:''; position:absolute; inset:0; background: radial-gradient(circle at 25% 15%, var(--glow, rgba(255,183,77,0.16)), transparent 60%); }
.ml-hero .ml-h-label { position: relative; font-size: 9.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--ml-text-dim); margin: 0 0 3px; white-space: nowrap; }
.ml-hero .ml-h-value { position: relative; font-size: 22px; font-weight: 800; letter-spacing: 0.3px; margin: 0; color: var(--val, var(--ml-gold-1)); text-shadow: 0 0 14px var(--glowstrong, rgba(255,183,77,0.4)); }
.ml-hero.big { grid-column: 1/-1; padding: 16px 18px; }
.ml-hero.big .ml-h-value { font-size: 30px; letter-spacing: 0.4px; }

/* ── Radial gauge ─────────────────────────────────────────────────────── */
.ml-gauge-row { display: flex; align-items: center; gap: 14px; }
.ml-gauge { position: relative; width: 76px; height: 76px; flex-shrink: 0; }
.ml-gauge svg { transform: rotate(-90deg); filter: drop-shadow(0 0 8px rgba(255,183,77,0.5)); }
.ml-gauge .ml-gauge-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; color: var(--ml-gold-1); }
@keyframes mlGaugeFill { from { stroke-dashoffset: var(--circ, 201); } to { stroke-dashoffset: var(--offset, 100); } }
.ml-gauge-ring { animation: mlGaugeFill 1.5s cubic-bezier(.16,.84,.44,1) 0.4s backwards; }

/* ── Glow progress bar ────────────────────────────────────────────────── */
.ml-bar-label-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--ml-text-dim); margin: 0 0 4px; }
.ml-bar-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; margin-bottom: 10px; }
.ml-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ml-gold-1), var(--ml-gold-2)); box-shadow: 0 0 10px rgba(255,183,77,0.6); animation: mlBarGrow 1.5s cubic-bezier(.16,.84,.44,1) 0.4s backwards; }
.ml-bar-fill.green { background: linear-gradient(90deg, var(--ml-good), var(--ml-good-2)); box-shadow: 0 0 10px rgba(110,231,168,0.5); }
.ml-bar-fill.red   { background: linear-gradient(90deg, var(--ml-bad), var(--ml-bad-2));   box-shadow: 0 0 10px rgba(255,107,122,0.5); }
@keyframes mlBarGrow { from { width: 0%; } }

/* ── Chip grid — "more with less" infographic replacing plain line lists,
   e.g. balance-sheet assets/loans. Icon + label + value per chip. ──────── */
.ml-chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 7px; margin-bottom: 4px; }
.ml-chip {
  background: var(--ml-glass); border: 1px solid var(--ml-glass-brd); border-radius: 12px;
  padding: 9px 10px; text-align: left;
}
.ml-chip .ml-chip-icon { font-size: 15px; margin-bottom: 3px; display: block; }
.ml-chip .ml-chip-label { font-size: 9px; color: var(--ml-text-faint); text-transform: uppercase; letter-spacing: 0.4px; margin: 0 0 2px; white-space: nowrap; }
.ml-chip .ml-chip-value { font-size: 13px; font-weight: 700; letter-spacing: 0.2px; font-variant-numeric: tabular-nums; }

/* ── Row list (income lines, tax lines, CIBIL events, income-assets) ────
   The part of a page most likely to grow — lives inside a normally-flowed
   glass card so #mlPage's scroll absorbs any overflow. ── */
.ml-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; }
.ml-row:last-child { border-bottom: none; }
.ml-row .ml-row-icon { margin-right: 8px; }
.ml-row-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.ml-amt-pos { color: var(--ml-good); text-shadow: 0 0 8px rgba(110,231,168,0.35); }
.ml-amt-neg { color: var(--ml-bad); text-shadow: 0 0 8px rgba(255,107,122,0.35); }
.ml-row-total { display: flex; justify-content: space-between; padding: 8px 0 0; font-weight: 800; font-size: 14px; }

/* ── Munimji chat bubble ──────────────────────────────────────────────── */
.ml-bubble {
  display: flex; gap: 10px; align-items: center;
  background: linear-gradient(135deg, rgba(139,92,246,0.10), rgba(255,183,77,0.07));
  border: 1px solid var(--ml-glass-brd);
  border-radius: 14px; padding: 8px 12px; margin-top: 6px;
  font-size: 11.5px; line-height: 1.42; color: rgba(242,240,235,0.85);
}
.ml-bubble img { height: 56px; width: auto; flex-shrink: 0; }
.ml-bubble .ml-bubble-fallback {
  height: 40px; width: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ml-gold-1), var(--ml-violet));
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}

/* ── Munimji hero panel — Cover / Closing only, real artwork bleeding off
   the bottom edge, no wrapper/circle, warm glow behind. ── */
#mlMunimjiPanel {
  width: 210px; flex-shrink: 0; position: relative;
  display: flex; align-items: flex-start; justify-content: center;
  overflow: hidden; margin: 6px 6px 6px 0;
}
#mlMunimjiPanel::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 70%, rgba(255,183,77,0.22), transparent 65%);
}
#mlMunimjiPanel img {
  position: relative; height: 100%; width: auto; max-width: none;
  object-fit: contain; object-position: top;
  filter: drop-shadow(0 10px 26px rgba(0,0,0,0.5));
}

/* ── Verified badge — modern replacement for the ink stamp; same "filed by
   Munimji" meaning, fits the glow language instead of a wax seal. ──────── */
.ml-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(110,231,168,0.1); border: 1px solid rgba(110,231,168,0.3);
  color: var(--ml-good); border-radius: 999px; padding: 6px 12px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  box-shadow: 0 0 16px rgba(110,231,168,0.2);
}

/* ── Net worth trend — glow line chart, no chart library ────────────────── */
.ml-chart-wrap svg { width: 100%; height: auto; display: block; }
.ml-chart-line { fill: none; stroke: url(#mlChartGrad); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 6px rgba(255,183,77,0.5)); }
.ml-chart-dot { fill: var(--ml-gold-1); }
.ml-chart-label { font-size: 9px; fill: var(--ml-text-faint); }

/* ── Two-column content layout (Cover/Closing use the Munimji panel) ──── */
.ml-split { display: flex; height: 100%; }
.ml-split-main { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; padding-right: 6px; }

/* ── Info icon + popover — click a term to get a plain-language definition,
   click anywhere else to close. Shared single popover, repositioned per icon. ── */
.ml-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; margin-left: 4px;
  background: rgba(255,255,255,0.1); color: var(--ml-text-dim);
  font-size: 10px; font-style: italic; font-weight: 700; cursor: pointer;
  vertical-align: middle; user-select: none;
}
.ml-info:hover { background: rgba(255,183,77,0.25); color: var(--ml-gold-1); }
#mlInfoPopover {
  position: fixed; z-index: 50; max-width: 260px;
  background: rgba(24,20,16,0.97); backdrop-filter: blur(16px);
  border: 1px solid rgba(255,183,77,0.3); border-radius: 12px;
  padding: 10px 13px; font-size: 12px; line-height: 1.5; color: var(--ml-text);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  white-space: pre-line;
  display: none;
  animation: mlFadeUp 0.15s ease;
}
#mlInfoPopover.open { display: block; }
#mlInfoPopover .ml-info-term { font-weight: 800; color: var(--ml-gold-1); margin: 0 0 4px; font-size: 12.5px; }

/* ── HLV / coverage adequacy — big color-graded number, "not too dark" at
   either extreme, with a matching background glow. ── */
.ml-hlv { text-align: center; padding: 14px; border-radius: 16px; position: relative; overflow: hidden; }
.ml-hlv-value { position: relative; font-size: 30px; font-weight: 800; margin: 0; text-shadow: 0 0 20px var(--hlv-glow, transparent); }
.ml-hlv-tier { position: relative; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; margin: 3px 0 0; }
@media (max-height: 480px) {
  #munimjiLedgerBook { height: 96vh; }
  #mlPage { padding: 4px 16px 10px; }
  h1.ml-title, h2.ml-title { font-size: 17px; }
  .ml-h-value { font-size: 17px !important; }
  #mlMunimjiPanel { width: 150px; }
}
@media (max-width: 480px) {
  #mlTabRail { width: 60px; }
  .ml-tab { width: 48px; }
  .ml-tab .ml-tab-label { display: none; }
  #mlMunimjiPanel { display: none; } /* not enough width to do him justice — cover/closing fall back to text-only hero */
}
