/* ============================================================
   LifeOS — Pay Down (mobile, ≤900px)
   ----------------------------------------------------------------
   Activated by app.html <link media="(max-width: 900px)">. No
   @media queries inside; the link tag is the gate. Tokens read
   from css/app.css :root only. Tap targets respect 44×44 via
   existing .btn / .btn-icon-sm patterns.
   ============================================================ */

/* KPI strip — mobile: 2x2 grid (ac-1) */
.pd-kpi-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.pd-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.pd-kpi .v {
  font-size: var(--fs-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.pd-kpi .l {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--sp-1);
}

/* Overview chart card */
.pd-overview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.pd-overview-card .pd-overview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.pd-overview-card h3 {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
}
.pd-overview-tabs {
  display: flex;
  gap: var(--sp-1);
  margin-left: auto;
}
.pd-overview-tabs button {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-xs);
  min-height: 44px;
  cursor: pointer;
}
.pd-overview-tabs button.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.pd-overview-card svg {
  height: auto !important;
  max-height: 200px;
  width: 100%;
}

/* P&I donuts — mobile: stacked vertically */
.pd-pi-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-5);
  padding: var(--sp-3) 0;
}
.pd-pi-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-3);
  align-items: center;
}
.pd-pi-block h4 {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-2);
}
.pd-pi-block .pd-legend-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-size: var(--fs-sm);
}
.pd-pi-block .pd-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}
.pd-pi-donut {
  width: 160px;
  height: 160px;
  margin: 0 auto;
}
.pd-pi-unpayable-note {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: var(--sp-3);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-xs);
  background: var(--surface);
}

/* Timeline line chart legend on mobile */
.pd-line-chart {
  width: 100%;
  height: auto;
  max-height: 200px;
  display: block;
}
.pd-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: var(--sp-2);
}
.pd-chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.pd-chart-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

/* Unpayable banner — danger-toned, above the active chart panel */
.pd-unpayable-banner {
  font-size: var(--fs-sm);
  color: var(--danger);
  background: var(--danger-dim);
  border: 1px solid rgba(240, 63, 63, 0.3);
  border-radius: var(--radius-xs);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
}

/* Bottom grid — mobile: stacked, account-list FIRST per ac-10. Account-list
   appears first in the DOM, so default block flow gives it priority. */
.pd-bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
}
.pd-acct-section h4 {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-2);
}

/* Per-account row — bottom-edge border per ac-8 */
.pd-acct-row {
  background: var(--card);
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-2);
}
.pd-acct-row .pd-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: var(--accent-dim);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.pd-acct-row .pd-name {
  font-weight: 600;
  color: var(--text);
  font-size: var(--fs-sm);
}
.pd-acct-row .pd-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
.pd-acct-row .pd-out {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
  font-size: var(--fs-sm);
}
.pd-acct-row .pd-out-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-align: right;
  margin-top: 2px;
}

/* "Set up Pay Down" CTA — accent color per ac-6, 44px tap target */
.pd-acct-row .pd-setup-cta {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: var(--fs-xs);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-xs);
  cursor: pointer;
  min-height: 44px;
}

/* Excluded toggle — text-muted per ac-9 */
.pd-excluded-toggle {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding: var(--sp-2) 0;
  cursor: pointer;
  text-decoration: underline;
  min-height: 44px;
}

/* Savings calculator */
.pd-savings-calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.pd-savings-calc h3 {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-3);
}
.pd-calc-option {
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  cursor: pointer;
  min-height: 44px;
}
.pd-calc-option:first-of-type { border-top: 0; }
.pd-radio {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1.5px solid var(--border-2);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
}
.pd-calc-option.selected .pd-radio { border-color: var(--accent); }
.pd-calc-option.selected .pd-radio::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  background: var(--accent);
}
.pd-calc-option .pd-copy { flex: 1; }
.pd-calc-option .pd-opt-title {
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text);
  margin-bottom: var(--sp-1);
}
.pd-calc-option .pd-opt-desc {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.pd-calc-extra { display: none; margin-top: var(--sp-3); }
.pd-calc-option.selected .pd-calc-extra { display: block; }
.pd-stepper-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  margin: var(--sp-3) 0 var(--sp-1);
}
.pd-stepper {
  display: flex;
  align-items: center;
  background: var(--card-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: var(--sp-1);
}
.pd-stepper .pd-num {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: var(--fs-md);
}
.pd-stepper button {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border-2);
  color: var(--text);
  cursor: pointer;
  font-size: var(--fs-lg);
  line-height: 1;
  padding: 0;
}

/* Empty / loading / error states */
.pd-state-banner {
  margin-bottom: var(--sp-4);
  padding: var(--sp-4) var(--sp-3);
  border-radius: var(--r-md);
  border: 1px dashed var(--border-2);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  background: var(--surface);
  text-align: center;
}
.pd-state-banner .pd-retry-btn {
  margin-top: var(--sp-2);
  background: var(--accent);
  color: var(--bg);
  border: 0;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-xs);
  font-size: var(--fs-sm);
  cursor: pointer;
  min-height: 44px;
}

/* ─── Cross-feature "Save up | Pay down" tab bar ───────────────────────────
   Rendered at the top of the Pay Down surface. Tokens read from css/app.css
   :root — no hardcoded brand values. Larger tap target on mobile. */
.pd-saveup-tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  margin-top: var(--sp-2);
}
.pd-saveup-tabs .pd-tab {
  background: transparent;
  border: 0;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 999px;
  user-select: none;
  min-height: 44px;
  transition: color 0.15s ease, background 0.15s ease;
}
.pd-saveup-tabs .pd-tab:hover {
  color: var(--text);
  background: var(--card-2);
}
.pd-saveup-tabs .pd-tab.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}
