/* =============================================================
   ULTI-CARE DATA PLATFORM PORTAL STYLES
   Extends health-theme.css design system
   ============================================================= */

/* ---- Lucide icon defaults ---- */
i[data-lucide] {
  stroke-width: 2.5;
  transition: color 0.15s, filter 0.15s;
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.05));
}
i[data-lucide]:hover {
  filter: drop-shadow(0 0 3px currentColor);
}

/* ---- Data Platform Portal Specific Tokens ---- */
:root {
  /* Layout */
  --sidebar-width: 280px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;

  /* Component sizing */
  --stat-card-height: 120px;
  --card-padding: 24px;
  --section-gap: 24px;
}

/* ---- Skip Link ---- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  z-index: 10000;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus {
  top: 16px;
}

/* ---- Mobile Nav Backdrop ---- */
.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, 0.5);
  z-index: 900;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.mobile-nav-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-label span,
.sidebar.collapsed .nav-group-links,
.sidebar.collapsed .nav-section {
  display: none;
}
.sidebar.collapsed .nav-label {
  justify-content: center;
  padding: 12px;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-mark {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  color: white;
  flex-shrink: 0;
}
.brand-icon { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-360 {
  color: var(--primary);
  font-weight: 800;
}
.brand-text span:last-child {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Navigation Sections */
.nav-section {
  padding: 12px 12px 8px;
  flex: 1;
}
.nav-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  background: none;
  border: none;
  width: 100%;
  font-family: var(--font-body);
}
.nav-label:hover { color: var(--text-primary); background: var(--panel-2); }
.nav-label i[data-lucide] {
  width: 14px; height: 14px;
  transition: transform 0.2s;
}
.nav-label[aria-expanded='true'] i[data-lucide] {
  transform: rotate(180deg);
}
.nav-group-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}
.nav-group-links.collapsed { max-height: 0; opacity: 0; pointer-events: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  font-weight: 500;
  font-size: 14px;
  position: relative;
}
.nav-item:hover { background: var(--panel-2); color: var(--primary); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }
.nav-badge {
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  margin-left: auto;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--panel-3); color: var(--primary); border-color: var(--primary); }
.icon-btn i[data-lucide] { width: 20px; height: 20px; }
.page-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* Theme Toggle */
.theme-toggle {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { background: var(--panel-3); color: var(--primary); border-color: var(--primary); }
.theme-toggle i { width: 20px; height: 20px; position: absolute; transition: opacity 0.2s, transform 0.2s; }
.theme-toggle .icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }
html[data-theme='dark'] .theme-toggle .icon-sun { opacity: 0; transform: rotate(90deg) scale(0.5); }
html[data-theme='dark'] .theme-toggle .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }

/* User Avatar */
.user-avatar {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  color: white;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-heading);
  cursor: pointer;
}

/* User menu (avatar -> sign out) */
.user-menu { position: relative; }
.user-avatar { border: none; padding: 0; }
.user-avatar:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.user-menu-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.user-menu-panel[hidden] { display: none; }

.user-menu-meta {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.user-menu-meta strong { font-size: 12px; color: var(--text-primary); word-break: break-all; }
.user-menu-meta span { font-size: 11px; color: var(--text-muted); }

.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 11px 14px;
  background: none; border: none; cursor: pointer;
  font: inherit; font-size: 13px; text-align: left;
  color: var(--text-primary);
}
.user-menu-item:hover { background: var(--panel-2, rgba(148, 163, 184, 0.12)); }
.user-menu-item i[data-lucide] { width: 16px; height: 16px; color: var(--text-muted); }

/* Main Layout */
.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-app);
  transition: margin-left 0.3s ease;
}
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-collapsed); }

/* Page Sections */
.page-section { padding: 32px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page-section:not(.active) { display: none; }

.section-header { margin-bottom: 24px; }
.section-header h2 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.section-subtitle { color: var(--text-muted); font-size: 15px; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--primary); box-shadow: var(--shadow-primary); transform: translateY(-2px); }
.stat-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.stat-icon i[data-lucide] { width: 24px; height: 24px; }
.stat-content { flex: 1; }
.stat-value {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* Content Grid */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
  gap: 20px;
}
@media (max-width: 900px) { .content-grid { grid-template-columns: 1fr; } }

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.card-header h3 {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.card-header i[data-lucide] { width: 20px; height: 20px; color: var(--primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Flow Diagram */
.flow-diagram,
.flow-diagram * { box-sizing: border-box; }
.flow-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 24px;
  max-width: 100%;
  min-width: 0;
  font-family: var(--font-body);
}
.flow-diagram.vertical { flex-direction: column; align-items: stretch; gap: 12px; }
.flow-step {
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 120px;
  max-width: 100%;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.flow-step:hover { border-color: var(--primary); box-shadow: var(--shadow-primary); }
.flow-step svg.lucide, .flow-step i[data-lucide] { width: 28px; height: 28px; flex-shrink: 0; color: var(--primary); margin-bottom: 8px; }
.flow-step span, .flow-step small { max-width: 100%; overflow-wrap: anywhere; }
.flow-step span { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.flow-step small { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.flow-arrow { display: flex; align-items: center; justify-content: center; color: var(--border); font-size: 18px; flex-shrink: 0; }
.flow-diagram.vertical .flow-arrow { align-self: center; transform: none; }

/* Quick Access Grid */
.quick-access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 8px;
}
.quick-access-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.quick-access-card:hover { border-color: var(--primary); box-shadow: var(--shadow-primary); transform: translateY(-2px); }
.quick-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.quick-icon i[data-lucide] { width: 22px; height: 22px; }
.quick-title { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.quick-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Product Grid */
.product-filters {
  display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.filter-btn {
  padding: 8px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
@media (max-width: 700px) { .product-grid { grid-template-columns: 1fr; } }

.product-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  position: relative;
}
.product-card:hover { border-color: var(--primary); box-shadow: var(--shadow-primary); transform: translateY(-4px); }
.product-card h3 {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
}
.tier {
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: var(--radius-full);
  background: var(--panel-2); color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0; margin-top: 2px;
}
.product-card .domain { font-size: 11px; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.product-card .owner { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.product-card .slas { font-size: 12px; color: var(--success); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.product-card .slas::before { content: ''; width: 6px; height: 6px; background: var(--success); border-radius: 50%; }

/* Detail Panel */
.detail-panel {
  border: 2px solid var(--primary) !important;
  box-shadow: var(--shadow-primary-lg);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.detail-panel h3 {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.detail-panel .meta { display: grid; grid-template-columns: 100px 1fr; gap: 8px 16px; margin: 16px 0; }
.detail-panel .meta dt { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.detail-panel .meta dd { color: var(--text-primary); font-size: 13px; margin: 0; font-weight: 500; }
.detail-panel p { color: var(--text-secondary); font-size: 14px; line-height: 1.6; margin-bottom: 16px; }
.detail-panel .tables h4 { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.detail-panel .tables span { display: inline-block; background: var(--panel-2); color: var(--text-primary); padding: 4px 10px; border-radius: var(--radius-sm); margin: 4px; font-size: 12px; font-family: var(--font-mono); font-weight: 500; }
.detail-panel .actions { display: flex; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn i[data-lucide] { width: 16px; height: 16px; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn { background: var(--primary); color: white; }
.btn:hover { background: var(--primary-dark); box-shadow: var(--shadow-primary); }
.btn-secondary { background: var(--panel-2); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--panel-3); border-color: var(--primary); color: var(--primary); }

/* Footer */
.footer {
  margin-left: var(--sidebar-width);
  padding: 16px 32px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  transition: margin-left 0.3s ease;
}
.sidebar.collapsed ~ .footer { margin-left: var(--sidebar-collapsed); }

/* Vertical flow (lineage / CDC trigger) — steps fill the card, text wraps inside */
.flow-diagram.vertical .flow-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  width: 100%; max-width: 100%;
  padding: 14px 18px;
  min-width: 0;
  text-align: left;
}
.flow-diagram.vertical .flow-step svg.lucide,
.flow-diagram.vertical .flow-step i[data-lucide] {
  grid-column: 1; grid-row: 1 / span 2;
  width: 28px; height: 28px;
  margin: 0;
}
.flow-diagram.vertical .flow-step span { grid-column: 2; display: block; min-width: 0; margin-bottom: 1px; }
.flow-diagram.vertical .flow-step small { grid-column: 2; display: block; min-width: 0; margin-top: 1px; }

.artifact-list, .contract-list, .feature-list { list-style: none; padding: 0; margin: 0; }
.artifact-list li, .contract-list li, .feature-list li {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 13px;
}
.artifact-list li:last-child, .contract-list li:last-child, .feature-list li:last-child { border-bottom: none; }
.artifact-list i[data-lucide], .contract-list i[data-lucide], .feature-list i[data-lucide] {
  width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; margin-top: 2px;
}
.artifact-list a { color: var(--primary); text-decoration: none; font-weight: 500; }
.artifact-list a:hover { text-decoration: underline; }
.artifact-list small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }

.coverage-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
@media (max-width: 700px) { .coverage-grid { grid-template-columns: repeat(2, 1fr); } }
.coverage-item { text-align: center; padding: 20px; background: var(--panel-2); border-radius: var(--radius-md); border: 1px solid var(--border); min-width: 0; }
.coverage-value { display: block; font-family: var(--font-heading); font-size: 36px; font-weight: 800; color: var(--primary); line-height: 1; overflow-wrap: anywhere; word-break: break-word; }
.coverage-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 4px; overflow-wrap: anywhere; word-break: break-word; }

/* Consumers & entitlements */
.consumer-table-wrap { overflow-x: auto; }
.consumer-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.consumer-table th {
  padding: 13px 16px;
  text-align: left;
  vertical-align: bottom;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.consumer-table td {
  padding: 14px 16px;
  vertical-align: top;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 12.5px;
}
.consumer-table tbody tr:last-child td { border-bottom: none; }
.consumer-table tbody tr:hover { background: var(--panel-2); }
.consumer-table th:first-child,
.consumer-table td:first-child { padding-left: 24px; width: 32%; }
.consumer-table th:last-child,
.consumer-table td:last-child { padding-right: 24px; }
.consumer-table th:nth-child(2),
.consumer-table td:nth-child(2) { width: 112px; }
.consumer-name {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.consumer-id {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.consumer-empty { color: var(--text-muted); }
.tier-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.tier-domain { background: var(--primary-bg); color: var(--primary); }
.tier-stakeholder { background: var(--secondary-bg); color: var(--secondary); }
.chip-role { background: var(--info-bg); border-color: transparent; color: var(--info); }

/* Control plane */
.card-body { padding: 18px 24px 22px; }
.card-header { flex-wrap: wrap; row-gap: 6px; }
.card-header .card-subtitle { margin: 0 0 0 auto; text-align: right; }
.control-lead {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.control-lead strong { color: var(--text-primary); }
.control-domains { margin: 12px 0 16px; }
.control-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.control-list li {
  position: relative;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.control-list li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}
.control-list code,
.feature-list code,
.artifact-list code,
.contract-list code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text-primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Card content spacing */
.card > .feature-list,
.card > .artifact-list,
.card > .contract-list { padding: 10px 24px 18px; }
.card > .coverage-grid:not(.arch-slo) { padding: 20px 24px 24px; }
.card > .catalog-grid { padding: 16px 24px 20px; }

.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.catalog-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none; color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.catalog-item:hover { border-color: var(--primary); box-shadow: var(--shadow-primary); transform: translateY(-2px); }
.catalog-icon { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); flex-shrink: 0; }
.catalog-icon i[data-lucide] { width: 22px; height: 22px; }
.catalog-item strong { display: block; color: var(--text-primary); font-size: 14px; margin-bottom: 2px; }
.catalog-item small { color: var(--text-muted); font-size: 11px; }
.catalog-item { cursor: pointer; }
.catalog-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Catalog asset viewer */
body.modal-open { overflow: hidden; }

.asset-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(2px);
}

.asset-dialog {
  display: flex; flex-direction: column;
  width: min(960px, 100%); max-height: 86vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.asset-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-alt, rgba(148, 163, 184, 0.06));
}
.asset-header h3 { margin: 0; font-size: 16px; color: var(--text-primary); }
.asset-header > div { flex: 1; min-width: 0; }
.asset-path {
  display: block; margin-top: 2px;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 11px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.asset-close {
  border: none; background: none; cursor: pointer;
  font-size: 24px; line-height: 1; padding: 0 4px;
  color: var(--text-muted);
}
.asset-close:hover { color: var(--text-primary); }

.asset-body { padding: 16px 20px 20px; overflow: auto; }
.asset-meta { margin-bottom: 10px; font-size: 11px; color: var(--text-muted); }
.asset-code {
  margin: 0; padding: 16px;
  background: var(--code-bg, rgba(15, 23, 42, 0.55));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px; line-height: 1.55;
  color: var(--text-primary);
  white-space: pre; overflow: auto;
}
.asset-status { margin: 0; color: var(--text-muted); font-size: 13px; }
.asset-error { color: var(--danger, #f87171); }
.asset-hint { margin: 10px 0 0; font-size: 12px; color: var(--text-muted); }
.asset-hint code, .asset-error code { font-family: var(--font-mono, ui-monospace, monospace); }

/* Footer for grid items */
.footer { margin-top: auto; }

/* Mobile Sidebar Toggle */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar.collapsed ~ .main { margin-left: 0; }
  .footer { margin-left: 0; }
  .sidebar.collapsed ~ .footer { margin-left: 0; }
  .mobile-nav-backdrop.visible { opacity: 1; visibility: visible; }
}

/* Dark theme adjustments */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg-app: linear-gradient(180deg, #0a1612 0%, #0f1a1c 100%);
    --panel: #142823;
    --panel-2: #1a302a;
    --panel-3: #213b33;
    --bg-card: #142823;
    --bg-elevated: #1a302a;
    --border: #2a4339;
    --border-light: #1e3a31;
    --border-strong: #3a5648;
    --text-primary: #f0fdfa;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary-bg: #064e4a;
    --secondary-bg: #1e1b4b;
    --accent-bg: #422006;
    --success-bg: #064e3b;
    --warning-bg: #451a03;
    --info-bg: #1e3a5f;
    --panel-2: #1a302a;
    --panel-3: #213b33;
    --border-light: #1e3a31;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast */
@media (prefers-contrast: high) {
  :root { --border: currentColor; --border-light: currentColor; --border-strong: currentColor; }
}

/* Architecture section */
.arch-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.arch-actions .btn i[data-lucide] { width: 16px; height: 16px; }

.arch-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  font-size: 13px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.arch-note strong { color: var(--text-primary); }
.arch-note-text { flex: 1 1 260px; min-width: 0; }

.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-deployed { background: var(--success-bg); color: var(--success); }
.status-config { background: var(--info-bg); color: var(--info); }
.status-target { background: var(--warning-bg); color: var(--warning); }
.status-gap { background: var(--danger-bg); color: var(--danger); }

.arch-layers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 24px;
}
.arch-layer {
  display: grid;
  grid-template-columns: 52px minmax(160px, 240px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  min-width: 0;
}
.arch-layer-code {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.4;
}
.arch-layer-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-primary);
}
.arch-layer-name i[data-lucide] { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.arch-layer-name strong { font-size: 14px; }
.arch-layer-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.arch-layer-body span { font-size: 13px; color: var(--text-secondary); overflow-wrap: anywhere; }
.arch-layer-body small { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; overflow-wrap: anywhere; }

.arch-table-wrap { overflow-x: auto; padding: 8px 16px 16px; max-width: 100%; }
#archDags { min-width: 0; max-width: 100%; }
.arch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 480px;
}
.arch-table th,
.arch-table td {
  padding: 10px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-light);
  overflow-wrap: anywhere;
}
.arch-table th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}
.arch-table tbody tr:last-child td { border-bottom: none; }
.arch-table td { color: var(--text-secondary); }
.arch-table td strong { color: var(--text-primary); }
.arch-table .mono,
.mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.arch-tables { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.arch-table-group { min-width: 0; }
.arch-table-group-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--panel);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.arch-slo { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; padding: 0 24px 20px; }
.arch-slo .coverage-item { padding: 16px 12px; }
.arch-slo .coverage-value { font-size: 26px; }
.arch-slo .coverage-label { font-size: 11px; line-height: 1.35; }
@media (max-width: 900px) {
  .arch-layer { grid-template-columns: 1fr; gap: 6px; }
  .arch-slo { grid-template-columns: repeat(2, 1fr); }
}
.arch-gap-list li { gap: 10px; }
.arch-gap-list .status { flex-shrink: 0; margin-top: 1px; }
.arch-gap-list li > span:last-child { min-width: 0; overflow-wrap: anywhere; }

/* Prevent text overflow / truncation in cards, control plane & dashboards */
.content-grid > * { min-width: 0; }
.card { min-width: 0; }
.card-header { gap: 12px; min-width: 0; }
.card-header h3 { min-width: 0; flex-wrap: wrap; overflow-wrap: anywhere; }

.feature-list li,
.artifact-list li,
.contract-list li {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
}
.feature-list li strong { overflow-wrap: anywhere; }

/* Dashboard bar charts */
.dash-chart {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.dash-bar-row { min-width: 0; }
.dash-bar-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.dash-bar-label .name {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}
.dash-bar-label .value {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-primary);
}
.dash-bar-track {
  height: 10px;
  background: var(--panel-3, #334155);
  border-radius: 5px;
  overflow: hidden;
}
.dash-bar-fill {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, #24a39d, #38bdf8);
}

/* Live dashboard status + KPI tiles */
.dash-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--text-secondary);
  min-width: 0;
}
.dash-status #dashStatusText { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.dash-status .btn { flex: 0 0 auto; }
.dash-status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-muted, #94a3b8);
  flex: 0 0 auto;
}
.dash-status-dot.pending { background: #f59e0b; animation: dashPulse 1s ease-in-out infinite; }
.dash-status-dot.ok { background: #10b981; }
.dash-status-dot.warn { background: #f59e0b; }
.dash-status-dot.err { background: #ef4444; }
@keyframes dashPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-width: 0;
}
.kpi-value {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.kpi-label {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.kpi-source {
  margin-top: 6px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.dash-foot {
  padding: 0 24px 16px;
  font-size: 10.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.dash-empty {
  padding: 12px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.dash-empty.dash-error { color: #ef4444; }
.dash-note {
  margin: 0 0 18px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.dash-note code {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-3, rgba(148, 163, 184, 0.16));
}

/* Print styles */
@media print {
  .sidebar, .topbar, .footer, .theme-toggle, .icon-btn, .mobile-nav-backdrop { display: none !important; }
  .main { margin-left: 0; }
  .page-section { page-break-inside: avoid; }
  .stat-card, .card { break-inside: avoid; }
}

/* Per-epic sequence diagrams (Mermaid, rendered client-side) */
.diagram-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 12px;
}
.diagram-item {
  border: 1px solid var(--border, rgba(148, 163, 184, 0.28));
  border-radius: 10px;
  padding: 14px 16px 16px;
  background: var(--panel-2, rgba(148, 163, 184, 0.06));
  min-width: 0;
}
.diagram-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.diagram-head h4 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.3;
}
.diagram-head a {
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0.75;
}
.diagram-sub {
  margin: 4px 0 10px;
  font-size: 0.76rem;
  line-height: 1.4;
  opacity: 0.72;
}
.diagram-canvas {
  overflow-x: auto;
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
}
.diagram-canvas svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
[data-theme="dark"] .diagram-canvas { background: #0f172a; }

/* ==========================================================================
   Presentation polish (2026-10-22)
   Rhythm, readability and overflow safety across every section.
   ========================================================================== */

/* theme.js injects a floating pill; this portal already has a topbar toggle
   and the pill overlapped the sidebar footer. */
#themeToggle { display: none !important; }

/* ---------- Sidebar: never truncate labels ---------- */
.sidebar { padding-bottom: 20px; }
.sidebar .nav-item { align-items: flex-start; line-height: 1.35; gap: 10px; }
/* health-theme.css re-injected by theme.js sets `nav a span` to nowrap/ellipsis
   with higher specificity, so scope these to the portal sidebar id. */
#portalSidebar .nav-item > span:not(.nav-icon):not(.nav-icon-svg):not(.nav-badge) {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: break-word;
}
#portalSidebar .nav-item > .nav-badge {
  flex: 0 0 auto;
  margin-top: 1px;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
#portalSidebar .nav-item > svg.lucide,\n#portalSidebar .nav-item > .nav-icon { flex: 0 0 auto; margin-top: 1px; }

/* ---------- Cards: consistent body padding for loose children ---------- */
.content-grid { align-items: start; }
.content-grid > .card.is-wide { grid-column: 1 / -1; }
.card:not(.detail-panel) > p,
.card:not(.detail-panel) > .dash-note {
  margin: 0;
  padding: 16px 24px 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.card:not(.detail-panel) > p code {
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-2);
}
.card:not(.detail-panel) > p:last-child { padding-bottom: 20px; }
.card:not(.detail-panel) > .btn { margin: 16px 24px 20px; }
.card:not(.detail-panel) > p + .btn { margin-top: 14px; }
.card:not(.detail-panel) > .btn + p { padding-top: 14px; }
.card-header { padding: 16px 24px; }

/* Data Flow Check: compact status strip instead of a half-empty card */
.card.flow-check-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 20px;
  row-gap: 10px;
  padding: 18px 24px 20px;
}
.card.flow-check-card .card-header {
  grid-column: 1 / -1;
  padding: 0 0 12px;
  margin: 0;
  background: none;
  border-bottom: 1px solid var(--border);
}
article.card.flow-check-card > p { padding: 0; margin: 0; }
.card.flow-check-card > .btn { margin: 0; grid-row: 2; grid-column: 2; }
.card.flow-check-card > #dataFlowResult { grid-column: 1 / -1; margin: 0 !important; }

/* ---------- Section rhythm ---------- */
.section-header { margin-bottom: 22px; }
.section-header h2 { letter-spacing: -0.01em; }
.stat-card { padding: 18px 20px; }
.stat-value { font-variant-numeric: tabular-nums; }

/* ---------- Buttons & focus ---------- */
.btn { min-height: 38px; border-radius: 10px; }
.btn:focus-visible,
.nav-item:focus-visible,
.quick-access-card:focus-visible,
.icon-btn:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Flow diagrams: one row, readable arrows ---------- */
.flow-arrow { color: var(--text-muted); }
.flow-arrow svg.lucide,
.flow-arrow i[data-lucide] { width: 16px; height: 16px; stroke-width: 2.4; }
.flow-diagram:not(.vertical) {
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 6px;
  padding: 22px 20px;
  overflow-x: auto;
}
.flow-diagram:not(.vertical) .flow-step {
  flex: 1 1 0;
  min-width: 92px;
  padding: 14px 10px;
}
.flow-diagram:not(.vertical) .flow-step svg.lucide,
.flow-diagram:not(.vertical) .flow-step i[data-lucide] {
  width: 22px; height: 22px; margin-bottom: 6px;
}
.flow-diagram:not(.vertical) .flow-step span { font-size: 12px; }
.flow-diagram:not(.vertical) .flow-step small { font-size: 10.5px; line-height: 1.3; }
.flow-diagram.vertical { padding: 18px 20px; gap: 10px; }
.flow-diagram.vertical .flow-arrow { padding: 2px 0; }

/* ---------- Quick access ---------- */
.quick-access-grid { padding: 16px; gap: 12px; }

/* ---------- Per-epic sequence diagrams: full width, readable ---------- */
.diagram-list { grid-template-columns: minmax(0, 1fr); gap: 18px; margin-top: 16px; }
.diagram-item { padding: 16px 18px 18px; }
.diagram-head { align-items: center; }
.diagram-head h4 { font-size: 0.92rem; }
.diagram-sub { margin: 6px 0 12px; }
.diagram-canvas { padding: 12px; }
.diagram-canvas svg { min-width: 720px; }
/* Explicit two-row flows (architecture E2E) wrap on a controlled break instead
   of hiding steps behind a horizontal scrollbar. */
.flow-diagram.flow-wrap { flex-wrap: wrap; justify-content: center; row-gap: 16px; }
.flow-break { flex: 0 0 100%; height: 0; margin: 0; }
.flow-continue { transform: rotate(90deg); align-self: center; }

/* Tables break long tokens only when unavoidable (no letter soup). */
.arch-table th, .arch-table td { overflow-wrap: break-word; }

@media (max-width: 1150px) {
  /* Wrap instead of horizontal scroll so every step stays visible */
  .flow-diagram:not(.vertical) { flex-wrap: wrap; justify-content: center; row-gap: 12px; }
  .flow-diagram:not(.vertical) .flow-step { flex: 0 1 auto; min-width: 104px; }
}
@media (max-width: 900px) {
  .diagram-canvas svg { min-width: 600px; }
}

/* ---------- Live dashboards ---------- */
.kpi-tile { padding: 16px 18px; }
.kpi-value { font-size: 26px; }
.dash-foot { padding-top: 6px; }

/* ---------- Architecture tables: let columns breathe, scroll if needed ---------- */
.arch-table { min-width: 660px; }
/* Half-width cards fit their table by wrapping prose instead of scrolling it away. */
.content-grid > .card:not(.is-wide) .arch-table { min-width: 0; }
.arch-table-wrap::-webkit-scrollbar,
.consumer-table-wrap::-webkit-scrollbar,
.flow-diagram::-webkit-scrollbar,
.diagram-canvas::-webkit-scrollbar { height: 9px; width: 9px; }
.arch-table-wrap::-webkit-scrollbar-thumb,
.consumer-table-wrap::-webkit-scrollbar-thumb,
.flow-diagram::-webkit-scrollbar-thumb,
.diagram-canvas::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
.arch-table-wrap::-webkit-scrollbar-track,
.consumer-table-wrap::-webkit-scrollbar-track,
.flow-diagram::-webkit-scrollbar-track,
.diagram-canvas::-webkit-scrollbar-track { background: transparent; }

/* ---------- Footer ---------- */
.footer { padding: 18px 32px; font-size: 12.5px; letter-spacing: 0.01em; }

/* ---------- Responsive tuning ---------- */
@media (max-width: 1024px) {
  .page-section { padding: 22px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
}
@media (max-width: 720px) {
  .page-section { padding: 16px 14px 28px; }
  .section-header h2 { font-size: 22px; }
  .section-subtitle { font-size: 13.5px; }
  .stats-grid { grid-template-columns: 1fr; gap: 12px; }
  .card-header, .card-body, .dash-chart { padding-left: 16px; padding-right: 16px; }
  .card:not(.detail-panel) > p,
  .card:not(.detail-panel) > .dash-note { padding-left: 16px; padding-right: 16px; }
  .card:not(.detail-panel) > .btn { margin-left: 16px; margin-right: 16px; }
  .card.flow-check-card { grid-template-columns: 1fr; padding: 16px; }
  .card.flow-check-card > .btn { grid-column: 1 / -1; grid-row: auto; justify-self: start; margin-top: 4px; }
  .flow-diagram:not(.vertical) { padding: 16px; }
  .flow-diagram:not(.vertical) .flow-step { min-width: 84px; }
  .diagram-item { padding: 14px; }
  .diagram-canvas { padding: 8px; }
  .diagram-canvas svg { min-width: 540px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 10px; }
  .kpi-value { font-size: 22px; }
  .consumer-table th:first-child, .consumer-table td:first-child { padding-left: 16px; }
  .consumer-table th:last-child, .consumer-table td:last-child { padding-right: 16px; }
  .footer { padding: 16px 18px; }
}
@media (max-width: 420px) {
  .diagram-canvas svg { min-width: 480px; }
  .flow-diagram:not(.vertical) .flow-step { min-width: 78px; padding: 12px 8px; }
  .flow-diagram:not(.vertical) .flow-step span { font-size: 11px; }
}

/* SLO tiles: long values (BACKWARD) must not break mid-word. */
.arch-slo { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.arch-slo .coverage-value { font-size: 22px; letter-spacing: -0.01em; overflow-wrap: normal; word-break: normal; }


/* ---------- SDG analytics ---------- */
.sdg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.sdg-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 18px 18px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.sdg-card.is-gap { border-style: dashed; }
.sdg-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sdg-code {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(36, 163, 157, 0.16);
  color: #2dd4bf;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.sdg-goal-title {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.sdg-score-row { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.sdg-score {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.sdg-card.is-gap .sdg-score { font-size: 16px; color: var(--text-muted); }
.sdg-score-unit { font-size: 11px; color: var(--text-muted); }
.sdg-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--panel-3, #334155);
  overflow: hidden;
}
.sdg-bar > span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #24a39d, #38bdf8);
}
.sdg-indicators { display: grid; gap: 8px; min-width: 0; }
.sdg-indicator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.sdg-ind-label { font-size: 12px; color: var(--text-secondary); overflow-wrap: anywhere; }
.sdg-ind-value {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.sdg-ind-hint {
  grid-column: 1 / -1;
  font-size: 10.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.sdg-gap {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: #f59e0b;
  overflow-wrap: anywhere;
}
.sdg-sources { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.sdg-sources code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--panel-3, rgba(148, 163, 184, 0.16));
  color: var(--text-muted);
  font-size: 10px;
  overflow-wrap: anywhere;
}
@media (max-width: 720px) {
  .sdg-grid { grid-template-columns: 1fr; }
  .sdg-card { padding: 16px; }
}


/* ---------- Business analytics ---------- */
.biz-chart { overflow: hidden; }
.biz-svg { display: block; width: 100%; height: auto; }
.biz-svg-label { fill: var(--text-primary); font-size: 11px; font-weight: 600; }
.biz-svg-muted { fill: var(--text-muted); font-size: 10px; }
.biz-svg-value {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.biz-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.biz-donut-total { fill: var(--text-primary); font-size: 15px; font-weight: 800; }
.biz-heat-value { fill: var(--text-primary); font-size: 10px; font-weight: 700; }
.biz-heat-value.is-strong { fill: var(--text-primary); font-weight: 800; }

.biz-donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.biz-donut-wrap > .biz-svg { flex: 0 1 208px; max-width: 208px; }
.biz-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  flex: 1 1 180px;
  min-width: 0;
}
.biz-legend li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  min-width: 0;
}
.biz-legend-wrap { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.biz-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: 0 0 auto; }
.biz-legend-label { color: var(--text-secondary); overflow-wrap: anywhere; }
.biz-legend-value { font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.biz-legend-share { color: var(--text-muted); font-size: 10.5px; text-align: right; white-space: nowrap; }

.biz-legend-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.biz-legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.biz-legend-inline i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.biz-gb-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.biz-gb-legend span { display: inline-flex; align-items: center; gap: 6px; }
.biz-gb-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.biz-gb-legend i.budget { background: rgba(148, 163, 184, 0.55); }
.biz-gb-legend i.actual { background: linear-gradient(90deg, #24a39d, #38bdf8); }
.biz-gb-row { padding: 9px 0; border-top: 1px solid var(--border); min-width: 0; }
.biz-gb-row:first-of-type { border-top: 0; padding-top: 2px; }
.biz-gb-head { display: flex; justify-content: space-between; gap: 10px; min-width: 0; }
.biz-gb-name { font-size: 12px; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.biz-gb-meta { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }
.biz-gb-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--panel-3, #334155);
  margin-top: 5px;
  overflow: hidden;
}
.biz-gb-budget, .biz-gb-actual { display: block; height: 100%; border-radius: 4px; }
.biz-gb-budget { background: rgba(148, 163, 184, 0.55); }
.biz-gb-actual { background: linear-gradient(90deg, #24a39d, #38bdf8); }

.biz-alloc-bar {
  display: flex;
  height: 18px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel-3, #334155);
  margin-bottom: 14px;
}
.biz-alloc-bar > span { display: block; height: 100%; }

.biz-cov-row { padding: 10px 0; border-top: 1px solid var(--border); min-width: 0; }
.biz-cov-row:first-child { border-top: 0; padding-top: 2px; }
.biz-cov-head { display: flex; justify-content: space-between; gap: 10px; min-width: 0; }
.biz-cov-name { font-size: 12px; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.biz-cov-meta { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.biz-cov-track {
  height: 8px;
  border-radius: 4px;
  background: var(--panel-3, #334155);
  margin: 6px 0 4px;
  overflow: hidden;
}
.biz-cov-track > span { display: block; height: 100%; background: linear-gradient(90deg, #a78bfa, #38bdf8); }
.biz-cov-foot { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-muted); }
.biz-cov-pct { color: var(--text-primary); font-weight: 700; }

#businessKpis { grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
@media (min-width: 1200px) {
  #businessKpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  #bizChartHeat { overflow-x: auto; }
  #bizChartHeat .biz-svg { min-width: 520px; }
  .biz-donut-wrap { flex-direction: column; align-items: stretch; }
  .biz-donut-wrap > .biz-svg { align-self: center; flex-basis: auto; width: 180px; }
  .biz-legend { grid-template-columns: 1fr; }
  .biz-gb-head, .biz-cov-head { flex-wrap: wrap; }
  .biz-gb-meta, .biz-cov-meta { white-space: normal; }
}
