:root {
  --bg: #121212;
  --surface: #1c1c1c;
  --surface-2: #242424;
  --surface-3: #2c2c2c;
  --border: #333;
  --text: #e8e8e8;
  --text-dim: #999;
  --accent: #5b8def;
  --accent-dim: rgba(91, 141, 239, 0.15);
  --success: #2ecc71;
  --warning: #f1c40f;
  --danger: #e74c3c;
  --pending: #7f8c8d;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1, h2 {
  margin: 0;
  font-weight: 600;
}

.hint {
  color: var(--text-dim);
  font-size: 0.85em;
}

code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------------- */
/* Topbar                                                                  */
/* ---------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.topbar-title h1 {
  font-size: 1.3em;
  letter-spacing: -0.01em;
}

.topbar-title .subtitle {
  color: var(--text-dim);
  font-size: 0.85em;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-controls input[type="number"] {
  width: 64px;
}

.stats {
  display: flex;
  gap: 6px;
  margin-right: 8px;
}

.stats .stat-chip {
  font-size: 0.78em;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

/* Auto-send progress bar */

.auto-progress-bar {
  position: relative;
  height: 28px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.auto-progress-bar.hidden {
  display: none;
}

.auto-progress-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--accent-dim);
  border-right: 2px solid var(--accent);
  transition: width 0.4s ease;
}

.auto-progress-label {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
  line-height: 28px;
  font-size: 0.82em;
  color: var(--text);
}

/* ---------------------------------------------------------------------- */
/* Layout                                                                  */
/* ---------------------------------------------------------------------- */

main {
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.import-panel {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 24px;
}

.import-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 260px;
}

.import-block h2 {
  font-size: 0.85em;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.input-row input {
  flex: 1;
  min-width: 140px;
}

.input-row .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}

.input-row .field label {
  color: var(--text-dim);
  font-size: 0.8em;
}

.input-row > .btn {
  align-self: flex-end;
}

/* ---------------------------------------------------------------------- */
/* Form controls                                                          */
/* ---------------------------------------------------------------------- */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.95em;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="text"]:-webkit-autofill,
input[type="email"]:-webkit-autofill,
input[type="password"]:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px var(--surface-2) inset;
  box-shadow: 0 0 0px 1000px var(--surface-2) inset;
  transition: background-color 9999s ease-in-out 0s;
}

textarea {
  resize: vertical;
}

.btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.9em;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-3);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0f1a;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: #4c7bdb;
  border-color: #4c7bdb;
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(231, 76, 60, 0.12);
}

/* ---------------------------------------------------------------------- */
/* Queue table                                                            */
/* ---------------------------------------------------------------------- */

.queue-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 22px;
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.queue-header-actions {
  display: flex;
  gap: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.92em;
}

thead th {
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.75em;
  letter-spacing: 0.05em;
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr.active-row {
  background: var(--accent-dim);
}

tbody tr.active-row td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

td .btn {
  padding: 5px 10px;
  font-size: 0.82em;
  margin-right: 6px;
}

.empty-state {
  text-align: center;
  padding: 24px 0 8px;
}

.empty-state.hidden {
  display: none;
}

/* ---------------------------------------------------------------------- */
/* Status pills                                                           */
/* ---------------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8em;
  text-transform: capitalize;
}

.pill-pending {
  background: rgba(127, 140, 141, 0.2);
  color: var(--pending);
}

.pill-generated {
  background: rgba(91, 141, 239, 0.2);
  color: var(--accent);
}

.pill-sent {
  background: rgba(46, 204, 113, 0.2);
  color: var(--success);
}

.pill-failed {
  background: rgba(231, 76, 60, 0.2);
  color: var(--danger);
}

.pill-brand {
  background: var(--surface-3);
  color: var(--text);
  text-transform: none;
}

.warn-icon {
  color: var(--warning);
  cursor: help;
  margin-left: 6px;
}

/* ---------------------------------------------------------------------- */
/* Modal (single-row preview/edit)                                        */
/* ---------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: min(600px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-card label {
  color: var(--text-dim);
  font-size: 0.85em;
  margin-top: 8px;
}

.modal-card textarea {
  width: 100%;
  min-height: 220px;
  font-family: inherit;
}

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

.prompt-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}

/* ---------------------------------------------------------------------- */
/* Prompt settings                                                        */
/* ---------------------------------------------------------------------- */

.prompt-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: min(640px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prompt-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prompt-section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prompt-section h3 {
  margin: 0 0 4px;
  font-size: 0.95em;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.prompt-card label {
  color: var(--text-dim);
  font-size: 0.85em;
  margin-top: 6px;
}

.prompt-card textarea {
  width: 100%;
  font-family: inherit;
  line-height: 1.4;
}

.prompt-textarea-sm {
  min-height: 50px;
}

.prompt-textarea-lg {
  min-height: 140px;
}

.prompt-collapsible > summary {
  cursor: pointer;
  list-style: none;
}

.prompt-collapsible > summary::-webkit-details-marker {
  display: none;
}

.prompt-collapsible > summary h3 {
  display: inline;
}

.prompt-collapsible > summary::before {
  content: "\25B8";
  color: var(--text-dim);
  margin-right: 6px;
}

.prompt-collapsible[open] > summary::before {
  content: "\25BE";
}

.prompt-collapsible > summary .hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: normal;
}

.prompt-vars {
  margin-top: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: max-content 90px 1fr;
  align-items: center;
  gap: 8px 12px;
}

.prompt-card .settings-grid label {
  margin-top: 0;
}

.settings-grid .hint {
  font-size: 0.8em;
}

@media (max-width: 600px) {
  .settings-grid {
    grid-template-columns: 1fr 90px;
  }
  .settings-grid .hint {
    grid-column: 1 / -1;
  }
}

/* ---------------------------------------------------------------------- */
/* Daily send quota badge + toast                                         */
/* ---------------------------------------------------------------------- */

.quota-badge {
  font-size: 0.78em;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.quota-badge.quota-full {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(231, 76, 60, 0.12);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  z-index: 2000;
}

.toast-error {
  border-color: var(--danger);
}

/* ---------------------------------------------------------------------- */
/* Review (step-through) mode                                             */
/* ---------------------------------------------------------------------- */

.review-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: min(680px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.review-topline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.review-progress-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.review-progress-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.review-progress-dots .dot.dot-current {
  background: var(--accent);
  transform: scale(1.3);
}

.review-progress-dots .dot.dot-sent {
  background: var(--success);
}

.review-progress-dots .dot.dot-failed {
  background: var(--danger);
}

.review-close {
  margin-left: auto;
}

.review-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.review-heading h2 {
  font-size: 1.1em;
}

.review-blurb {
  margin: -6px 0 0;
  font-style: italic;
}

.review-generating {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  padding: 12px 0;
}

.review-generating.hidden {
  display: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

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

.review-draft {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-draft.hidden {
  display: none;
}

.review-draft label {
  color: var(--text-dim);
  font-size: 0.85em;
  margin-top: 6px;
}

.review-draft textarea {
  min-height: 260px;
  font-family: inherit;
  line-height: 1.5;
}

.review-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

/* ---------------------------------------------------------------------- */
/* Login page                                                             */
/* ---------------------------------------------------------------------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card h1 {
  font-size: 1.3em;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.login-card label {
  color: var(--text-dim);
  font-size: 0.85em;
  margin-top: 6px;
}

.login-submit {
  margin-top: 14px;
}

.login-error {
  color: var(--danger);
  font-size: 0.88em;
  margin: 4px 0 0;
}

/* ---------------------------------------------------------------------- */
/* Nav + topbar user                                                      */
/* ---------------------------------------------------------------------- */

.main-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9em;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.topbar-user {
  margin-left: 6px;
}

/* ---------------------------------------------------------------------- */
/* Add Email — "more details" disclosure                                  */
/* ---------------------------------------------------------------------- */

.more-details {
  margin-top: 4px;
}

.more-details summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.85em;
}

.more-details .input-row {
  margin-top: 10px;
}

/* ---------------------------------------------------------------------- */
/* Queue / Sent tables — extra cells                                      */
/* ---------------------------------------------------------------------- */

tbody tr.row-replied {
  opacity: 0.6;
}

.auto-fu-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.auto-fu-delay {
  width: 52px;
  padding: 4px 6px;
  font-size: 0.85em;
}

.contact-link {
  color: var(--accent);
  text-decoration: none;
}

.contact-link:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------------- */
/* Details modal                                                          */
/* ---------------------------------------------------------------------- */

.details-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}

.detail-label {
  color: var(--text-dim);
  flex-shrink: 0;
}

.detail-value {
  text-align: right;
  word-break: break-word;
}

.detail-row-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}

.detail-value-block {
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------------------------------------------------------------------- */
/* Inbox                                                                  */
/* ---------------------------------------------------------------------- */

.reply-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reply-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.reply-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.reply-card-badges {
  display: flex;
  gap: 6px;
}

.reply-subject {
  font-weight: 600;
  margin-top: 8px;
}

.reply-snippet {
  color: var(--text-dim);
  margin: 6px 0;
  font-size: 0.9em;
  white-space: pre-wrap;
}

.reply-meta {
  margin-bottom: 8px;
}

.reply-actions {
  display: flex;
  justify-content: flex-end;
}

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

main.dash-main {
  max-width: 1320px;
}

select,
input[type="date"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  font-family: inherit;
  font-size: 0.9em;
  color-scheme: dark;
}

select:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px 10px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-field > label {
  color: var(--text-dim);
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-field input[type="text"] {
  padding: 7px 9px;
  font-size: 0.9em;
}

.filter-grow {
  flex: 1;
  min-width: 180px;
}

.range-pair {
  display: flex;
  gap: 4px;
}

.range-pair input,
#f-minn {
  width: 72px;
  padding: 7px 8px;
  font-size: 0.9em;
}

.filter-reset {
  margin-left: auto;
}

.filter-summary {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

/* Segmented control */

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.seg button {
  background: var(--surface-2);
  color: var(--text-dim);
  border: 0;
  border-right: 1px solid var(--border);
  padding: 8px 11px;
  font-size: 0.85em;
  cursor: pointer;
  font-family: inherit;
}

.seg button:last-child {
  border-right: 0;
}

.seg button:hover {
  color: var(--text);
  background: var(--surface-3);
}

.seg button.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.seg-sm button {
  padding: 5px 9px;
  font-size: 0.78em;
}

/* Multi-select */

.ms {
  position: relative;
}

.ms details {
  position: relative;
}

.ms-summary {
  list-style: none;
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 26px 7px 9px;
  font-size: 0.9em;
  min-width: 130px;
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.ms-summary::-webkit-details-marker {
  display: none;
}

.ms-summary::after {
  content: "▾";
  position: absolute;
  right: 9px;
  color: var(--text-dim);
}

.ms details[open] .ms-summary {
  border-color: var(--accent);
}

.ms-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  min-width: 220px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.ms-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.ms-actions .btn {
  padding: 3px 9px;
  font-size: 0.78em;
}

.ms-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 4px;
  font-size: 0.88em;
  cursor: pointer;
}

.ms-opt:hover {
  background: var(--surface-3);
}

.ms-opt span:nth-child(2) {
  flex: 1;
}

/* KPI tiles */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

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

.kpi-label {
  color: var(--text-dim);
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.75em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.kpi-sub {
  color: var(--text-dim);
  font-size: 0.8em;
}

.kpi-accent {
  box-shadow: inset 3px 0 0 var(--accent);
}

.kpi-warn {
  box-shadow: inset 3px 0 0 var(--warning);
}

.kpi-bad {
  box-shadow: inset 3px 0 0 var(--danger);
}

.delta {
  font-weight: 600;
}

.delta.up {
  color: var(--success);
}

.delta.down {
  color: var(--danger);
}

/* Cards */

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  min-width: 0;
}

.dash-wide {
  grid-column: 1 / -1;
}

.dash-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.dash-card-head h2 {
  font-size: 0.95em;
}

.dash-subhead {
  font-size: 0.8em;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  margin: 18px 0 6px;
}

.chart-box {
  position: relative;
  height: 280px;
}

.chart-box-sm {
  height: 220px;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 0.82em;
  color: var(--text-dim);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-sq {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-line {
  width: 14px;
  height: 2px;
  border-radius: 1px;
}

/* Funnel + bar lists */

.funnel,
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.funnel-row,
.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 0.9em;
}

.funnel-row {
  grid-template-columns: 100px 1fr 56px 130px;
}

.funnel-label {
  color: var(--text-dim);
}

.funnel-track {
  background: var(--surface-2);
  border-radius: 4px;
  height: 16px;
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.25s ease;
}

.funnel-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.funnel-conv {
  font-size: 0.8em;
}

/* Heatmap */

.heatmap {
  display: grid;
  grid-template-columns: 36px repeat(24, minmax(0, 1fr));
  gap: 2px;
}

.hm-hour,
.hm-day {
  font-size: 0.72em;
  color: var(--text-dim);
}

.hm-hour {
  text-align: left;
  padding-bottom: 2px;
}

.hm-day {
  display: flex;
  align-items: center;
}

.hm-cell {
  height: 22px;
  border-radius: 3px;
  cursor: default;
}

.hm-cell:hover {
  outline: 2px solid var(--text);
  outline-offset: -1px;
}

.hm-empty {
  opacity: 0.6;
}

.heatmap-scale {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  font-size: 0.9em;
}

.heatmap-scale .hint:first-child {
  margin-right: 4px;
}

.hm-swatch {
  width: 18px;
  height: 10px;
  border-radius: 2px;
}

.heatmap-scale .hm-swatch + .hint {
  margin-left: 4px;
}

/* Dashboard tables */

.dash-table th,
.dash-table td {
  padding: 8px 10px;
  font-size: 0.86em;
}

.dash-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dash-table .clip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.err-cell {
  color: var(--text-dim);
  word-break: break-word;
}

.chart-tip {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82em;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .dash-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-bar {
    position: static;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .funnel-row {
    grid-template-columns: 90px 1fr 48px;
  }

  .funnel-conv {
    display: none;
  }

  .dash-card {
    overflow-x: auto;
  }
}
