/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0a0a0a;
  --bg-card:     #1a1a1a;
  --bg-card-alt: #141414;
  --gold:        #d4af37;
  --gold-bright: #f0d878;
  --gold-dim:    #8b7355;
  --text:        #e0e0e0;
  --text-muted:  #888;
  --border:      #2a2a2a;
  --radius:      8px;
  --shadow:      0 2px 8px rgba(0,0,0,.4);
}

html { font-size: 14px; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 56px;
}

.logo { height: 28px; }

/* ── Tabs ──────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  padding: .75rem 1.25rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── Filters bar ───────────────────────────────────────────────── */
.filters-section {
  background: var(--bg-card-alt);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
}

.filters-section-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.filter-group label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.filter-group select,
.filter-group input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .6rem;
  font-size: .85rem;
  font-family: inherit;
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--gold);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .2s, color .2s;
  font-family: inherit;
}

.btn-gold {
  background: var(--gold);
  color: #0a0a0a;
}
.btn-gold:hover {
  background: var(--gold-bright);
}

.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  color: var(--gold);
  border-color: var(--gold);
}

/* ── Main content ──────────────────────────────────────────────── */
.main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Panel header ──────────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.panel-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--gold);
}

.period-label {
  font-size: .9rem;
  color: var(--text-muted);
  padding: .25rem .6rem;
  background: var(--bg-card);
  border-radius: var(--radius);
}

/* ── KPI cards grid ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.kpi-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .5rem;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.2;
}

.kpi-subtitle {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

/* ── Chart containers ──────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.charts-row--full {
  grid-template-columns: 1fr;
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
  min-height: 300px;
}

.chart-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}

/* ── Tables ────────────────────────────────────────────────────── */
.section-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

thead th {
  text-align: left;
  padding: .6rem .75rem;
  color: var(--gold);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(212, 175, 55, .05);
}

/* ── Loading & Error states ────────────────────────────────────── */
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 1rem;
}

.loading::before {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.error-state {
  text-align: center;
  color: #e57373;
  padding: 3rem 1rem;
}

.error-state p { margin-bottom: 1rem; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

/* ── Extra filter selectors (project, closer, year-only) ───────── */
.extra-filter {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
  .header-inner { gap: 1rem; }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .header-inner { flex-wrap: wrap; height: auto; padding: .75rem 0; }
  .filters-bar { flex-direction: column; align-items: stretch; }
}
