/* ── Fonts ─────────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url('/dashboard/assets/fonts/PlusJakartaSans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url('/dashboard/assets/fonts/PlusJakartaSans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --brand:   #4A154B;
  --brand-d: #3b1040;
  --bg:      #f7f7f8;
  --surface: #ffffff;
  --border:  #e3e3e6;
  --text:    #1a1a2e;
  --muted:   #6b7280;
  --danger:  #dc2626;
  --success: #16a34a;
  --radius:  8px;
  --sidebar: 240px;
}

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

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  text-align: center;
}

.back-to-site {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.back-to-site:hover { color: var(--text); }

/* ── App layout ────────────────────────────────────────────────────────────── */
.app-page {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar);
  min-height: 100vh;
  background: var(--brand);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.wm-primary {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.wm-secondary {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  padding: 8px 8px 4px;
}

.key-list {
  list-style: none;
  margin-bottom: 8px;
}

.key-list li {
  border-radius: 6px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
}

.key-list li a {
  flex: 1;
  display: block;
  padding: 8px 10px;
  color: rgba(255,255,255,0.85);
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-list li a:hover,
.key-list li.active a {
  background: rgba(255,255,255,0.12);
  color: #fff;
  text-decoration: none;
}

.sidebar-new-btn {
  margin: 4px 8px;
  width: calc(100% - 16px);
}

.sidebar-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-email {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-rename-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 4px;
}
.key-rename-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.key-rename-input {
  flex: 1;
  margin: 2px 6px;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 13px;
  outline: none;
}
.stats-chart, .stats-heatmap { margin: 12px 0; }
.svg-chart { width: 100%; height: auto; display: block; }
.sub-heading {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted, #666);
  letter-spacing: 0.05em;
  margin: 16px 0 4px;
}
.avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.avatar-row img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #eee;
}
.muted { color: var(--muted, #888); font-weight: normal; font-size: 11px; }

.field-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.field-row .field { margin-bottom: 0; }

/* ── Admin-section indicator & back-link ──────────────────────────────────── */
.sidebar-section-indicator {
  margin: 12px 12px 4px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(236,179,40,0.18), rgba(236,179,40,0.08));
  border: 1px solid rgba(236,179,40,0.35);
  border-radius: 8px;
  text-align: center;
}
.sidebar-section-indicator .label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ecb328;
  margin-bottom: 2px;
}
.sidebar-section-indicator .value {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

/* ── Pill-button nav links — unified look for all sidebar menu links ─────── */
.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, color 0.15s;
}
.sidebar-nav-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.26);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav-btn.active {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.32);
  color: #fff;
  box-shadow: inset 3px 0 0 rgba(255,255,255,0.55);
}
.sidebar-nav-btn[hidden] { display: none; }
.sidebar-nav-btn .icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.85;
}

/* Footer pills live in a flex-column with gap — no side margin needed */
.sidebar-footer .sidebar-nav-btn { margin: 0; }

/* Back-to-dashboard button — neutral "exit" feel with leftward hover motion */
.sidebar-nav-btn.sidebar-back-link {
  margin-bottom: 12px;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.16);
}
.sidebar-nav-btn.sidebar-back-link:hover { transform: translateX(-2px); }

/* Admin-entry link (lives in app.html footer) — gold gradient, rightward hover */
.sidebar-nav-btn.sidebar-admin-link {
  background: linear-gradient(135deg, rgba(236,179,40,0.18), rgba(236,179,40,0.06));
  border-color: rgba(236,179,40,0.35);
  color: #fff;
}
.sidebar-nav-btn.sidebar-admin-link:hover {
  background: linear-gradient(135deg, rgba(236,179,40,0.28), rgba(236,179,40,0.12));
  border-color: rgba(236,179,40,0.55);
  transform: translateX(2px);
}

/* Admin-section nav items (inside .sidebar-nav--admin) — gold tint so the
   admin section stays visually distinct from the regular dashboard. The back
   link inside this nav keeps its neutral look. */
.sidebar-nav--admin .sidebar-nav-btn:not(.sidebar-back-link) {
  background: linear-gradient(135deg, rgba(236,179,40,0.08), rgba(236,179,40,0.02));
  border-color: rgba(236,179,40,0.20);
  color: rgba(255,255,255,0.88);
}
.sidebar-nav--admin .sidebar-nav-btn:not(.sidebar-back-link):hover {
  background: linear-gradient(135deg, rgba(236,179,40,0.20), rgba(236,179,40,0.08));
  border-color: rgba(236,179,40,0.40);
  color: #fff;
}
.sidebar-nav--admin .sidebar-nav-btn.active {
  background: linear-gradient(135deg, rgba(236,179,40,0.30), rgba(236,179,40,0.12));
  border-color: rgba(236,179,40,0.60);
  color: #fff;
  box-shadow: inset 3px 0 0 #ecb328;
}

/* ── Key status card (plan + expiry / next-invoice) ───────────────────────── */
.key-status-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.key-status-card.plan-free    { border-left-color: #9ca3af; }
.key-status-card.plan-demo    { border-left-color: #3b82f6; }
.key-status-card.plan-monthly { border-left-color: #4A154B; }
.key-status-card.plan-annual  {
  border-left-color: #16a34a;
  background: linear-gradient(90deg, rgba(22,163,74,0.08), rgba(22,163,74,0) 60%);
}
.plan-badge {
  flex-shrink: 0;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #e5e7eb;
}
.plan-badge-free    { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }
.plan-badge-demo    { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.plan-badge-monthly { background: #f5e9f6; color: #4A154B; border-color: #e9cce9; }
.plan-badge-annual  { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.key-status-text {
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #374151;
}
.key-status-text strong { color: #111827; }
.key-status-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  max-width: 340px;
}
.key-status-actions .billing-address-required {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.35;
  color: #9a3412;
  text-align: right;
}
.key-status-actions .billing-address-required .btn {
  flex: 0 0 auto;
}
.key-status-card.plan-annual .key-status-text {
  color: #14532d;
  font-weight: 600;
}
.key-status-card.plan-annual .key-status-text strong { color: #15803d; }
.key-status-card.plan-annual .savings-note {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #16a34a;
  font-weight: 700;
}

@media (max-width: 720px) {
  .key-status-card {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }
  .key-status-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    max-width: none;
  }
  .key-status-actions .billing-address-required {
    justify-content: flex-start;
    text-align: left;
  }
}

/* ── Main ──────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar);
  padding: 32px;
  max-width: 860px;
}

/* ── Panel ─────────────────────────────────────────────────────────────────── */
.panel { }

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

.panel-header h2 {
  font-size: 20px;
  font-weight: 600;
}

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

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ── Form fields ───────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 14px;
}

.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"],
.field input[type="number"],
.field input[type="date"],
.field input[type="month"],
.field input[type="tel"],
.field input[type="url"],
.field input[type="time"],
.field select,
.field textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="tel"],
input[type="url"],
input[type="time"],
input[type="color"],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  min-height: 34px;
  line-height: 1.35;
  appearance: none;
  -webkit-appearance: none;
}

input[type="color"] {
  padding: 2px 4px;
  height: 34px;
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: auto;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

input[type="date"],
input[type="month"],
input[type="time"] {
  color-scheme: light;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.65;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(74,21,75,0.12);
}

textarea { resize: vertical; font-family: monospace; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: none;
}
.btn-full { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-d); }

.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #e9eaec; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost { background: transparent; color: rgba(255,255,255,0.8); }
.btn-ghost:hover:not(:disabled) { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Code blocks ───────────────────────────────────────────────────────────── */
.code-block {
  position: relative; /* needed so .copy-btn absolute positioning is scoped here */
  background: #1e1e2e;
  border-radius: 6px;
  padding: 12px 44px 12px 14px;
}

.code-block code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: #cdd6f4;
  word-break: break-all;
  white-space: pre-wrap;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}

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

/* ── Toggle ────────────────────────────────────────────────────────────────── */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

/* ── Stats ─────────────────────────────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

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

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

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

.stats-table th, .stats-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.stats-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-table tbody tr[style*="cursor"]:hover {
  background: var(--bg-alt);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.table-toolbar h3 {
  margin: 0;
}

.conversations-table {
  width: 100%;
  table-layout: fixed;
}

.conversations-table th,
.conversations-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.conversations-table th:nth-child(1),
.conversations-table td:nth-child(1),
.conversations-table th:nth-child(2),
.conversations-table td:nth-child(2) {
  width: 130px;
}

.conversations-table th:nth-child(5),
.conversations-table td:nth-child(5) {
  width: 72px;
  text-align: right;
}

.conversations-table th:last-child,
.conversations-table td:last-child {
  width: 132px;
}

.conversations-table td {
  white-space: nowrap;
}

.page-url-cell,
.snippet-cell,
.conversations-table td:nth-child(3),
.conversations-table td:nth-child(4) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.actions-cell .btn-sm {
  padding-left: 9px;
  padding-right: 9px;
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.invoices-report-table {
  table-layout: fixed;
}

.invoices-report-table th,
.invoices-report-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.invoices-report-table th:nth-child(1),
.invoices-report-table td:nth-child(1) {
  width: 170px;
}

.invoices-report-table th:nth-child(2),
.invoices-report-table td:nth-child(2) {
  width: 30%;
}

.invoices-report-table th:nth-child(7),
.invoices-report-table td:nth-child(7) {
  width: 86px;
}

.invoicing-documents-table {
  table-layout: fixed;
}

.invoicing-documents-table th,
.invoicing-documents-table td {
  vertical-align: middle;
  padding: 8px 10px;
}

.invoicing-documents-table th:nth-child(1),
.invoicing-documents-table td:nth-child(1) {
  width: 17%;
  white-space: nowrap;
}

.invoicing-documents-table th:nth-child(2),
.invoicing-documents-table td:nth-child(2) {
  width: 9%;
  white-space: nowrap;
}

.invoicing-documents-table th:nth-child(3),
.invoicing-documents-table td:nth-child(3) {
  width: 23%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invoicing-documents-table th:nth-child(4),
.invoicing-documents-table td:nth-child(4),
.invoicing-documents-table th:nth-child(5),
.invoicing-documents-table td:nth-child(5) {
  width: 10%;
  white-space: nowrap;
}

.invoicing-documents-table th:nth-child(6),
.invoicing-documents-table td:nth-child(6) {
  width: 9%;
  white-space: nowrap;
}

.invoicing-documents-table th:nth-child(7),
.invoicing-documents-table td:nth-child(7) {
  width: 8%;
  white-space: nowrap;
}

.invoicing-documents-table th:nth-child(8),
.invoicing-documents-table td:nth-child(8) {
  width: 24%;
}

.invoicing-documents-table .actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  white-space: normal;
}

.invoicing-documents-table .actions-cell .btn,
.invoicing-documents-table .actions-cell a.btn {
  flex: 0 0 auto;
  min-width: 0;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.sort-btn:hover,
.sort-btn.active {
  color: var(--text);
}

.sort-arrow {
  font-size: 10px;
  line-height: 1;
}

.pdf-link-list {
  display: grid;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  padding-right: 4px;
}

.pdf-link-list a {
  display: block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Modals ────────────────────────────────────────────────────────────────── */
/*
 * Do NOT put display:flex here — author CSS overrides UA [hidden]{display:none}.
 * Instead, only apply flex when the hidden attribute is absent.
 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop:not([hidden]) {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}

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

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

.reveal-code { margin: 12px 0; }

/* ── Setup steps ───────────────────────────────────────────────────────────── */
.setup-steps {
  padding-left: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setup-steps li {
  line-height: 1.5;
}

.setup-steps li strong {
  display: block;
  font-weight: 600;
  margin-bottom: 3px;
}

.setup-steps li p {
  color: var(--muted);
  font-size: 13px;
}

.setup-steps li a {
  color: var(--brand);
}

.inline-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text);
}

.setup-webhook {
  margin-top: 4px;
}

/* ── FAQs ───────────────────────────────────────────────────────────────────── */
.faq-card h3 {
  margin-bottom: 14px;
}

.faq-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.faq-list dt {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.faq-list dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.faq-list dd + dt {
  margin-top: 4px;
}

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.hint-inline { font-weight: 400; color: var(--muted); }

.no-domain-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

.inline-warning {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.required-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 2px 6px;
  vertical-align: middle;
  margin-left: 6px;
}

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.save-status {
  font-size: 12px;
  margin-left: 8px;
  color: var(--success);
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-blue  { background: #dbeafe; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-gray  { background: #f3f4f6; color: #6b7280; }

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.health-check {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}

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

.health-check-title {
  font-weight: 700;
  color: var(--text);
}

.health-check-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.health-check-details {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.timeline-list {
  margin: 0;
  padding-left: 20px;
}

.timeline-list li {
  margin: 0 0 12px;
}

.timeline-detail {
  margin: 6px 0 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ── Conversation viewer ──────────────────────────────────────────────────── */
.modal-wide {
  max-width: 640px;
}

.transcript-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.transcript-header h3 { margin-bottom: 0; }

.transcript-body {
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}

.transcript-msg {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 85%;
  word-wrap: break-word;
}

.transcript-msg.visitor {
  background: var(--brand);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.transcript-msg.agent {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.transcript-msg.system {
  background: #fef9c3;
  border: 1px solid #fde68a;
  color: #92400e;
  align-self: center;
  font-size: 12px;
  font-style: italic;
}

.transcript-sender {
  font-weight: 600;
  font-size: 11px;
  margin-bottom: 2px;
}

.transcript-msg.visitor .transcript-sender { color: rgba(255,255,255,0.8); }
.transcript-msg.agent .transcript-sender { color: var(--brand); }

.transcript-time {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.6;
}

.btn-close-transcript { color: var(--text); }
.btn-close-transcript:hover { color: var(--brand); background: #f3f4f6; }

.conv-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
}

.page-url-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}

.snippet-cell {
  max-width: 280px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
}

.snippet-cell mark {
  background: #fde68a;
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}

/* ── Business hours table ───────────────────────────────────────────────── */
.bh-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bh-table th, .bh-table td { padding: 4px 6px; text-align: left; }
.bh-table td input[type="time"] { width: 110px; }
.bh-table td input[type="checkbox"] { margin: 0; }

/* ── Widget preview ─────────────────────────────────────────────────────── */
#widget-preview-container {
  width: 340px;
  height: 460px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #f5f5f5;
  position: relative;
}

.label-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 9px;
  background: #3b82f6;
  color: #fff;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

/* Highlight pulse for buy-key card */
@keyframes highlight-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 21, 75, 0.4); }
  40%  { box-shadow: 0 0 0 8px rgba(74, 21, 75, 0.15); }
  100% { box-shadow: 0 0 0 0 rgba(74, 21, 75, 0); }
}
.highlight-pulse {
  animation: highlight-pulse 0.8s ease-out 2;
  border-color: #4A154B;
}

/* Stripe embedded checkout modal */
#checkout-mount {
  min-height: 300px;
}
