/* ── Dashboard app styles ─────────────────────────────────────────────────── */
/* Extends theme.css design tokens. Landing page styles are in theme.css. */

/* Nav */
.app-body { background: var(--bg-primary); min-height: 100vh; }

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-actions { display: flex; gap: 0.75rem; align-items: center; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #0a0e17;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #38e4ff; }

.btn-ghost {
  background: transparent;
  color: var(--fg-secondary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-accent); color: var(--fg-primary); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* Landing CTAs (used in hero and closing) */
.btn-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  background: var(--accent);
  color: #0a0e17;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.btn-cta:hover { background: #38e4ff; transform: translateY(-1px); }
.btn-arrow { font-size: 1.1rem; }
.hero-cta { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 2.5rem; }
.closing-cta { display: flex; align-items: center; justify-content: center; gap: 1.25rem; }
.cta-hint { font-size: 0.8rem; color: var(--fg-muted); font-family: var(--font-mono); }

/* App layout */
.app-main { max-width: 1280px; margin: 0 auto; padding: 2rem; }

/* Summary bar */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.summary-item {
  background: var(--bg-secondary);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.summary-label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.summary-value {
  font-size: 1.25rem;
  font-weight: 600;
}
.summary-value.positive { color: var(--green); }
.summary-value.negative { color: var(--red); }
.mono { font-family: var(--font-mono); }

/* App grid */
.app-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 0.9rem; font-weight: 600; }
.card-hint { font-size: 0.75rem; color: var(--fg-muted); font-family: var(--font-mono); }

/* Holdings table */
.table-wrap { overflow-x: auto; }
.holdings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.holdings-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.holdings-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.holdings-table tr:last-child td { border-bottom: none; }
.holdings-table tr:hover td { background: var(--bg-accent); }
.holdings-table .col-name { color: var(--fg-secondary); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.holdings-table .col-actions { width: 72px; white-space: nowrap; }
.holdings-table .row-invalid td { opacity: 0.45; }
.preview-more { text-align: center; padding: 0.75rem; }

.ticker-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.2rem 0.5rem;
  background: var(--bg-accent);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg-secondary);
}

.currency-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-muted);
  background: var(--bg-accent);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.type-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  font-family: var(--font-mono);
}
.type-stock { background: rgba(34,211,238,0.1); color: var(--accent); }
.type-etf { background: rgba(16,185,129,0.1); color: var(--green); }
.type-bond { background: rgba(167,139,250,0.1); color: #a78bfa; }
.type-crypto { background: rgba(245,158,11,0.1); color: var(--amber); }
.type-other { background: var(--bg-accent); color: var(--fg-muted); }

.action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--fg-muted);
  transition: background 0.15s, color 0.15s;
}
.action-btn:hover { background: var(--bg-accent); color: var(--fg-primary); }
.delete-btn:hover { color: var(--red); }

/* Empty state */
.empty-state {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--fg-secondary);
}
.empty-state p { margin-bottom: 0.5rem; }
.text-muted { color: var(--fg-muted); font-size: 0.85rem; }

/* Allocation */
.allocation-section .card-header { border-bottom: 1px solid var(--border); }
.alloc-chart { padding: 1.5rem; display: flex; justify-content: center; }
.donut-wrap { position: relative; width: 160px; height: 160px; }
.donut {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  position: relative;
}
.donut::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  background: var(--bg-secondary);
  border-radius: 50%;
}
.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  pointer-events: none;
}
.donut-total {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg-primary);
  white-space: nowrap;
}
.donut-label {
  font-size: 0.6rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.alloc-empty { color: var(--fg-muted); font-size: 0.85rem; padding: 1.5rem; text-align: center; }
.alloc-list { padding: 0 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; }
.alloc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}
.alloc-left { display: flex; align-items: center; gap: 0.5rem; }
.alloc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alloc-type { color: var(--fg-secondary); }
.alloc-right { display: flex; align-items: center; gap: 0.75rem; }
.alloc-value { color: var(--fg-primary); font-size: 0.8rem; }
.alloc-pct { color: var(--fg-muted); font-size: 0.75rem; font-family: var(--font-mono); min-width: 3rem; text-align: right; }

/* Performance */
.performance-section .card-header { border-bottom: 1px solid var(--border); }
.perf-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 0;
}
.perf-metric {
  padding: 1.25rem 1rem;
  text-align: center;
  border-right: 1px solid var(--border);
}
.perf-metric:last-child { border-right: none; }
.perf-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}
.perf-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg-primary);
}
.perf-value .positive { color: var(--green); }
.perf-value .negative { color: var(--red); }

.perf-benchmark-bar {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}
.benchmark-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
}
.benchmark-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.benchmark-row:last-child { margin-bottom: 0; }
.benchmark-name {
  font-size: 0.75rem;
  color: var(--fg-secondary);
  min-width: 4.5rem;
}
.benchmark-track {
  flex: 1;
  height: 6px;
  background: var(--bg-accent);
  border-radius: 3px;
  overflow: hidden;
}
.benchmark-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
  min-width: 2px;
}
.benchmark-fill.benchmark-ftse { background: #a78bfa; }
.benchmark-fill.benchmark-sp500 { background: var(--green); }
.benchmark-val {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  min-width: 4rem;
  text-align: right;
  color: var(--fg-secondary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-wide { max-width: 680px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1.25rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg-accent); color: var(--fg-primary); }
.modal-desc { padding: 1.25rem 1.5rem; color: var(--fg-secondary); font-size: 0.875rem; line-height: 1.6; }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.75rem; font-weight: 600; color: var(--fg-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input, .form-group select {
  background: var(--bg-accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.form-group select { cursor: pointer; }
.form-error {
  margin: 0 1.5rem;
  padding: 0.75rem 1rem;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  color: var(--red);
  font-size: 0.85rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* CSV modal */
.drop-zone {
  margin: 0 1.5rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.drop-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.drop-label { font-size: 0.95rem; color: var(--fg-secondary); margin-bottom: 0.35rem; }
.drop-label .link { color: var(--accent); text-decoration: underline; }
.drop-hint { font-size: 0.75rem; color: var(--fg-muted); font-family: var(--font-mono); }

.csv-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.csv-mapping { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.csv-mapping h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted); margin-bottom: 0.75rem; }
.mapping-list { display: flex; flex-direction: column; gap: 0.4rem; }
.mapping-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; font-family: var(--font-mono); }
.mapping-field { color: var(--fg-muted); min-width: 80px; }
.mapping-arrow { color: var(--fg-muted); }
.mapping-col.mapped { color: var(--green); }
.mapping-col.unmapped { color: var(--fg-muted); font-style: italic; }
.csv-preview-table-wrap { overflow-x: auto; max-height: 240px; overflow-y: auto; }
.csv-preview-table { font-size: 0.8rem; }

.csv-success {
  padding: 3rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.success-icon {
  width: 48px;
  height: 48px;
  background: rgba(16,185,129,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--green);
}

/* Settings button */
.btn-settings { font-size: 1.1rem; padding: 0.4rem 0.6rem; }

/* Account type badge in summary bar */
.account-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.account-badge-ISA  { background: rgba(16,185,129,0.15);  color: var(--green); }
.account-badge-GIA  { background: rgba(167,139,250,0.15); color: #a78bfa; }
.account-badge-SIPP { background: rgba(34,211,238,0.15); color: var(--accent); }

/* Tax info row */
.tax-indicator {
  font-size: 0.68rem;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  margin-top: 0.2rem;
}

/* Form hint */
.form-hint {
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-top: 0.25rem;
}

/* ── Price display ─────────────────────────────────────────────────────────── */

/* Table column widths for price columns */
.holdings-table th:nth-child(n+5),
.holdings-table td:nth-child(n+5) { text-align: right; }
.holdings-table .col-actions { text-align: left; }

/* Price cell */
.price-cell { font-size: 0.82rem; }
.price-cell.unavailable { color: var(--fg-muted); font-style: italic; }

/* Market value */
.mkt-value { font-size: 0.82rem; font-weight: 600; }

/* Gain/Loss cell */
.gain-cell { font-size: 0.82rem; }
.gain-positive { color: var(--green); }
.gain-negative { color: var(--red); }
.gain-neutral { color: var(--fg-muted); }
.gain-cell small {
  font-size: 0.68rem;
  display: block;
  opacity: 0.75;
  font-family: var(--font-mono);
}

/* Price status bar */
.price-status {
  font-size: 0.72rem;
  color: var(--fg-muted);
  padding: 0 1.5rem 0.75rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.price-status.error { color: var(--amber); }

/* Refresh button */
#btnRefreshPrices { min-width: 140px; }
#btnRefreshPrices.loading { opacity: 0.6; cursor: wait; }
.stale-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

/* Theme toggle */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-accent); color: var(--fg-primary); }

/* Responsive */
  .app-grid { grid-template-columns: 1fr; }
  .summary-bar { grid-template-columns: 1fr 1fr; }
  .summary-bar-6 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .app-main { padding: 1rem; }
  .app-nav { padding: 0.75rem 1rem; }
  .summary-bar { grid-template-columns: 1fr; }
  .summary-bar-6 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
