:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.95);
  --border-color: rgba(75, 85, 99, 0.4);
  --border-active: #3b82f6;
  
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo-badge {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-text span {
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 600;
  text-transform: uppercase;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 16px 16px 6px;
  letter-spacing: 0.8px;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.nav-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), rgba(6, 182, 212, 0.05));
  color: var(--accent-cyan);
  border-left: 3px solid var(--accent-cyan);
  font-weight: 600;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.tenant-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.tenant-info {
  display: flex;
  flex-direction: column;
}

.tenant-name {
  font-size: 12px;
  font-weight: 600;
}

.tenant-role {
  font-size: 10px;
  color: var(--accent-emerald);
}

/* Main Workspace Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.top-bar {
  height: 56px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.view-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-title {
  font-size: 18px;
  font-weight: 700;
}

.badge-live {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-active);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), #2563eb);
  border: none;
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.btn-danger {
  background-color: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.4);
}

.btn-danger:hover {
  background-color: var(--accent-rose);
  color: white;
}

/* Content Views */
.view-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: none;
}

.view-panel.active {
  display: block;
}

/* KPI Summary Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.kpi-title {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0;
  font-family: var(--font-mono);
}

.kpi-sub {
  font-size: 11px;
  color: var(--accent-emerald);
}

.kpi-sub.warn {
  color: var(--accent-amber);
}

.kpi-sub.danger {
  color: var(--accent-rose);
}

/* Section Grids */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-p0 { background-color: rgba(244, 63, 94, 0.2); color: var(--accent-rose); border: 1px solid var(--accent-rose); }
.badge-p1 { background-color: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.badge-p2 { background-color: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.badge-p3 { background-color: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-good { background-color: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

/* SVG Live Chart Area */
.chart-container {
  height: 220px;
  width: 100%;
  position: relative;
  margin-top: 10px;
}

svg.telemetry-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-line {
  fill: none;
  stroke-width: 2;
}

.chart-grid-line {
  stroke: var(--border-color);
  stroke-dasharray: 4, 4;
}

/* Schematic Interactive Box */
.schematic-box {
  background-color: #0d131f;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.node-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.node-name {
  font-weight: 600;
}

.node-voltage {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Hypothesis Card */
.hypothesis-card {
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent-cyan);
  padding: 14px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.hypo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.hypo-title {
  font-weight: 700;
  font-size: 14px;
}

.hypo-confidence {
  font-weight: 800;
  color: var(--accent-emerald);
  font-family: var(--font-mono);
}

.hypo-desc {
  font-size: 12px;
  color: var(--text-muted);
}
