:root {
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  
  --bg-app: #060b14;
  --bg-header: rgba(10, 18, 32, 0.85);
  --bg-card: rgba(13, 22, 38, 0.85);
  --bg-card-hover: rgba(18, 30, 52, 0.95);
  --bg-input: #040810;
  
  --border-subtle: rgba(45, 65, 95, 0.55);
  --border-hover: rgba(88, 214, 179, 0.4);
  --border-focus: #10b981;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.15);
  --emerald-light: #e3f5ec;
  --cyan: #06b6d4;
  --indigo: #6366f1;
  --amber: #f59e0b;
  --coral: #f43f5e;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px -5px rgba(16, 185, 129, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: 
    radial-gradient(circle at 10% 0%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(6, 182, 212, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
    var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  display: flex;
  justifyContent: space-between;
  align-items: center;
  padding: 14px max(24px, 4vw);
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge strong {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
  animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.header-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
}

.control-plane-tag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--emerald);
  background: var(--emerald-glow);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.cluster-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.header-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-ext-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-ext-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--coral);
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: rgba(244, 63, 94, 0.2);
}

/* Main Container */
.main-container {
  width: min(1200px, 92vw);
  margin: 36px auto 60px;
}

/* Hero Section */
.hero-section {
  display: flex;
  justifyContent: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 20px;
  flex-wrap: wrap;
}

.hero-content {
  flex: 1;
  min-width: 320px;
}

.eyebrow-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--emerald);
  margin-bottom: 8px;
}

.hero-section h1 {
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 8px 0;
  color: #fff;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 720px;
  margin: 0;
  line-height: 1.6;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justifyContent: space-between;
  transition: all 0.2s ease;
}

.metric-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.metric-header {
  display: flex;
  justifyContent: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.metric-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.status-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.status-immutable {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.status-ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-bad {
  background: rgba(244, 63, 94, 0.15);
  color: var(--coral);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.status-cyan {
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.status-amber {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.metric-value-row {
  margin-bottom: 8px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #fff;
  letter-spacing: -0.02em;
}

.metric-value.ok {
  color: var(--emerald);
}

.metric-value.bad {
  color: var(--coral);
}

.metric-footer {
  font-size: 12px;
  color: var(--text-dim);
}

/* Panel Card */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.panel-header {
  display: flex;
  justifyContent: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.panel-title-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.panel-icon-box {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  display: grid;
  placeItems: center;
  flex-shrink: 0;
}

.panel-icon-box.cyan {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.25);
}

.panel-title-area h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 3px 0;
  color: #fff;
}

.panel-title-area p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.editor-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #041a12;
  font-weight: 800;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Status Banner */
.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.banner-valid {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.banner-invalid {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

/* Textarea Code Editor */
.textarea-wrapper {
  position: relative;
}

textarea#policy {
  width: 100%;
  min-height: 480px;
  padding: 18px;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: #7dd3fc;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea#policy:focus {
  border-color: var(--border-focus);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.panel-status-bar {
  display: flex;
  justifyContent: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 12px;
}

.status-message {
  margin: 0;
  font-weight: 600;
  color: var(--emerald);
}

.status-hint {
  color: var(--text-dim);
}

/* Data Table */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

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

.data-table th {
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(45, 65, 95, 0.3);
  color: var(--text-main);
}

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

.provider-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.progress-bar-container {
  width: 100%;
  max-width: 140px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  border-radius: 3px;
}

/* Dock Footer */
.dock-footer {
  margin-top: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.dock-header {
  display: flex;
  justifyContent: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 11px;
}

.dock-title {
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--emerald);
}

.dock-sub {
  color: var(--text-dim);
}

.dock-links {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.dock-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.dock-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.dock-item strong {
  font-weight: 600;
}

.dock-item small {
  color: var(--text-dim);
  font-size: 10px;
}

.dock-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.dock-dot.green { background: #10b981; }
.dock-dot.blue { background: #3b82f6; }
.dock-dot.emerald { background: #059669; }
.dock-dot.indigo { background: #6366f1; }
.dock-dot.amber { background: #f59e0b; }
.dock-dot.sky { background: #0284c7; }

/* Responsive */
@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 580px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .header-links span {
    display: none;
  }
}
