/* ============================================================
   Finance Portal — Component Styles
   ============================================================ */

/* ── Toast notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9000;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  max-width: 360px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
  font-size: var(--text-sm);
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast-icon    { font-size: 16px; flex-shrink: 0; }
.toast-msg     { flex: 1; }
.toast-close   { background: none; border: none; color: var(--text-muted); font-size: 16px; padding: 0; flex-shrink: 0; line-height: 1; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn .15s ease;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: zoomIn .15s ease;
}
.modal-box.modal-lg { max-width: 800px; }
.modal-box.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: var(--text-lg); font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoomIn  { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

/* ── Category icon backgrounds ─────────────────────────── */
.icon-banking    { background: rgba(59,130,246,.15);  color: #93c5fd; }
.icon-savings    { background: rgba(16,185,129,.15);  color: #6ee7b7; }
.icon-investment { background: rgba(139,92,246,.15);  color: #c4b5fd; }
.icon-pension    { background: rgba(245,158,11,.15);  color: #fcd34d; }
.icon-db_pension { background: rgba(13,148,136,.15);  color: #5eead4; }
.icon-property   { background: rgba(239,68,68,.15);   color: #fca5a5; }
.icon-commodity  { background: rgba(249,115,22,.15);  color: #fdba74; }

/* ── FIRE planner page ─────────────────────────────────── */
.fire-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 640px) { .fire-inputs { grid-template-columns: 1fr; } }

.scenario-tabs { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); }
.scenario-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  transition: all .15s;
}
.scenario-tab.active.conservative { background: rgba(245,158,11,.15); color: var(--warning); border-color: var(--warning); }
.scenario-tab.active.base        { background: rgba(59,130,246,.15);  color: var(--accent-light); border-color: var(--accent); }
.scenario-tab.active.optimistic  { background: rgba(16,185,129,.15);  color: var(--success); border-color: var(--success); }

.milestone-list { list-style: none; }
.milestone-item {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.milestone-item:last-child { border-bottom: none; }
.milestone-age {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(59,130,246,.15);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
}
.milestone-detail { flex: 1; }
.milestone-title { font-weight: 600; font-size: var(--text-sm); }
.milestone-sub  { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* ── Pension access warning ─────────────────────────────── */
.pension-gap-alert {
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: var(--radius);
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: #fcd34d;
  margin-bottom: var(--space-4);
}

/* ── Bridge analysis stat boxes ─────────────────────────── */
.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
}

/* ── Portfolio Journal ─────────────────────────────────── */

/* Timeline container */
#journal-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Individual entry row */
.journal-entry {
  display: flex;
  gap: 0;
  position: relative;
}

/* Left spine: dot + vertical connecting line */
.journal-entry-spine {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 28px;
  flex-shrink: 0;
  padding-top: 18px;
}
.journal-entry-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 2px currentColor;
  z-index: 1;
}
.journal-entry-line {
  flex: 1;
  width: 2px;
  background: var(--border);
  margin-top: 6px;
  min-height: 24px;
}
.journal-entry:last-child .journal-entry-line { display: none; }

/* Entry card */
.journal-entry-content {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px 12px;
  margin-bottom: 16px;
  margin-left: 12px;
  transition: border-color .15s;
}
.journal-entry-content:hover { border-color: var(--border-light); }

.journal-entry-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.journal-entry-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.journal-mood-badge {
  font-size: var(--text-xs);
  font-weight: 600;
}
.journal-portfolio-value {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  margin-left: auto;
}

.journal-entry-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.journal-body-preview {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  /* Clamp to ~3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}
.journal-body-preview.journal-body-expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.journal-entry-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.journal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}
.journal-tag {
  font-size: 11px;
  color: #c4b5fd;
  background: rgba(139,92,246,.12);
  border: 1px solid rgba(139,92,246,.25);
  border-radius: var(--radius-full);
  padding: 1px 7px;
}
.journal-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.journal-entry-content:hover .journal-actions { opacity: 1; }
.journal-delete-btn { color: var(--danger) !important; }

/* Mood picker in form */
.journal-mood-picker {
  display: flex;
  gap: 6px;
}
.journal-mood-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.journal-mood-btn:hover { border-color: var(--accent); color: var(--text-primary); }

/* Tag suggestion chips */
.journal-tag-suggestion {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px dashed var(--border-light);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.journal-tag-suggestion:hover {
  border-color: #c4b5fd;
  color: #c4b5fd;
  background: rgba(139,92,246,.08);
}

/* ── Valuation form inline ─────────────────────────────── */
.inline-add {
  background: var(--bg-elevated);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-top: var(--space-4);
}
.inline-add-row { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; }
.inline-add-row .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ============================================================
   Tax & Benefits Intelligence — page-specific styles
   ============================================================ */

/* Layout */
.tb-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: var(--space-6);
  align-items: start;
}
@media (max-width: 1100px) {
  .tb-layout { grid-template-columns: 1fr; }
}

/* Input with prefix (£) */
.input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-prefix {
  position: absolute;
  left: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  pointer-events: none;
  z-index: 1;
}
.input-prefixed { padding-left: var(--space-6) !important; }
.form-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); }
.divider { border: none; border-top: 1px solid var(--border); }

/* ANI result strip */
.tb-ani-strip {
  margin-top: var(--space-4);
}
.tb-ani-result {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: var(--space-4);
}
.tb-ani-main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-4);
}
.tb-ani-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}
.tb-ani-band {
  font-size: var(--text-sm);
  font-weight: 600;
}
.tb-ani-tax {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

/* Allowances grid */
.tb-allowances-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.tb-allowance-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.tb-allowance-row:last-child { border-bottom: none; padding-bottom: 0; }
.tb-allowance-label { font-size: var(--text-sm); color: var(--text-secondary); grid-column: 1; }
.tb-allowance-val   { font-size: var(--text-sm); font-weight: 600; grid-column: 2; text-align: right; }
.tb-allowance-note  { grid-column: 1 / -1; }

/* ── Cliff map ─────────────────────────────────────────── */
.tb-cliff-wrap {
  padding: var(--space-8) var(--space-4) var(--space-2);
  position: relative;
}
.tb-cliff-bar {
  position: relative;
  height: 32px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  overflow: visible;
  border: 1px solid var(--border);
}
.tb-cliff-band {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
}
.tb-cliff-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
  cursor: default;
}
.tb-cliff-line {
  width: 2px;
  flex: 1;
  opacity: .9;
}
.tb-cliff-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  margin-top: 3px;
  text-align: center;
}

/* User needle */
.tb-cliff-needle {
  position: absolute;
  top: -32px;
  bottom: -32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 5;
}
.tb-cliff-needle--partner { z-index: 4; }
.tb-cliff-needle-line {
  width: 3px;
  flex: 1;
}
.tb-cliff-needle-flag {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  text-align: center;
  line-height: 1.3;
  white-space: nowrap;
  margin-bottom: 3px;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  left: 50%;
}

/* Cliff axis labels */
.tb-cliff-axis {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 0;
}

/* Legend */
.tb-cliff-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.tb-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.tb-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Threshold cards ────────────────────────────────────── */
.tb-threshold-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0;
}
.tb-threshold-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin: 0;
}
.tb-threshold-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tb-threshold-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.tb-threshold-body {
  padding: var(--space-3) var(--space-4);
}
.tb-threshold-impact {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  font-size: var(--text-sm);
}
.tb-threshold-action {
  background: rgba(59,130,246,.08);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-3);
}

/* ── Optimisation actions ────────────────────────────────── */
.tb-actions-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.tb-action-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}
.tb-action-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tb-action-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tb-action-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.tb-action-body {
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* badge extras needed */
.badge-muted { background: rgba(100,116,139,.15); color: var(--text-muted); }

/* Closed / liquidated holdings row */
tr.holding-closed td {
  opacity: 0.45;
}
tr.holding-closed:hover td {
  opacity: 0.65;
}
.holding-closed-note {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
  white-space: nowrap;
}

/* Tax & Benefits warning banner */
.tb-warning-banner {
  background: rgba(245,158,11,.12);
  border: 1px solid rgba(245,158,11,.35);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}
