/* ==========================================================================
   Global Platform Admin — Premium Dark Design System
   Source of Truth: docs/governance/ADMIN_UI_DESIGN_SYSTEM.md
   Scope: Platform Owner Control Plane (Multi-Tenant Governance)
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #0a0d14;
  --sidebar-bg: #0e121b;
  --topbar-bg: rgba(14, 18, 27, 0.88);
  --surface: #131823;
  --surface-2: #182030;
  --surface-3: #1e283a;
  --surface-hover: #222d42;
  --border: rgba(148, 163, 184, 0.12);
  --border-subtle: rgba(148, 163, 184, 0.08);
  --border-focus: rgba(96, 165, 250, 0.45);
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.15);
  --primary-border: rgba(59, 130, 246, 0.35);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.12);
  --green-border: rgba(16, 185, 129, 0.32);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.32);
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.14);
  --purple-border: rgba(139, 92, 246, 0.32);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --red-border: rgba(239, 68, 68, 0.32);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* ==========================================================================
   Shell Layout
   ========================================================================== */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mobile-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */

.sidebar {
  width: 270px;
  flex: 0 0 270px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  z-index: 50;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: grid;
  place-items: center;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.brand-copy strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-copy small {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-close {
  display: none;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 20px;
  padding: 4px 8px;
}

.workspace-chip {
  margin: 12px 14px 4px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-chip .avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 11px;
}

.workspace-chip span strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.workspace-chip span small {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
}

.workspace-chip .chevron {
  margin-left: auto;
  color: var(--text-subtle);
  font-size: 12px;
}

.nav-label {
  margin: 14px 18px 4px;
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
}

.primary-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 550;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-subtle);
}

.nav-item.active {
  background: var(--surface-2);
  color: #fff;
  border-color: rgba(59, 130, 246, 0.4);
  font-weight: 650;
  box-shadow: inset 3px 0 0 #3b82f6;
}

.nav-icon {
  font-size: 14px;
  color: var(--text-muted);
  width: 16px;
  text-align: center;
}

.nav-item.active .nav-icon {
  color: #60a5fa;
}

.nav-state {
  margin-left: auto;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
}

.nav-state.good {
  background: var(--green-soft);
  color: #6ee7b7;
}

.nav-state.notwired {
  background: var(--purple-soft);
  color: #c4b5fd;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(10, 13, 20, 0.5);
}

.isolation-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  color: #93c5fd;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(30, 58, 138, 0.25);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.isolation-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 6px #60a5fa;
}

/* ==========================================================================
   Main Layout & Topbar
   ========================================================================== */

.main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.topbar {
  height: 68px;
  flex: 0 0 68px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.mobile-menu {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  place-items: center;
  font-size: 16px;
}

.breadcrumb {
  font-size: 11px;
  font-weight: 600;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.page-title {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.015em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-subtitle {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.secondary-button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.secondary-button:hover {
  background: var(--surface-2);
  color: #fff;
  border-color: var(--border-focus);
}

.topbar-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.topbar-profile .avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1e3a8a, #4338ca);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 11px;
}

.profile-copy strong {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
}

.profile-copy small {
  display: block;
  font-size: 9.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   Content Area
   ========================================================================== */

.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.scope-banner {
  background: linear-gradient(180deg, rgba(19, 24, 35, 0.95), rgba(15, 20, 30, 0.95));
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.scope-banner-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.scope-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #93c5fd;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.scope-banner h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: #fff;
}

.scope-banner p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  max-width: 860px;
  line-height: 1.5;
}

.scope-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.tag.blue {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: #93c5fd;
}

.tag.purple {
  background: var(--purple-soft);
  border-color: var(--purple-border);
  color: #c4b5fd;
}

.tag.amber {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: #fcd34d;
}

/* ==========================================================================
   Section & Card Composition
   ========================================================================== */

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-header h2 {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: #fff;
}

.section-header p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-badge.good {
  background: var(--green-soft);
  color: #6ee7b7;
  border-color: var(--green-border);
}

.status-badge.readonly {
  background: var(--primary-soft);
  color: #93c5fd;
  border-color: var(--primary-border);
}

.status-badge.pending {
  background: var(--amber-soft);
  color: #fcd34d;
  border-color: var(--amber-border);
}

.status-badge.notwired {
  background: var(--purple-soft);
  color: #c4b5fd;
  border-color: var(--purple-border);
}

.status-badge.warn {
  background: var(--red-soft);
  color: #fca5a5;
  border-color: var(--red-border);
}

/* ==========================================================================
   Grids
   ========================================================================== */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.metric-card:hover {
  border-color: rgba(148, 163, 184, 0.25);
  transform: translateY(-1px);
}

.metric-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-card-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-card-icon {
  font-size: 15px;
  color: #93c5fd;
}

.metric-card-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 2px 0;
}

.metric-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.inner-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.inner-card:last-child {
  margin-bottom: 0;
}

.inner-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.inner-card p {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(30, 58, 138, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 14px;
}

.callout.warn {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fde68a;
}

.callout-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

.callout.warn .callout-icon {
  background: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.callout strong {
  display: block;
  color: #fff;
  margin-bottom: 2px;
}

/* ==========================================================================
   Tables & Lists
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.data-table th {
  background: var(--surface-3);
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.1);
  padding: 2px 5px;
  border-radius: 4px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row span {
  color: var(--text-muted);
}

.list-row strong {
  color: #fff;
}

/* ==========================================================================
   Telemetry & Quality Slotted Cards
   ========================================================================== */

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.telemetry-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.telemetry-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.telemetry-value {
  font-size: 16px;
  font-weight: 750;
  color: #fff;
}

.telemetry-bar-wrap {
  height: 4px;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 2px;
}

.telemetry-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.telemetry-bar.amber { background: var(--amber); }
.telemetry-bar.purple { background: var(--purple); }
.telemetry-bar.green { background: var(--green); }

.telemetry-help {
  font-size: 10px;
  color: var(--text-subtle);
}

/* ==========================================================================
   Navigation Shortcuts
   ========================================================================== */

.surface-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.surface-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s ease;
}

.surface-tile:hover {
  background: var(--surface-3);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.surface-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.surface-tile-icon {
  font-size: 14px;
  color: #93c5fd;
}

.surface-tile strong {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.surface-tile small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   Empty State & Toast
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 38px 24px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.empty-icon {
  font-size: 28px;
  color: var(--text-subtle);
  margin-bottom: 8px;
}

.empty-state h3 {
  margin: 0 0 4px;
  font-size: 14px;
  color: #fff;
}

.empty-state p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 480px;
  margin-inline: auto;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-3);
  border: 1px solid var(--border-focus);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1200px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .telemetry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .surface-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .two-column {
    grid-template-columns: 1fr;
  }
  .three-column {
    grid-template-columns: 1fr;
  }
  .metric-grid.cols-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: block;
  }

  .mobile-menu {
    display: grid;
  }

  .topbar {
    padding: 0 16px;
  }

  .content-scroll {
    padding: 16px;
  }

  .scope-banner-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .topbar-actions .topbar-profile {
    display: none;
  }
}
