:root {
  --bg-main: #090a0f;
  --bg-card: #12141c;
  --bg-card-hover: #171a25;
  --bg-subtle: #1c202d;
  --bg-code: #0c0e14;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  
  --accent-emerald: #10b981;
  --accent-emerald-bg: rgba(16, 185, 129, 0.12);
  --accent-rose: #f43f5e;
  --accent-rose-bg: rgba(244, 63, 94, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.12);
  --accent-indigo: #6366f1;
  --accent-indigo-bg: rgba(99, 102, 241, 0.12);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Header */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

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

.brand-icon {
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: white;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

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

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-faint);
  display: inline-block;
}

.status-dot.connected {
  background-color: var(--accent-emerald);
}

.status-dot.pulsing {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease-in-out;
  font-family: inherit;
}

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

.btn-secondary:hover {
  background-color: #242939;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background-color: var(--accent-rose-bg);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.25);
}

.btn-danger:hover {
  background-color: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.4);
}

.btn-success {
  background-color: var(--accent-emerald-bg);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background-color: rgba(16, 185, 129, 0.22);
}

.btn-warning {
  background-color: var(--accent-amber-bg);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
  background-color: rgba(245, 158, 11, 0.22);
}

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

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}

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

.metric-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.metric-value.metric-code {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  letter-spacing: 2px;
  padding-top: 4px;
}

.metric-footer {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 6px;
}

.metric-footer code,
.guide-card code {
  font-family: var(--font-mono);
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  color: #cbd5e1;
  font-size: 0.75rem;
}

/* Badges */
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.badge-success {
  background: var(--accent-emerald-bg);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-warning {
  background: var(--accent-amber-bg);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-danger {
  background: var(--accent-rose-bg);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.badge-accent {
  background: var(--accent-indigo-bg);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* Tabs */
.tabs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.tabs-nav {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: #fff;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-indigo);
  border-radius: 2px 2px 0 0;
}

.tab-badge {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 700;
}

.badge-danger-subtle {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
}

.time-label {
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* Panes */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Audit Intro */
.audit-intro {
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 18px;
  font-size: 0.85rem;
  color: #fcd34d;
}

/* Webhook Cards */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.webhook-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.webhook-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.webhook-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}

.item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.method-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

.item-id {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 600;
}

.item-ip {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.item-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.item-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.expand-chevron {
  color: var(--text-faint);
  transition: transform 0.2s ease;
}

.webhook-item.expanded .expand-chevron {
  transform: rotate(180deg);
}

/* Expanded Details */
.webhook-details {
  display: none;
  padding: 0 18px 18px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-code);
}

.webhook-item.expanded .webhook-details {
  display: block;
}

.detail-section {
  margin-top: 16px;
}

.detail-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.copy-mini-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.copy-mini-btn:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.code-viewer {
  background: #08090d;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #e2e8f0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 280px;
}

.headers-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: #08090d;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.header-key {
  color: #818cf8;
  font-weight: 600;
}

.header-val {
  color: #cbd5e1;
  word-break: break-all;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.empty-icon {
  margin-bottom: 14px;
  color: var(--text-faint);
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 440px;
  margin: 0 auto 20px;
}

/* Guide Cards */
.guide-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
}

.guide-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.guide-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.code-box {
  position: relative;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.code-box pre {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #e2e8f0;
  overflow-x: auto;
  line-height: 1.6;
}

.btn-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  padding: 3px 10px;
  cursor: pointer;
}

.btn-copy:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transform: translateY(10px);
  transition: transform 0.2s ease;
}

.modal-backdrop.show .modal-card {
  transform: translateY(0);
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.btn-close:hover {
  color: #fff;
}

.modal-body {
  padding: 20px;
}

.modal-text {
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 8px;
}

.modal-text.subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
}

.form-group {
  margin: 14px 0;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group textarea {
  width: 100%;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 10px;
  resize: vertical;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.simulation-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.sim-alert {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.sim-alert.success {
  background: var(--accent-emerald-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.sim-alert.error {
  background: var(--accent-rose-bg);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

.hidden {
  display: none !important;
}

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

.toast {
  background: #1e2230;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .navbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .nav-actions {
    width: 100%;
    justify-content: space-between;
  }
}
