/* =================================================================
   IAO Architecture Portal — Unified Design System
   Shared CSS for Dashboard, Tower, and Capability pages
   ================================================================= */

/* ── 1. Design Tokens ───────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-primary: #0071c5;
  --brand-dark: #00285a;
  --brand-dark-alt: #00395d;
  --brand-accent: #00aeef;

  /* Status */
  --color-success: #34a853;
  --color-warning: #fbbc04;
  --color-danger: #ea4335;
  --color-info: #00aeef;

  /* Surfaces */
  --surface-page: #f0f2f5;
  --surface-card: #fff;
  --surface-border: #e4e8ed;
  --surface-border-light: #f0f2f5;
  --surface-hover: #f5f8fc;
  --surface-active: #e8f4fd;

  /* Text */
  --text-primary: #1a1a2e;
  --text-secondary: #5f6368;
  --text-tertiary: #999;
  --text-inverse: #fff;

  /* Typography */
  --font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "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;
  --space-12: 48px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 20px;

  /* Shadows */
  --shadow-card: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-elevated: 0 2px 8px rgba(0,0,0,0.15);
  --shadow-dropdown: 0 4px 12px rgba(0,0,0,0.1);

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


/* ── 2. Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background: var(--surface-page);
  color: var(--text-primary);
  line-height: 1.5;
}

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

code {
  font-family: var(--font-mono);
  background: #f0f2f5;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}


/* ── 3. Accessibility ───────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--brand-dark);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: var(--space-2);
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  text-decoration: none;
}

/* Focus ring for interactive elements */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}


/* ── 4. Topbar — Shared Base ────────────────────────────────────── */
.topbar {
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  z-index: 100;
}

/* Dashboard variant (sticky, flat dark) */
.topbar:not(.topbar-portal) {
  background: var(--brand-dark-alt);
  padding: var(--space-3) var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
}
.topbar:not(.topbar-portal) h1 {
  font-size: 1.2rem;
  font-weight: 600;
  flex: 1;
}
.topbar:not(.topbar-portal) .meta {
  font-size: 0.85rem;
  opacity: 0.8;
}
.topbar:not(.topbar-portal) .nav-links {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.topbar:not(.topbar-portal) .nav-links a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.82rem;
  padding: var(--space-1) var(--space-3);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  transition: all var(--transition-fast);
}
.topbar:not(.topbar-portal) .nav-links a:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
  text-decoration: none;
}
.topbar:not(.topbar-portal) .nav-links button.pdf-btn {
  color: #fff;
  font-size: 0.82rem;
  padding: var(--space-1) var(--space-3);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition-fast);
}
.topbar:not(.topbar-portal) .nav-links button.pdf-btn:hover {
  background: rgba(255,255,255,0.25);
}
.topbar .release-select {
  padding: var(--space-1) 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.35);
  background: #fff;
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  appearance: auto;
}
.topbar .release-select:focus {
  outline: none;
  border-color: var(--brand-primary);
}
.topbar .release-select option {
  color: var(--brand-dark);
  background: #fff;
}

/* Portal variant (fixed, gradient) */
.topbar.topbar-portal {
  background: linear-gradient(135deg, #00285a 0%, #0071c5 100%);
  padding: 0 var(--space-8);
  height: 56px;
  box-shadow: var(--shadow-elevated);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}
.topbar.topbar-portal img {
  height: 28px;
  width: 28px;
  object-fit: contain;
  margin-right: var(--space-3);
  border-radius: var(--radius-sm);
}
.topbar.topbar-portal h1 {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.5px;
}
.topbar.topbar-portal .back-link {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 14px;
  margin-left: auto;
}
.topbar.topbar-portal .back-link:hover {
  color: #fff;
  text-decoration: none;
}
.topbar.topbar-portal .sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  margin-right: var(--space-3);
  padding: var(--space-1) var(--space-2);
}
/* Cap page: center title, truncate */
.topbar.topbar-portal h1.cap-title {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar.topbar-portal .back-link-right {
  white-space: nowrap;
}


/* ── 5. Tower Navigation Pills (Dashboard) ──────────────────────── */
.tower-nav {
  background: #fff;
  border-bottom: 1px solid var(--surface-border);
  padding: var(--space-2) var(--space-6);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.tower-nav a {
  display: inline-block;
  padding: 6px var(--space-4);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--brand-primary);
  background: var(--surface-page);
  border: 1px solid var(--surface-border);
  transition: all var(--transition-fast);
}
.tower-nav a:hover, .tower-nav a.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  text-decoration: none;
}


/* ── 6. Sidebar (Portal Pages) ──────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 280px;
  background: #fff;
  border-right: 1px solid var(--surface-border);
  overflow-y: auto;
  z-index: 90;
  transition: transform var(--transition-normal);
  padding-bottom: var(--space-6);
}
.sidebar .search-box {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--surface-border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.sidebar .search-box input {
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) 34px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
  background: #f8f9fb url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2716%27 height=%2716%27 fill=%27%23999%27 viewBox=%270 0 16 16%27%3E%3Cpath d=%27M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z%27/%3E%3C/svg%3E") 10px center no-repeat;
}
.sidebar .search-box input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(0,113,197,0.15);
}
.sidebar .nav-tree { padding: var(--space-2) 0; }
.sidebar .tower-group { margin-bottom: 2px; }
.sidebar .tower-header {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-dark);
  cursor: pointer;
  user-select: none;
}
.sidebar .tower-header:hover { background: var(--surface-hover); }
.sidebar .tower-header .arrow {
  font-size: 10px;
  margin-right: var(--space-2);
  transition: transform 0.2s;
  color: var(--text-tertiary);
}
.sidebar .tower-header.open .arrow { transform: rotate(90deg); }
.sidebar .tower-header .icon { margin-right: 6px; }
.sidebar .tower-header a {
  color: inherit;
  text-decoration: none;
  flex: 1;
}
.sidebar .proc-group { margin-left: var(--space-4); display: none; }
.sidebar .tower-header.open + .proc-group,
.sidebar .proc-group.search-open { display: block; }
.sidebar .proc-label {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-2) var(--space-4) var(--space-1);
  margin-top: var(--space-1);
  cursor: pointer;
  user-select: none;
}
.sidebar .proc-label:hover { color: var(--brand-dark); }
.sidebar .proc-label .l1-arrow {
  font-size: 9px;
  margin-right: var(--space-1);
  display: inline-block;
  transition: transform 0.2s;
  color: #aaa;
}
.sidebar .proc-label.open .l1-arrow { transform: rotate(90deg); }
.sidebar .l1-children { display: none; margin-left: var(--space-2); }
.sidebar .proc-label.open + .l1-children { display: block; }
.sidebar .cap-link {
  display: block;
  padding: var(--space-1) var(--space-4) var(--space-1) var(--space-6);
  font-size: 13px;
  color: #444;
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin: 1px var(--space-2);
}
.sidebar .cap-link:hover {
  background: var(--surface-active);
  color: var(--brand-primary);
  text-decoration: none;
}
.sidebar .cap-link.active {
  background: var(--brand-primary);
  color: #fff;
  font-weight: 600;
}
.sidebar .cap-id { font-weight: 600; color: var(--brand-dark); margin-right: var(--space-1); }
.sidebar .cap-link.active .cap-id { color: #fff; }
.sidebar .no-results {
  padding: var(--space-4);
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
  font-style: italic;
}

/* Sidebar quick-link buttons */
.sidebar-nav-btn {
  display: block;
  padding: var(--space-2) 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: opacity var(--transition-fast);
}
.sidebar-nav-btn:hover { text-decoration: none; }
.sidebar-nav-btn-home {
  background: var(--surface-hover);
  color: var(--brand-dark);
  border: 1px solid var(--surface-border);
  margin-bottom: var(--space-1);
}
.sidebar-nav-btn-dashboard {
  background: linear-gradient(135deg, #00285a, #0060a9);
  color: #fff;
  margin-bottom: var(--space-2);
}
.sidebar-nav-btn-dashboard:hover { opacity: 0.85; }


/* ── 7. Page Layout (Portal) ────────────────────────────────────── */
.page-body {
  margin-top: 56px;
  margin-left: 280px;
  transition: margin-left var(--transition-normal);
}
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-12);
}
.breadcrumb {
  font-size: 13px;
  color: #666;
  margin-bottom: var(--space-5);
}
.breadcrumb a {
  color: var(--brand-primary);
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }


/* ── 8. Hero Sections ───────────────────────────────────────────── */
/* Tower page hero */
.hero {
  background: linear-gradient(135deg, #00285a, #0060a9);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-10);
  margin-bottom: var(--space-8);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 300 200%27%3E%3Cpath d=%27M0 100L80 100L120 60L200 60L240 100L300 100%27 stroke=%27rgba(255,255,255,.08)%27 fill=%27none%27 stroke-width=%272%27/%3E%3Cpath d=%27M0 140L60 140L100 180L180 180L220 140L300 140%27 stroke=%27rgba(255,255,255,.06)%27 fill=%27none%27 stroke-width=%272%27/%3E%3C/svg%3E") no-repeat center;
  opacity: 0.5;
  pointer-events: none;
}
.hero h2 { font-size: 32px; margin: 0 0 var(--space-2); font-weight: 700; position: relative; }
.hero p { font-size: 16px; opacity: 0.85; margin: 0; position: relative; }
.hero .badge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-pill);
  padding: var(--space-1) 14px;
  font-size: 12px;
  margin-top: var(--space-3);
  position: relative;
}
.hero-btn {
  display: inline-block;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition-fast);
}
.hero-btn:hover { text-decoration: none; }
.hero-btn-primary { background: rgba(255,255,255,0.25); border: 1px solid rgba(255,255,255,0.45); }
.hero-btn-secondary { background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.35); }
.hero-btn-tertiary {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.85);
  font-weight: 500;
}
@media (hover: hover) {
  .hero-btn-primary:hover { background: rgba(255,255,255,0.35); }
  .hero-btn-secondary:hover { background: rgba(255,255,255,0.3); }
  .hero-btn-tertiary:hover { background: rgba(255,255,255,0.2); }
}

/* Capability page hero */
.cap-hero {
  background: #fff;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-card);
}
.cap-hero h2 { margin: 0 0 var(--space-2); color: var(--brand-dark); font-size: 26px; }
.cap-hero p { color: #666; margin: 0 0 var(--space-4); }


/* ── 9. KPI Cards (Dashboard) ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  padding: var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
}
.kpi-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-5);
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.kpi-card .value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--brand-primary);
}
.kpi-card .label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}
.kpi-card.kpi-pass .value { color: var(--color-success); }
.kpi-card.kpi-fail .value { color: var(--color-danger); }
.kpi-card.kpi-warn .value { color: var(--color-warning); }
.kpi-card.kpi-nogo .value { color: var(--color-danger); font-size: 1.4rem; }
.kpi-card.kpi-go .value { color: var(--color-success); font-size: 1.4rem; }


/* ── 10. Chart Cards (Dashboard) ────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  padding: 0 var(--space-6) var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
}
.chart-card {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: var(--space-5);
  min-height: 380px;
  display: flex;
  flex-direction: column;
}
.chart-card .js-plotly-plot,
.chart-card .plot-container,
.chart-card .svg-container {
  flex: 1;
  width: 100% !important;
}
.chart-card.full { grid-column: 1 / -1; }
.chart-card h3 {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--brand-primary);
}


/* ── 11. Tables ─────────────────────────────────────────────────── */
/* Dashboard doc tables */
.doc-section {
  padding: 0 var(--space-6) var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
}
.doc-section h2 {
  font-size: 1.15rem;
  color: var(--brand-dark-alt);
  margin-bottom: var(--space-3);
  padding-top: var(--space-2);
  border-top: 2px solid var(--surface-border);
}
.doc-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-size: 0.9rem;
}
.doc-table th {
  background: var(--brand-dark-alt);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
}
.doc-table td {
  padding: var(--space-2) 14px;
  border-bottom: 1px solid var(--surface-border);
}
.doc-table tr:hover { background: #f0f7ff; }
.doc-table a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 500;
}
.doc-table a:hover { text-decoration: underline; }

/* Portal tables (scoped to page-body to avoid dashboard conflict) */
.page-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--surface-border);
  margin-bottom: var(--space-5);
}
.page-body th {
  background: var(--brand-dark);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.page-body td {
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--surface-border-light);
  font-size: 14px;
}
.page-body tr:last-child td { border-bottom: none; }
.page-body tr:hover td { background: var(--surface-hover); }
.page-body td a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 500;
}
.page-body td a:hover { text-decoration: underline; }


/* ── 12. Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-ok { background: #e6f4ea; color: #137333; }
.badge-warn { background: #fef7e0; color: #b06000; }
.badge-miss { background: #fce8e6; color: #c5221f; }
.badge-sev-p0 { background: #c5221f; color: #fff; }
.badge-sev-p1 { background: #ea4335; color: #fff; }
.badge-sev-p2 { background: #fbbc04; color: var(--text-primary); }
.badge-sev-p3 { background: #e8ecf0; color: var(--text-secondary); }

/* Inline stat badges (used in tower summaries) */
.stat-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}


/* ── 13. Buttons ────────────────────────────────────────────────── */
/* Document action buttons (cap pages) */
.cap-hero .doc-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.doc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  flex: 1 1 0;
  min-width: 200px;
  text-align: center;
}
.doc-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-dropdown);
  text-decoration: none;
}
.doc-btn.sad { background: var(--brand-primary); color: #fff; border-color: #0060a9; }
.doc-btn.sad:hover { background: #0060a9; }
.doc-btn.ricefw { background: var(--color-success); color: #fff; border-color: #2d9249; }
.doc-btn.ricefw:hover { background: #2d9249; }
.doc-btn.testing { background: var(--color-danger); color: #fff; border-color: #d33628; }
.doc-btn.testing:hover { background: #d33628; }
.doc-btn.disabled {
  background: var(--surface-border);
  color: var(--text-tertiary);
  cursor: default;
  border-color: #d0d5dd;
}
.doc-btn.disabled:hover { transform: none; box-shadow: none; }

/* Responsive: stack on small screens */
@media (max-width: 600px) {
  .doc-btn {
    flex: 1 1 100%;
    min-width: unset;
  }
}


/* ── 14. Filter Bar & Chips (Dashboard) ─────────────────────────── */
.filter-bar {
  padding: 10px var(--space-6);
  background: #fff;
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-bar .filter-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.filter-bar .filter-search {
  padding: 5px 10px;
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  font-size: 0.82rem;
  width: 180px;
  outline: none;
}
.filter-bar .filter-search:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(0,113,197,0.15);
}
.filter-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  max-height: 120px;
  overflow-y: auto;
}
.filter-chip {
  padding: 3px var(--space-3);
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--surface-border);
  background: var(--surface-page);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}
.filter-chip.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}
.filter-chip:hover { border-color: var(--brand-primary); }


/* ── 15. Pillar Tabs (Dashboard) ────────────────────────────────── */
.pillar-tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--space-6);
  max-width: 1400px;
  margin: 0 auto;
  border-bottom: 2px solid var(--surface-border);
  background: #fff;
}
.pillar-tab {
  padding: 14px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.pillar-tab:hover { color: var(--brand-primary); background: #f0f7ff; }
.pillar-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  background: #f0f7ff;
}
.pillar-tab .tab-icon { font-size: 1.1rem; }
.pillar-section { display: none; }
.pillar-section.active { display: block; }


/* ── 16. Section Title, Summary Panel, Footer (Portal) ──────────── */
.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-dark);
  margin: var(--space-8) 0 var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--surface-border);
}
.summary-panel {
  background: #f8f9fb;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}
.summary-panel h4 {
  margin: 0 0 var(--space-2);
  font-size: 14px;
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.footer {
  text-align: center;
  padding: var(--space-8) 0;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--surface-border);
  margin-top: var(--space-12);
}


/* ── 17. 404 Page ───────────────────────────────────────────────── */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.error-container {
  text-align: center;
  max-width: 600px;
  padding: var(--space-10) var(--space-6);
}
.error-container .icon { font-size: 72px; margin-bottom: var(--space-4); }
.error-container h1 { font-size: 28px; color: var(--brand-primary); margin-bottom: var(--space-2); }
.error-container .subtitle { font-size: 16px; color: #666; margin-bottom: var(--space-8); }
.error-container .message-box {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  text-align: left;
}
.error-container .message-box h3 { font-size: 15px; color: var(--brand-primary); margin-bottom: var(--space-3); }
.error-container .message-box ul { padding-left: var(--space-5); font-size: 14px; line-height: 1.8; color: #555; }
.error-container .actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block;
  padding: 10px var(--space-6);
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { background: #005a9e; }
.btn-secondary { background: #fff; color: var(--brand-primary); border: 1px solid var(--brand-primary); }
.btn-secondary:hover { background: #f0f7ff; }


/* ── 18. Responsive ─────────────────────────────────────────────── */
/* Dashboard breakpoints */
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-card { min-height: 320px; padding: var(--space-3); }
  .topbar:not(.topbar-portal) { flex-wrap: wrap; gap: var(--space-2); padding: 10px var(--space-4); }
  .topbar:not(.topbar-portal) h1 { font-size: 1rem; flex: 0 0 100%; }
  .topbar:not(.topbar-portal) .meta { font-size: 0.75rem; }
  .topbar:not(.topbar-portal) .nav-links { flex-wrap: wrap; gap: var(--space-1); }
  .tower-nav { padding: 6px var(--space-3); }
  .tower-nav a { padding: var(--space-1) 10px; font-size: 0.78rem; }
  .kpi-card .value { font-size: 1.6rem; }
  .kpi-card .label { font-size: 0.78rem; }
  .doc-table { font-size: 0.8rem; }
  .doc-table th, .doc-table td { padding: 6px var(--space-2); }
  .filter-bar { padding: var(--space-2) var(--space-3); }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-2); padding: var(--space-3); }
  .chart-card { min-height: 280px; padding: var(--space-2); }
  .chart-card h3 { font-size: 0.85rem; }
  .doc-table { font-size: 0.72rem; display: block; overflow-x: auto; }
}

/* Portal breakpoints */
@media (max-width: 768px) {
  .topbar.topbar-portal { padding: 0 var(--space-3); }
  .topbar.topbar-portal .sidebar-toggle { display: block; }
  .topbar.topbar-portal h1 { font-size: 14px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 16px rgba(0,0,0,0.15); }
  .page-body { margin-left: 0; }
  .hero { padding: 28px var(--space-5); text-align: center; }
  .hero h2 { font-size: 24px; }
  .hero div { flex-direction: column; align-items: center; }
}


/* ── 19. Print / PDF (Dashboard) ────────────────────────────────── */
@page {
  size: A4 landscape;
  margin: 12mm 10mm;
}
@media print {
  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body { background: #fff !important; font-size: 10pt; }

  /* Topbar — simple title bar */
  .topbar {
    position: static !important;
    background: var(--brand-dark-alt) !important;
    padding: var(--space-2) var(--space-4);
  }
  .topbar .nav-links { display: none; }
  .topbar .pdf-btn { display: none !important; }
  .topbar h1 { font-size: 14pt; }
  .topbar .meta { font-size: 9pt; }
  .topbar.topbar-portal { position: static !important; }

  /* Hide interactive elements */
  .tower-nav, .filter-bar, .pillar-tabs, .skip-link { display: none !important; }
  .pillar-section { display: block !important; }
  .sidebar { display: none !important; }
  .page-body { margin-left: 0 !important; margin-top: 0 !important; }

  /* KPI cards — 4 per row */
  .kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: var(--space-2);
    padding: var(--space-3) 0;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .kpi-card {
    padding: 10px;
    box-shadow: none;
    border: 1px solid #ddd;
  }
  .kpi-card .value { font-size: 1.4rem; }
  .kpi-card .label { font-size: 0.7rem; }

  /* Charts — single column */
  .chart-grid { display: block !important; padding: 0; }
  .chart-card {
    min-height: auto !important;
    max-height: none !important;
    height: auto !important;
    margin-bottom: var(--space-3);
    padding: var(--space-3);
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
    break-inside: avoid;
    overflow: hidden;
  }
  .chart-card .js-plotly-plot,
  .chart-card .plot-container,
  .chart-card .svg-container {
    max-height: 320px !important;
    overflow: hidden !important;
  }
  .chart-card .js-plotly-plot .main-svg { max-height: 320px !important; }
  .chart-card img.chart-snapshot {
    display: block !important;
    margin: 0 auto !important;
    max-width: 520px !important;
    max-height: 340px !important;
    width: auto !important;
    height: auto !important;
  }
  .chart-card.full { page-break-before: always; max-height: none !important; }
  .chart-card.full .js-plotly-plot,
  .chart-card.full .plot-container,
  .chart-card.full .svg-container,
  .chart-card.full .js-plotly-plot .main-svg { max-height: 450px !important; }
  .chart-card.full img.chart-snapshot {
    max-width: 90% !important;
    max-height: 420px !important;
  }

  /* Tables */
  .doc-section { padding: 0; }
  .doc-section h2 { font-size: 11pt; margin-bottom: 6px; }
  .doc-table { font-size: 8pt; box-shadow: none; border: 1px solid #ddd; }
  .doc-table th { padding: 6px var(--space-2); font-size: 7pt; }
  .doc-table td { padding: var(--space-1) var(--space-2); }
  .doc-table thead { display: table-header-group; }
  .doc-table tr { page-break-inside: avoid; break-inside: avoid; }

  /* Badges preserve color */
  .badge { border: 1px solid currentColor; }
}
