/* Admin design system — ink palette + brand teal, Inter, soft cards. */
:root {
  --ink-50: #f8fafc; --ink-100: #f1f5f9; --ink-200: #e2e8f0; --ink-300: #cbd5e1;
  --ink-400: #94a3b8; --ink-500: #64748b; --ink-600: #475569; --ink-700: #334155;
  --ink-800: #1e293b; --ink-900: #0f172a; --ink-950: #0a0f1c;
  --brand-50: #ecfcfd; --brand-100: #cff6f9; --brand-200: #a3ebf1;
  --brand-500: #3cc7d2; --brand-600: #1abdca; --brand-700: #1597a2;
  --shadow-card: 0 1px 2px 0 rgba(16,24,40,.05), 0 1px 3px 0 rgba(16,24,40,.10);
  --shadow-cardlg: 0 10px 30px -12px rgba(16,24,40,.18), 0 4px 8px -6px rgba(16,24,40,.10);
}

/* Stand-in for Inter while the web font loads: Arial scaled to Inter's metrics,
   so text doesn't change width when Inter arrives (no jump on page load). */
@font-face {
  font-family: "Inter Fallback"; src: local("Arial");
  ascent-override: 90.2%; descent-override: 22.48%; line-gap-override: 0%; size-adjust: 107.4%;
}

* { box-sizing: border-box; }
/* `hidden` always hides, even on elements whose class sets a display (e.g. .btn). */
[hidden] { display: none !important; }
/* Reserve the scrollbar's space on every page, so the layout doesn't shift
   sideways between pages that scroll and pages that don't. */
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: Inter, "Inter Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-600);
  background: var(--ink-50);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); }
a:hover { color: var(--brand-700); }
h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink-900); margin: 1.4rem 0 1rem; }
h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink-900); margin: 1.8rem 0 .7rem; }
code {
  background: var(--ink-100); color: var(--ink-800);
  padding: 1px 6px; border-radius: 6px; font-size: 13px;
}
.muted { color: var(--ink-500); }
.small-text { font-size: 12px; }
.spacer { flex: 1; }

/* ---- Top navigation ---- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ink-200);
  padding: 0 22px; height: 62px;
}
.topnav .brand { display: flex; align-items: center; gap: 11px; margin-right: 20px; }
.topnav a.brand { padding: 0; margin-right: 28px; background: none; line-height: 0; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand-600); color: #fff;
  font-size: 13px; font-weight: 800; letter-spacing: .02em;
  box-shadow: var(--shadow-card);
  overflow: hidden; flex: 0 0 36px;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14.5px; font-weight: 800; letter-spacing: -.02em; color: var(--ink-900); }
.brand-text span { font-size: 11px; font-weight: 500; color: var(--ink-400); }
.topnav a {
  color: var(--ink-600); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  padding: 7px 12px; border-radius: 10px;
  transition: background .15s, color .15s;
}
.topnav a:hover { background: var(--ink-50); color: var(--ink-900); }
/* "Log out" is a form button (logout is a POST) that looks like the links. */
.topnav .nav-form { display: contents; }
.topnav .nav-button {
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink-600);
  background: none; border: 0; cursor: pointer;
  padding: 7px 12px; border-radius: 10px;
  transition: background .15s, color .15s;
}
.topnav .nav-button:hover { background: var(--ink-50); color: var(--ink-900); }
.topnav a.active { background: var(--ink-100); color: var(--ink-900); font-weight: 600; }
/* A hidden bold copy of each label sizes the link at its bold width, so a link
   doesn't get wider (and push the others) when it becomes the active one. */
.topnav a[data-label] { display: inline-flex; flex-direction: column; align-items: center; }
.topnav a[data-label]::after {
  content: attr(data-label); font-weight: 600;
  height: 0; overflow: hidden; visibility: hidden; pointer-events: none; user-select: none;
}

.container { max-width: 1060px; margin: 0 auto; padding: 12px 24px 70px; }

/* ---- Flash messages ---- */
.flash {
  padding: 11px 15px; border-radius: 12px; margin: 16px 0;
  background: #ecfdf5; color: #047857; font-weight: 500;
  border: 1px solid #a7f3d0; box-shadow: var(--shadow-card);
}
.flash.error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* ---- Dashboard stats ---- */

/* ---- Tables ---- */
table {
  width: 100%; border-collapse: collapse;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 14px;
  overflow: hidden; box-shadow: var(--shadow-card);
}
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--ink-100); font-size: 13.5px; vertical-align: top; }
th {
  background: var(--ink-50); color: var(--ink-500);
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
tr:last-child td { border-bottom: none; }
td { color: var(--ink-700); }
.source-cell { max-width: 420px; overflow-wrap: anywhere; }
.error-text { color: #b91c1c; font-size: 12px; margin-top: 3px; }
.actions { white-space: nowrap; }
.actions form { display: inline-block; margin-right: 4px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #fff; border: 1px solid var(--ink-300); border-radius: 10px;
  padding: 8px 15px; font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--ink-800); text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--ink-50); color: var(--ink-900); }
.btn.primary {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff;
  box-shadow: var(--shadow-card);
}
.btn.primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn.primary:disabled { opacity: .45; cursor: default; background: var(--brand-600); }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: #b91c1c; }
.btn.danger:hover { border-color: #fca5a5; background: #fef2f2; }

/* ---- Sources page ---- */

/* ---- Sources page header ---- */
.sources-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 1.4rem 0 1.1rem; }
.sources-head h1 { margin: 0; }
.sources-head-meta { display: flex; align-items: center; gap: 16px; font-size: 14px; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 12px;
  padding: 8px 12px 8px 14px; font-weight: 600; font-size: 14px; color: var(--ink-900);
  box-shadow: var(--shadow-card); transition: background .12s;
}
.menu-btn:hover { background: var(--ink-50); }
.menu-btn svg { color: var(--ink-500); transition: transform .15s; }
.menu[open] .menu-btn svg { transform: rotate(180deg); }
.pill {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  padding: 2px 10px; font-size: 12px; font-weight: 600;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.off { background: var(--ink-100); color: var(--ink-500); }
.pill.on { background: var(--brand-50); color: var(--brand-700); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 290px;
  display: grid; gap: 2px; padding: 6px;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 14px; box-shadow: var(--shadow-cardlg);
}
.menu-pop button {
  display: grid; gap: 1px; text-align: left; cursor: pointer;
  border: none; background: none; border-radius: 10px; padding: 9px 12px; font: inherit;
}
.menu-pop button:hover { background: var(--ink-50); }
.menu-pop button.selected { background: var(--brand-50); }
.menu-pop strong { font-size: 13.5px; color: var(--ink-900); }
.menu-pop span { font-size: 12.5px; color: var(--ink-500); line-height: 1.4; }

/* Add-source cards */
/* Landscape cards filling the row: icon on the left, label and hint beside it. */
.source-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.source-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 14px; row-gap: 1px; align-items: center; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 16px;
  padding: 14px 18px; font: inherit; box-shadow: var(--shadow-card);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.source-card:hover { border-color: var(--brand-200); box-shadow: var(--shadow-cardlg); transform: translateY(-1px); }
.source-card:focus-visible { outline: 3px solid var(--brand-200); outline-offset: 2px; }
.source-card-icon {
  grid-row: 1 / span 2; display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--ink-200); border-radius: 10px; color: var(--ink-700);
}
.source-card-label { align-self: end; font-size: 15px; font-weight: 600; color: var(--ink-900); }
.source-card-hint { align-self: start; font-size: 12.5px; color: var(--ink-500); }

.train-strip {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 16px 0 22px; padding: 10px 12px 10px 18px;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 14px;
}
.train-strip strong { color: var(--ink-900); }
.modal > textarea, .modal > input[type=file] { width: 100%; }
@media (max-width: 560px) {
  .source-cards { grid-template-columns: 1fr; gap: 10px; }
  .source-card { padding: 12px 14px; }
  .sources-head-meta { width: 100%; justify-content: space-between; }
}

.add-forms textarea, .add-forms input[type=text],
.settings-form input[type=text], .settings-form input[type=number], .settings-form textarea,
.settings-form input[type=email], .settings-form input[type=password], .inline-form input[type=text],
.modal input[type=text], .modal input[type=email], .modal textarea {
  width: 100%; border: 1px solid var(--ink-300); border-radius: 10px;
  padding: 9px 12px; font: inherit; font-weight: 400; color: var(--ink-800);
  background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.add-forms textarea:focus, .add-forms input[type=text]:focus,
.settings-form input:focus, .settings-form textarea:focus,
.modal input:focus, .modal textarea:focus, .inline-form input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(26, 189, 202, .15);
}

.filter-row { display: flex; align-items: center; gap: 6px; margin: 12px 0 14px; flex-wrap: wrap; }
.filter-row a {
  text-decoration: none; font-size: 13px; font-weight: 500; color: var(--ink-500);
  padding: 5px 11px; border-radius: 999px; transition: background .15s, color .15s;
}
.filter-row a:hover { background: var(--ink-100); color: var(--ink-800); }
.filter-row a.active { background: var(--ink-900); color: #fff; font-weight: 600; }

/* ---- Sources list toolbar: search, type, sort, bulk select ---- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.list-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.search-box, .select-box {
  display: flex; align-items: center; height: 44px;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 12px;
  box-shadow: var(--shadow-card); transition: border-color .15s, box-shadow .15s;
}
.search-box { flex: 1 1 300px; max-width: 460px; gap: 10px; padding: 0 14px; color: var(--ink-400); }
.search-box input {
  flex: 1; min-width: 0; border: none; outline: none; background: none;
  font: inherit; font-size: 14.5px; color: var(--ink-900);
}
.search-box:focus-within, .select-box:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(26,189,202,.15); }
.select-box { position: relative; }
.select-box select {
  appearance: none; -webkit-appearance: none; height: 100%; cursor: pointer;
  border: none; outline: none; background: none; border-radius: 12px;
  padding: 0 40px 0 16px; font: inherit; font-size: 14.5px; color: var(--ink-900);
}
.select-box > svg { position: absolute; right: 13px; color: var(--ink-500); pointer-events: none; transition: transform .15s; }

/* Our own dropdown (assets/dropdown.js) replacing the browser's option list. */
.select-box .dd-native { display: none; }
.dd-button {
  height: 100%; display: flex; align-items: center; cursor: pointer; white-space: nowrap;
  border: none; outline: none; background: none; border-radius: 12px;
  padding: 0 42px 0 16px; font: inherit; font-size: 14.5px; color: var(--ink-900);
}
.select-box:hover { background: var(--ink-50); }
.select-box.dd-open > svg { transform: rotate(180deg); }
.dd-list {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 100%; max-height: 300px; overflow-y: auto;
  margin: 0; padding: 6px; list-style: none; outline: none;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 14px; box-shadow: var(--shadow-cardlg);
  opacity: 0; visibility: hidden; transform: translateY(-4px) scale(.98); transform-origin: top left;
  transition: opacity .12s ease-in, transform .12s ease-in, visibility 0s linear .12s;
}
.dd-open .dd-list {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .14s ease-out, transform .14s ease-out, visibility 0s;
}
.dd-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 9px 10px 9px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap;
  font-size: 14px; color: var(--ink-800);
}
.dd-list li.active { background: var(--ink-50); color: var(--ink-900); }
.dd-list li[aria-selected="true"] { font-weight: 600; color: var(--ink-900); }
.dd-list li svg { color: var(--brand-600); visibility: hidden; flex: 0 0 auto; }
.dd-list li[aria-selected="true"] svg { visibility: visible; }
@media (prefers-reduced-motion: reduce) {
  .dd-list, .dd-open .dd-list { transform: none; }
}
.toolbar-btn { height: 44px; padding: 0 18px; border-color: var(--ink-200); border-radius: 12px; box-shadow: var(--shadow-card); font-size: 14.5px; }
.toolbar-btn.active { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }

.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: -4px 0 12px; padding: 9px 12px 9px 16px;
  background: var(--brand-50); border: 1px solid var(--brand-200); border-radius: 12px;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar strong { color: var(--ink-900); font-size: 13.5px; }
.bulk-bar .btn:disabled { opacity: .45; cursor: default; }

/* Checkbox column only in bulk mode */
.sources-table .cell-check { display: none; width: 36px; padding-right: 0; }
.bulk-mode .sources-table .cell-check { display: table-cell; }
.sources-table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand-600); cursor: pointer; }
#sources-list.loading { opacity: .55; transition: opacity .15s; }

.pager { display: flex; align-items: center; gap: 10px; margin: 12px 2px 0; font-size: 13px; }
@media (max-width: 640px) {
  .search-box { flex-basis: 100%; max-width: none; }
  .select-box, .toolbar-btn { flex: 1 1 auto; }
}

/* Pills */
.tag {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 9px; border-radius: 999px; box-shadow: inset 0 0 0 1px transparent;
}
.tag-link { background: #eff6ff; color: #1d4ed8; box-shadow: inset 0 0 0 1px #bfdbfe; }
.tag-qa { background: #f5f3ff; color: #6d28d9; box-shadow: inset 0 0 0 1px #ddd6fe; }
.tag-snippet { background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px #a7f3d0; }

.status { font-size: 11.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.status-ready { background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px #a7f3d0; }
.status-pending { background: #fffbeb; color: #b45309; box-shadow: inset 0 0 0 1px #fde68a; }
.status-fetched { background: #eff6ff; color: #1d4ed8; box-shadow: inset 0 0 0 1px #bfdbfe; }
.status-error { background: #fef2f2; color: #b91c1c; box-shadow: inset 0 0 0 1px #fecaca; }

/* ---- Code block ---- */
.code-block {
  background: var(--ink-950); color: #d9e1ef; padding: 15px 18px; border-radius: 14px;
  overflow-x: auto; font-size: 13px; box-shadow: var(--shadow-card);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- Settings & embed forms ---- */
.settings-form {
  background: #fff; border: 1px solid var(--ink-200); border-radius: 16px;
  padding: 20px 22px 22px; display: grid; gap: 13px; max-width: 620px;
  box-shadow: var(--shadow-card);
}
.settings-form h2 { margin: 12px 0 0; padding-top: 14px; border-top: 1px solid var(--ink-100); }
.settings-form h2:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.settings-form label,
.settings-form .field { display: grid; gap: 6px; font-weight: 600; font-size: 13.5px; color: var(--ink-800); }
.settings-form .field-label { font-weight: 600; }
.settings-form input[type=color] {
  width: 68px; height: 42px; padding: 3px; border: 1px solid var(--ink-300);
  border-radius: 10px; background: #fff; cursor: pointer;
}
.settings-form .field-row { display: flex; gap: 16px; }
.settings-form .field-row label { flex: 1; }
.settings-form button { justify-self: start; margin-top: 6px; }
.settings-form p { margin: 0; font-size: 13px; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; color: var(--ink-600) !important; }

.label-hint { font-weight: 400; font-size: 12.5px; color: var(--ink-500); }

/* Rich-text editor */
.rich-editor {
  border: 1px solid var(--ink-300); border-radius: 10px; overflow: hidden; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.rich-editor:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(26,189,202,.15); }
.rich-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 6px 8px; border-bottom: 1px solid var(--ink-200); background: var(--ink-50);
}
.rich-toolbar button {
  border: none; background: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 7px; color: var(--ink-700);
  font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
}
.rich-toolbar button:hover { background: var(--ink-200); color: var(--ink-900); }
.rich-sep { width: 1px; height: 18px; background: var(--ink-300); margin: 0 5px; }
.rich-area {
  min-height: 66px; padding: 10px 12px; font: inherit; font-weight: 400;
  color: var(--ink-800); outline: none; line-height: 1.55;
}
.rich-area:empty:before { content: attr(data-placeholder); color: var(--ink-400); pointer-events: none; }
.rich-area a { color: var(--brand-600); }

/* Settings + preview split */
.settings-layout { display: grid; grid-template-columns: minmax(0,1fr) 372px; gap: 28px; align-items: start; }
@media (max-width: 960px) { .settings-layout { grid-template-columns: 1fr; } }
.settings-preview { position: sticky; top: 80px; display: grid; gap: 10px; }
.settings-preview h2 { margin-top: 0; }
.settings-preview .window-card { }
.settings-preview .widget-preview { height: 560px; }
.settings-preview .preview-note { font-size: 12px; color: var(--ink-500); }

/* Temperature slider */
.slider-row { display: flex; align-items: center; gap: 14px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--brand-600); }
.slider-value {
  min-width: 44px; text-align: center; font-weight: 700; color: var(--ink-900);
  background: var(--ink-100); border-radius: 8px; padding: 3px 8px; font-size: 13px;
}
.slider-labels { display: flex; justify-content: space-between; font-size: 12px; font-weight: 400; color: var(--ink-400); }

/* Rate limit inline row */
.rate-row { align-items: flex-end; }
.rate-row label { flex: 0 0 110px; }
.rate-join { padding-bottom: 10px; color: var(--ink-600); font-size: 13.5px; white-space: nowrap; }

/* Training card */
.trained-at {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: var(--ink-50); border: 1px solid var(--ink-200); border-radius: 12px;
  padding: 12px 16px; color: var(--ink-700); font-size: 14px;
}
.trained-at strong { color: var(--ink-900); }
.trained-icon { color: var(--brand-600); font-size: 16px; }

/* Toggle switch */
.toggle-label { display: flex !important; align-items: flex-start; gap: 12px; cursor: pointer; font-weight: 400 !important; }
.toggle-label input { position: absolute; opacity: 0; pointer-events: none; }
.toggle {
  flex: 0 0 42px; width: 42px; height: 24px; border-radius: 999px;
  background: var(--ink-200); position: relative; transition: background .18s; margin-top: 2px;
}
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-card); transition: left .18s;
}
.toggle-label input:checked + .toggle { background: var(--brand-600); }
.toggle-label input:checked + .toggle::after { left: 21px; }
.toggle-label strong { color: var(--ink-900); }

/* ---- Embed page split layout ---- */
.embed-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 30px; align-items: start; margin-top: 6px; }
@media (max-width: 900px) { .embed-split { grid-template-columns: 1fr; } }
.embed-split .settings-form { max-width: none; }
.preview-pane { position: sticky; top: 82px; display: grid; gap: 16px; }
.preview-pane h2 { margin-top: 0; }

.bubble-preview {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 16px;
  padding: 14px 18px; box-shadow: var(--shadow-card);
}
.bubble-demo {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  overflow: hidden; flex: 0 0 56px;
}
.bubble-demo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Browser-window style frame around the widget preview */
.window-card {
  background: #fff; border: 1px solid var(--ink-200); border-radius: 16px;
  overflow: hidden; box-shadow: var(--shadow-cardlg);
}
.window-bar {
  display: flex; align-items: center; gap: 7px;
  background: var(--ink-50); border-bottom: 1px solid var(--ink-200);
  padding: 11px 15px;
}
.win-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-300); }
.window-bar .window-title { margin-left: 6px; font-size: 12px; font-weight: 500; color: var(--ink-500); }
.widget-preview { width: 100%; height: 520px; border: none; display: block; background: #fff; }

/* ---- Chat logs ---- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #fff; color: var(--ink-600); border: 1px solid var(--ink-200);
  border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 500;
  line-height: 1.4; text-transform: none; letter-spacing: 0; font-family: inherit;
}
.chip.dark { background: var(--ink-800); border-color: var(--ink-800); color: #fff; }
.chip-btn { cursor: pointer; transition: background .12s, color .12s; }

/* Hover tooltip: <span data-tip="…">. Dark bubble with an arrow, above the element. */
[data-tip] { position: relative; cursor: default; }
[data-tip]::before, [data-tip]::after {
  position: absolute; left: 50%; transform: translate(-50%, 4px) scale(.96); transform-origin: 50% 100%;
  opacity: 0; visibility: hidden; pointer-events: none; z-index: 20;
  /* Hiding: quick fade, then visibility flips once it's invisible. */
  transition: opacity .1s ease-in, transform .1s ease-in, visibility 0s linear .1s;
}
[data-tip]::after {
  content: attr(data-tip); bottom: calc(100% + 9px);
  background: var(--ink-950); color: #fff; white-space: nowrap;
  font-size: 13px; font-weight: 500; padding: 7px 12px; border-radius: 9px;
  box-shadow: var(--shadow-cardlg);
}
[data-tip]::before {
  /* 7px tall, so it reaches 1px up behind the bubble: the two never leave a
     hairline gap between them while the pop-in animation scales them. */
  content: ''; bottom: calc(100% + 3px);
  border: 6px solid transparent; border-top-width: 7px; border-bottom: none; border-top-color: var(--ink-950);
}
/* Showing: a brief delay (so passing the mouse over doesn't flash tooltips),
   then fade in while gliding up into place. */
[data-tip]:hover::before, [data-tip]:hover::after {
  opacity: 1; visibility: visible; transform: translate(-50%, 0) scale(1);
  transition: opacity .14s ease-out .1s, transform .14s cubic-bezier(.2, .8, .3, 1.2) .1s, visibility 0s linear .1s;
}
@media (prefers-reduced-motion: reduce) {
  [data-tip]::before, [data-tip]::after { transform: translate(-50%, 0); }
  [data-tip]:hover::before, [data-tip]:hover::after { transition: opacity .1s linear .1s, visibility 0s linear .1s; }
}
/* With tooltip.js the bubble lives on <body> instead, so panels and scroll areas don't clip it. */
.js-tips [data-tip]::before, .js-tips [data-tip]::after { content: none; }
.tip {
  position: absolute; top: 0; left: 0; z-index: 1000; pointer-events: none;
  width: max-content; max-width: min(320px, calc(100vw - 16px));
  background: var(--ink-950); color: #fff; font-size: 13px; font-weight: 500; line-height: 1.4;
  padding: 7px 12px; border-radius: 9px; box-shadow: var(--shadow-cardlg);
  opacity: 0; visibility: hidden; transform: translateY(4px) scale(.96); transform-origin: var(--arrow-x, 50%) 100%;
  transition: opacity .1s ease-in, transform .1s ease-in, visibility 0s linear .1s;
}
.tip.below { transform: translateY(-4px) scale(.96); transform-origin: var(--arrow-x, 50%) 0; }
.tip.show {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .14s ease-out, transform .14s cubic-bezier(.2, .8, .3, 1.2), visibility 0s;
}
.tip::after {
  /* 7px tall, reaching 1px behind the bubble so no hairline gap shows while it scales. */
  content: ''; position: absolute; left: var(--arrow-x, 50%); top: 100%; margin: -1px 0 0 -6px;
  border: 6px solid transparent; border-top: 7px solid var(--ink-950); border-bottom: none;
}
.tip.below::after { top: auto; bottom: 100%; margin: 0 0 -1px -6px; border-top: none; border-bottom: 7px solid var(--ink-950); }
@media (prefers-reduced-motion: reduce) {
  .tip, .tip.below { transform: none; }
}
.chip-btn:hover { background: var(--ink-50); color: var(--ink-900); }

/* Full-width page: no max width, the two panes fill the viewport under the nav. */
.container.full {
  max-width: none; padding: 0;
  display: flex; flex-direction: column; height: calc(100vh - 62px); min-height: 480px;
}
.container.full > .flash { margin: 12px 20px; flex: 0 0 auto; }
.logs-blank { padding: 12px 28px; }

.logs-layout {
  display: grid; grid-template-columns: minmax(300px, 400px) 1fr;
  flex: 1; min-height: 0; /* fills what's left under the nav (and any flash message) */
}
.logs-side {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--ink-50); border-right: 1px solid var(--ink-200);
}
.logs-side-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; }
.logs-side-head h1 { margin: 0; flex: 1; font-size: 1.6rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--ink-200); border-radius: 12px; background: #fff;
  color: var(--ink-600); cursor: pointer; box-shadow: var(--shadow-card);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--ink-50); color: var(--ink-900); }
.icon-btn.spinning svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.logs-search {
  display: flex; align-items: center; gap: 9px; margin: 0 20px 12px;
  padding: 0 10px 0 13px; height: 42px; color: var(--ink-400);
  background: #fff; border: 1px solid var(--ink-200); border-radius: 12px;
}
.logs-search:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(26,189,202,.15); }
.logs-search input {
  flex: 1; min-width: 0; border: none; outline: none; background: none;
  font: inherit; font-size: 14px; color: var(--ink-900);
}
.logs-search kbd {
  font: 500 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-500);
  border: 1px solid var(--ink-200); border-radius: 6px; padding: 4px 7px; background: var(--ink-50);
}

.logs-list { flex: 1; overflow-y: auto; padding: 2px 12px 16px; min-height: 0; }
.logs-list.loading { opacity: .5; }
.logs-none { padding: 10px 8px; font-size: 13.5px; }
.log-item {
  display: flex; gap: 11px; align-items: flex-start;
  text-decoration: none; color: inherit;
  padding: 11px 12px; margin-bottom: 4px;
  border: 1px solid transparent; border-radius: 14px; transition: background .12s;
}
.log-item:hover { background: rgba(255,255,255,.7); }
.log-item.active { background: #fff; border-color: var(--ink-200); box-shadow: var(--shadow-card); }
.log-avatar {
  flex: 0 0 auto; display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-700);
}
.log-avatar.lg { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--ink-200); background: #fff; color: var(--brand-600); }
.log-avatar.lg svg { width: 22px; height: 22px; }
.log-item-text { flex: 1; min-width: 0; display: block; }
.log-item-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.log-item-title {
  font-weight: 600; font-size: 14px; color: var(--ink-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.log-item-time { flex: 0 0 auto; font-size: 12px; color: var(--ink-400); }
.log-item-sub {
  display: block; font-size: 13px; color: var(--ink-500); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.logs-detail { overflow-y: auto; background: #fff; min-width: 0; }
.logs-detail.loading { opacity: .5; }
.logs-empty { display: grid; place-items: center; height: 100%; font-size: 14px; }
.detail-head { display: flex; align-items: center; gap: 14px; padding: 18px 32px 6px; }
.detail-title { display: flex; flex-direction: column; line-height: 1.3; }
.detail-head h2 { margin: 0; font-size: 1.2rem; }
.detail-tabs {
  position: sticky; top: 0; z-index: 2; background: #fff;
  display: flex; gap: 26px; padding: 0 32px; border-bottom: 1px solid var(--ink-200);
}
.detail-tab {
  border: none; background: none; cursor: pointer; font: inherit;
  font-size: 15px; font-weight: 500; color: var(--ink-500);
  padding: 12px 0 11px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.detail-tab:hover { color: var(--ink-900); }
.detail-tab.active { color: var(--ink-900); font-weight: 600; border-bottom-color: var(--ink-900); }
.detail-panel { padding: 24px 32px 40px; }

.log-thread { display: flex; flex-direction: column; gap: 14px; max-width: 980px; }
.bubble-row { display: flex; flex-direction: column; gap: 7px; }
.bubble-row.bot { align-items: flex-start; }
.bubble-row.user { align-items: flex-end; }
.bubble {
  max-width: min(760px, 88%); padding: 12px 18px; border-radius: 20px;
  font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere;
}
.bubble.bot { background: var(--ink-100); color: var(--ink-800); border-top-left-radius: 8px; }
.bubble.user { background: var(--ink-900); color: #fff; border-top-right-radius: 8px; }
.bubble-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 8px; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.bubble a { color: inherit; font-weight: 500; text-decoration: underline; }
.bubble strong { color: var(--ink-900); }
.bubble code {
  background: rgba(15,23,42,.07); border-radius: 5px; padding: 1px 5px; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.bubble pre {
  background: rgba(15,23,42,.07); border-radius: 8px; padding: 10px 12px; margin: 0 0 8px;
  overflow-x: auto; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.log-sources { font-size: 12.5px; color: var(--ink-500); max-width: min(760px, 88%); }
.log-sources a { margin-right: 10px; }

/* Details tab: label-value rows across the whole panel. */
.info-heading {
  display: flex; align-items: center; gap: 10px; margin: 0 0 10px;
  font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-600);
}
.info-heading svg { color: var(--ink-500); }
.info-list { margin: 0; }
.info-row { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding: 11px 0; font-size: 15px; }
.info-row dt { color: var(--ink-500); flex: 0 0 auto; }
.info-row dd { margin: 0; color: var(--ink-900); font-weight: 500; text-align: right; overflow-wrap: anywhere; }

@media (max-width: 820px) {
  .container.full { height: auto; }
  .logs-layout { grid-template-columns: 1fr; }
  .logs-side { border-right: none; border-bottom: 1px solid var(--ink-200); }
  .logs-list { max-height: 340px; }
  .detail-head, .detail-tabs, .detail-panel { padding-left: 16px; padding-right: 16px; }
  .bubble { max-width: 94%; }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 15, 28, .55);
  display: grid; place-items: center; z-index: 1000; padding: 20px;
  backdrop-filter: blur(2px);
  /* Closed: invisible and not clickable. Closing fades out a bit faster than opening. */
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .15s ease-in, visibility 0s linear .15s;
}
.modal-overlay.open {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: opacity .2s ease-out, visibility 0s;
}
.modal {
  background: #fff; border-radius: 18px; padding: 24px 26px;
  width: 580px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  display: grid; gap: 13px; box-shadow: var(--shadow-cardlg);
  transform: translateY(12px) scale(.97);
  transition: transform .15s ease-in;
}
.modal-overlay.open .modal { transform: none; transition: transform .25s cubic-bezier(.2, .9, .3, 1.1); }
@media (prefers-reduced-motion: reduce) {
  .modal, .modal-overlay.open .modal { transform: none; transition: none; }
}
.modal h2 { margin: 0; }
.modal p { margin: 0; font-size: 13px; }
.modal label { display: grid; gap: 6px; font-weight: 600; font-size: 13.5px; color: var(--ink-800); }
.modal textarea[readonly] { background: var(--ink-50); color: var(--ink-500); }
/* Buttons stay pinned to the bottom of a dialog that scrolls. The negative
   margins stretch the bar to the dialog's edges so content scrolls under it. */
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: -24px; z-index: 1;
  margin: 4px -26px -24px; padding: 14px 26px 20px;
  background: #fff; border-top: 1px solid var(--ink-100); border-radius: 0 0 18px 18px;
}

/* ---- Login ---- */
.login-page {
  display: grid; place-items: center; min-height: 100vh;
  background-color: var(--ink-50);
  background-image:
    linear-gradient(to right, rgba(15,23,42,.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15,23,42,.045) 1px, transparent 1px);
  background-size: 56px 56px;
}
.login-box {
  background: #fff; border: 1px solid var(--ink-200); border-radius: 18px;
  padding: 34px 34px 30px; width: 350px; display: grid; gap: 13px; text-align: center;
  box-shadow: var(--shadow-cardlg);
}
.login-logo { height: 46px; width: auto; display: block; margin: 0 auto 10px; }
.login-box h1 { margin: 0; font-size: 1.25rem; }
.login-box p { margin: 0 0 8px; font-size: 13px; }
.login-box input {
  border: 1px solid var(--ink-300); border-radius: 10px; padding: 10px 13px; font: inherit;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.login-box input:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(26,189,202,.15); }
.login-box button {
  background: var(--brand-600); color: #fff; border: none; border-radius: 10px;
  padding: 10px; font: inherit; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-card); transition: background .15s;
}
.login-box button:hover { background: var(--brand-700); }

/* Training strip: nothing left to train */
#train-status.all-trained { color: #047857; font-weight: 600; }

/* ---- Dashboard ---- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin: 1.6rem 0 1.4rem; }
.dash-head h1 { margin: 0 0 4px; }
.dash-head p { margin: 0; font-size: 14px; }
.dash-status {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  font-size: 13.5px; font-weight: 500; color: var(--ink-800);
  padding: 7px 14px; border: 1px solid var(--ink-200); border-radius: 999px; background: #fff;
}
.dash-status:hover { background: var(--ink-50); color: var(--ink-900); }
.dash-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; }
.dash-status.pending .dot { background: #f59e0b; }

.panel {
  background: #fff; border: 1px solid var(--ink-200); border-radius: 16px;
  margin-bottom: 20px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 22px 16px; border-bottom: 1px solid var(--ink-100);
}
.panel-head h2 { margin: 0 0 2px; font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.panel-head p { margin: 0; font-size: 13px; }
.panel-link { flex: 0 0 auto; font-size: 13px; font-weight: 500; text-decoration: none; color: var(--ink-500); padding-top: 1px; }
.panel-link:hover { color: var(--ink-900); }
.panel > .flash { margin: 14px 22px 0; }
.panel-empty { margin: 0; padding: 18px 22px; font-size: 13.5px; }

/* One row of figures, separated by hairlines */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.metric { display: grid; gap: 6px; padding: 18px 22px 20px; border-left: 1px solid var(--ink-100); }
.metric:first-child { border-left: none; }
.metric-label { font-size: 12.5px; color: var(--ink-500); }
.metric-value {
  font-size: 22px; font-weight: 600; letter-spacing: -.02em; color: var(--ink-900);
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.metric-value.is-bad { color: #b91c1c; }

.panel-table { border-top: 1px solid var(--ink-100); overflow-x: auto; }
.data-table { border: none; border-radius: 0; box-shadow: none; }
.data-table th { background: none; padding-top: 12px; padding-bottom: 10px; }
.data-table th:first-child, .data-table td:first-child { padding-left: 22px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 22px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .strong { font-weight: 600; color: var(--ink-900); }
.data-table tr:hover td { background: var(--ink-50); }

.convo-list { list-style: none; margin: 0; padding: 4px 0; }
.convo-list a {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 110px; align-items: center; gap: 14px;
  padding: 11px 22px; text-decoration: none; color: var(--ink-700); font-size: 13.5px;
}
.convo-list a:hover { background: var(--ink-50); }
.convo-id { color: var(--ink-400); font-variant-numeric: tabular-nums; }
.convo-question { color: var(--ink-900); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-meta { color: var(--ink-500); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .metric { border-left: none; border-top: 1px solid var(--ink-100); }
  .convo-list a { grid-template-columns: minmax(0, 1fr) auto; }
  .convo-id, .convo-list .convo-meta:nth-child(3) { display: none; }
}

/* Visitor feedback chips in Chat logs */
.chip.fb-up { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.chip.fb-down { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.chip.fb-down svg { transform: rotate(180deg); }

/* Revised answers in Chat logs */
.revise-btn.is-revised { background: #ecfdf5; border-color: #a7f3d0; color: #047857; font-weight: 600; }
.revise-btn.is-revised:hover { background: #d1fae5; color: #065f46; }

/* Popup notification (toast), top-right just below the 62px nav bar */
.toast {
  position: fixed; right: 24px; top: 78px; z-index: 2000; max-width: min(420px, calc(100vw - 48px));
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 18px 13px 14px; border-radius: 12px; background: #fff;
  border: 1px solid var(--ink-200); box-shadow: var(--shadow-cardlg);
  font-size: 14px; font-weight: 500; color: var(--ink-800); line-height: 1.45;
  opacity: 0; transform: translateY(-12px) scale(.98);
  transition: opacity .2s ease, transform .25s cubic-bezier(.2, .9, .3, 1.1);
}
.toast.show { opacity: 1; transform: none; }
.toast::before {
  content: ''; flex: 0 0 auto; width: 20px; height: 20px; margin-top: 0; border-radius: 50%;
  background: #10b981 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.toast-error::before {
  background: #ef4444 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 7v6M12 17h.01'/%3E%3C/svg%3E") center / 14px no-repeat;
}
@media (prefers-reduced-motion: reduce) { .toast { transform: none; } }

/* Sources list: Q&A question opens the edit dialog */
.qa-link {
  display: inline; padding: 0; border: none; background: none; cursor: pointer; text-align: left;
  font: inherit; font-weight: 500; color: var(--ink-900);
}
.qa-link:hover { color: var(--brand-700); text-decoration: underline; text-underline-offset: 3px; }
.qa-preview { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 560px; }
.modal-actions .spacer { flex: 1; }

/* ---- Accounts, agents and the platform panel ---- */
.acting-banner {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  margin: 0; padding: 8px 16px; background: var(--ink-900); color: #e2e8f0; font-size: 13px;
}
.acting-banner strong { color: #fff; }
.acting-banner button {
  border: 1px solid rgba(255,255,255,.3); background: none; color: #fff; border-radius: 8px;
  padding: 4px 10px; font: inherit; font-weight: 600; cursor: pointer;
}
.acting-banner button:hover { background: rgba(255,255,255,.1); }
.area-badge {
  margin: 0 14px 0 -14px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .02em; text-transform: uppercase; background: var(--ink-900); color: #fff;
}

/* Agent switcher in the top bar */
.agent-menu { margin: 0 12px 0 -14px; }
.agent-switch {
  display: flex; align-items: center; gap: 8px; cursor: pointer; max-width: 260px;
  padding: 6px 10px 6px 12px; border: 1px solid var(--ink-200); border-radius: 10px; background: #fff;
  box-shadow: var(--shadow-card); font-size: 13.5px; transition: background .15s;
}
.agent-switch:hover { background: var(--ink-50); }
.agent-switch-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-400); }
.agent-switch-name { font-weight: 600; color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-switch svg { flex: 0 0 auto; color: var(--ink-500); transition: transform .15s; }
.agent-menu[open] .agent-switch svg { transform: rotate(180deg); }
.agent-pop { left: 0; right: auto; width: 280px; max-height: 70vh; overflow-y: auto; }
.agent-pop form { display: grid; gap: 2px; }
.agent-pop strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-pop-foot { display: grid; gap: 2px; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--ink-100); }
.menu-pop .agent-pop-add {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--brand-700);
}
.menu-pop .agent-pop-add:hover { background: var(--brand-50); }
.topnav .agent-pop-link { display: block; padding: 9px 12px; border-radius: 10px; font-size: 13px; }
.topnav .agent-pop-link::after { content: none; }

.panel.panel-pad { padding: 20px 22px 22px; overflow: visible; }
.account-meta { overflow-wrap: anywhere; } /* long IPv6 addresses */

/* Section tabs of a page (an account in the admin panel). */
.page-tabs {
  display: flex; overflow-x: auto; margin: 0 0 20px;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 16px; box-shadow: var(--shadow-card);
}
.page-tabs a {
  flex: 0 0 auto; padding: 13px 20px; font-size: 14px; font-weight: 500;
  color: var(--ink-700); text-decoration: none; white-space: nowrap; transition: background .15s, color .15s;
}
.page-tabs a:first-child { border-radius: 15px 0 0 15px; }
.page-tabs a:hover { background: var(--ink-50); color: var(--ink-900); }
.page-tabs a.active { background: var(--brand-600); color: #fff; font-weight: 600; }
/* Content under a .panel-head, padded like it. */
.panel-body { padding: 16px 22px 20px; }
.panel-head:last-child { border-bottom: 0; } /* a panel that is just its heading */
/* Panels with tooltips inside: don't clip them at the panel's edge. */
.panel.panel-open { overflow: visible; }
.panel-pad > h2:first-child { margin-top: 0; }
.panel.settings-form { max-width: none; }
.inline-form { display: flex; gap: 10px; max-width: 560px; }
.inline-form input { flex: 1; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.two-col > .panel { margin-bottom: 20px; }
.account-forms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (max-width: 820px) { .two-col, .account-forms { grid-template-columns: 1fr; } }
.metrics-row { border-top: 1px solid var(--ink-100); }
.crumbs { margin: 0 0 2px; font-size: 13px; }
.crumbs a { color: var(--ink-500); text-decoration: none; }
.crumbs a:hover { color: var(--ink-900); }
.dash-head h1 .status { vertical-align: middle; margin-left: 6px; }
.agent-name { color: var(--ink-900); margin-right: 6px; }
.data-table td.actions { white-space: nowrap; }
.data-table td.actions .btn { margin-left: 4px; }
.convo-list a.account-row { grid-template-columns: minmax(0, 1fr) auto auto; }

/* Plan usage bars */
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px 28px; padding: 18px 22px 20px; }
.meter { display: grid; gap: 8px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.meter-count { font-size: 13px; color: var(--ink-500); font-variant-numeric: tabular-nums; }
.meter-count strong { font-size: 17px; color: var(--ink-900); }
.meter-bar { height: 7px; border-radius: 999px; background: var(--ink-100); overflow: hidden; }
.meter-bar span { display: block; height: 100%; border-radius: inherit; background: var(--brand-600); }
.meter.near .meter-bar span { background: #f59e0b; }
.meter.full .meter-bar span { background: #dc2626; }
.meter.full .meter-count strong { color: #b91c1c; }
.feature-list { list-style: none; margin: 0; padding: 14px 22px 18px; border-top: 1px solid var(--ink-100);
  display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13.5px; }
.feature-list li { display: flex; align-items: center; gap: 7px; color: var(--ink-800); }
.feature-list li.off { color: var(--ink-400); }
.feature-mark { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; font-size: 11px; font-weight: 700;
  background: var(--brand-50); color: var(--brand-700); }
.feature-list li.off .feature-mark { background: var(--ink-100); color: var(--ink-400); }
.plan-lock {
  padding: 10px 14px; border-radius: 10px; background: var(--ink-50); border: 1px dashed var(--ink-300);
  color: var(--ink-600) !important; font-size: 13px !important;
}

/* Users of an account */
.user-list { list-style: none; margin: 0 0 14px; padding: 0; }
.user-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--ink-100); }
.user-list li:last-child { border-bottom: none; }
.user-list strong { color: var(--ink-900); font-size: 13.5px; margin-right: 6px; overflow-wrap: anywhere; }
.user-list .actions { display: flex; gap: 6px; }
.danger-zone { border-color: #fecaca; }
.btn.primary.danger-fill { background: #dc2626; border-color: #dc2626; }
.btn.primary.danger-fill:hover { background: #b91c1c; border-color: #b91c1c; }

/* Plans editor */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 20px; align-items: start; }
.plan-grid .panel { margin-bottom: 0; }
.plan-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.plan-card-head h2 { margin: 0 !important; padding: 0 !important; border: none !important; }
.feature-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.plan-card-actions { display: flex; gap: 8px; }
.plan-card-actions .btn { margin-top: 0 !important; }

/* Account → Change plan (Paddle) */
.shop-plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 14px; padding: 18px 22px 22px; }
.shop-plan { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--ink-200); border-radius: 12px; }
.shop-plan.current { border-color: var(--brand-600); box-shadow: inset 0 0 0 1px var(--brand-600); }
.shop-plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.shop-plan-head h3 { margin: 0; font-size: 15px; }
.shop-price { font-weight: 700; font-size: 17px; }
.shop-price .muted { font-weight: 400; font-size: 12.5px; }
.shop-limits { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--ink-700); flex: 1; }
.shop-plan .pill, .shop-plan form { align-self: flex-start; }
.billing-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; font-size: 13.5px; }
.billing-facts dt { color: var(--ink-500); }
.billing-facts dd { margin: 0; }

/* Log in / sign up */
.login-box .auth-links { margin: 4px 0 0; font-size: 13px; color: var(--ink-500); }
.login-box .muted { margin: 0; font-size: 13px; }
