/* Veronica UI - Dark theme */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #162032;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --info: #06b6d4;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* Nav */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 32px;
}

.nav-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: 0.05em;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--surface);
}

/* Main layout */
.main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-value.danger { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-value.success { color: var(--success); }
.stat-value.primary { color: var(--primary); }

/* Card */
.card {
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 0;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

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

tr:last-child td {
  border-bottom: none;
}

tr:nth-child(odd) td {
  background: var(--surface-alt);
}

tr:nth-child(even) td {
  background: var(--surface);
}

tr:hover td {
  background: #243144;
}

.mono {
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

/* Decision badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-allow   { background: rgba(34, 197, 94, 0.15);  color: var(--success); }
.badge-halt    { background: rgba(239, 68, 68, 0.15);  color: var(--danger); }
.badge-degrade { background: rgba(234, 179, 8, 0.15);  color: var(--warning); }
.badge-queue   { background: rgba(6, 182, 212, 0.15);  color: var(--info); }
.badge-retry   { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.badge-default { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* Form elements */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input,
.form-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  min-width: 240px;
  animation: slide-in 0.2s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Status dot */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.green { background: var(--success); }
.status-dot.red   { background: var(--danger); }

/* Refresh indicator */
.refresh-indicator {
  font-size: 11px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav {
    padding: 0 16px;
    gap: 16px;
  }

  .main {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Policy editor -- policy_hash in header */
.editor-policy-hash {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Policy editor -- diff summary */
.diff-summary {
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--warning);
  margin-bottom: 16px;
}

/* Policy editor -- changed field highlight */
.field-changed {
  border-color: rgba(234, 179, 8, 0.5) !important;
  background: rgba(234, 179, 8, 0.04) !important;
}

.form-group-changed .form-label {
  color: var(--warning);
}

/* Policy editor -- Simulate button */
.btn-simulate {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.4);
}
.btn-simulate:hover {
  background: rgba(59, 130, 246, 0.25);
}
.btn-simulate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Policy editor -- simulate result panel */
.simulate-result {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: var(--surface-alt);
  font-size: 12px;
}

.sim-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

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

.sim-tag-ok {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
}

.sim-tag-warn {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.sim-hash {
  color: var(--text-muted);
  font-size: 11px;
}

.sim-hash code {
  font-family: 'Courier New', monospace;
  color: var(--text);
}

.sim-no-steps {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

.sim-steps-table {
  width: 100%;
  font-size: 11px;
  margin-top: 4px;
}

.sim-steps-table th {
  font-size: 10px;
  padding: 6px 8px;
}

.sim-steps-table td {
  padding: 5px 8px;
  font-size: 11px;
}

/* Events table -- Replay link */
.replay-link {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.replay-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.replay-link-na {
  color: var(--text-muted);
  font-size: 11px;
}

td.td-replay {
  white-space: nowrap;
  text-align: center;
}
