:root {
  --bg-main: #070a12;
  --bg-surface: #0b101d;
  --bg-card: #0f172a;
  --bg-card-header: #131c2e;
  --border-color: #1e293b;
  --border-color-hover: #334155;
  --text-primary: #f8fafc;
  --text-muted: #64748b;
  --text-sub: #94a3b8;
  --accent-cyan: #00f2fe;
  --accent-blue: #38bdf8;
  --accent-purple: #7f00ff;
  --status-success: #10b981;
  --status-warning: #f59e0b;
  --status-danger: #ef4444;
  --status-offline: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* HEADER SUPERIOR */
.app-header {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 10;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-img {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 15px;
  color: var(--text-primary);
}

.brand-sub {
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.header-center-info {
  display: flex;
  align-items: center;
}

.header-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-sub);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: var(--status-success);
  box-shadow: 0 0 8px var(--status-success);
}

.status-dot.offline {
  background-color: var(--status-offline);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.system-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.version-badge {
  background: var(--border-color);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* LAYOUT PRINCIPAL */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* SIDEBAR */
.app-sidebar {
  width: 230px;
  background: var(--bg-main);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.nav-item.active {
  color: var(--text-primary);
  border-left-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.05);
  font-weight: 600;
}

.nav-icon {
  font-size: 14px;
  width: 18px;
  display: inline-block;
  text-align: center;
}

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

.node-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.node-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.node-value {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent-blue);
}

/* CONTENIDO */
.app-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.content-view {
  display: none;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.content-view.active {
  display: flex;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.view-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.view-actions {
  display: flex;
  gap: 12px;
}

/* BOTONES */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent-cyan), #4facfe);
  color: #070a12;
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-color);
}

/* GRIDS Y PANELES */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

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

.metric-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-blue);
  font-family: var(--font-mono);
}

.metric-value .unit {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.workspace-grid {
  display: grid;
  gap: 16px;
  width: 100%;
}

.workspace-grid.split-2-1 {
  grid-template-columns: 2fr 1fr;
}

.workspace-grid.split-1-1 {
  grid-template-columns: 1fr 1fr;
}

.workspace-grid.split-1-2 {
  grid-template-columns: 1fr 2fr;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 380px;
}

.panel-header {
  background: var(--bg-card-header);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-body {
  padding: 16px;
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

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

.data-table th {
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.5);
  color: var(--text-sub);
}

/* ESTADO VACÍO (EMPTY STATE) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  padding: 40px 20px;
  text-align: center;
  width: 100%;
}

.empty-icon-container {
  width: 56px;
  height: 56px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-brand-icon {
  width: 28px;
  height: 28px;
  opacity: 0.4;
}

.empty-state h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.4;
}

/* COMPONENTES ESPECÍFICOS DE VISTAS */

/* System Health List */
.system-health-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.health-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
}

.item-name {
  color: var(--text-primary);
  font-weight: 500;
}

.item-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.status-offline {
  color: var(--status-offline);
  background: rgba(100, 116, 139, 0.1);
}

/* Pipeline Canvas */
.pipeline-canvas-panel {
  min-height: 480px;
}

.canvas-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--bg-main);
  background-image: radial-gradient(var(--border-color) 1px, transparent 0);
  background-size: 24px 24px;
}

.pipeline-flow-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 900px;
  margin-bottom: 24px;
}

.node-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 180px;
  text-align: center;
  overflow: hidden;
}

.node-header {
  background: var(--bg-card-header);
  padding: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.node-content {
  padding: 16px 12px;
  font-size: 12px;
  color: var(--text-sub);
  font-family: var(--font-mono);
}

.connector-line {
  height: 2px;
  flex: 1;
  background: var(--border-color);
  position: relative;
}

/* Editor Humano Code Block */
.editor-json-container {
  flex: 1;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: auto;
}

.code-block {
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

/* Mapa Panel */
.map-panel {
  min-height: 520px;
}

.map-container {
  padding: 0;
}

.map-placeholder-bg {
  width: 100%;
  height: 100%;
  min-height: 460px;
  background: #050811;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(to right, rgba(30, 41, 59, 0.3) 1px, transparent 1px),
                    linear-gradient(to bottom, rgba(30, 41, 59, 0.3) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Plantillas de Informes */
.report-templates-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-item {
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-item:hover, .template-item.active {
  border-color: var(--accent-blue);
  color: var(--text-primary);
  background: rgba(56, 189, 248, 0.05);
}

/* Console Logs */
.console-panel {
  min-height: 500px;
}

.log-filters {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.log-filters label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.console-body {
  background: var(--bg-main);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 16px;
}

.console-line {
  margin-bottom: 6px;
  line-height: 1.5;
}

.system-msg {
  color: var(--text-muted);
}

/* Metric Charts Placeholder */
.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  border-radius: 8px;
  margin: 8px;
}