/**
 * public/css/main.css
 * BuildIQ HQ Dashboard — complete stylesheet
 * Mobile-first. Dark theme. Brand colors: Navy #0D1B2A | Cyan #00C2FF | Indigo #6366F1
 * Font: Plus Jakarta Sans (loaded via Google Fonts in index.html)
 */

/* ── CSS Custom Properties (Design Tokens) ─────────────────────────────────── */
:root {
  /* Brand palette */
  --color-navy:      #0D1B2A;
  --color-cyan:      #00C2FF;
  --color-indigo:    #6366F1;

  /* Background layers */
  --bg-base:         #0a1628;    /* Deepest background */
  --bg-surface:      #112240;    /* Cards, panels */
  --bg-elevated:     #1a2f50;    /* Hover states, raised elements */
  --bg-border:       #1e3a5f;    /* Borders, dividers */

  /* Text */
  --text-primary:    #e8f0fe;    /* Main text */
  --text-secondary:  #8899aa;    /* Muted labels, metadata */
  --text-muted:      #4a6080;    /* Very muted / placeholder */

  /* Accent */
  --accent:          #00C2FF;    /* Primary action color */
  --accent-dim:      rgba(0, 194, 255, 0.12);
  --accent-hover:    rgba(0, 194, 255, 0.20);
  --indigo:          #6366F1;
  --indigo-dim:      rgba(99, 102, 241, 0.15);

  /* Semantic colors */
  --color-success:   #22c55e;
  --color-warning:   #f59e0b;
  --color-error:     #ef4444;
  --color-info:      var(--accent);

  /* Typography */
  --font-sans:       'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:       'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);

  /* Layout */
  --sidebar-width:     240px;
  --header-height:     52px;
  --bottom-nav-height: 60px;
  --content-max-width: 1200px;

  /* Transitions */
  --transition-fast:   0.15s ease;
  --transition-base:   0.25s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

img, svg { display: block; max-width: 100%; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden    { display: none !important; }
.sr-only   { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate  { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── App Layout ──────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Main content fills available space, padded for bottom nav */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
}

/* ── Mobile Header ───────────────────────────────────────────────────────── */
.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.mobile-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mobile-header-icon {
  font-size: 20px;
}

.mobile-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.mobile-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── Sidebar (tablet+) ───────────────────────────────────────────────────── */
.sidebar {
  display: none;          /* Hidden on mobile */
  flex-direction: column;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  height: 100dvh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  flex-shrink: 0;
}

.sidebar-header {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--bg-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-logo-icon { font-size: 28px; }
.sidebar-logo-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.sidebar-logo-sub {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin: 2px var(--space-2);
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}

.nav-item:hover {
  background: var(--accent-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-icon { font-size: 16px; }
.nav-label { }

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--bg-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 14px;
  color: var(--text-secondary);
}

.sidebar-user-avatar {
  width: 28px; height: 28px;
  background: var(--indigo);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  color: white;
  flex-shrink: 0;
}

/* ── Bottom Navigation (mobile) ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--bg-border);
  display: flex;
  align-items: stretch;
  z-index: 200;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-fast);
  min-height: 44px;  /* Accessible touch target */
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--accent);
  text-decoration: none;
}

.bottom-nav-icon  { font-size: 20px; }
.bottom-nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em; }

/* ── Content Sections ───────────────────────────────────────────────────── */
.section {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-footer-ts {
  margin-top: var(--space-6);
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-base);
}
.btn-primary:hover { background: #33cfff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--bg-border);
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-sm {
  font-size: 12px;
  padding: var(--space-1) var(--space-3);
}

.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  transition: background var(--transition-fast), color var(--transition-fast);
  min-width: 44px; min-height: 44px; /* accessible tap target */
}
.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ── KPI Cards ───────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.kpi-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-delta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}
.kpi-delta.up   { color: var(--color-success); }
.kpi-delta.down { color: var(--color-error); }

/* ── Charts ──────────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.chart-card-header {
  margin-bottom: var(--space-3);
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chart-container {
  position: relative;
  height: 200px;
  width: 100%;
}
.chart-container-sm {
  height: 180px;
}

/* ── Document Browser ────────────────────────────────────────────────────── */
.docs-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: calc(100dvh - var(--header-height) - var(--bottom-nav-height) - 80px);
}

.docs-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  overflow-y: auto;
  max-height: 200px;
}

.docs-content {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  overflow-y: auto;
}

.category-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-radius: 0;
  min-height: 44px;
}
.category-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.category-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.category-count {
  margin-left: auto;
  font-size: 11px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 99px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--bg-border);
  transition: background var(--transition-fast);
  min-height: 60px;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg-elevated); }
.file-item:active { background: var(--accent-dim); }

.file-icon { font-size: 16px; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.file-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.docs-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: var(--space-8);
}

/* ── Document Reader ─────────────────────────────────────────────────────── */
.doc-reader {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  z-index: 500;
  display: flex;
  flex-direction: column;
}

.doc-reader-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-height);
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  flex-shrink: 0;
}

.doc-back-btn {
  color: var(--accent);
  font-size: 14px;
  white-space: nowrap;
  width: auto;
  min-width: 60px;
}

.doc-reader-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.doc-reader-controls {
  display: flex;
  gap: 2px;
}

.doc-reader-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-4);
  padding-bottom: calc(var(--space-8) + env(safe-area-inset-bottom));
}

/* Document content typography */
.doc-reader-body .doc-body {
  font-size: var(--doc-font-size, 16px);
  line-height: 1.75;
  max-width: 72ch;
  margin: 0 auto;
  color: var(--text-primary);
}

.doc-body h1 { font-size: 1.75rem; font-weight: 700; margin-top: 2rem; margin-bottom: 0.75rem; line-height: 1.3; }
.doc-body h2 { font-size: 1.375rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.5rem; color: var(--accent); }
.doc-body h3 { font-size: 1.125rem; font-weight: 600; margin-top: 1.25rem; margin-bottom: 0.5rem; }
.doc-body h4 { font-size: 1rem; font-weight: 600; margin-top: 1rem; margin-bottom: 0.4rem; }
.doc-body p  { margin-bottom: 1rem; }
.doc-body ul, .doc-body ol { margin-bottom: 1rem; padding-left: 1.5em; }
.doc-body li { margin-bottom: 0.25rem; }
.doc-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-style: italic;
}
.doc-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: rgba(0,194,255,0.08);
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--accent);
}
.doc-body pre {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}
.doc-body pre code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  color: var(--text-primary);
}
.doc-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  display: block;
}
.doc-body th, .doc-body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bg-border);
  text-align: left;
}
.doc-body th {
  background: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-primary);
}
.doc-body td { color: var(--text-secondary); }
.doc-body tr:hover td { background: var(--bg-elevated); color: var(--text-primary); }
.doc-body a { color: var(--accent); }
.doc-body hr {
  border: none;
  border-top: 1px solid var(--bg-border);
  margin: 2rem 0;
}
.doc-body mark {
  background: rgba(0,194,255,0.25);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 1px 2px;
}
.doc-body img { max-width: 100%; border-radius: var(--radius-sm); }

/* Font size variants for reader */
.font-sm .doc-body { --doc-font-size: 14px; }
.font-md .doc-body { --doc-font-size: 16px; }
.font-lg .doc-body { --doc-font-size: 19px; }

/* ── Search ──────────────────────────────────────────────────────────────── */
.search-bar-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-4);
  transition: border-color var(--transition-fast);
}
.search-bar-wrapper:focus-within {
  border-color: var(--accent);
}

.search-icon { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: var(--space-3) var(--space-2);
  font-family: inherit;
  font-size: 16px;   /* Never smaller than 16px to prevent iOS zoom */
  color: var(--text-primary);
  min-height: 48px;
}
.search-input::placeholder { color: var(--text-muted); }

.search-clear {
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-2);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.search-empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--text-muted);
}
.search-hint { font-size: 14px; }

.search-result-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  min-height: 72px;
}
.search-result-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.search-result-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.search-result-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.search-result-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 99px;
  background: var(--indigo-dim);
  color: var(--indigo);
  flex-shrink: 0;
}
.search-result-excerpt {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result-excerpt mark {
  background: rgba(0,194,255,0.25);
  color: var(--text-primary);
  border-radius: 2px;
}

.search-loading,
.search-no-results {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Status Section ──────────────────────────────────────────────────────── */
.status-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.status-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--bg-border);
}
.status-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.status-age {
  font-size: 12px;
  color: var(--text-muted);
}
.status-age.warn { color: var(--color-warning); }
.status-age.stale { color: var(--color-error); }

/* BRIEFING.md card */
.briefing-card .status-card-header { }
.briefing-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.briefing-content {
  padding: var(--space-4);
  max-height: 400px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.briefing-content h1 { font-size: 1.25rem; color: var(--text-primary); margin-bottom: 0.5rem; }
.briefing-content h2 { font-size: 1rem; color: var(--accent); margin: 1rem 0 0.25rem; }
.briefing-content h3 { font-size: 0.9rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }
.briefing-content p  { margin-bottom: 0.75rem; }
.briefing-content ul, .briefing-content ol { padding-left: 1.25em; margin-bottom: 0.75rem; }
.briefing-content li { margin-bottom: 0.2rem; }
.briefing-content hr { border-top: 1px solid var(--bg-border); margin: 1rem 0; }
.briefing-content code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: rgba(0,194,255,0.08);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--accent);
}

/* Health grid */
.health-grid {
  padding: var(--space-2) 0;
}
.health-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--bg-border);
  font-size: 14px;
  min-height: 44px;
}
.health-row:last-child { border-bottom: none; }
.health-icon { font-size: 16px; flex-shrink: 0; }
.health-label { flex: 1; color: var(--text-primary); font-weight: 500; }
.health-value { font-size: 12px; color: var(--text-secondary); text-align: right; }

/* Cron grid */
.cron-grid { padding: var(--space-2) 0; }
.cron-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--bg-border);
  font-size: 13px;
  min-height: 44px;
}
.cron-row:last-child { border-bottom: none; }
.cron-icon { font-size: 14px; text-align: center; }
.cron-name { font-weight: 500; color: var(--text-primary); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cron-last { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.cron-duration { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ── PWA Banner ──────────────────────────────────────────────────────────── */
.pwa-banner {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--bg-border);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

/* ── Skeleton Loaders ────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-text  { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-text.short { width: 70%; }
.skeleton-row   { height: 44px; margin: 4px 8px; border-radius: var(--radius-sm); }
.skeleton-block { padding: var(--space-4); }

.skeleton-card {
  position: relative;
  overflow: hidden;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.03) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ── Error States ────────────────────────────────────────────────────────── */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-4);
  text-align: center;
  color: var(--text-muted);
}
.error-state-icon { font-size: 32px; margin-bottom: var(--space-3); }
.error-state-msg  { font-size: 14px; margin-bottom: var(--space-4); }
.error-state-retry {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

/* ── Tablet+ Layout (≥ 768px) ───────────────────────────────────────────── */
@media (min-width: 768px) {
  /* Show sidebar, hide bottom nav and mobile header */
  .sidebar       { display: flex; }
  .bottom-nav    { display: none; }
  .mobile-header { display: none; }

  /* Shift main content to the right of the sidebar */
  .app { flex-direction: row; }
  .main-content {
    margin-left: var(--sidebar-width);
    padding-bottom: 0;
  }

  .section { padding: var(--space-8); }

  .kpi-grid { grid-template-columns: repeat(4, 1fr); }

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

  .docs-layout {
    flex-direction: row;
    height: calc(100dvh - 120px);
  }
  .docs-sidebar { max-height: none; width: 220px; flex-shrink: 0; }
  .docs-content { flex: 1; }

  .chart-container     { height: 260px; }
  .chart-container-sm  { height: 220px; }
}

/* ── Large desktop (≥ 1200px) ──────────────────────────────────────────── */
@media (min-width: 1200px) {
  .section { max-width: var(--content-max-width); }
  .chart-container { height: 300px; }
}

/* ── Scrollbar styling (Webkit) ─────────────────────────────────────────── */
::-webkit-scrollbar         { width: 6px; height: 6px; }
::-webkit-scrollbar-track   { background: var(--bg-base); }
::-webkit-scrollbar-thumb   { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-border); }

/* ── Focus styles (accessibility) ──────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
