/* LDR Reports Dashboard — shared styles */
/* Matches existing static report visual language */

:root {
  --brand-blue: #00B9F5;
  --brand-blue-faded: rgba(0, 185, 245, 0.08);
  --navy: #112337;
  --slate: #374151;
  --graphite: #6B7280;
  --steel: #9CA3AF;
  --iron: #E5E7EB;
  --silver: #F3F4F6;
  --ghost: #F9FAFB;
  --white: #FFFFFF;
  --success: #059669;
  --warning: #D97706;
  --error: #DC2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--ghost);
  color: var(--slate);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar Nav --- */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--navy);
  color: var(--iron);
  padding: 1.5rem 0;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar .logo {
  display: block;
  padding: 0 1.25rem;
  margin-bottom: 0.25rem;
}

.sidebar .logo svg {
  width: 140px;
  height: auto;
}

.sidebar .logo-sub {
  font-size: 0.72rem;
  color: rgba(229, 231, 235, 0.5);
  display: block;
  padding: 0 1.25rem;
  margin-bottom: 1.5rem;
}

.sidebar h2 {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(229, 231, 235, 0.5);
  margin-bottom: 0.5rem;
  padding: 0 1.25rem;
}

.sidebar a {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--iron);
  text-decoration: none;
  padding: 0.45rem 1.25rem;
  margin-bottom: 0.1rem;
  transition: all 0.15s;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.sidebar a.active {
  background: rgba(0, 185, 245, 0.15);
  color: var(--brand-blue);
  font-weight: 600;
}

.sidebar .page-nav {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .page-nav a {
  font-size: 0.78rem;
  color: rgba(229, 231, 235, 0.5);
  padding: 0.25rem 1.25rem;
}

.sidebar .page-nav a:hover {
  color: var(--brand-blue);
}

/* --- Main Content --- */
.main {
  margin-left: 240px;
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1200px;
}

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-header-left { flex: 1; }

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--graphite);
  margin-top: 0.15rem;
}

/* --- Date Filter --- */
.date-filter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.date-filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--graphite);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 0.25rem;
}

.date-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  border: 1px solid var(--iron);
  background: var(--white);
  color: var(--slate);
  cursor: pointer;
  transition: all 0.15s;
}

.date-btn:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.date-btn.active {
  background: var(--brand-blue);
  color: var(--white);
  border-color: var(--brand-blue);
}

.date-range-inputs {
  display: none;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.25rem;
}

.date-range-inputs.visible { display: flex; }

.date-range-inputs input {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--iron);
  border-radius: 5px;
  color: var(--slate);
}

/* --- KPI Cards --- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--white);
  border: 1px solid var(--iron);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--graphite);
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  font-family: 'JetBrains Mono', monospace;
}

/* --- Cards --- */
.card {
  background: var(--white);
  border: 1px solid var(--iron);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* --- Trend Charts Grid --- */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

.trend-card {
  background: var(--white);
  border: 1px solid var(--iron);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.trend-card-header {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--graphite);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.trend-chart-wrap {
  height: 140px;
  position: relative;
}

.trend-summary {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--silver);
}

.trend-summary-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
  font-family: 'JetBrains Mono', monospace;
}

.trend-summary-label {
  font-size: 0.72rem;
  color: var(--graphite);
  margin-left: 0.35rem;
}

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

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

thead th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--graphite);
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--iron);
  position: sticky;
  top: 0;
  background: var(--white);
}

thead th.numeric { text-align: right; }

tbody tr { border-bottom: 1px solid var(--silver); }
tbody tr:nth-child(even) { background: var(--ghost); }
tbody tr:hover { background: rgba(0, 185, 245, 0.04); }

tbody td {
  padding: 0.6rem 1rem;
  vertical-align: middle;
}

td.numeric {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

td.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.niche-link {
  color: var(--brand-blue);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 500;
}

.niche-link:hover { text-decoration: underline; }

.sparkline-wrap {
  width: 100px;
  height: 28px;
}

/* --- Section Headers --- */
.section-header {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
  margin: 2rem 0 0.5rem;
}

.subsection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  margin: 2rem 0 0.75rem;
}

.subsection-note {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--graphite);
}

/* --- Export Button --- */
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  border: 1px solid var(--iron);
  background: var(--white);
  color: var(--graphite);
  cursor: pointer;
  transition: all 0.15s;
}

.export-btn:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

/* --- Status Badges --- */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-healthy { background: #ECFDF5; color: var(--success); }
.badge-warning { background: #FFFBEB; color: var(--warning); }
.badge-critical { background: #FEF2F2; color: var(--error); }
.badge-paused { background: var(--silver); color: var(--graphite); }

.badge-seed { background: var(--silver); color: var(--graphite); }
.badge-validate { background: #DBEAFE; color: #2563EB; }
.badge-scale { background: #ECFDF5; color: var(--success); }
.badge-optimize { background: #F5F3FF; color: #7C3AED; }

.tier-up { color: var(--success); }
.tier-down { color: var(--error); }

/* --- Loading & Error --- */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(249, 250, 251, 0.85);
  z-index: 9998;
  justify-content: center;
  align-items: center;
}

.loading-overlay.visible { display: flex; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--iron);
  border-top-color: var(--brand-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.error-box {
  display: none;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  color: var(--error);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.error-box.visible { display: block; }

/* --- Password Gate --- */
.password-gate {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(249, 250, 251, 0.97);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.password-box {
  background: var(--white);
  border: 1px solid var(--iron);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.password-box h2 {
  font-size: 1.2rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
  text-transform: none;
  letter-spacing: 0;
}

.password-box p {
  font-size: 0.85rem;
  color: var(--graphite);
  margin-bottom: 1.25rem;
}

.password-box input {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--iron);
  border-radius: 6px;
  width: 100%;
  margin-bottom: 0.75rem;
}

.password-box button {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  border: none;
  background: #06B6D4;
  color: var(--white);
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.password-box button:hover { background: #0891B2; }

.password-error {
  color: var(--error);
  font-size: 0.78rem;
  display: none;
  margin-top: 0.5rem;
}

/* --- Back Button --- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--brand-blue);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--brand-blue);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 1rem;
}

.back-btn:hover {
  background: var(--brand-blue);
  color: var(--white);
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 1.5rem; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}
