/* ============================================================
   Base & Reset
   ============================================================ */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #f0f2f5;
  color: #333;
}

/* ============================================================
   App Shell - Sidebar + Main Content Layout
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: #1a1d23;
  color: #c9cdd4;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar-collapsed .sidebar {
  width: 56px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid #2d3039;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-text {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  white-space: nowrap;
}

.brand-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  background: #f59e0b;
  color: #1a1d23;
  border-radius: 3px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  color: #aaa;
  background: #2d3039;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #555b66;
  padding: 16px 8px 6px;
  text-transform: uppercase;
}

.nav-section-divider {
  height: 1px;
  background: #2d3039;
  margin: 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  color: #9ca3af;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  white-space: nowrap;
}

.nav-item:hover {
  background: #24272e;
  color: #e5e7eb;
}

.nav-item.nav-active {
  background: #2563eb;
  color: #fff;
}

.nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #2d3039;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #374151;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name-text {
  font-size: 12px;
  color: #e5e7eb;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-client {
  font-size: 10px;
  color: #6b7280;
}

.signout-btn {
  width: 100%;
  padding: 6px 10px;
  background: #2d3039;
  color: #9ca3af;
  border: 1px solid #3d4049;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.signout-btn:hover {
  background: #3d4049;
  color: #e5e7eb;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  max-height: 100vh;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.page-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.content-body {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
}

.content-panel {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ============================================================
   Session Info
   ============================================================ */
.session-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 12px;
  font-size: 12px;
  color: #166534;
  font-weight: 500;
}

.session-dot {
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   Service Form
   ============================================================ */
.service-form {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  max-width: 800px;
}

/* Auth Section */
.auth-section {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: #fafafa;
}

.auth-section legend {
  font-weight: 600;
  font-size: 13px;
  color: #666;
  padding: 0 8px;
}

/* Form Rows */
.row {
  margin-bottom: 16px;
}

.row label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: #444;
  font-size: 14px;
}

.row-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.row-inline label {
  min-width: 90px;
  margin-bottom: 0;
  font-size: 13px;
}

.row-inline input {
  flex: 1;
}

/* Inputs */
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

textarea {
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  resize: vertical;
  line-height: 1.5;
}

/* Submit Button */
.submit-btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 10px 28px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.submit-btn:hover:not(:disabled) {
  background: #1d4ed8;
}

.submit-btn:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

/* Routing Info */
.routing-info {
  margin-bottom: 16px;
}

.route-badge {
  display: inline-block;
  padding: 6px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  color: #1d4ed8;
}

.route-badge.route-direct {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.route-badge strong {
  color: inherit;
  opacity: 0.7;
}

/* Response */
.response-section {
  margin-top: 20px;
}

.response-status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.response-status.status-ok {
  background: #dcfce7;
  color: #166534;
}

.response-status.status-fail {
  background: #fef2f2;
  color: #991b1b;
}

.response {
  margin-top: 8px;
  padding: 16px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-details {
  margin-top: 12px;
}

.json-details summary {
  cursor: pointer;
  padding: 8px 12px;
  background: #e9ecef;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #495057;
  user-select: none;
}

.json-details summary:hover {
  background: #dee2e6;
}

.json-details[open] summary {
  border-radius: 6px 6px 0 0;
}

/* ============================================================
   Health Dashboard
   ============================================================ */
.health-dashboard {
  /* no extra wrapper needed */
}

.health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.health-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.health-title {
  margin: 0;
  font-size: 16px;
  color: #333;
  display: none; /* Title is in the content header now */
}

.health-summary {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.health-summary.all-healthy {
  background: #dcfce7;
  color: #166534;
}

.health-summary.has-issues {
  background: #fef3c7;
  color: #92400e;
}

.health-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.health-timestamp {
  font-size: 12px;
  color: #888;
}

/* ============================================================
   Service Node (clickable architecture diagram nodes)
   ============================================================ */
.svc-node {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
  min-width: 130px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.svc-node:hover {
  border-color: #94a3b8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.svc-node-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  position: absolute;
  top: 8px;
  right: 8px;
}
.svc-node-name {
  font-size: 11px;
  font-weight: 700;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  letter-spacing: 0.02em;
  margin-bottom: 3px;
  padding-right: 16px;
}
.svc-node-sub {
  font-size: 10px;
  color: #94a3b8;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}
.svc-node-ms {
  font-size: 10px;
  color: #64748b;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  margin-top: 4px;
}

/* ============================================================
   Architecture Diagram v2
   ============================================================ */
.arch2-wrap {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px 24px 16px;
  margin-bottom: 0;
}
.arch2-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #94a3b8;
  text-transform: uppercase;
  margin-bottom: 16px;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}
.arch2-hint {
  font-size: 11px;
  color: #94a3b8;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  margin: 0 0 12px 0;
  letter-spacing: 0.02em;
}
.arch2-top {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 0;
}
.arch2-tier {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.arch2-tier-reg {
  min-width: 150px;
}
.arch2-tier-internal {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px 12px;
}
.arch2-tier-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #94a3b8;
  text-transform: uppercase;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  margin-bottom: 8px;
}
.arch2-tier-nodes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.arch2-tier-nodes-center {
  justify-content: center;
}
.arch2-db-connector {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-left: 20px;
}
.arch2-vline {
  width: 1px;
  height: 14px;
  background: #cbd5e1;
}
.arch2-db {
  font-size: 10px;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}
.arch2-pillar-sep {
  width: 1px;
  min-height: 80px;
  background: #e2e8f0;
  border-left: 1px dashed #cbd5e1;
  align-self: stretch;
  margin: 24px 4px 0;
}
.arch2-arrow-zone {
  display: flex;
  justify-content: flex-start;
  padding: 10px 0;
  padding-left: 40px;
}
.arch2-arrow-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cbd5e1;
}
.arch2-arrow-line::before {
  content: "↓";
  color: #cbd5e1;
}
.arch2-arrow-line::after {
  content: "↓";
  color: #cbd5e1;
}
.arch2-arrow-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}
.arch2-legend {
  display: flex;
  gap: 18px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.arch2-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #64748b;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}
.arch2-legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ============================================================
   Service Popup
   ============================================================ */
.svc-popup-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.svc-popup {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  width: 100%;
  max-width: 540px;
  overflow: hidden;
  animation: slideUp 0.2s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.svc-popup-bar {
  height: 4px;
  width: 100%;
}
.svc-popup-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f1f5f9;
}
.svc-popup-title {
  font-size: 15px;
  font-weight: 700;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  letter-spacing: 0.02em;
}
.svc-popup-sub {
  font-size: 11px;
  color: #94a3b8;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  margin-top: 3px;
}
.svc-popup-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.15s;
}
.svc-popup-close:hover { color: #475569; }
.svc-popup-status-row {
  display: flex;
  gap: 24px;
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
}
.svc-popup-stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #94a3b8;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  margin-bottom: 4px;
}
.svc-popup-stat-value {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  display: flex;
  align-items: center;
  gap: 6px;
}
.svc-popup-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.svc-popup-section {
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
}
.svc-popup-section:last-child { border-bottom: none; }
.svc-popup-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #94a3b8;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  margin-bottom: 6px;
}
.svc-popup-about {
  font-size: 13px;
  line-height: 1.65;
  color: #475569;
  margin: 0;
}
.svc-popup-about p { margin: 0 0 8px; }
.svc-popup-about p:last-child { margin: 0; }
.svc-popup-tech {
  font-size: 11px;
  color: #64748b;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}
.svc-popup-code {
  display: block;
  font-size: 11px;
  color: #475569;
  background: #f1f5f9;
  padding: 8px 10px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
  word-break: break-all;
  border: 1px solid #e2e8f0;
}
.svc-popup-error {
  color: #d97706;
  background: #fffbeb;
  border-color: #fde68a;
}
.svc-popup-loading {
  color: #94a3b8;
  font-size: 12px;
  font-style: italic;
}
/* ============================================================
   Health Check Button (standalone)
   ============================================================ */
.token-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

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

.token-btn-primary {
  background: #2563eb;
  color: white;
  border-color: #1d4ed8;
}

.token-btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.token-btn-small {
  padding: 4px 10px;
  font-size: 12px;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  white-space: nowrap;
  flex-shrink: 0;
}

.token-btn-small:hover {
  background: #e5e7eb;
}

/* ============================================================
   Sign-In Overlay
   ============================================================ */
.app-container {
  position: relative;
  min-height: 100vh;
}

.app-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: #666;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.dashboard {
  transition: filter 0.3s ease, opacity 0.3s ease;
}

.dashboard-blurred {
  filter: blur(8px);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

.signin-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.signin-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.signin-header {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  padding: 32px;
  text-align: center;
}

.signin-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  margin-bottom: 16px;
}

.signin-logo svg { color: white; }

.signin-header h1 {
  margin: 0 0 4px 0;
  font-size: 24px;
  font-weight: 600;
}

.signin-subtitle {
  margin: 0;
  opacity: 0.8;
  font-size: 14px;
}

.signin-body { padding: 32px; }

.signin-message {
  text-align: center;
  color: #666;
  margin: 0 0 24px 0;
  font-size: 14px;
  line-height: 1.5;
}

.signin-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #991b1b;
  font-size: 13px;
  margin-bottom: 20px;
}

.error-dismiss {
  background: none;
  border: none;
  color: #991b1b;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.signin-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 24px;
  background: #2f2f2f;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.signin-button:hover:not(:disabled) { background: #1f1f1f; }
.signin-button:disabled { background: #666; cursor: not-allowed; }

.signin-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.signin-footer {
  padding: 16px 32px;
  background: #f9fafb;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  border-top: 1px solid #e5e7eb;
}

/* ============================================================
   Google Token Tool
   ============================================================ */
.token-tool { max-width: 800px; }

.token-tool-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.token-tool-header h3 {
  margin: 0;
  font-size: 16px;
  color: #333;
}

.token-tool-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: #f0f0f0;
  color: #666;
  border-radius: 10px;
  font-weight: 500;
}

.token-step {
  margin-bottom: 16px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.token-step summary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  background: #f9f9f9;
  border-radius: 6px;
}

.token-step[open] summary {
  border-bottom: 1px solid #e0e0e0;
  border-radius: 6px 6px 0 0;
}

.token-step .token-field { padding: 8px 14px; }
.token-step .token-field:last-child { padding-bottom: 12px; }

.token-step-open {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.token-step-open:last-of-type { border-bottom: none; }

.step-label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.step-hint {
  font-size: 12px;
  color: #777;
  margin: 4px 0 12px 0;
  line-height: 1.4;
}

.token-field { margin-bottom: 8px; }

.token-field label {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 4px;
  font-weight: 500;
}

.token-field input[type="text"] {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
}

.token-field input.has-value {
  border-color: #22c55e;
  background: #f0fdf4;
}

.token-field-inline { padding-top: 4px; }

.token-field-inline label {
  display: inline;
  font-size: 12px;
  color: #666;
  cursor: pointer;
}

.token-field-inline input[type="checkbox"] { margin-right: 4px; }

.token-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  color: #991b1b;
  margin-bottom: 16px;
}

.token-result {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 16px;
  margin-top: 16px;
}

.token-value-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 6px;
}

.token-value {
  flex: 1;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  word-break: break-all;
  line-height: 1.4;
}

.token-cmd {
  font-size: 11px;
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

.token-details { font-size: 12px; color: #555; }
.token-details summary { cursor: pointer; font-weight: 500; }

.token-details pre {
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 10px;
  font-size: 11px;
  overflow-x: auto;
  margin-top: 6px;
}

/* ============================================================
   Creative Preview
   ============================================================ */
.creative-preview {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.preview-title {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-meta { font-size: 13px; color: #666; }

.headline-list,
.description-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.headline-item,
.description-item {
  padding: 10px 14px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  font-size: 14px;
}

.headline-item { font-weight: 600; color: #1a0dab; }
.description-item { color: #545454; font-size: 13px; }

.char-count {
  font-size: 11px;
  color: #888;
  float: right;
  font-weight: normal;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.image-card {
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
}

.image-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.image-card .image-info {
  padding: 8px 10px;
  font-size: 11px;
  color: #666;
}

/* ============================================================
   Audience Preview
   ============================================================ */
.audience-preview {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

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

.retrieved-at {
  font-size: 11px;
  color: #888;
  margin-bottom: 16px;
}

.segment-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
}

.segment-section:last-of-type { border-bottom: none; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 4px 0;
  font-size: 14px;
  color: #333;
}

.section-header.clickable {
  cursor: pointer;
  padding: 8px 12px;
  margin: -8px -12px 4px -12px;
  border-radius: 6px;
  transition: background 0.2s;
}

.section-header.clickable:hover { background: #f5f5f5; }

.expand-icon { font-size: 10px; color: #888; }

.section-desc {
  font-size: 12px;
  color: #888;
  margin: 0 0 12px 0;
}

.segment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.segment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  font-size: 13px;
}

.segment-icon { font-size: 14px; }
.segment-name { flex: 1; color: #333; }

.segment-id {
  font-size: 11px;
  color: #888;
  font-family: 'SF Mono', 'Monaco', monospace;
  padding: 2px 6px;
  background: #e9ecef;
  border-radius: 4px;
}

.toggle-btn {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 12px;
  padding: 8px 0;
  cursor: pointer;
  width: 100%;
  text-align: center;
}

.toggle-btn:hover { color: #1d4ed8; text-decoration: underline; }

.no-results {
  color: #888;
  font-style: italic;
  padding: 20px;
  text-align: center;
}

/* Geo Results */
.geo-results { overflow-x: auto; }

.geo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.geo-table th,
.geo-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
}

.geo-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #555;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.geo-table tr:hover td { background: #f8f9fa; }

.geo-id { font-family: 'SF Mono', 'Monaco', monospace; font-size: 12px; color: #666; }
.geo-name { font-weight: 500; color: #333; }
.geo-canonical { color: #666; font-size: 12px; }

.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
}

.type-badge.type-city { background: #dbeafe; color: #1e40af; }
.type-badge.type-state, .type-badge.type-region { background: #fef3c7; color: #92400e; }
.type-badge.type-country { background: #dcfce7; color: #166534; }
.type-badge.type-postal_code, .type-badge.type-postal-code { background: #f3e8ff; color: #7c3aed; }

/* Quick Reference */
.quick-reference {
  margin-top: 20px;
  padding: 16px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
}

.quick-reference h5 { margin: 0 0 12px 0; font-size: 13px; color: #0369a1; }
.static-options { display: grid; gap: 8px; }
.option-group { font-size: 12px; color: #555; }
.option-group strong { color: #333; margin-right: 4px; }

/* ============================================================
   Warning
   ============================================================ */
.warning {
  margin-top: 12px;
  padding: 8px 12px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  color: #856404;
  font-size: 13px;
}

/* ============================================================
   Response Panel (legacy - keep for compatibility)
   ============================================================ */
#response-panel {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  min-width: 300px;
  font-family: 'SF Mono', 'Monaco', monospace;
  font-size: 12px;
  color: #666;
}

/* ══════════════════════════════════════════════════════════════
   Architecture Diagram
   ══════════════════════════════════════════════════════════════ */

.arch-diagram {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px 20px 14px;
  margin-bottom: 24px;
  font-family: 'DM Sans', system-ui, sans-serif;
}

.arch-diagram-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 16px;
}

/* ── Top row: Tier-1 + Registration ─────────────── */

.arch-top-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 0;
}

.arch-group {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px 14px;
  flex: 1;
}

.arch-group-reg {
  flex: 0 0 auto;
  min-width: 160px;
}

.arch-group-full {
  width: 100%;
  margin-top: 0;
}

.arch-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #94a3b8;
  margin-bottom: 10px;
}

.arch-group-nodes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.arch-group-nodes-centered {
  justify-content: center;
}

/* ── Individual node ─────────────────────────────── */

.arch-node-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.arch-node {
  border: 1px solid #e2e8f0;
  border-top-width: 3px;
  border-radius: 6px;
  padding: 8px 12px;
  min-width: 120px;
  background: #fff;
  text-align: center;
  outline-offset: 3px;
  outline-style: solid;
  transition: outline-color 0.3s;
}

.arch-node-primary {
  min-width: 130px;
}

.arch-node-provider {
  min-width: 110px;
}

.arch-node-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.arch-node-sub {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
}

/* ── DB connector ────────────────────────────────── */

.arch-vline {
  width: 1px;
  height: 14px;
  background: #cbd5e1;
}

.arch-db {
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.arch-db-icon {
  font-size: 12px;
}

/* ── Pillar separator ────────────────────────────── */

.arch-pillar-sep {
  width: 1px;
  align-self: stretch;
  background: repeating-linear-gradient(
    to bottom,
    #cbd5e1 0px, #cbd5e1 6px,
    transparent 6px, transparent 12px
  );
  margin: 0 12px;
  flex-shrink: 0;
}

/* ── Arrow zone between tiers ────────────────────── */

.arch-arrow-zone {
  display: flex;
  justify-content: flex-start;
  padding-left: 20%;
  margin: 10px 0 10px;
}

.arch-arrow-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.arch-arrow-line::before {
  content: '';
  display: block;
  width: 1px;
  height: 18px;
  background: #94a3b8;
}

.arch-arrow-line::after {
  content: '▼';
  font-size: 9px;
  color: #94a3b8;
  margin-top: -4px;
}

.arch-arrow-label {
  font-size: 9px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-left: 6px;
  white-space: nowrap;
}

/* ── Legend ──────────────────────────────────────── */

.arch-legend {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.arch-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #64748b;
}

.arch-legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Help Content Panel + shared admin styles ──────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.data-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}
.data-table tr:hover { background: rgba(0,0,0,0.015); }
.empty-row { text-align: center !important; color: var(--text-dim); padding: 40px !important; }
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-active { background: var(--success-bg); color: var(--success); }
.status-inactive { background: #f3f4f6; color: #6b7280; }
.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    font-family: inherit;
}
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 12px; }
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { margin: 0 0 8px; color: #374151; }
.empty-state p { margin: 0; font-size: 14px; }

.help-trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 3px 8px 3px 4px;
    cursor: pointer;
    color: var(--accent, #3b82f6);
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
}
.help-trigger:hover {
    background: var(--accent-light, rgba(59,130,246,0.08));
    border-color: var(--accent, #3b82f6);
    color: var(--accent-hover, #2563eb);
}
.help-trigger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--accent-light, rgba(59,130,246,0.1));
    border-radius: 50%;
    flex-shrink: 0;
    color: var(--accent, #3b82f6);
}
.help-trigger-label {
    color: var(--accent, #3b82f6);
    font-size: 12px;
}
.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: helpFadeIn 0.15s ease;
}
.help-modal {
    background: var(--surface, #fff);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: helpSlideUp 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.09));
    flex-shrink: 0;
}
.help-modal-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.help-modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--accent-light, rgba(59,130,246,0.1));
    border-radius: 8px;
    color: var(--accent, #3b82f6);
    flex-shrink: 0;
}
.help-modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text, #1a1d23);
    margin: 0;
}
.help-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-dim, #9099a4);
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.help-modal-close:hover {
    background: var(--bg, #f4f5f7);
    color: var(--text, #1a1d23);
}
.help-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.help-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim, #9099a4);
    font-size: 14px;
    padding: 8px 0;
}
.help-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border, #e5e7eb);
    border-top-color: var(--accent, #3b82f6);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.help-error {
    color: var(--danger, #dc2626);
    font-size: 14px;
    background: var(--danger-bg, #fef2f2);
    padding: 10px 14px;
    border-radius: 8px;
    margin: 0;
}
.help-content {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text, #1a1d23);
}
.help-content p      { margin: 0 0 12px; }
.help-content p:last-child { margin-bottom: 0; }
.help-content h4     { font-size: 13px; font-weight: 600; margin: 16px 0 6px; color: var(--text-secondary, #374151); text-transform: uppercase; letter-spacing: 0.3px; }
.help-content ul, .help-content ol { margin: 0 0 12px 20px; }
.help-content li     { margin-bottom: 5px; }
.help-content strong { font-weight: 600; }
.help-content a      { color: var(--accent, #3b82f6); text-decoration: none; }
.help-content a:hover { text-decoration: underline; }
.help-modal-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border, rgba(0,0,0,0.06));
    flex-shrink: 0;
    background: var(--bg, #f4f5f7);
}
.help-key-badge {
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    color: var(--text-dim, #9099a4);
}
.help-panel {
    padding: 24px;
    max-width: 1000px;
    position: relative;
}
.help-panel-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success, #16a34a);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: helpFadeIn 0.2s ease;
}
.help-panel-toast.help-panel-toast-error {
    background: var(--danger, #dc2626);
}
.help-edit-card {
    background: var(--surface, #fff);
    border: 1px solid var(--accent, #3b82f6);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 0 0 4px var(--accent-light, rgba(59,130,246,0.08));
}
.help-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.help-edit-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text, #1a1d23);
    margin: 0;
}
.help-form-row {
    margin-bottom: 14px;
}
.help-form-row-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.help-form-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #5f6672);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.help-form-hint {
    font-weight: 400;
    font-size: 11px;
    color: var(--text-dim, #9099a4);
    text-transform: none;
    letter-spacing: 0;
}
.help-key-suggestions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.help-key-chip {
    background: var(--accent-light, rgba(59,130,246,0.08));
    border: 1px solid var(--accent, #3b82f6);
    color: var(--accent, #3b82f6);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-family: var(--font-mono, monospace);
    cursor: pointer;
    transition: background 0.12s;
}
.help-key-chip:hover {
    background: var(--accent-light, rgba(59,130,246,0.16));
}
.help-key-display {
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    color: var(--text, #1a1d23);
    background: var(--bg, #f4f5f7);
    border: 1px solid var(--border, rgba(0,0,0,0.09));
    border-radius: 6px;
    padding: 7px 10px;
}
.help-body-textarea {
    resize: vertical;
    min-height: 160px;
}
.help-table-wrap {
    background: var(--surface, #fff);
    border: 1px solid var(--border, rgba(0,0,0,0.09));
    border-radius: 10px;
    overflow: hidden;
}
.help-row-inactive {
    opacity: 0.5;
}
.help-key-code {
    font-family: var(--font-mono, monospace);
    font-size: 12px;
    background: var(--bg, #f4f5f7);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text, #1a1d23);
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary, #5f6672);
    cursor: pointer;
    user-select: none;
}
