:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-elevated: #192232;
  --border: #263247;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

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

body {
  background: radial-gradient(circle at top, #131c2e 0%, var(--bg) 65%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  padding: 24px 16px;
}

/* --- FÆLLES TOPBAR --- */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.chat-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chat-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 2px;
}

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

/* --- KNAPPER & LINKS --- */
button,
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

button[type="submit"],
.btn-small {
  background: var(--primary);
  color: #ffffff;
}

button[type="submit"]:hover,
.btn-small:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.nav-link {
  background: var(--surface-elevated);
  color: var(--text);
  border-color: var(--border);
}

.nav-link:hover {
  border-color: var(--primary);
  color: #ffffff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
  padding: 7px 12px;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

/* --- INPUTS & FORMULARER --- */
.admin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: -6px;
}

input[type="text"],
input[type="password"],
input[type="url"], select,
textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.header-actions input[type="url"] {
  flex: 1;
  min-width: 240px;
}

/* --- ADMIN DASHBOARD GRID --- */
.admin-container {
  max-width: 1180px;
  margin: 0 auto;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.admin-card.full-width {
  grid-column: 1 / -1;
}

.admin-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- KOMPAKTE RULLELISTER --- */
.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.list-item {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.list-item strong {
  font-size: 0.94rem;
  color: #ffffff;
}

.list-item p {
  font-size: 0.88rem;
  color: #cbd5e1;
  white-space: pre-line;
}

.list-item small {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.76rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* --- BORGER-CHAT (INDEX.HTML) --- */
.chat-wrapper {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
}

.chat-log {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.msg {
  max-width: 82%;
  padding: 13px 16px;
  border-radius: 14px;
  font-size: 0.95rem;
  white-space: pre-line;
  line-height: 1.5;
}

.msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.source-tag {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
}

.chat-input-bar input {
  border: none;
  background: transparent;
}

.chat-input-bar input:focus {
  box-shadow: none;
}

@media (max-width: 860px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .msg {
    max-width: 92%;
  }
}


.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 0;
}

.prompt-chip {
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #dbeafe;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.prompt-chip:hover {
  background: rgba(59, 130, 246, 0.28);
}

.typing-indicator {
  font-style: italic;
  opacity: 0.85;
}

.source-badge {
  margin-top: 10px;
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.12);
  border-left: 3px solid #10b981;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #a7f3d0;
}

.secondary-btn {
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.secondary-btn:hover {
  background: rgba(148, 163, 184, 0.26);
}

.source-badge {
  cursor: pointer;
  transition: background 0.15s ease;
}
.source-badge:hover {
  background: rgba(16, 185, 129, 0.22);
}
.source-preview {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 6px;
  font-size: 0.78rem;
  color: #cbd5e1;
}
.source-preview pre {
  margin-top: 6px;
  white-space: pre-wrap;
  font-family: inherit;
  color: #94a3b8;
  max-height: 180px;
  overflow-y: auto;
}
/* === CSP-COMPLIANT KVITTERINGS- & RADAR-KLASSER === */
.btn-aureon-receipt {
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.65);
  color: #e2e8f0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-aureon-receipt:hover {
  background: rgba(30, 41, 59, 0.9);
}

/* aureon-dark-mobile-toolbar */
.chat-toolbar, .chat-actions, .chat-action-bar {
  background: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(148, 163, 184, 0.25) !important;
  border-radius: 10px;
  padding: 6px;
}
.chat-toolbar button, .chat-actions button, .chat-action-bar button {
  background: rgba(30, 41, 59, 0.9) !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(148, 163, 184, 0.3) !important;
}

/* === WCAG 2.1 AA TILGÆNGELIGHED === */
body.aureon-large-text {
  font-size: 19px !important;
  line-height: 1.65 !important;
}
body.aureon-large-text .msg, body.aureon-large-text input, body.aureon-large-text button {
  font-size: 18px !important;
}
body.aureon-high-contrast {
  background: #000000 !important;
  color: #ffffff !important;
}
body.aureon-high-contrast .msg, body.aureon-high-contrast .card, body.aureon-high-contrast input {
  background: #090d16 !important;
  color: #ffffff !important;
  border: 2px solid #facc15 !important;
}

/* zero-csp-inline */
.toolbar-row, .chat-controls, .action-bar, #chatToolbar, [role="toolbar"] {
  background: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(148, 163, 184, 0.25) !important;
  border-radius: 10px !important;
  padding: 6px 8px !important;
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.toolbar-row button, .chat-controls button, .action-bar button, #chatToolbar button, [role="toolbar"] button {
  background: rgba(30, 41, 59, 0.92) !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(148, 163, 184, 0.3) !important;
}

div:has(> #btnExportChatMd) {
  background: rgba(15, 23, 42, 0.88) !important;
  border: 1px solid rgba(148, 163, 184, 0.25) !important;
  border-radius: 10px !important;
  padding: 6px 8px !important;
}

html body div:has(> #btnExportChatMd) {
  background: #0f172a !important;
  border: 1px solid rgba(148, 163, 184, 0.25) !important;
  border-radius: 10px !important;
  padding: 6px 8px !important;
}
html body div:has(> #btnExportChatMd) > button {
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid rgba(148, 163, 184, 0.35) !important;
}

/* === CSP-CLEAN LAYOUT & TOOLBAR === */
#aureonChainHealthCard, #aureonGapClustersCard {
  grid-column: 1 / -1;
}
#aureonChatToolbar button[type="button"] {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  width: auto;
  min-width: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
#aureonChatToolbar button:hover {
  background: #334155;
}

/* === 100% CSP-CLEAN FEEDBACK & SOURCE PREVIEW === */
.fb-row {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.75rem;
  color: #94a3b8;
}
.btn-fb {
  padding: 2px 8px;
  font-size: 0.74rem;
}
.source-preview-item {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.source-preview-meta {
  color: #6ee7b7;
}

/* === FULD BREDDE RADAR-BANNERE & POLERET KNAPRÆKKE === */
#aureonDedupeAlert, #aureonAnomalyAlert, #aureonExpiryRadarBanner, #aureonFeedbackAlert {
  grid-column: 1 / -1;
  width: 100%;
}
#aureonChainHealthCard {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#aureonChainHealthCard > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* === ROLIG & BRUGERVENLIG BORGER-UI === */
.source-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #a7f3d0;
  font-size: 0.85rem;
}
.source-tech-toggle {
  background: transparent;
  border: 1px solid rgba(167, 243, 208, 0.35);
  color: #a7f3d0;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
.source-tech-toggle:hover {
  background: rgba(16, 185, 129, 0.2);
}
.source-tech-details {
  width: 100%;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(167, 243, 208, 0.2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  color: #cbd5e1;
  word-break: break-word;
}
.feedback-row {
  margin-top: 8px;
  font-size: 0.82rem;
  opacity: 0.85;
}
.feedback-row button {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
}
#charCounterBadge, .btn-aureon-receipt, .btn-copy-citizen-answer { display: none !important; }

.guide-layout { max-width: 820px; margin: 2rem auto; padding: 1.5rem; }
.guide-card { margin-top: 1.25rem; line-height: 1.6; }

/* === CSP-COMPLIANT TELEMETRI-BAR === */
#adminTelemetryBar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
#adminTelemetryBar .admin-card {
  padding: 12px;
}
#telCodebase, #telChain, #telZip, #telModel {
  font-weight: 700;
  font-size: 1.02rem;
  margin-top: 4px;
}
/* === CSP-COMPLIANT RED-TEAM SIMULATOR === */
.redteam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.rt-box {
  background: rgba(5, 9, 20, 0.85);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.86rem;
}
.rt-box.rt-fail {
  border-color: rgba(248, 113, 113, 0.5);
}
.rt-badge {
  display: inline-block;
  font-weight: 700;
  color: #34d399;
  margin-bottom: 4px;
}
.rt-box.rt-fail .rt-badge {
  color: #f87171;
}
/* === CSP-COMPLIANT KUNDE-ONBOARDING === */
.prov-result {
  margin-top: 12px;
}
.prov-box {
  background: rgba(5, 9, 20, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}
/* === CSP-COMPLIANT TRUST & COMPLIANCE CENTER === */
.trust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.trust-metric {
  font-weight: 700;
  font-size: 1.05rem;
  color: #38bdf8;
  margin: 4px 0;
}
.trust-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.trust-item {
  background: rgba(5, 9, 20, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
}
.trust-hash {
  display: block;
  word-break: break-all;
  color: #34d399;
  margin: 8px 0 12px 0;
}