/* Dashboard-specific styles — built on top of theme.css design tokens */

/* ---- NAV ---- */
.dash-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.dash-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  flex-shrink: 0;
}

.dash-file-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dash-file-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-file-meta {
  font-size: 12px;
  color: var(--fg-muted);
}

.dash-new-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 20px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
}

.dash-new-btn:hover {
  background: rgba(201,162,39,0.25);
}

/* ---- LOADING ---- */
.dash-loading {
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--fg-muted);
  font-size: 16px;
}

.loading-spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- ERROR ---- */
.dash-error {
  min-height: calc(100vh - 64px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  gap: 16px;
}

.dash-error .error-icon { font-size: 48px; }
.dash-error h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--fg);
}
.dash-error p { color: var(--fg-muted); max-width: 400px; }

/* ---- MAIN LAYOUT ---- */
.dash-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 40px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---- KPI ROW ---- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  transition: border-color 0.3s;
}

.kpi-card:hover { border-color: var(--border); }

.kpi-card.kpi-highlight {
  border-color: rgba(201,162,39,0.4);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(201,162,39,0.06) 100%);
}

.kpi-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.kpi-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.kpi-value.positive { color: var(--accent); }
.kpi-value.negative { color: #f87171; }
.kpi-value.neutral  { color: var(--fg); }

.kpi-sub {
  font-size: 13px;
  color: var(--fg-dim);
}

/* ---- CHART CARDS ---- */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  overflow: hidden;
}

.chart-card--wide {}

.chart-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.chart-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}

.chart-subtitle {
  font-size: 13px;
  color: var(--fg-muted);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.chart-container {
  position: relative;
  height: 280px;
}

.chart-container--donut {
  height: 220px;
}

/* ---- EXPENSE LEGEND ---- */
.expense-legend {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exp-legend-item {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.exp-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.exp-legend-label {
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-legend-val {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--fg);
  font-size: 12px;
  text-align: right;
  min-width: 60px;
}

.exp-legend-pct {
  font-size: 12px;
  color: var(--fg-dim);
  text-align: right;
  min-width: 38px;
}

/* ---- P&L TABLE ---- */
.table-section {}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.pl-table th {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.pl-table th.num { text-align: right; }

.pl-table td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(42,42,53,0.5);
  color: var(--fg-muted);
  white-space: nowrap;
}

.pl-table td.num { text-align: right; font-family: 'Space Grotesk', sans-serif; font-weight: 500; }
.pl-table td.month-cell { color: var(--fg); font-weight: 500; }
.pl-table td.pos { color: #4ade80; }
.pl-table td.neg { color: #f87171; }

.pl-table tbody tr:hover td { background: rgba(201,162,39,0.04); }

.pl-table tr.totals-row td {
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--fg);
  font-size: 14px;
  background: rgba(201,162,39,0.06);
}

.pl-table tr.totals-row td.pos { color: var(--accent); }
.pl-table tr.totals-row td.neg { color: #f87171; }

/* ---- CTA ---- */
.dash-cta {
  margin-top: 16px;
}

.dash-cta-inner {
  background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(201,162,39,0.08) 100%);
  border: 1px solid rgba(201,162,39,0.3);
  border-radius: 16px;
  padding: 40px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.dash-cta-text h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.dash-cta-text p {
  font-size: 15px;
  color: var(--fg-muted);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: var(--accent);
  color: #0a0a0f;
  border: none;
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary:hover { background: #dbb53a; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .charts-row {
    grid-template-columns: 1fr;
  }
  .chart-container--donut { height: 240px; }
}

@media (max-width: 768px) {
  .dash-nav { padding: 14px 20px; }
  .dash-file-info { display: none; }
  .dash-main { padding: 24px 20px 60px; gap: 20px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .kpi-value { font-size: 28px; }
  .chart-card { padding: 20px; }
  .dash-cta-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 28px;
  }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 24px; }
  .kpi-card { padding: 20px 18px; }
}
