/* Dough Tracker — clean light fintech theme. App UI uses system fonts; the
   brand wordmark uses self-hosted Baloo 2 (matches the approved logo lockup). */

@font-face {
  font-family: 'Baloo 2';
  src: url('fonts/baloo2-latin-800.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand language (logo): emerald #004134 + gold #eebb4b. Light theme:
   * pale mint surfaces, emerald for text accents, gold for primary actions. */
  --green: #0b7a5c;
  --green-dark: #004134;
  --green-soft: #dcf0e7;
  --gold: #eebb4b;
  --emerald: #004134;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --ink: #0c1f1a;
  --grey: #5c6f68;
  --grey-soft: #e9f2ed;
  --line: #d8e6de;
  --card: #ffffff;
  --bg: #f1f6f3;
  --blue: #2e7d8f;
  --blue-soft: #d9edf2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(4, 65, 52, 0.08), 0 1px 2px rgba(4, 65, 52, 0.05);
  --row-hover: #edf5f0;
  --tooltip-bg: #06392d;
  --tooltip-fg: #ffffff;
  --node-fill: #dbe9e1;
  --node-stroke: #8fae9f;
}

/* Dark theme (the default — see <html data-theme="dark">). Light stays the
 * :root palette above; only the main surfaces flip. */
html[data-theme='dark'] {
  /* Brand language (logo): deep emerald surfaces stepped up from the
   * #004134 family, gold #eebb4b accents, mint for positive values. */
  --green: #3ecf8e;
  --green-dark: #7ce3ae;
  --green-soft: #0a3527;
  --red: #f87171;
  --red-soft: #3d1f24;
  --amber: #fbbf24;
  --amber-soft: #38300f;
  --ink: #eef7f2;
  --grey: #93aca1;
  --grey-soft: #0b4636;
  --line: #11503f;
  --card: #07362b;
  --bg: #03211b;
  --blue: #5fb4c7;
  --blue-soft: #0d3542;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --row-hover: #0a4232;
  --tooltip-bg: #e9f5ef;
  --tooltip-fg: #03211b;
  --node-fill: #0d4a3a;
  --node-stroke: #4d7a6b;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* ------------------------------ Top bar ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  display: inline-block;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-block;
}

.brand-gold { color: var(--gold); }

/* The wordmark is a single flex item so the .brand gap (meant for the icon)
   can never split "Ugot" and "Dough" apart. */
.brand-word { white-space: nowrap; }

.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }

.nav-tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 7px 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  color: var(--grey);
  cursor: pointer;
}

.nav-tab:hover { background: var(--grey-soft); color: var(--ink); }
.nav-tab.active { background: #fdf3d7; color: var(--emerald); }
html[data-theme='dark'] .nav-tab.active { background: rgba(238, 187, 75, 0.16); color: var(--gold); }

.topbar-ver { margin-left: auto; color: var(--grey); font-size: 12px; white-space: nowrap; }

.fatal-banner {
  margin: 12px 20px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ------------------------------ Cards/buttons ------------------------------ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card-title { margin: 0 0 12px; font-size: 16px; font-weight: 700; }

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.card-head-row .card-title { margin-bottom: 0; }

.section-title { margin: 4px 0 0; font-size: 17px; font-weight: 700; }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: var(--grey-soft); }
.btn:disabled { opacity: 0.55; cursor: wait; }

.btn-primary {
  /* Brand: primary actions are the logo's gold coin — gold face, deep
   * emerald ink. */
  background: var(--gold);
  border-color: var(--gold);
  color: #241a02;
}
.btn-primary:hover { background: #f5cd68; border-color: #f5cd68; }

.btn-chip.active { background: var(--green-soft); border-color: var(--green); color: var(--green-dark); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.status-line { min-height: 1.2em; color: var(--grey); font-size: 13px; }
.status-line.error { color: var(--red); font-weight: 600; }
.status-line.ok { color: var(--green-dark); font-weight: 600; }

.help-text { color: var(--grey); font-size: 13px; margin: 8px 0; }
.empty-note { color: var(--grey); padding: 14px 4px; font-style: italic; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}
.badge-amber { background: var(--amber-soft); color: var(--amber); }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.chip-green { background: var(--green-soft); color: var(--green-dark); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-grey { background: var(--grey-soft); color: var(--grey); }
.chip-blue { background: var(--blue-soft); color: var(--blue); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }

.pos { color: var(--green-dark); }
.neg { color: var(--red); }

/* ------------------------------ Dashboard ------------------------------ */

.dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.dash-times { display: flex; flex-direction: column; gap: 2px; color: var(--grey); }
.dash-times strong { color: var(--ink); }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.month-progress-card { padding: 14px 18px; }
.month-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}
.progress-track {
  height: 12px;
  border-radius: 999px;
  background: var(--grey-soft);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--gold);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.ledger {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.day-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  min-height: 190px;
}
.day-card.is-today { border-color: var(--gold); border-width: 2px; }

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.day-name { font-weight: 700; }
.day-date { color: var(--grey); font-size: 12px; }

.day-items { display: flex; flex-direction: column; gap: 5px; flex: 1; }

.day-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
}
.day-item .tk { font-weight: 700; min-width: 52px; }
.day-item .sh { color: var(--grey); font-size: 12px; }
.day-item .amt { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.day-item .basis-tag { margin-left: 6px; }
.day-item.not-available { color: var(--grey); font-style: italic; display: block; }
.day-item.not-available .tk { font-style: normal; }

.day-summary {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.day-summary .row { display: flex; justify-content: space-between; }
.day-summary .row span:first-child { color: var(--grey); }
.day-summary .row span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.target-line { font-weight: 600; font-size: 12.5px; }
.target-line.ok { color: var(--green-dark); }
.target-line.short { color: var(--red); }
.target-line.none { color: var(--grey); font-weight: 500; }

.source-list { display: flex; flex-direction: column; gap: 6px; }
.source-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.source-row .tk { font-weight: 700; min-width: 56px; }
.source-row .msg { color: var(--grey); }

/* ------------------------------ Tables ------------------------------ */

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.data-table th, .data-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th { color: var(--grey); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--ink); }
.data-table tbody tr:hover { background: var(--row-hover); }
.data-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: none; }

.ticker-cell .tk { font-weight: 700; font-size: 14px; }
.ticker-cell .fund-name { display: block; color: var(--grey); font-size: 11.5px; font-weight: 400; white-space: normal; max-width: 300px; }

.change-chip { font-weight: 700; }

/* ------------------------------ Calendar ------------------------------ */

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.calendar-months {
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  gap: 16px;
}

.month-grid-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-weekday {
  text-align: center;
  color: var(--grey);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 0;
}
.cal-cell {
  aspect-ratio: 1 / 0.92;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 44px;
}
.cal-cell .cal-amt { font-size: 10.5px; font-weight: 700; }
.cal-cell.out { opacity: 0.38; cursor: default; }
.cal-cell.lvl0 { background: var(--grey-soft); color: var(--grey); }
/* Heat ramp in the brand language: emerald steps rising to gold — the
 * biggest dividend days are gold. */
.cal-cell.lvl1 { background: #cdeede; color: #0a4632; }
.cal-cell.lvl2 { background: #8fd8b6; color: #083d2a; }
.cal-cell.lvl3 { background: #35b586; color: #ffffff; }
.cal-cell.lvl4 { background: var(--gold); color: #241a02; }
html[data-theme='dark'] .cal-cell.lvl1 { background: #0d4a36; color: #bfe9d6; }
html[data-theme='dark'] .cal-cell.lvl2 { background: #116148; color: #d8f5e7; }
html[data-theme='dark'] .cal-cell.lvl3 { background: #17805f; color: #ffffff; }
html[data-theme='dark'] .cal-cell.lvl4 { background: var(--gold); color: #241a02; }
.cal-cell.today { border-color: var(--gold); border-width: 2px; }
.cal-cell.selected { outline: 2px solid var(--blue); outline-offset: 1px; }

.month-label { text-align: center; font-weight: 700; margin-top: 10px; }

.legend {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  color: var(--grey);
  font-size: 12px;
}
.legend .swatch { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.legend .swatch.lvl0 { background: var(--grey-soft); }
.legend .swatch.lvl1 { background: #cdeede; }
.legend .swatch.lvl2 { background: #8fd8b6; }
.legend .swatch.lvl3 { background: #35b586; }
.legend .swatch.lvl4 { background: var(--gold); }

.day-detail { position: sticky; top: 76px; }
.day-detail h3 { margin: 0 0 4px; font-size: 15px; }
.day-detail .dd-count { color: var(--grey); font-size: 13px; margin-bottom: 10px; }
.dd-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.dd-row .tk { font-weight: 700; min-width: 52px; }
.dd-row .sh { color: var(--grey); font-size: 12px; }
.dd-row .amt { margin-left: auto; font-weight: 700; }
.dd-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  padding-top: 10px;
  font-size: 14.5px;
}

.search-input { max-width: 260px; }

/* ------------------------------ Forms ------------------------------ */

.input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}
.input:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 10px 0;
}
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; color: var(--grey); }
.field .input, .field select.input { color: var(--ink); font-weight: 400; }

.radio-row { display: flex; gap: 18px; margin: 6px 0 4px; }
.radio { display: flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-weight: 500;
  cursor: pointer;
}
.toggle-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }

/* ------------------------------ Charts/Expected/Future ------------------------------ */

.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100%; display: block; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--tooltip-bg);
  color: var(--tooltip-fg);
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transform: translate(-50%, -130%);
  z-index: 5;
}
.chart-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--grey); margin-top: 6px; flex-wrap: wrap; }
.chart-legend .sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.stat-card {
  background: var(--grey-soft);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat-card .stat-label { color: var(--grey); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-size: 20px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-card .stat-sub { color: var(--grey); font-size: 12px; }

.horizon-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.horizon-label { font-weight: 600; color: var(--grey); }
.fv-ending { font-size: 17px; font-weight: 800; }

.projection-note {
  display: inline-block;
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
}

.blurb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.blurb { background: var(--grey-soft); border-radius: 10px; padding: 12px 14px; }
.blurb p { margin: 4px 0 0; color: var(--grey); font-size: 13px; }

/* ------------------------------ Responsive ------------------------------ */

@media (max-width: 1180px) {
  .ledger { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .calendar-layout { grid-template-columns: 1fr; }
  .day-detail { position: static; }
}
@media (max-width: 760px) {
  .calendar-months { grid-template-columns: 1fr; }
  .topbar { gap: 12px; }
  .topbar-ver { display: none; }
}

/* ------------------------------ Theme toggle ------------------------------ */

.theme-toggle { margin-left: auto; white-space: nowrap; }
.topbar-ver { margin-left: 0; }

/* ------------------------------ Total Return ------------------------------ */

.portfolio-picker { min-width: 230px; margin: 0; }
.portfolio-picker select.input { width: 100%; }
.total-return-strip { margin: 6px 0 2px; }
.total-return-strip .stat-value.pos { color: var(--green-dark); }
.total-return-strip .stat-value.neg { color: var(--red); }

/* ------------------------------ Overlap ------------------------------ */

.overlap-unavailable { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.overlap-switcher { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.overlap-explain-toggle { margin-left: auto; }
.overlap-legend { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; margin: 8px 0 12px; font-size: 12.5px; color: var(--grey); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.etf-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sev-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; border: 2px solid var(--grey); background: var(--node-fill); }
.sev-dot.high { border-color: var(--red); }
.sev-dot.moderate { border-color: var(--amber); }

.overlap-svg-wrap { width: 100%; }
.overlap-svg-wrap svg { width: 100%; height: auto; display: block; }
.overlap-svg-wrap text { font-family: inherit; }
.ov-node { cursor: pointer; }
.ov-node:hover circle.ov-main { stroke-width: 3; }

.overlap-etf-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.etf-pick { display: inline-flex; align-items: center; gap: 6px; }
.etf-pick.active { border-color: var(--ink); background: var(--grey-soft); }

.overlap-detail {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--grey-soft);
}
.overlap-detail h3 { margin: 0 0 2px; font-size: 15px; }
.overlap-detail .od-meta { color: var(--grey); font-size: 12.5px; margin-bottom: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.od-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-top: 1px solid var(--line); font-size: 13px;
}
.od-row .od-amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.od-close { float: right; }

.overlap-row { padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.overlap-row:hover { background: var(--row-hover); }
.overlap-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.overlap-row-head .or-name { font-weight: 700; }
.overlap-row-head .or-amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.overlap-row-head .or-pct { color: var(--grey); font-variant-numeric: tabular-nums; }
.segmented-bar {
  display: flex; height: 10px; border-radius: 999px; overflow: hidden;
  background: var(--grey-soft); margin-top: 6px; width: 100%;
}
.segmented-bar .seg { height: 100%; min-width: 2px; }

/* Two-factor (Security card, Setup view) */
.recovery-codes {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px; line-height: 1.7; letter-spacing: 1px;
  background: var(--panel-2, rgba(127, 127, 127, 0.12));
  border: 1px solid var(--line, rgba(127, 127, 127, 0.35));
  border-radius: 8px; padding: 12px 16px; white-space: pre-wrap;
}
#mfa-qr { background: #fff; border-radius: 8px; padding: 6px; }

/* FAQ (auth screen + Setup Help & FAQ card; rendered by faq.js) */
.faq-card { width: 100%; max-width: 560px; margin: 16px auto 32px; text-align: left; }
.faq-item { border-top: 1px solid var(--line, rgba(127, 127, 127, 0.3)); padding: 10px 0; }
.faq-item:first-child { border-top: none; }
.faq-item summary { cursor: pointer; font-weight: 600; padding: 2px 0; }
.faq-item summary:hover { color: var(--gold, #eebb4b); }
.faq-item p { margin: 6px 0 2px; }

/* Billing: struck-through full-year amount next to the discounted price. */
.billing-card-price .price-was { opacity: 0.55; font-size: 0.62em; font-weight: 400; }
