/* ── Placeholder text ────────────────────────────────────────── */
::placeholder {
  color: var(--text-faint);
  opacity: 1;
}
:focus::placeholder {
  color: transparent;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* ── Collapsible list item (income, assets, liabilities) ─────── */
.list-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}
.list-item:active { border-color: var(--primary); }

.list-item-header {
  display: flex;
  align-items: center;
  padding: 13px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  gap: 10px;
}
.list-item-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}
.list-item-amount {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -0.3px;
  flex-shrink: 0;
}
.list-item-chevron {
  color: var(--text-faint);
  font-size: 11px;
  margin-left: 6px;
  transition: transform var(--transition);
  flex-shrink: 0;
}
.list-item.open .list-item-chevron { transform: rotate(180deg); }

.list-item-body {
  border-top: 1px solid var(--border);
  padding: 16px;
  display: none;
}
.list-item.open .list-item-body { display: block; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-fast);
  letter-spacing: 0.2px;
}
.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  flex: 1;
  transition: all var(--transition-fast);
}
.btn-secondary:active { background: var(--border); }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
  border: 1.5px solid rgba(255,77,77,0.2);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-add {
  width: 100%;
  border: 1.5px dashed var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  padding: 11px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  text-align: center;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 6px;
}
.btn-add:active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.btn-outline:active { background: var(--primary-light); }

/* ── Form fields ─────────────────────────────────────────────── */
.field-group {
  margin-bottom: 14px;
}
.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 5px;
  display: block;
}
.field-input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
  font-size: 15px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
  min-width: 0;
}
.field-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  color: var(--text-primary);
  -webkit-text-fill-color: var(--text-primary);
}
select.field-input { cursor: pointer; }

/* Compact inputs for grids */
.input-sm {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

/* ── Sheet form grid ─────────────────────────────────────────── */
.sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 479px) { .sheet-grid { grid-template-columns: 1fr; } }

/* ── Progress bars ───────────────────────────────────────────── */
.progress-bar-track {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Cash flow rows ──────────────────────────────────────────── */
.cf-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
}
.cf-label { color: var(--text-muted); }
.cf-value { font-weight: 600; }
.cf-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}
.cf-total-label { font-weight: 700; color: var(--text-primary); }
.cf-total-value { font-weight: 800; font-size: 16px; font-family: var(--font-display); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-green  { background: var(--green-light);  color: var(--green-dark); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-blue   { background: var(--primary-light);color: var(--primary); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ── Stat tiles (outcome cards) ──────────────────────────────── */
.outcome-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
}
.outcome-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.outcome-value {
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -0.5px;
}
.outcome-pct {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* ── Slider ──────────────────────────────────────────────────── */
.slider-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
}
input[type="range"] {
  accent-color: var(--primary);
  height: 4px;
}

/* ── Disclaimer ──────────────────────────────────────────────── */
.disclaimer {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.6;
  margin-top: 12px;
  border: 1px solid var(--border);
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}
.empty-state-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state-text {
  font-size: 14px;
  color: var(--text-faint);
  font-weight: 500;
}

/* ── CTA banner ──────────────────────────────────────────────── */
.cta-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  color: white;
  margin-bottom: var(--space-md);
}
.cta-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.cta-sub { font-size: 12px; opacity: 0.8; margin-bottom: 14px; }

/* ── Chart ───────────────────────────────────────────────────── */
.chart-wrapper {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}
.chart-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.chart-canvas-container {
  position: relative;
  height: 220px;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}
.legend-swatch {
  width: 12px; height: 3px;
  border-radius: 2px;
}

/* ── Mobile overflow fixes ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

input, select, textarea {
  max-width: 100%;
  min-width: 0;
  font-family: var(--font-sans);
}

.sheet-body input,
.sheet-body select {
  width: 100%;
}

/* ── Plan grid (My Plan) ─────────────────────────────────────── */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

/* ── Asset card (inside sheet) ───────────────────────────────── */
.asset-card {
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface);
}
.asset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 479px) { .asset-grid { grid-template-columns: 1fr; } }
.asset-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.asset-name-input {
  flex: 1; min-width: 0;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 10px;
  outline: none;
  font-family: var(--font-sans);
}
.asset-name-input:focus {
  border-color: var(--primary);
  color: var(--text-primary);
  -webkit-text-fill-color: var(--text-primary);
}

.input-row {
  display: flex; align-items: center; gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
}
.input-row:focus-within { border-color: var(--primary); }
.input-prefix {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-faint);
  background: transparent;
  white-space: nowrap;
}
.amount-input {
  flex: 1; min-width: 80px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 6px;
  outline: none;
  font-family: var(--font-sans);
  width: 100%;
  -webkit-text-fill-color: var(--text-muted);
}
.rate-input {
  flex: 1; min-width: 50px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 6px;
  outline: none;
  font-family: var(--font-sans);
  width: 100%;
  -webkit-text-fill-color: var(--text-muted);
}
.wide-input {
  flex: 1; min-width: 70px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 6px;
  outline: none;
  font-family: var(--font-sans);
  width: 100%;
  -webkit-text-fill-color: var(--text-muted);
}

/* ── Explicit input visibility fixes ─────────────────────────── */
/* Ensures inputs are always readable regardless of context */
input[type="number"],
input[type="text"],
input[type="email"],
input[type="date"] {
  color: var(--text-muted) !important;
  background: var(--bg-elevated) !important;
  -webkit-text-fill-color: var(--text-muted) !important;
  opacity: 1 !important;
}

input[type="number"]:focus,
input[type="text"]:focus {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
}

/* amount-input / rate-input inside input-row inherit transparent bg from parent */
.input-row input[type="number"],
.input-row input[type="text"] {
  background: transparent !important;
  color: var(--text-muted) !important;
  -webkit-text-fill-color: var(--text-muted) !important;
}
.input-row input[type="number"]:focus,
.input-row input[type="text"]:focus {
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
}

/* Sheet body inputs — ensure white background context */
.sheet-body input[type="number"],
.sheet-body input[type="text"],
.sheet-body select {
  color: var(--text-muted) !important;
  -webkit-text-fill-color: var(--text-muted) !important;
  background: var(--bg-elevated) !important;
  opacity: 1 !important;
}
.sheet-body input[type="number"]:focus,
.sheet-body input[type="text"]:focus {
  color: var(--text-primary) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
}
.sheet-body .input-row input {
  background: transparent !important;
}

/* ════════════════════════════════════════════════════════════
   DESKTOP OVERRIDES — replaces mobile bottom-sheet with modal
════════════════════════════════════════════════════════════ */

/* Bottom sheet → Desktop modal dialog */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.sheet-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.bottom-sheet {
  position: fixed;
  /* Center as a dialog on desktop */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%) scale(0.97);
  z-index: 501;
  width: min(560px, 92vw);
  max-height: 85vh;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bottom-sheet.visible {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}

.sheet-handle { display: none; }

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.sheet-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.sheet-footer {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Desktop hover states for list items */
.btn-add:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  border-style: solid;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary:hover { background: var(--border); }
.btn-danger:hover { background: var(--red-light); border-color: var(--red); }
.btn-outline:hover { background: var(--primary-light); }

.list-item-header:hover { background: var(--bg-elevated); }

/* Desktop auth input (referenced in profile.js) */
.auth-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}

.auth-input:focus { border-color: var(--primary); }

/* Wider grid for desktop */
@media (min-width: 900px) {
  .sheet-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ── Info tooltip (breakdown table headers) ──────────────────── */
.info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.info-tooltip .tooltip-badge {
  cursor: help;
  color: var(--text-faint);
  font-size: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 3px;
  font-weight: 700;
  line-height: 1;
  font-family: var(--font-sans);
  flex-shrink: 0;
}
.info-tooltip .tooltip-card {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  z-index: 200;
  pointer-events: none;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  cursor: default;
}
.info-tooltip:hover .tooltip-card {
  display: block;
}
