/* ===================================================================
   DESIGN SYSTEM v3 \u2014 near-monochrome (black/white/gray), a floating
   dark pill nav, color used sparingly as a deliberate accent rather
   than the dominant palette. Every class name unchanged from before;
   only visual properties changed.
=================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400..800;1,14..32,400..700&display=swap');

:root {
  --bg: #FFFFFF;
  --panel: #FFFFFF;
  --panel2: #F5F5F3;
  --border: #E7E7E4;
  --borderBright: #D6D6D2;
  --navDark: #141414;
  --navDarkText: #FFFFFF;
  --navDarkMuted: #9A9A9C;
  --cyan: #4A6FA5;
  --amber: #C98A3E;
  --green: #3F9364;
  --red: #D25B4D;
  --violet: #7C71B8;
  --gold: #C98A3E;
  --tiger: #E0793A;
  --tigerDark: #C25F26;
  --text: #141416;
  --muted: #6E6E72;
  --mutedDim: #A6A6A9;
  --mono: "Inter", ui-monospace, "SF Mono", monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 16px;
  --radiusSm: 10px;
  --shadowSm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
  --shadowMd: 0 14px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

#app {
  position: relative;
  min-height: 100vh;
  padding: 20px;
}

#bgGrid { display: none; } /* flat white field, no ambient texture \u2014 matches the reference exactly */

.wrap { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; }

.headerLogo { height: 52px; width: auto; flex-shrink: 0; }
@media (max-width: 700px) {
  .headerLogo { height: 40px; }
}

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 20px;
  flex-wrap: wrap; gap: 10px;
}
.statusRow { display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.statusText { font-family: var(--sans); font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; }
.title { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; color: var(--text); }
.subtitle { font-family: var(--sans); font-size: 13.5px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.headerStats { display: flex; gap: 10px; flex-wrap: wrap; }

/* Layout */
.layout { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.controlPanel { width: 300px; flex-shrink: 0; }
.mainArea { flex: 1; min-width: 320px; }

/* Panel (collapsible group) \u2014 minimal, near-borderless, separated mostly by whitespace */
.panel {
  border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius);
  position: relative; margin-bottom: 12px; box-shadow: var(--shadowSm); overflow: hidden;
}
.panelHeader {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: transparent; border: none; color: var(--text); padding: 14px 16px; cursor: pointer;
  font-family: var(--sans); text-align: left;
}
.panelHeaderLabel {
  display: flex; align-items: flex-start; gap: 8px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: none; color: var(--text); text-align: left;
}
.panelBody { padding: 4px 16px 16px; }
.panelBody.hidden { display: none; }

.corner { display: none; }

/* Fields */
.field { margin-bottom: 12px; }
.fieldLabel { font-family: var(--sans); font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; margin-bottom: 5px; text-transform: none; font-weight: 600; }
.fieldRow { display: flex; align-items: center; gap: 6px; }
.fieldInput, select.fieldInput {
  width: 100%; background: var(--panel2); border: 1.5px solid var(--border); border-radius: var(--radiusSm); color: var(--text);
  font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 14.5px; padding: 9px 11px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fieldInput:focus { border-color: var(--text); box-shadow: 0 0 0 3px rgba(20,20,22,0.08); }
.fieldInput::placeholder { color: var(--mutedDim); opacity: 0.9; font-style: normal; }
.fieldInput:focus::placeholder { opacity: 0.5; }
.fieldSuffix { font-family: var(--sans); font-size: 12.5px; color: var(--mutedDim); white-space: nowrap; }

/* Toggle */
.toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--panel2); border: 1.5px solid var(--border); border-radius: var(--radiusSm);
  padding: 9px 12px; cursor: pointer; margin-bottom: 9px; font-family: var(--sans);
  transition: border-color .15s;
}
.toggle.on { border-color: var(--text); }
.toggleLabel { font-size: 12px; color: var(--text); letter-spacing: 0.01em; font-weight: 500; }
.toggleTrack { width: 32px; height: 18px; border-radius: 10px; background: var(--border); position: relative; transition: background .15s; }
.toggleTrack.on { background: var(--text); }
.toggleThumb { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: var(--shadowSm); transition: left .15s; }
.toggleThumb.on { left: 16px; }

/* Stat chips */
.statChip {
  border: 1px solid var(--border); background: var(--panel); border-radius: var(--radiusSm);
  padding: 12px 15px; flex: 1; min-width: 130px; box-shadow: var(--shadowSm);
}
.statLabel { font-family: var(--sans); font-size: 10.5px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 5px; font-weight: 600; }
.statValue { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }

/* Tabs — floating dark pill nav. Wraps to a second row and shrinks with available width
 * instead of scrolling off-screen, since scrollable nav rows have low discoverability. */
.mainArea { container-type: inline-size; }
.tabRow {
  display: flex; flex-wrap: wrap; background: var(--navDark); border-radius: 16px; margin-bottom: 20px;
  gap: 4px; padding: 6px; box-shadow: var(--shadowMd); border: none;
}
.tabBtn {
  display: flex; align-items: center; gap: 6px; padding: 10px 18px; cursor: pointer;
  background: transparent; border: none; border-radius: 999px;
  color: var(--navDarkMuted); font-family: var(--sans); font-size: 13px; font-weight: 600;
  letter-spacing: 0; white-space: nowrap; transition: color .15s, background .15s;
}
@container (max-width: 560px) {
  .tabBtn { padding: 9px 13px; font-size: 12px; }
}
@container (max-width: 380px) {
  .tabBtn { padding: 8px 10px; font-size: 11px; gap: 4px; }
  .tabProBadge { display: none; }
}
.tabBtn:hover { color: #fff; }
.tabBtn.active { background: rgba(255,255,255,0.1); color: #fff; font-weight: 700; }

/* Premium ("paid") tabs \u2014 an actual colored pill within the dark nav, not just tinted text,
 * so it reads as a distinct "paid tier" element at a glance. Only shown while NOT subscribed. */
.tabBtnPremium {
  color: #FFD9B3; background: rgba(224,121,58,0.35);
  animation: tabPremiumPulse 2.6s ease-in-out infinite;
}
.tabBtnPremium:hover { background: rgba(224,121,58,0.5); color: #FFE7CC; }
.tabBtnPremium.active { background: var(--tiger); color: #fff; font-weight: 700; animation: none; }
@keyframes tabPremiumPulse {
  0%, 100% { background: rgba(224,121,58,0.35); }
  50% { background: rgba(224,121,58,0.55); }
}
.tabProBadge {
  display: inline-block; margin-left: 7px; padding: 2px 7px; border-radius: 999px;
  background: var(--tiger); color: #fff; font-size: 9px; font-weight: 800;
  letter-spacing: 0.04em; vertical-align: 1.5px;
}

.tabHoverPitch {
  display: none; position: fixed; transform: translateX(-50%); width: 240px; z-index: 100;
  background: #141414; color: #fff; border-radius: var(--radiusSm);
  padding: 11px 13px; font-family: var(--sans); font-size: 12px; line-height: 1.55;
  text-transform: none; letter-spacing: normal; text-align: left; pointer-events: none;
  box-shadow: var(--shadowMd);
}
.tabHoverPitch b { color: var(--tiger); }

/* Chart frame */
.chartFrame {
  border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; position: relative; box-shadow: var(--shadowSm);
}
.chartTitle { font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; text-transform: none; color: var(--text); margin-bottom: 12px; }
.chartSvgWrap { position: relative; width: 100%; }
.chartLegend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-family: var(--sans); font-size: 12.5px; }
.legendItem { display: flex; align-items: center; gap: 6px; }
.legendSwatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip {
  position: absolute; pointer-events: none; background: #141414; border: none; border-radius: var(--radiusSm);
  padding: 10px 12px; font-family: var(--sans); font-size: 13px; color: #fff; display: none; z-index: 5;
  white-space: nowrap; box-shadow: var(--shadowMd);
}
.tooltipTitle { color: var(--tiger); margin-bottom: 4px; font-weight: 700; }

/* Note / footer / body text */
.note { font-family: var(--sans); font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 4px; }
.footer {
  margin-top: 20px; padding: 12px 16px; border: 1px solid var(--border); background: var(--panel);
  border-radius: var(--radius); font-family: var(--sans); font-size: 12px; color: var(--muted); display: flex; gap: 8px;
  box-shadow: var(--shadowSm);
}

.cardGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.optCard { border: 1px solid var(--border); background: var(--panel); border-radius: var(--radiusSm); padding: 14px; box-shadow: var(--shadowSm); }
.optCardLabel { font-family: var(--sans); font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0.01em; color: var(--text); }
.optCardAmt { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; margin-top: 5px; }
.optCardSub { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* Table */
.tableWrap { border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius); position: relative; overflow: auto; max-height: 480px; box-shadow: var(--shadowSm); }
table.dataTable { width: 100%; border-collapse: collapse; font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 11.5px; }
table.dataTable th {
  position: sticky; top: 0; background: var(--panel2); text-align: right; padding: 10px 12px; color: var(--text);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 700; border-bottom: 1px solid var(--border); z-index: 1;
}
table.dataTable td { text-align: right; padding: 8px 12px; color: var(--text); white-space: nowrap; border-bottom: 1px solid var(--border); font-size: 12.5px; }

/* Install banner */
#installBanner {
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  border: 1.5px dashed var(--borderBright); background: var(--panel2); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px;
  font-family: var(--sans); font-size: 12.5px; color: var(--text);
}
#installBanner button {
  background: var(--text); color: #fff; border: none; padding: 8px 16px; border-radius: 999px; font-family: var(--sans);
  font-weight: 700; font-size: 11.5px; letter-spacing: 0.02em; cursor: pointer;
}
#installBanner .dismiss { background: transparent; color: var(--muted); text-decoration: underline; padding: 0; }

@media (max-width: 700px) {
  .controlPanel { width: 100%; }
  .title { font-size: 20px; }
}

/* Account widget */
.accountWidget { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.acctEmail { font-family: var(--sans); font-size: 12.5px; color: var(--muted); margin-right: 2px; }
.acctBtn {
  background: var(--text); border: 1.5px solid var(--text); color: #fff; border-radius: 999px;
  font-family: var(--sans); font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em;
  padding: 8px 15px; cursor: pointer; transition: opacity .15s;
}
.acctBtn:hover { opacity: 0.8; }
.acctBtn.ghost { background: #fff; border-color: var(--border); color: var(--text); }
.acctBtn.ghost:hover { border-color: var(--red); color: var(--red); opacity: 1; }
.acctBtn.signout { background: #fff; border-color: var(--border); color: var(--red); }
.acctBtn.signout:hover { background: var(--red); border-color: var(--red); color: #fff; }
.acctSaved { background: #fff !important; color: var(--green) !important; border-color: var(--green) !important; }

/* Modal */
.modalOverlay {
  position: fixed; inset: 0; background: rgba(10,10,10,0.5); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px);
}
.modalBox {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); max-width: 420px; width: 100%;
  max-height: 84vh; overflow: auto; padding: 24px; position: relative; box-shadow: var(--shadowMd);
}
.modalTitle { font-family: var(--sans); font-size: 17px; font-weight: 800; letter-spacing: -0.01em; color: var(--text); margin-bottom: 16px; }
.modalClose {
  position: absolute; top: 16px; right: 18px; background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; line-height: 1;
}

/* Auth form */
.authForm { display: flex; flex-direction: column; gap: 10px; }
.authForm .fieldInput { padding: 10px 12px; font-size: 13.5px; }
.authError { color: var(--red); font-family: var(--sans); font-size: 11.5px; min-height: 14px; }
.authSubmit {
  background: var(--text); color: #fff; border: none; border-radius: 999px; padding: 12px 16px; font-family: var(--sans);
  font-weight: 700; font-size: 13px; letter-spacing: 0; cursor: pointer; margin-top: 4px;
  transition: opacity .15s;
}
.authSubmit:hover { opacity: 0.82; }
.authSubmit:disabled { opacity: 0.4; cursor: default; }
.authSwitch { font-family: var(--sans); font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 6px; }
.authSwitch a { color: var(--text); text-decoration: underline; cursor: pointer; font-weight: 600; }

/* Scenario list */
.scenarioRow {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--border); background: var(--panel2); border-radius: var(--radiusSm); padding: 11px 13px; margin-bottom: 8px;
}
.scenarioInfo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scenarioName { font-family: var(--sans); font-size: 12.5px; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenarioDate { font-family: var(--sans); font-size: 11.5px; color: var(--mutedDim); }
.scenarioActions { display: flex; gap: 6px; flex-shrink: 0; }

/* AI Coach chat */
.chatHistory { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 4px 2px; }
.chatBubble { max-width: 80%; padding: 11px 15px; font-family: var(--sans); font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; border-radius: 16px; }
.chatBubble.user { align-self: flex-end; background: var(--text); color: #fff; border-bottom-right-radius: 4px; }
.chatBubble.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }

/* Multi-entry list cards */
.listEntryCard { border: 1px solid var(--border); background: var(--panel2); border-radius: var(--radiusSm); padding: 11px 11px 3px; margin-bottom: 10px; }
.listEntryHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.listEntryTitle { font-family: var(--sans); font-size: 11px; font-weight: 700; color: var(--text); text-transform: none; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listEntryRemove { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 50%; width: 22px; height: 22px; line-height: 1; cursor: pointer; flex-shrink: 0; margin-left: 8px; }
.listEntryRemove:hover { border-color: var(--red); color: var(--red); }

/* AI Coach voice controls */
.voiceControls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.voiceToggleBtn { background: #fff; border: 1.5px solid var(--border); color: var(--muted); border-radius: 999px; font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: 0.01em; padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.voiceToggleBtn.on { border-color: var(--green); color: var(--green); }
.voiceSelect { background: var(--panel2); border: 1.5px solid var(--border); border-radius: var(--radiusSm); color: var(--text); font-family: var(--sans); font-size: 11.5px; padding: 7px 9px; max-width: 200px; }
.replayBtn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 50%; color: var(--mutedDim); background: #fff; cursor: pointer; margin-left: 8px; font-size: 10px; flex-shrink: 0; vertical-align: middle; }
.replayBtn:hover { border-color: var(--text); color: var(--text); }
.replayBtn.speaking { border-color: var(--green); color: var(--green); }

/* Sample-data indicators — number stays fully visible (bold, colored per category); the
 * SAMPLE badge alone signals "this isn't your data yet," instead of blur which read as broken. */
.statValue.sampleValue { user-select: none; }
.sampleBadge { display: inline-block; margin-top: 4px; padding: 2px 7px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); color: var(--muted); font-family: var(--sans); font-size: 9px; font-weight: 800; letter-spacing: 0.06em; }

.statChip { position: relative; }
.chipHelpBtn { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border: 1.5px solid var(--borderBright); border-radius: 50%; color: var(--muted); font-size: 9.5px; font-weight: 700; font-family: var(--sans); cursor: pointer; flex-shrink: 0; }
.chipHelpBtn:hover { background: var(--text); border-color: var(--text); color: #fff; }
.chipHelpPopup { position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; width: 230px; background: #141414; border: none; border-radius: var(--radiusSm); padding: 10px 12px; font-family: var(--sans); font-size: 11.5px; color: #fff; line-height: 1.5; white-space: normal; box-shadow: var(--shadowMd); }
.chipHelpPopup.hidden { display: none; }

/* Savings goals */
.goalCard { border: 1px solid var(--border); background: var(--panel); border-radius: var(--radiusSm); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadowSm); }
.goalHead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.goalTitle { font-family: var(--sans); font-size: 13.5px; font-weight: 700; color: var(--text); }
.goalTarget { font-family: var(--sans); font-size: 11.5px; color: var(--muted); }
.goalProgressTrack { width: 100%; height: 8px; background: var(--panel2); border-radius: 999px; margin: 9px 0; overflow: hidden; }
.goalProgressFill { height: 100%; background: var(--text); border-radius: 999px; transition: width .25s; }
.goalMetaRow { display: flex; gap: 16px; flex-wrap: wrap; font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.goalMetaRow b { color: var(--text); }
.goalActionsRow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Panel help ("?") toggle */
.panelHelpBtn { display: inline-flex; align-items: center; justify-content: center; width: 19px; height: 19px; border: 1.5px solid var(--borderBright); border-radius: 50%; color: var(--muted); font-size: 11px; font-weight: 700; font-family: var(--sans); cursor: pointer; flex-shrink: 0; }
.panelHelpBtn:hover { background: var(--text); border-color: var(--text); color: #fff; }
.panelHelpNote { border: 1.5px dashed var(--borderBright); background: var(--panel2); border-radius: var(--radiusSm); padding: 10px 12px; margin-bottom: 10px; }
.panelHelpNote.hidden { display: none; }
