/*
 * AUTOPOSTER — Buro app shell + product UI
 * Design tokens from app_design_wireframe (quiz-app-tokens.css)
 */

:root {
  --brand-deep: #072b2e;
  --brand-primary: #5ab774;
  --brand-primary-hover: #4a9d63;
  --brand-off: #e8fcec;
  --brand-accent: #fef3a4;

  --app-bg: #f6f8fb;
  --line-hair: #e5eaf1;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --surface-elevated: #f8fafc;
  --border: #e5eaf1;
  --border-hover: #cbd5e1;

  --text: #111827;
  --text-heading: #0f172a;
  --text-secondary: #6b7280;
  --text-tertiary: #94a3b8;

  --primary-soft: rgba(90, 183, 116, 0.12);
  --primary-ring: rgba(90, 183, 116, 0.28);
  --focus-ring: 0 0 0 3px rgba(90, 183, 116, 0.22);

  --success: #10b981;
  --success-bg: #d1fae5;
  --success-text: #065f46;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;

  --header-h: 52px;
  --header-control-h: 32px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

  --header-bg: var(--brand-deep);
  --header-border: rgba(255, 255, 255, 0.12);
  --header-text: #f3fcf6;
  --header-text-muted: rgba(255, 255, 255, 0.72);
  --header-control-bg: rgba(255, 255, 255, 0.1);
  --header-control-bg-hover: rgba(255, 255, 255, 0.18);
  --header-control-border: rgba(255, 255, 255, 0.22);

  --sidebar-w: 240px;
  --sidebar-brand-bg: #062528;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Legacy aliases used in JS-rendered markup */
  --bg: var(--app-bg);
  --panel: var(--surface);
  --ink: var(--text);
  --muted: var(--text-secondary);
  --line: var(--border);
  --accent: var(--brand-primary);
  --accent-2: var(--brand-deep);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

[hidden] {
  display: none !important;
}

body.buro-app {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--app-bg);
  min-height: 100vh;
}

.shell-root {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

/* ─── Left sidebar ─── */
.sidebar-overlay {
  display: none;
}

.sidebar {
  background: var(--brand-deep);
  border-right: 1px solid var(--header-border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  overflow: hidden;
}

.sidebar-brand {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 14px 12px;
  background: var(--sidebar-brand-bg);
  border-bottom: 1px solid var(--header-border);
}

.sidebar-brand-logo {
  justify-content: center;
}

.sidebar-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 14px 20px;
  overflow: hidden;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  color: var(--header-text);
}

.logo:hover {
  opacity: 0.92;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.logo-mark img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

.sidebar .logo-mark {
  background: none;
  box-shadow: none;
  border-radius: 0;
}

.sidebar .logo-mark img {
  filter: brightness(0) invert(1);
}

.logo-mark--lg {
  width: 56px;
  height: 56px;
}

.logo-mark--lg img {
  width: 48px;
  height: 48px;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.auth-logo .logo-text {
  font-size: 22px;
  color: var(--text);
}

.sidebar-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--header-control-bg);
  color: var(--header-text);
  cursor: pointer;
  flex-shrink: 0;
  z-index: 1;
}

.sidebar-close:hover {
  background: var(--header-control-bg-hover);
}

.sidebar-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--header-text-muted);
  margin-bottom: 6px;
}

.sidebar-workspace {
  margin-bottom: 8px;
}

.workspace-select {
  width: 100%;
  min-height: var(--header-control-h);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--header-control-border);
  background: var(--header-control-bg);
  color: var(--header-text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.workspace-select option {
  color: var(--text);
  background: var(--surface);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 2px;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
}

.sidebar-nav-group .sidebar-label {
  padding: 0 12px;
  margin-bottom: 2px;
}

.sidebar-nav-group-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav-bottom {
  margin-top: auto;
  padding-top: 12px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--header-text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.sidebar-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke-width: 2;
  opacity: 0.86;
}

.sidebar-link:hover {
  color: var(--header-text);
  background: var(--header-control-bg);
}

.sidebar-link.active {
  background: rgba(232, 252, 236, 0.16);
  color: var(--brand-off);
  font-weight: 600;
}

.sidebar-link.active .sidebar-icon {
  opacity: 1;
}

.sidebar-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--header-border);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(220, 38, 38, 0.22);
  color: #fecaca;
}

.sidebar-logout:hover {
  background: rgba(220, 38, 38, 0.35);
}

/* ─── Main content area ─── */
.shell-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.content-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.content-topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-heading);
}

.mobile-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-menu-toggle:hover {
  background: var(--surface-muted);
}

/* ─── Main content ─── */
.main-content {
  flex: 1;
  padding: 24px;
}

.page-container {
  max-width: 1100px;
  margin: 0 auto;
  min-width: 0;
}

.page-container.page-container--wide {
  max-width: none;
  width: 100%;
}

.page-header {
  text-align: center;
  margin-bottom: 4px;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  margin: 8px 0 0;
}

.page-subtitle {
  margin: 8px auto 0;
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 560px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-accent {
  background: var(--brand-accent);
  color: var(--brand-deep);
}

.app-toolbar {
  margin-bottom: 24px;
}

.app-toolbar--posts {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 16px;
}

.app-toolbar--posts .posts-subnav {
  flex: 0 0 auto;
  width: fit-content;
  max-width: none;
  margin-bottom: 0;
}

.app-toolbar--posts .toolbar-spacer {
  flex: 1;
  min-width: 12px;
}

.app-toolbar--posts .toolbar-actions {
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.toolbar-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

/* ─── Buttons ─── */
button, input, select, textarea {
  font: inherit;
}

.btn,
button.secondary,
button.ghost,
button.danger,
button:not(.btn):not(.secondary):not(.ghost):not(.danger):not(.sidebar-link):not(.sidebar-close):not(.sidebar-logout):not(.mobile-menu-toggle):not(.toast-dismiss):not(.calendar-post):not(.settings-nav-item):not(.posts-review-item):not(.chip-input-remove):not(.onboarding-icon-btn):not(.onboarding-step-option):not(.onboarding-collapsed-card):not(.template-detail-value):not(.template-detail-value--editable):not(.template-detail-value--inline):not(.template-drawer-title-edit):not(.table-sort-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--brand-primary);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  background: var(--brand-primary);
  color: #fff;
}

.btn-primary:hover,
button:not(.btn):not(.sidebar-link):not(.sidebar-close):not(.sidebar-logout):not(.mobile-menu-toggle):not(.toast-dismiss):not(.calendar-post):not(.settings-nav-item):not(.posts-review-item):not(.secondary):not(.ghost):not(.danger):not(.chip-input-remove):not(.onboarding-icon-btn):not(.onboarding-step-option):not(.onboarding-collapsed-card):not(.template-detail-value):not(.template-detail-value--editable):not(.template-detail-value--inline):not(.template-drawer-title-edit):not(.table-sort-button):hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

.btn-sm {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-secondary,
button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover,
button.secondary:hover {
  border-color: var(--border-hover);
  background: var(--surface-muted);
}

.btn-ghost,
button.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover,
button.ghost:hover {
  color: var(--text);
  background: var(--surface-muted);
}

button.danger,
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

button:disabled {
  opacity: 0.78;
  cursor: wait;
}

button.is-testing {
  cursor: wait;
}

.btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ─── Forms & inputs ─── */
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--brand-primary);
}

textarea {
  resize: vertical;
}

.panel-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-card);
}

.panel-form h2 {
  margin: 0;
  font-size: 18px;
  color: var(--text-heading);
}

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

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ─── Auth ─── */
.auth-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 24px;
}

.auth-card {
  max-width: 440px;
  width: 100%;
  text-align: center;
}

.auth-forms {
  margin-top: 28px;
  text-align: left;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-switch {
  margin: 8px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-switch--below {
  margin-top: 16px;
}

.auth-switch-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.auth-switch-link:hover {
  text-decoration: underline;
}

.auth-switch-text {
  cursor: pointer;
}

.auth-switch-text:hover {
  text-decoration: underline;
}

/* ─── Views & layout ─── */
.view {
  animation: fadeIn 0.2s ease;
}

#dashboard {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

#leads {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

#superadmin {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

#superadmin .superadmin-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.superadmin-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 12px 14px;
}

.superadmin-toolbar .field-label {
  margin: 0;
}

.superadmin-toolbar select {
  min-width: 140px;
}

.superadmin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.superadmin-tabs .settings-nav-item {
  width: auto;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 8px;
}

.superadmin-total-analytics {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.superadmin-total-card {
  margin-bottom: 0;
}

.superadmin-total-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

#superadmin .settings-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#superadmin .settings-group > .table {
  padding: 0 20px 20px;
}

.superadmin-lists {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

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

.settings-group-header.superadmin-list-header h2 {
  margin-bottom: 0;
}

.superadmin-form {
  display: grid;
  gap: 14px;
  align-items: end;
}

.superadmin-form--workspace {
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.8fr);
}

.superadmin-form--member {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(92px, 0.55fr);
}

.superadmin-form .settings-form-actions,
.superadmin-form .modal-footer {
  grid-column: 1 / -1;
}

#superadmin .members-panel .members-subtitle:first-child {
  margin-top: 0;
}

#superadminUsersPanel,
#superadminWorkspacesPanel {
  border-top: none;
}

#superadmin .member-row {
  align-items: center;
}

#superadmin .member-actions {
  justify-content: flex-start;
}

#superadmin .settings-table-head {
  align-items: center;
}

#superadmin .table .field-help {
  margin: 0;
}

.superadmin-usage-cell {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 86px;
}

.superadmin-usage-cell strong,
.superadmin-usage-cell small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.superadmin-usage-cell small {
  color: var(--text-secondary);
  font-size: 12px;
}

.superadmin-analytics-drawer {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.superadmin-analytics-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.superadmin-analytics-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.superadmin-analytics-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.superadmin-analytics-tabs .settings-nav-item {
  width: auto;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 8px;
}

.superadmin-analytics-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.superadmin-analytics-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.superadmin-analytics-table td,
.superadmin-analytics-table th {
  white-space: nowrap;
}

.superadmin-template-analytics-table {
  min-width: 980px;
}

.superadmin-template-analytics-table .cell-title small {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

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

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-heading);
  margin: 0 0 12px;
}

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

.section-header .section-title {
  margin: 0;
}

.section-header-action {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--brand-primary);
}

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

.metric {
  padding: 20px;
  text-align: center;
}

.metric-value {
  display: block;
  font-size: 36px;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
}

.metric-label {
  display: block;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
}

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

.panel-section {
  min-width: 0;
}

.toolbar {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 20px;
}

.advanced-fields {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 9px 12px;
}

.advanced-fields summary {
  cursor: pointer;
  color: var(--text-secondary);
}

.advanced-fields input {
  margin-top: 10px;
}

.hint {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}

.hint code {
  font-size: 0.85rem;
  background: var(--surface-muted);
  padding: 1px 4px;
  border-radius: 3px;
}

.openrouter-model-select,
#draftingModelSelect {
  min-height: 220px;
}

label {
  display: block;
  margin-top: 4px;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ─── Settings ─── */
.settings-page {
  max-width: none;
}

.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-nav {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.settings-nav::-webkit-scrollbar {
  display: none;
}

.settings-nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 0 0 auto;
  min-height: 0;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.settings-nav-item:hover:not(.active) {
  color: var(--text-heading);
  background: rgba(255, 255, 255, 0.72);
  border-color: transparent;
}

.settings-nav-item.active {
  color: var(--brand-deep);
  font-weight: 700;
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.settings-nav-item.active::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 5px;
  height: 3px;
  border-radius: 999px;
  background: var(--brand-primary);
}

.settings-nav-item.active:hover {
  color: var(--brand-deep);
  background: var(--surface);
  border-color: var(--border);
}

.settings-nav-item--attention::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--brand-primary);
  vertical-align: middle;
}

.settings-main {
  min-width: 0;
}

.settings-tab-panel[hidden] {
  display: none !important;
}

.settings-status-group--global:not(:has(.settings-output:not(:empty))) {
  display: none;
}

.settings-status-group--global {
  margin-bottom: 16px;
}

.settings-status-group--global .settings-group-header {
  padding-bottom: 0;
}

.settings-status-group--global .settings-output {
  margin-top: 0;
}

/* ─── Toasts ─── */
.toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  pointer-events: auto;
  animation: toast-in 0.28s ease-out;
}

.toast--success {
  border-color: #6ee7b7;
  background: var(--success-bg);
  color: var(--success-text);
}

.toast--error {
  border-color: #fca5a5;
  background: var(--danger-soft);
  color: var(--danger);
}

.toast--info {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1e40af;
}

.toast-message {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.toast-dismiss {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: -4px -4px -4px 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.72;
}

.toast-dismiss:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.toast.is-leaving {
  animation: toast-out 0.2s ease-in forwards;
}

/* ─── Onboarding ─── */
.onboarding-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1050;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.onboarding-widget.is-collapsed {
  width: min(230px, calc(100vw - 32px));
}

.onboarding-card,
.onboarding-collapsed-card {
  pointer-events: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
}

.onboarding-card {
  overflow: hidden;
}

.onboarding-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.onboarding-kicker,
.onboarding-collapsed-kicker,
.onboarding-step-count {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.onboarding-header h2,
.onboarding-active-step h3 {
  margin: 0;
  color: var(--text-heading);
  line-height: 1.2;
}

.onboarding-header h2 {
  margin-top: 2px;
  font-size: 18px;
}

.onboarding-icon-btn {
  flex-shrink: 0;
  width: 32px;
  min-height: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
}

.onboarding-icon-btn:hover {
  background: var(--surface-elevated);
  color: var(--text);
}

.onboarding-progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.onboarding-progress-bar {
  height: 8px;
  margin: 0 16px 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.onboarding-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  transition: width 0.2s ease;
}

.onboarding-active-step {
  margin: 0 16px 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.onboarding-active-step h3 {
  margin-top: 4px;
  font-size: 16px;
}

.onboarding-active-step p {
  margin: 8px 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.onboarding-active-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.onboarding-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.onboarding-status.is-complete {
  border-color: #86efac;
  background: var(--success-bg);
  color: var(--success-text);
}

.onboarding-step-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 0 16px 12px;
}

.onboarding-step-option {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}

.onboarding-step-option:hover,
.onboarding-step-option.is-active {
  border-color: var(--border);
  background: var(--surface-muted);
}

.onboarding-step-option.is-complete {
  color: var(--text-secondary);
}

.onboarding-step-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.onboarding-step-option.is-complete .onboarding-step-marker {
  border-color: #86efac;
  background: var(--success-bg);
  color: var(--success-text);
}

.onboarding-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

.onboarding-collapsed-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  color: var(--text);
  text-align: left;
}

.onboarding-collapsed-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-muted);
}

.onboarding-collapsed-card strong {
  font-size: 14px;
  line-height: 1.2;
}

.onboarding-collapsed-progress {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--brand-primary);
  background: var(--primary-soft);
  color: var(--brand-deep);
  font-weight: 800;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (max-width: 640px) {
  .toast-host {
    top: 12px;
    right: 12px;
    left: 12px;
    width: auto;
  }

  .onboarding-widget,
  .onboarding-widget.is-collapsed {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }

  .onboarding-footer {
    justify-content: stretch;
  }

  .onboarding-footer .btn {
    flex: 1;
  }
}

@media (max-width: 360px) {
  .onboarding-step-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .settings-nav-item {
    padding: 9px 12px;
    font-size: 13px;
  }
}

.settings-group {
  margin-bottom: 20px;
  overflow: hidden;
}

.settings-group-header {
  padding: 20px 20px 0;
}

.settings-group-header h2 {
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--text-heading);
}

.settings-group-subtitle {
  margin: -6px 0 14px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}

.settings-group-header .hint {
  margin-bottom: 14px;
}

.settings-models-table,
.settings-form,
.settings-output {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.settings-form textarea {
  width: 100%;
  min-height: 180px;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b8c2ca;
  flex-shrink: 0;
}

.status-dot.on,
.connection-status.on .status-dot {
  background: var(--success);
}

.connections-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 20px 20px;
}

.connection-chip {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.connection-chip.on {
  border-color: #9ed0ae;
  background: var(--brand-off);
}

.connection-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.35;
}

.connection-status .connection-label {
  font-weight: 600;
}

.connection-status small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 0.85rem;
}

.connections-status .connection-status {
  align-items: center;
  width: 100%;
}

.connections-status .connection-status .connection-label {
  flex-shrink: 0;
  white-space: nowrap;
}

.connections-status .connection-status small {
  flex: 1 1 auto;
  display: block;
  min-width: 0;
  margin-top: 0;
  margin-left: auto;
  padding-left: 16px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.muted-inline {
  color: var(--text-secondary);
}

.settings-model-row--off {
  opacity: 0.92;
}

.settings-models-table {
  padding: 0 20px 20px;
}

.settings-form {
  padding: 0 20px 20px;
  max-width: none;
}

.connections-setup {
  display: grid;
  gap: 14px;
  padding: 0 20px 20px;
}

.connection-setup-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  overflow: hidden;
}

.connection-setup-card.configured {
  border-color: #9ed0ae;
  background: var(--brand-off);
}

.connection-setup-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.connection-setup-title--on {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 4px;
}

.credential-form input.secret-masked {
  color: var(--text-secondary);
  letter-spacing: 0.12em;
}

.connection-setup-header {
  padding: 16px 16px 0;
}

.connection-setup-header h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text-heading);
}

.connection-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--brand-deep);
  background: var(--brand-accent);
  border-radius: 999px;
  vertical-align: middle;
}

.connection-connected-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--success-text);
  background: var(--success-bg);
  border: 1px solid #6ee7b7;
  border-radius: 999px;
  vertical-align: middle;
}

.connection-key-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.45;
}

.connection-key-status--saved {
  color: var(--success-text);
  background: var(--success-bg);
  border: 1px solid #6ee7b7;
}

.connection-key-status--editing {
  color: var(--text-secondary);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.connection-key-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.connection-saved-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 16px 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--success-text);
  background: var(--success-bg);
  border: 1px solid #6ee7b7;
  font-size: 0.92rem;
  line-height: 1.45;
  animation: connection-saved-in 0.35s ease-out;
}

.connection-saved-notice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

@keyframes connection-saved-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.credential-form.connection-configured input[name="secret"].secret-masked {
  border-color: #6ee7b7;
  background: #f0fdf4;
  color: var(--success-text);
  font-weight: 600;
}

.credential-form.connection-configured input[name="secret"].secret-masked:focus {
  border-color: var(--brand-primary);
  background: var(--surface);
  color: var(--text);
  font-weight: 400;
}

.connection-setup-card .credential-form {
  padding: 0 16px 16px;
  margin: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

.connection-setup-card .settings-panel {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 14px;
}

.connection-setup-card .settings-panel h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.llm-model-control {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.llm-model-control-title {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--text-heading);
}

.llm-model-control .field {
  margin-top: 10px;
}

.llm-model-control .openrouter-model-select {
  min-height: 180px;
}

.settings-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
  display: grid;
  gap: 12px;
}

.settings-panel h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 600;
}

.field {
  display: grid;
  gap: 6px;
}

.form-inline-row {
  display: flex;
  gap: 12px;
  align-items: start;
}

.form-inline-row .field--grow {
  flex: 1;
  min-width: 0;
}

.form-inline-row .field--status {
  flex: 0 0 140px;
}

.field-help {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.45;
}

.field-help a {
  color: var(--brand-primary);
}

.settings-table-head {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--surface-elevated);
}

.settings-model-row {
  grid-template-columns: minmax(200px, 1.5fr) repeat(3, minmax(100px, auto));
  align-items: start;
}

.settings-model-row code {
  font-size: 0.88rem;
  word-break: break-all;
}

.llm-usage-panel {
  padding: 0 20px 20px;
}

.llm-usage-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.llm-usage-metric {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.llm-usage-metric span {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.llm-usage-metric strong {
  color: var(--text-heading);
  font-size: 1.25rem;
  line-height: 1.2;
}

.llm-usage-metric small {
  color: var(--text-secondary);
}

.llm-usage-section {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.llm-usage-section h3 {
  margin: 0;
  color: var(--text-heading);
  font-size: 15px;
}

.llm-usage-chart-section {
  margin-top: 16px;
}

.llm-usage-chart-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.llm-usage-chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.llm-usage-chart-header p {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.llm-usage-chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 12px;
  max-width: 520px;
}

.llm-usage-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.llm-usage-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--text-tertiary);
}

.llm-usage-legend-swatch--text-in,
.llm-usage-bar-segment--text-in {
  background: #2563eb;
}

.llm-usage-legend-swatch--text-out,
.llm-usage-bar-segment--text-out {
  background: #10b981;
}

.llm-usage-legend-swatch--image-in,
.llm-usage-bar-segment--image-in {
  background: #7c3aed;
}

.llm-usage-legend-swatch--image-out,
.llm-usage-bar-segment--image-out {
  background: #f97316;
}

.llm-usage-legend-swatch--other,
.llm-usage-bar-segment--other {
  background: #94a3b8;
}

.llm-usage-legend-swatch--cost {
  border-radius: 999px;
  background: #f59e0b;
}

.llm-usage-chart-scroll {
  overflow-x: auto;
  padding-bottom: 2px;
}

.llm-usage-chart-bars {
  display: grid;
  grid-template-columns: repeat(var(--usage-days), minmax(28px, 1fr));
  align-items: end;
  gap: 8px;
  min-width: max(100%, calc(var(--usage-days) * 38px));
  padding: 4px 2px 0;
}

.llm-usage-day-column {
  position: relative;
  display: grid;
  grid-template-rows: 180px 22px;
  gap: 6px;
  min-width: 0;
  outline: none;
}

.llm-usage-day-column:focus-visible .llm-usage-day-plot {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.llm-usage-day-plot {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: center;
  min-width: 0;
  height: 180px;
  border-bottom: 1px solid var(--border);
  background-image: linear-gradient(to top, rgba(148, 163, 184, 0.16) 1px, transparent 1px);
  background-size: 100% 25%;
}

.llm-usage-stacked-bar {
  display: flex;
  flex-direction: column-reverse;
  width: min(26px, 100%);
  min-height: 3px;
  overflow: hidden;
  border-radius: 5px 5px 3px 3px;
  background: var(--surface-elevated);
  transition: filter 0.15s ease, transform 0.15s ease;
}

.llm-usage-day-column:hover .llm-usage-stacked-bar,
.llm-usage-day-column:focus-visible .llm-usage-stacked-bar {
  filter: saturate(1.08);
  transform: translateY(-2px);
}

.llm-usage-bar-segment {
  display: block;
  min-height: 2px;
}

.llm-usage-cost-dot {
  position: absolute;
  left: 50%;
  z-index: 2;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.24);
  transform: translate(-50%, 50%);
}

.llm-usage-day-column small {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.llm-usage-day-tooltip {
  position: absolute;
  left: 50%;
  top: 10px;
  z-index: 8;
  display: grid;
  gap: 10px;
  width: 230px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 36px rgba(8, 28, 33, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.llm-usage-day-column:hover .llm-usage-day-tooltip,
.llm-usage-day-column:focus-visible .llm-usage-day-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.llm-usage-day-column:first-child .llm-usage-day-tooltip {
  left: 0;
  transform: translate(0, -4px);
}

.llm-usage-day-column:first-child:hover .llm-usage-day-tooltip,
.llm-usage-day-column:first-child:focus-visible .llm-usage-day-tooltip {
  transform: translate(0, 0);
}

.llm-usage-day-column:last-child .llm-usage-day-tooltip {
  right: 0;
  left: auto;
  transform: translate(0, -4px);
}

.llm-usage-day-column:last-child:hover .llm-usage-day-tooltip,
.llm-usage-day-column:last-child:focus-visible .llm-usage-day-tooltip {
  transform: translate(0, 0);
}

.llm-usage-tooltip-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.llm-usage-tooltip-header strong {
  color: var(--text-heading);
  font-size: 13px;
}

.llm-usage-tooltip-header span {
  color: var(--text-heading);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.llm-usage-tooltip-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.llm-usage-tooltip-stats span {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 6px;
  border-radius: 6px;
  background: var(--surface-muted);
}

.llm-usage-tooltip-stats small {
  margin: 0;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.15;
  text-align: left;
  white-space: normal;
}

.llm-usage-tooltip-stats strong {
  color: var(--text-heading);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.llm-usage-tooltip-breakdown {
  display: grid;
  gap: 5px;
}

.llm-usage-tooltip-breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 12px;
}

.llm-usage-tooltip-breakdown-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.llm-usage-tooltip-breakdown-row strong {
  color: var(--text-heading);
  font-variant-numeric: tabular-nums;
}

.llm-usage-tooltip-breakdown-row .llm-usage-legend-swatch {
  flex: 0 0 auto;
}

.llm-usage-table-wrap {
  margin: 0;
}

.llm-usage-click-row {
  cursor: pointer;
}

.llm-usage-click-row:focus-visible td {
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
}

.llm-usage-click-row.is-expanded td {
  background: var(--surface-elevated);
}

.data-table.llm-usage-table td.llm-usage-label-cell {
  white-space: normal;
}

.llm-usage-label-text {
  display: inline-grid;
  max-width: calc(100% - 22px);
  vertical-align: top;
}

.llm-usage-expand-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 5px 10px 0 0;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: rotate(-45deg);
  transition: transform 0.16s ease, border-color 0.16s ease;
  vertical-align: top;
}

.llm-usage-click-row.is-expanded .llm-usage-expand-icon {
  border-color: var(--brand-primary);
  transform: rotate(45deg);
}

.data-table.llm-usage-table .llm-usage-detail-row td,
.data-table.llm-usage-table .llm-usage-detail-row:hover td {
  overflow: visible;
  padding: 0;
  white-space: normal;
  text-overflow: clip;
  background: var(--surface);
}

.llm-usage-detail-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.llm-usage-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.llm-usage-detail-header strong {
  min-width: 0;
  color: var(--text-heading);
  overflow-wrap: anywhere;
}

.llm-usage-detail-header span {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.llm-usage-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.llm-usage-detail-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.llm-usage-detail-item span {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.llm-usage-detail-item strong,
.llm-usage-detail-item code {
  min-width: 0;
  color: var(--text-heading);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
  white-space: normal;
}

.llm-usage-table td small,
.llm-usage-table td code + small,
.llm-usage-table .cell-title small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.llm-usage-table code {
  font-size: 0.84rem;
  word-break: break-all;
}

.members-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 0;
  padding: 24px 20px 20px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.settings-group > .members-panel .section-title:first-child {
  margin-top: 0;
}

.settings-group > .members-panel .field-help {
  margin: 0;
}

.members-settings .members-invite-form {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.members-settings .members-panel {
  border-top: none;
  padding-top: 24px;
}

.members-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.members-data-table th,
.members-data-table td {
  vertical-align: middle;
}

.members-data-table td.member-cell--role select {
  width: 100%;
  max-width: 160px;
}

.members-data-table .member-cell {
  gap: 3px;
}

.members-data-table .member-actions {
  justify-content: flex-end;
}

.superadmin-users-table-wrap {
  overflow-x: auto;
}

.superadmin-users-table {
  min-width: 1080px;
}

.superadmin-users-table th,
.superadmin-users-table td {
  vertical-align: middle;
}

.superadmin-users-table th.cell-actions,
.superadmin-users-table td.cell-actions {
  width: 420px;
  min-width: 420px;
}

#superadmin .superadmin-users-table .cell-actions--wrap.member-actions {
  flex-wrap: nowrap;
}

#superadmin .superadmin-users-table .cell-actions button {
  white-space: nowrap;
}

.superadmin-workspaces-table th.cell-number,
.superadmin-workspaces-table td.cell-number {
  width: 76px;
}

.superadmin-workspaces-table th.cell-actions,
.superadmin-workspaces-table td.cell-actions {
  width: 170px;
}

#superadmin .superadmin-workspaces-table .cell-actions--wrap.member-actions {
  flex-wrap: nowrap;
}

#superadmin .superadmin-workspaces-table .cell-actions button {
  white-space: nowrap;
}

.members-table {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(110px, 0.75fr) minmax(150px, 0.95fr) minmax(190px, max-content);
  column-gap: 20px;
  row-gap: 10px;
  padding: 0;
  min-width: 0;
}

.members-table > .settings-table-head,
.members-table > .member-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  gap: 0;
  column-gap: 20px;
}

.members-table > .member-row {
  padding: 14px 18px;
}

.members-table > .settings-table-head {
  gap: 0;
  column-gap: 20px;
  padding: 10px 18px;
  box-shadow: none;
  border-style: dashed;
}

.members-table > .settings-table-head > span:last-child {
  justify-self: end;
  text-align: right;
}

.members-table > .member-row > .member-cell--actions {
  justify-self: end;
  width: 100%;
}

.members-table > .field-help {
  grid-column: 1 / -1;
  margin: 0;
  padding: 2px 0;
}

#superadmin .members-table {
  grid-template-columns: minmax(220px, 1.6fr) minmax(110px, 0.75fr) minmax(130px, 0.85fr) minmax(300px, max-content);
}

.members-invite-form .form-inline-row {
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.form-inline-row .field--action {
  flex: 0 0 auto;
}

.members-invite-action-label {
  visibility: hidden;
}

.members-settings .member-row,
#superadmin .member-row,
.member-row {
  align-items: center;
}

.members-settings .settings-table-head,
#superadmin .settings-table-head {
  align-items: center;
}

.members-settings .member-actions,
#superadmin .member-actions,
.member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.member-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.member-cell--user .member-cell-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  line-height: 1.35;
}

.member-cell-email {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.member-cell-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.member-cell--meta,
.member-cell--muted {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.member-cell--role select,
.member-row select {
  width: 100%;
  max-width: 160px;
}

.member-cell--actions {
  align-items: flex-end;
}

.settings-group > .members-table,
#superadmin .settings-group > .members-table {
  padding: 0 20px 20px;
}

.member-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid transparent;
  text-transform: capitalize;
}

.member-tag--active {
  background: var(--success-bg);
  color: var(--success-text);
}

.member-tag--disabled {
  background: var(--danger-soft);
  color: var(--danger);
}

.member-tag--pending {
  background: #fef9c3;
  color: #a16207;
  border-color: #fde68a;
}

.member-tag--superadmin {
  background: var(--brand-off);
  color: var(--brand-deep);
  border-color: rgba(90, 183, 116, 0.35);
}

.member-tag--owner {
  background: #ede9fe;
  color: #6d28d9;
}

.member-tag--admin {
  background: #dbeafe;
  color: #1d4ed8;
}

.member-tag--editor {
  background: #e0f2fe;
  color: #0369a1;
}

.member-tag--viewer,
.member-tag--neutral {
  background: var(--surface-muted);
  color: var(--text-secondary);
  border-color: var(--border);
}

.invite-link-callout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 4px;
}

.invite-link-callout input {
  min-width: 0;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
}

.members-subtitle {
  margin: 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.members-panel .members-subtitle:first-child {
  padding-top: 0;
  border-top: none;
}

.settings-callout {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-off);
  border: 1px solid #9ed0ae;
  color: var(--brand-deep);
  font-size: 0.92rem;
  line-height: 1.45;
}

.settings-callout.warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.settings-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.settings-status-group .settings-output {
  margin: 0 20px 20px;
  min-height: 3.5rem;
}

.stacked {
  max-width: none;
  margin-bottom: 20px;
}

.settings-form.stacked {
  display: grid;
  gap: 14px;
}

.automation-settings-panel {
  margin-top: 0;
}

.automation-draft-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.45fr) minmax(140px, 0.35fr);
  gap: 12px;
  align-items: start;
}

.automation-toggle-row {
  width: fit-content;
}

.automation-summary {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.automation-summary--off {
  background: #f8fafc;
}

/* ─── Data tables ─── */
.table-toolbar {
  display: inline-flex;
  align-items: end;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
}

.table-search-field {
  display: block;
  width: min(240px, 100%);
}

.table-select-field {
  display: block;
  width: min(180px, 100%);
}

.table-search-field input[type="search"] {
  height: 36px;
  min-height: 36px;
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.2;
}

.table-select-field select {
  height: 36px;
  min-height: 36px;
  padding: 8px 32px 8px 11px;
  font-size: 13px;
  line-height: 1.2;
}

.actions .table-toolbar,
.toolbar-actions .table-toolbar,
.section-header .table-toolbar {
  margin: 0;
}

.section-header .table-search-field {
  width: min(220px, 42vw);
}

.actions .table-search-field,
.toolbar-actions .table-search-field {
  width: clamp(160px, 18vw, 220px);
}

.toolbar-actions .table-search-field input[type="search"] {
  height: 32px;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.table-wrap {
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.data-table td:not(.cell-actions) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--surface-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.table-sort-button:hover,
.table-sort-button:focus-visible {
  color: var(--text-heading);
}

.table-sort-indicator {
  display: inline-flex;
  align-items: center;
  min-width: 12px;
  color: var(--brand-primary);
  font-size: 13px;
  line-height: 1;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--surface-elevated);
}

.data-table .empty-row td {
  color: var(--text-secondary);
  text-align: center;
  padding: 28px 14px;
}

.data-table .cell-title {
  min-width: 0;
}

.data-table .cell-title strong,
.data-table .cell-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table .cell-description {
  color: var(--text-secondary);
}

.data-table .cell-muted {
  color: var(--text-secondary);
  font-size: 13px;
}

.data-table .cell-links {
  font-size: 13px;
}

.data-table .table-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.data-table .table-link:hover {
  text-decoration: underline;
}

.data-table .cell-link-sep {
  margin: 0 6px;
  color: var(--text-secondary);
}

.data-table .cell-actions {
  text-align: right;
  white-space: normal;
  width: 1%;
  vertical-align: middle;
  overflow: visible;
}

.data-table .cell-actions--wrap {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.data-table .cell-actions button {
  flex: 0 0 auto;
}

.data-table th.cell-number,
.data-table td.cell-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table td.cell-number {
  color: var(--text-heading);
}

.calendar-toolbar {
  margin-bottom: 12px;
  padding: 10px 12px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.calendar-nav-btn {
  min-width: 34px;
  padding: 6px 10px;
  font-size: 18px;
  line-height: 1;
}

.calendar-nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.calendar-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 16px;
  color: var(--text-heading);
}

.calendar-page {
  width: 100%;
}

.calendar-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.calendar-stat {
  display: grid;
  gap: 4px;
  padding: 14px;
}

.calendar-stat strong {
  font-size: 20px;
  color: var(--text-heading);
}

.calendar-stat small {
  color: var(--text-secondary);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.calendar-weekday {
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.calendar-day {
  min-height: 132px;
  padding: 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.calendar-day--muted {
  background: var(--surface-muted);
}

.calendar-day--today {
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}

.calendar-day-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.calendar-day-posts {
  display: grid;
  gap: 6px;
}

.calendar-post {
  display: grid;
  gap: 2px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  font-size: 10px;
  line-height: 1.3;
}

button.calendar-post {
  display: grid;
  width: 100%;
  min-height: 0;
  padding: 6px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  color: inherit;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

button.calendar-post:hover {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

button.calendar-post:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.calendar-post--drafted,
button.calendar-post.calendar-post--drafted {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.calendar-post--drafted .calendar-post-status-icon {
  color: #64748b;
}

button.calendar-post.calendar-post--drafted:hover {
  background: #e8edf3;
}

.calendar-post--needs_review,
button.calendar-post.calendar-post--needs_review {
  background: #fef9c3;
  border-color: #fde047;
}

.calendar-post--needs_review .calendar-post-status-icon {
  color: #a16207;
}

button.calendar-post.calendar-post--needs_review:hover {
  background: #fef08a;
}

.calendar-post--approved,
button.calendar-post.calendar-post--approved {
  background: #dbeafe;
  border-color: #93c5fd;
}

.calendar-post--approved .calendar-post-status-icon {
  color: #1d4ed8;
}

button.calendar-post.calendar-post--approved:hover {
  background: #bfdbfe;
}

.calendar-post--scheduled,
button.calendar-post.calendar-post--scheduled {
  background: #ede9fe;
  border-color: #c4b5fd;
}

.calendar-post--scheduled .calendar-post-status-icon {
  color: #6d28d9;
}

button.calendar-post.calendar-post--scheduled:hover {
  background: #ddd6fe;
}

.calendar-post--published,
button.calendar-post.calendar-post--published {
  background: #dcfce7;
  border-color: #86efac;
}

.calendar-post--published .calendar-post-status-icon {
  color: #15803d;
}

button.calendar-post.calendar-post--published:hover {
  background: #bbf7d0;
}

.calendar-post--rejected,
button.calendar-post.calendar-post--rejected {
  background: #fee2e2;
  border-color: #fca5a5;
}

.calendar-post--rejected .calendar-post-status-icon {
  color: #b91c1c;
}

button.calendar-post.calendar-post--rejected:hover {
  background: #fecaca;
}

.calendar-post--needs_rewrite,
button.calendar-post.calendar-post--needs_rewrite {
  background: #ffedd5;
  border-color: #fdba74;
}

.calendar-post--needs_rewrite .calendar-post-status-icon {
  color: #c2410c;
}

button.calendar-post.calendar-post--needs_rewrite:hover {
  background: #fed7aa;
}

.calendar-post strong {
  color: var(--text-heading);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.25;
}

.calendar-post small,
.calendar-post span {
  color: var(--text-secondary);
  font-size: 9px;
}

.calendar-post-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.calendar-post-status-icon {
  display: block;
}

.calendar-post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.calendar-post-cta {
  color: var(--text-secondary);
}

.calendar-post-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 2px;
}

.calendar-post-stats span {
  font-size: 9px;
  color: var(--text-secondary);
}

.calendar-post-muted {
  font-size: 9px;
  color: var(--text-secondary);
}

.post-detail-meta {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.post-detail-meta-row {
  display: grid;
  grid-template-columns: minmax(120px, 34%) 1fr;
  gap: 8px 12px;
  align-items: start;
  font-size: 13px;
}

.post-detail-meta-label {
  color: var(--text-secondary);
  font-weight: 600;
}

.post-detail-meta-value {
  color: var(--text-heading);
  word-break: break-word;
}

.post-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.post-detail-stat {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
}

.post-detail-stat strong {
  font-size: 18px;
  color: var(--text-heading);
}

.post-detail-stat small {
  color: var(--text-secondary);
}

.post-detail-image-section {
  margin-bottom: 16px;
}

.post-detail-content {
  white-space: pre-wrap;
  line-height: 1.55;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-heading);
}

.post-detail-content--empty {
  color: var(--text-secondary);
  font-style: italic;
}

.leadshark-automation-preview {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.draft-edit-body .leadshark-automation-preview {
  margin: 0 20px 12px;
}

.leadshark-post-settings-preview {
  display: grid;
  gap: 12px;
  margin: 0 20px 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

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

.leadshark-post-settings-header h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text-heading);
}

.leadshark-post-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.leadshark-post-settings-item {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.leadshark-post-settings-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0;
}

.leadshark-post-settings-value {
  color: var(--text-heading);
  overflow-wrap: anywhere;
}

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

.leadshark-automation-header h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text-heading);
}

.leadshark-automation-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.leadshark-automation-keywords {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.leadshark-automation-field {
  display: grid;
  gap: 6px;
}

.leadshark-automation-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0;
}

.leadshark-automation-copy {
  white-space: pre-wrap;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-heading);
}

.leadshark-automation-empty,
.leadshark-automation-resource {
  line-height: 1.5;
  color: var(--text-secondary);
}

.leadshark-automation-empty {
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.leadshark-profiles-panel {
  margin: 0 20px 16px;
}

.leadshark-profiles-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.leadshark-profiles-card--empty,
.leadshark-profiles-card--error {
  border-style: dashed;
}

.leadshark-profiles-card--error {
  border-color: #fca5a5;
  background: #fef2f2;
}

.leadshark-profiles-card-header h4,
.leadshark-profiles-card--empty h4 {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--text-heading);
}

.leadshark-profiles-card-header .field-help {
  margin: 0 0 12px;
}

.connection-badge--muted {
  opacity: 0.65;
}

.key-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
}

.leadshark-profiles-table .row {
  grid-template-columns: 1.4fr 0.9fr 0.7fr;
}

.leadshark-profile-row strong {
  color: var(--text-heading);
}

.leadshark-webhook-panel {
  margin: 0 20px 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.leadshark-webhook-panel h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-heading);
}

.profiles-page .profiles-status {
  margin: 0 0 10px;
  min-height: 1rem;
}

.profiles-panel {
  margin-bottom: 14px;
}

.profiles-data-table .profile-table-row {
  cursor: pointer;
}

.profiles-data-table .profile-table-row.is-selected td {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-elevated));
}

.profiles-data-table .cell-title {
  width: 1%;
  white-space: nowrap;
}

.profiles-data-table .profile-table-schedule {
  color: var(--text-secondary);
  font-size: 13px;
}

.profiles-data-table .profile-table-review {
  width: 140px;
  color: var(--text-heading);
  font-size: 13px;
  white-space: nowrap;
}

.profiles-data-table .profile-table-lead-time {
  width: 110px;
  color: var(--text-heading);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.profiles-data-table .profile-table-posted {
  width: 120px;
  font-variant-numeric: tabular-nums;
  color: var(--text-heading);
  font-weight: 600;
}

.profiles-data-table td:last-child {
  width: 120px;
  white-space: nowrap;
}

.resources-data-table .resource-table-row {
  cursor: pointer;
}

.resources-data-table .resource-table-row.is-selected td {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-elevated));
}

.resources-data-table td.cell-actions {
  white-space: nowrap;
  width: 1%;
}

.resources-data-table .cell-actions--wrap {
  flex-wrap: nowrap;
}

.profile-drawer {
  position: fixed;
  inset: 0;
  z-index: 1250;
  pointer-events: none;
}

.profile-drawer:not([hidden]) {
  pointer-events: auto;
}

.profile-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 43, 46, 0.4);
}

.profile-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  max-width: 100%;
  margin: 0;
  border-radius: 0;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(7, 43, 46, 0.12);
  transform: translateX(100%);
  animation: profileDrawerIn 0.22s ease forwards;
}

@keyframes profileDrawerIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.profile-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.profile-drawer-heading {
  min-width: 0;
}

.profile-drawer-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-heading);
}

.profile-drawer-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.profile-drawer-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px;
}

.profile-drawer-timezone {
  margin: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  flex-shrink: 0;
}

.profile-drawer-timezone strong {
  color: var(--text-heading);
  font-weight: 600;
}

.profile-schedule-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.profile-settings-panel .profile-schedule-section .field--compact input[type="time"] {
  width: 100%;
  padding: 4px 6px;
  font-size: 13px;
  min-height: 32px;
}

.profile-slots-help {
  margin: 0 0 8px;
  font-size: 12px;
}

.profile-settings-panel .profile-slot-list {
  flex-direction: column;
  align-items: stretch;
}

.profile-settings-panel .profile-slot-row {
  display: flex;
  width: 100%;
}

.profile-settings-panel .profile-slot-row input[type="time"] {
  flex: 1;
}

.profile-settings-panel .profile-card-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.profiles-empty {
  padding: 16px 18px;
}

.profiles-empty h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.profiles-empty--error {
  border-color: #fca5a5;
  background: #fef2f2;
}

.profiles-add-card {
  max-width: 640px;
}

.profiles-add-card .settings-group-header {
  padding: 14px 16px 0;
}

.profiles-add-card .settings-group-header h2 {
  margin-bottom: 6px;
  font-size: 16px;
}

.profiles-add-card .panel-form {
  padding: 12px 16px 16px;
}

.profile-card {
  padding: 12px 14px;
}

.profile-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.profile-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.profile-card-header h3 {
  margin: 0;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.connection-badge--compact {
  font-size: 11px;
  padding: 2px 6px;
}

.profile-timezone-note {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.profile-timezone-note::before {
  content: "·";
  margin-right: 8px;
  color: var(--border);
}

.profile-card-meta .key-hint {
  font-size: 11px;
  padding: 1px 5px;
}

.profile-schedule-editor {
  display: grid;
  gap: 8px;
}

.profile-review-section {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.profile-review-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
}

.profile-review-mode {
  font-size: 12px;
  color: var(--text-secondary);
}

.profile-lead-time-field {
  margin-top: 8px;
}

.profile-lead-time-field select {
  width: 100%;
}

.profile-lead-time-help {
  margin: 0;
  font-size: 12px;
}

.profile-schedule-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr);
  gap: 10px 14px;
  align-items: start;
}

.profile-schedule-section {
  display: grid;
  gap: 4px;
}

.profile-schedule-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.profile-day-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.profile-day-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  font-size: 12px;
  line-height: 1.2;
}

.profile-window-fields {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.profile-window-fields .field--compact {
  gap: 4px;
}

.profile-window-fields input[type="time"] {
  padding: 4px 6px;
  font-size: 13px;
  min-height: 32px;
}

.profile-slots-section {
  padding-top: 2px;
}

.profile-slots-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.profile-slot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-slot-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.profile-slot-row input[type="time"] {
  padding: 4px 6px;
  font-size: 13px;
  min-height: 32px;
}

.profile-slots-empty {
  margin: 0;
  font-size: 12px;
}

.profile-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 2px;
}

.profile-card-actions .field-help {
  margin: 0;
  font-size: 12px;
}

@media (max-width: 720px) {
  .profile-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-card-meta {
    flex-wrap: wrap;
  }

  .profile-timezone-note::before {
    display: none;
  }

  .profile-schedule-grid {
    grid-template-columns: 1fr;
  }

  .automation-draft-grid {
    grid-template-columns: 1fr;
  }
}

.leadshark-settings-summary {
  margin: 0 20px 16px;
  display: grid;
  gap: 12px;
}

.draft-schedule-hint {
  margin: 0 20px 8px;
  color: var(--text-secondary);
}

.webhook-url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.webhook-url-row input[readonly] {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.webhook-events-wrap {
  margin-top: 16px;
}

.webhook-events-table .row {
  grid-template-columns: 1.4fr 0.7fr 1.4fr auto;
  align-items: center;
}

.webhook-event-error {
  color: var(--danger, #c0392b);
  font-size: 12px;
  word-break: break-word;
}

.webhook-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.webhook-status-pill--processed {
  background: var(--primary-soft);
  color: var(--brand-deep);
}

.webhook-status-pill--failed {
  background: #fdecea;
  color: #c0392b;
}

.webhook-status-pill--received {
  background: #fff8e6;
  color: #9a6700;
}

.draft-edit-body .draft-body {
  width: 100%;
  flex: 1;
  min-height: min(58vh, 640px);
  margin: 0 0 12px;
  resize: vertical;
}

.draft-image-section {
  margin: 0 20px 12px;
}

.draft-image-template-field {
  margin: 0 20px 12px;
}

.draft-edit-status-field {
  margin: 0 20px 12px;
}

.draft-edit-status-row {
  align-items: center;
}

.draft-edit-status-row select {
  flex: 1;
  min-width: 0;
}

.draft-image-template-row {
  align-items: center;
}

.draft-image-template-row select {
  flex: 1;
  min-width: 0;
}

.draft-image-preview {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.draft-image-status {
  margin: 0 20px 8px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 1.25em;
}

.draft-edit-footer {
  flex-wrap: wrap;
  align-items: center;
}

.draft-edit-schedule {
  margin-top: 4px;
  padding-bottom: 20px;
}

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--primary-soft);
  color: var(--brand-deep);
  text-transform: capitalize;
}

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

.status-pill--drafted {
  background: #f1f5f9;
  color: #64748b;
}

.status-pill--needs_review {
  background: #fef9c3;
  color: #a16207;
}

.status-pill--approved {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-pill--scheduled {
  background: #ede9fe;
  color: #6d28d9;
}

.status-pill--published {
  background: #dcfce7;
  color: #15803d;
}

.status-pill--rejected {
  background: #fee2e2;
  color: #b91c1c;
}

.status-pill--needs_rewrite {
  background: #ffedd5;
  color: #c2410c;
}

.status-pill--failed {
  background: #fee2e2;
  color: #b91c1c;
}

.draft-edit-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
}

.draft-edit-meta .status-pill,
.draft-edit-meta .meta-tag {
  font-size: 11px;
  padding: 2px 7px;
  font-weight: 500;
  text-transform: none;
}

.draft-edit-meta-template {
  font-size: 12px;
  color: var(--text-muted);
}

.meta-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.meta-tag--cta {
  background: #f8fafc;
  color: #475569;
  border-color: #e2e8f0;
}

.meta-tag--draft-status.status-pill--needs_review {
  background: #fef9c3;
  color: #a16207;
  border-color: #fde047;
}

.meta-tag--draft-status.status-pill--approved {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.meta-tag--draft-status.status-pill--rejected {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.meta-tag--draft-status.status-pill--needs_rewrite {
  background: #ffedd5;
  color: #c2410c;
  border-color: #fdba74;
}

.meta-tag--draft-status.status-pill--drafted {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.profile-tag {
  display: inline-block;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  border: 1px solid transparent;
}

.profile-tag--neutral {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.profile-tag--teal {
  background: #ccfbf1;
  color: #0f766e;
  border-color: #99f6e4;
}

.profile-tag--blue {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.profile-tag--violet {
  background: #ede9fe;
  color: #6d28d9;
  border-color: #c4b5fd;
}

.profile-tag--rose {
  background: #ffe4e6;
  color: #be123c;
  border-color: #fda4af;
}

.profile-tag--amber {
  background: #fef3c7;
  color: #b45309;
  border-color: #fcd34d;
}

.profile-tag--emerald {
  background: #d1fae5;
  color: #047857;
  border-color: #6ee7b7;
}

.profile-tag--cyan {
  background: #cffafe;
  color: #0e7490;
  border-color: #67e8f9;
}

.profile-tag--orange {
  background: #ffedd5;
  color: #c2410c;
  border-color: #fdba74;
}

.cell-badges {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

label.checkbox-row {
  display: flex;
  margin: 0;
}

.field--checkbox-group {
  gap: 10px;
}

.settings-form .field--checkbox-group {
  margin-top: 2px;
}

.agent-tool-option {
  align-items: flex-start;
}

.agent-tool-option span {
  display: grid;
  gap: 3px;
}

.agent-tool-option small {
  color: var(--text-secondary);
  font-weight: 400;
}

.agent-token-output {
  display: grid;
  gap: 8px;
}

.agent-token-output h3 {
  margin: 0;
  color: var(--brand-off);
  font-size: 15px;
}

.agent-token-output .field-help,
.agent-token-output .field-label {
  color: var(--brand-off);
}

.agent-token-output textarea {
  color: var(--brand-off);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.agent-token-row {
  grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1.5fr) minmax(110px, 0.8fr) minmax(95px, auto) minmax(86px, auto);
  align-items: start;
}

.api-key-row {
  grid-template-columns: minmax(190px, 1.3fr) minmax(120px, 0.8fr) minmax(110px, 0.8fr) minmax(80px, 0.6fr) minmax(95px, auto) minmax(150px, auto);
  align-items: start;
}

.api-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.api-doc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.settings-usage-table {
  display: grid;
  gap: 8px;
}

.api-usage-row {
  grid-template-columns: minmax(220px, 1.7fr) minmax(100px, 0.8fr) minmax(90px, 0.7fr) minmax(120px, 0.8fr);
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.api-usage-row small,
.api-key-row small {
  display: block;
  color: var(--text-secondary);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.panel-card {
  padding: 0;
  overflow: hidden;
  min-height: 120px;
}

.goal-section {
  margin-bottom: 16px;
}

.goal-card {
  padding: 0;
  overflow: hidden;
}

.goal-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 18px;
  padding: 18px 20px;
}

.goal-panel--dashboard {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.goal-main {
  min-width: 0;
}

.goal-header,
.goal-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.goal-header strong {
  display: block;
  color: var(--text-heading);
  font-size: 16px;
  font-weight: 700;
}

.goal-header small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
}

.goal-progress-row {
  margin-top: 18px;
  color: var(--text-secondary);
  font-size: 13px;
}

.goal-progress-row strong {
  color: var(--text-heading);
  font-size: 22px;
}

.goal-progress-track {
  height: 9px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.goal-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-primary);
}

.goal-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.goal-stat {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.goal-stat strong {
  color: var(--text-heading);
  font-size: 15px;
  font-weight: 700;
}

.goal-stat small {
  color: var(--text-secondary);
  font-size: 12px;
}

.goal-action-panel {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 10px;
  min-width: 148px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.goal-action-panel small {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.settings-goal-panel {
  padding: 0 20px 20px;
}

.goal-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 18px;
  align-items: start;
}

.goal-form {
  display: grid;
  align-content: start;
  gap: 10px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.goal-form label {
  display: grid;
  gap: 5px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.goal-form input {
  width: 100%;
}

.goal-panel--dashboard .dashboard-panel-empty {
  grid-column: 1 / -1;
  padding: 0;
}

.dashboard-panel-empty {
  margin: 0;
  padding: 24px 20px;
}

.dashboard-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 20px;
}

.dashboard-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.dashboard-panel-date {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.dashboard-panel-summary {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.dashboard-panel-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-stat {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.dashboard-stat strong {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-heading);
}

.dashboard-stat small {
  font-size: 12px;
  color: var(--text-secondary);
}

.dashboard-panel-details {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.dashboard-panel-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-heading);
}

.dashboard-panel-details ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.dashboard-panel-details li + li {
  margin-top: 6px;
}

.daily-optimization-panel {
  gap: 0;
  padding: 0;
}

.daily-optimization-list {
  display: grid;
}

.daily-run {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.daily-run:last-child {
  border-bottom: 0;
}

.daily-run-rail {
  position: relative;
  min-height: 100%;
}

.daily-run-rail::before,
.daily-run-rail::after {
  content: "";
  position: absolute;
  left: 7px;
  transform: translateX(-50%);
}

.daily-run-rail::before {
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand-primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.daily-run-rail::after {
  top: 20px;
  bottom: -16px;
  width: 1px;
  background: var(--border);
}

.daily-run:last-child .daily-run-rail::after {
  display: none;
}

.daily-run-content {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.daily-run-header,
.daily-run-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.daily-run-header {
  justify-content: space-between;
  gap: 12px;
}

.daily-run-title {
  flex-wrap: wrap;
}

.daily-run-title strong {
  color: var(--text-heading);
  font-size: 14px;
  font-weight: 700;
}

.daily-run-title time {
  color: var(--text-secondary);
  font-size: 12px;
}

.daily-run-mode {
  flex: 0 0 auto;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-run-outcome {
  margin: 0;
  color: var(--text-heading);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.daily-run-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.daily-run-metric {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.daily-run-metric strong {
  color: var(--text-heading);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.daily-run-metric small {
  color: var(--text-secondary);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-run-details {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.daily-run-details summary {
  width: fit-content;
  cursor: pointer;
  color: var(--brand-deep);
  font-weight: 700;
}

.daily-run-details-body {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.daily-run-details-body p {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.daily-run-details-body h3 {
  margin: 2px 0 -4px;
  color: var(--text-heading);
  font-size: 12px;
  font-weight: 700;
}

.daily-run-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.daily-run-detail-grid span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.daily-run-detail-grid strong {
  color: var(--text-heading);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.daily-run-detail-grid small {
  color: var(--text-secondary);
  font-size: 11px;
}

.daily-run-detail-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.daily-run-detail-list li + li {
  margin-top: 6px;
}

.daily-optimization-history {
  border-top: 1px solid var(--border);
}

.daily-optimization-history > summary {
  cursor: pointer;
  padding: 12px 20px;
  background: var(--surface-muted);
  color: var(--text-heading);
  font-size: 13px;
  font-weight: 700;
}

.daily-optimization-history[open] > summary {
  border-bottom: 1px solid var(--border);
}

.daily-optimization-list--history .daily-run:last-child {
  border-bottom: 0;
}

.dashboard-panel-list {
  display: flex;
  flex-direction: column;
}

.dashboard-panel-list-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.dashboard-panel-list-item:last-child {
  border-bottom: none;
}

.dashboard-panel-list-title {
  font-size: 14px;
  font-weight: 600;
}

.dashboard-panel-list-type {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.dashboard-panel-list-type span {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.dashboard-panel-list-type strong {
  color: var(--text-heading);
  font-weight: 700;
}

.dashboard-panel-list-type small {
  color: var(--text-secondary);
  font-size: inherit;
}

.dashboard-panel-list-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.dashboard-panel-progress {
  margin-top: 10px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.dashboard-panel-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-primary);
  transition: width 0.2s ease;
}

.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;
}

/* ─── Modal ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 43, 46, 0.55);
}

.modal-dialog {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  margin: 0;
  padding: 0;
  box-shadow: var(--shadow-card);
}

.modal-dialog--lg {
  width: min(720px, 100%);
}

.modal-dialog--post-edit {
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
}

.modal-dialog--post-edit .draft-edit-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
}

.draft-edit-body .draft-edit-footer {
  padding-left: 20px;
  padding-right: 20px;
}

.modal-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.field-label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.modal-form .field-label + select,
.modal-form .field-label + input {
  margin-bottom: 12px;
}

.chip-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.chip-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.chip-input-chips {
  display: contents;
}

.chip-input-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}

.chip-input-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.chip-input-remove:hover {
  background: var(--danger);
  color: #fff;
}

.chip-input input {
  flex: 1 1 160px;
  min-width: 120px;
  margin: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.chip-input input:focus {
  outline: none;
  box-shadow: none;
}

.chip-input-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-heading);
}

.modal-form {
  margin: 0;
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  padding-top: 4px;
}

body.modal-open {
  overflow: hidden;
}

/* ─── Tables & lists ─── */
.table {
  display: grid;
  gap: 8px;
}

.row, .list-item {
  display: grid;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.row {
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(120px, auto));
  align-items: center;
}

.row small, .list-item small {
  color: var(--text-secondary);
}

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

.list-item-header strong {
  flex: 1;
  min-width: 0;
}

.list-item-header .status-pill {
  flex-shrink: 0;
}

.list {
  display: grid;
  gap: 8px;
}

.template-preview {
  display: block;
  margin-top: 4px;
}

.draft-card {
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.draft-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.draft-meta small {
  color: var(--text-secondary);
}

.draft-body {
  min-height: 220px;
  line-height: 1.5;
  font-family: inherit;
}

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

.draft-save-status {
  color: var(--brand-primary);
  font-size: 0.9rem;
  min-width: 3.5rem;
}

.posts-page {
  display: grid;
  gap: 16px;
}

.posts-subnav {
  width: fit-content;
  max-width: 100%;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.posts-subnav .settings-nav-item {
  padding: 8px 12px;
  font-size: 13px;
}

.main-content.main-content--posts-review {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
}

.page-container.page-container--posts-review {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.posts-page.posts-page--review {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0;
}

.posts-tab-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.posts-review-page {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.posts-review-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.posts-review-sidebar .posts-subnav {
  width: 100%;
  max-width: none;
  flex-shrink: 0;
}

.posts-review-filters {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.posts-page--review .posts-review-filters {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.posts-review-queue {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.posts-review-list {
  display: grid;
  gap: 12px;
}

.posts-review-group {
  display: grid;
  gap: 8px;
}

.posts-review-group h3,
.posts-review-copy h3,
.posts-review-media h3 {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.posts-review-item {
  display: grid;
  width: 100%;
  min-height: 142px;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.posts-review-item:hover,
.posts-review-item:focus-visible {
  border-color: var(--border-hover);
  background: var(--surface-elevated);
  outline: none;
}

.posts-review-item:focus-visible {
  box-shadow: var(--focus-ring);
}

.posts-review-item.is-selected {
  border-color: var(--brand-primary);
  background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface));
}

.posts-review-item-top,
.posts-review-item-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.posts-review-item-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.posts-review-item.is-selected .posts-review-item-footer {
  align-items: flex-end;
}

.posts-review-item-top {
  justify-content: space-between;
}

.posts-review-item-time {
  color: var(--text-tertiary);
  font-size: 11px;
  white-space: nowrap;
}

.posts-review-item strong {
  color: var(--text-heading);
  font-size: 14px;
  line-height: 1.25;
  word-break: break-word;
}

.posts-review-item-profile {
  flex: 0 1 auto;
  min-width: 0;
}

.posts-review-item-profile .profile-tag {
  max-width: 100%;
}

.posts-review-item-tags {
  flex: 1 1 auto;
  justify-content: flex-end;
}

.posts-review-item-copy {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.posts-review-item-tags > span {
  font-size: 11px;
}

.posts-review-item-tags .posts-review-generate-image {
  flex-shrink: 0;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 11px;
}

.posts-review-preview {
  display: grid;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.posts-review-editor {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.posts-review-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.posts-review-preview-title {
  min-width: 0;
}

.posts-review-preview-title h2 {
  margin: 4px 0;
  color: var(--text-heading);
  font-size: 22px;
  line-height: 1.2;
  word-break: break-word;
}

.posts-review-preview-title p {
  margin: 0;
}

.posts-review-preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 360px;
}

.posts-review-preview-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.posts-review-preview-meta .post-detail-meta-row {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.posts-review-copy,
.posts-review-media {
  display: grid;
  gap: 8px;
}

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

.posts-review-image-header {
  align-items: flex-start;
}

.posts-review-image-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.posts-review-save-state {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.posts-review-save-state.is-dirty {
  color: var(--warning, #a16207);
}

.posts-review-edit-card .field-help {
  margin: 0;
}

.posts-review-body {
  width: 100%;
  min-height: min(48vh, 520px);
  margin: 0;
  resize: vertical;
  color: var(--text-heading);
  font-size: 14px;
  line-height: 1.55;
}

.posts-review-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.posts-review-control {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.posts-review-control-row {
  align-items: center;
}

.posts-review-control-row select {
  flex: 1;
  min-width: 0;
}

.posts-review-copy pre {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-heading);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
}

.posts-review-media img {
  display: block;
  width: min(280px, 100%);
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.posts-review-missing,
.posts-review-empty {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.posts-review-empty {
  align-content: center;
  min-height: 220px;
  text-align: center;
}

.posts-review-empty strong {
  color: var(--text-heading);
}

.posts-review-empty--queue {
  min-height: 180px;
}

.posts-review-automation {
  margin: 0;
  background: var(--surface-muted);
}

.posts-review-danger-zone {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.posts-data-table th,
.posts-data-table td:not(.cell-actions):not(.cell-status):not(.cell-media):not(.cell-date) {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
}

.posts-data-table th,
.posts-data-table td {
  padding: 8px 12px;
}

.posts-data-table .cell-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.posts-data-table .cell-title strong,
.posts-data-table .cell-title small {
  white-space: normal;
}

.posts-data-table .cell-stack {
  line-height: 1.35;
}

.posts-data-table .cell-date {
  width: 130px;
  min-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
  color: var(--text-secondary, #64748b);
}

.posts-data-table .cell-stack-meta {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.posts-data-table th.cell-actions,
.posts-data-table td.cell-actions {
  width: 220px;
  min-width: 220px;
}

.posts-data-table th.cell-template,
.posts-data-table td.cell-template {
  max-width: 112px;
  min-width: 72px;
  font-size: 0.9rem;
  color: var(--text-secondary, #64748b);
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  line-height: 1.35;
}

.posts-data-table th.cell-profile,
.posts-data-table td.cell-profile {
  width: 150px;
  min-width: 120px;
  max-width: 180px;
  font-size: 0.9rem;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  line-height: 1.35;
}

.posts-data-table th.cell-media,
.posts-data-table td.cell-media {
  width: 88px;
  min-width: 88px;
  max-width: 88px;
  white-space: nowrap;
  overflow: hidden;
}

.posts-data-table td.cell-media .status-pill {
  white-space: nowrap;
}

.posts-data-table th.cell-status,
.posts-data-table td.cell-status {
  width: 118px;
  min-width: 118px;
  max-width: 118px;
  white-space: nowrap;
  overflow: hidden;
}

.drafts-generating {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 40px 24px;
  margin: 12px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow-card);
}

.drafts-generating p {
  margin: 0;
  font-weight: 600;
  color: var(--text-heading);
}

.drafts-generating small {
  color: var(--text-secondary);
}

.spinner,
.spinner-lg {
  border: 3px solid var(--border);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.15em;
}

.spinner-lg {
  width: 44px;
  height: 44px;
  border-width: 4px;
}

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

#draftForm.is-loading {
  opacity: 0.65;
  pointer-events: none;
}

.draft-actions input[type="datetime-local"] {
  width: auto;
  min-width: 210px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.actions--split {
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
}

.actions--nested {
  align-items: center;
  flex-wrap: nowrap;
  margin-bottom: 0;
}

.template-purpose-nav {
  margin-bottom: 16px;
}

.templates-data-table .template-table-row {
  cursor: pointer;
}

.templates-data-table .template-table-row.is-selected td {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-elevated));
}

.templates-data-table .cell-title--wrap,
.templates-data-table td.cell-title--wrap,
.templates-data-table .cell-title--wrap strong {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
}

.templates-data-table td.cell-performance {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.template-performance-cell,
.template-performance-inline {
  display: grid;
  gap: 4px;
  align-items: start;
}

.template-performance-cell small,
.template-performance-inline small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
}

.template-drawer .profile-drawer-panel {
  width: min(720px, 100vw);
}

.resource-drawer .profile-drawer-panel {
  width: min(560px, 100vw);
}

.resource-drawer-form {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  align-content: start;
}

.resource-scraped-content {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.resource-scraped-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.resource-scraped-header .field-help {
  margin: 2px 0 0;
}

.resource-scraped-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.resource-scraped-content textarea {
  min-height: 280px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-heading);
}

.resource-scrape-error {
  margin: 0;
  color: var(--danger);
}

.post-edit-drawer .profile-drawer-panel {
  width: min(720px, 100vw);
}

.post-edit-drawer .draft-edit-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
}

.posts-data-table .post-table-row {
  cursor: pointer;
}

.posts-data-table .post-table-row.is-selected td {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-elevated));
}

.template-details-panel {
  display: grid;
  gap: 16px;
}

.template-details-hint {
  margin: 0;
}

.template-performance-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.template-performance-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.template-performance-header h3,
.template-performance-section h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text-heading);
}

.template-performance-header p {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.template-performance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.template-performance-stat {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.template-performance-stat strong {
  color: var(--text-heading);
  font-size: 17px;
}

.template-performance-stat small,
.template-performance-stat span,
.template-performance-loading,
.template-performance-error {
  color: var(--text-secondary);
  font-size: 12px;
}

.template-performance-error {
  color: var(--danger);
}

.template-performance-section {
  display: grid;
  gap: 8px;
}

.template-performance-version-list,
.template-performance-samples {
  display: grid;
  gap: 8px;
}

.template-performance-version {
  display: grid;
  grid-template-columns: 56px repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12px;
}

.template-performance-version span {
  color: var(--text-secondary);
  min-width: 0;
}

.template-performance-sample {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.template-performance-sample header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.template-performance-sample header strong,
.template-performance-sample header small {
  min-width: 0;
}

.template-performance-sample header small,
.template-performance-sample p,
.template-performance-sample-stats {
  color: var(--text-secondary);
}

.template-performance-sample p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.template-performance-sample-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
}

.template-detail-field {
  display: grid;
  gap: 5px;
}

.template-detail-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.template-detail-value {
  white-space: pre-wrap;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-heading);
  word-break: break-word;
}

.template-detail-value--editable {
  display: block;
  width: 100%;
  min-height: unset;
  text-align: left;
  white-space: normal;
  cursor: text;
  font: inherit;
  font-weight: inherit;
  background: var(--surface-elevated);
  color: var(--text-heading);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.template-detail-value--editable:hover,
.template-detail-value--editable:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
  outline: none;
}

.template-detail-value--inline {
  display: inline-block;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.template-detail-value--inline:hover,
.template-detail-value--inline:focus-visible {
  box-shadow: none;
}

.template-detail-display {
  display: block;
  white-space: pre-wrap;
}

.template-detail-value--empty {
  color: var(--text-secondary);
  font-style: italic;
}

.template-detail-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--text-heading);
  font: inherit;
  line-height: 1.5;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
}

textarea.template-detail-input {
  overflow: hidden;
  resize: vertical;
}

.template-detail-input--title {
  font-size: 18px;
  font-weight: 600;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--accent);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.template-drawer-title-wrap {
  display: block;
}

.template-drawer-title-edit {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-heading);
  text-align: left;
  cursor: text;
}

.template-drawer-title-edit:hover,
.template-drawer-title-edit:focus-visible {
  color: var(--accent);
  outline: none;
}

[data-template-field-wrap].is-editing {
  min-width: 0;
}

[data-template-field-wrap].is-saving {
  opacity: 0.65;
  pointer-events: none;
}

pre,
.settings-output {
  white-space: pre-wrap;
  background: var(--brand-deep);
  color: var(--brand-off);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}

.discover-panel {
  display: grid;
  gap: 18px;
}

.discover-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 18px;
}

.discover-header h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.discover-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.discover-metrics {
  margin: 0;
}

.discover-metric-detail {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.discover-visual {
  padding: 16px;
  min-height: 280px;
}

.discover-visual--wide {
  grid-column: 1 / -1;
}

.discover-visual--outlier {
  min-height: 430px;
}

.discover-visual-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.discover-visual-header--controls {
  align-items: center;
}

.discover-visual-title {
  display: grid;
  gap: 3px;
}

.discover-visual-header h2 {
  margin: 0;
  font-size: 18px;
}

.discover-visual-header span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.discover-visual-title span {
  text-align: left;
}

.discover-outlier-toggle {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
}

.discover-outlier-toggle .btn {
  min-height: 28px;
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}

.discover-outlier-toggle .btn:hover,
.discover-outlier-toggle .btn:focus-visible {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-heading);
}

.discover-outlier-toggle .btn.is-active {
  background: var(--text-heading);
  border-color: var(--text-heading);
  color: var(--surface);
}

.discover-heatmap {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) repeat(var(--discover-days), minmax(70px, 1fr));
  gap: 6px;
  overflow-x: auto;
}

.discover-heatmap-corner,
.discover-heatmap-day,
.discover-heatmap-topic,
.discover-heatmap-cell {
  min-height: 34px;
  border-radius: 6px;
}

.discover-heatmap-day {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.discover-heatmap-topic {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 700;
}

.discover-heatmap-cell {
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) calc(var(--heat) * 78%), var(--surface-soft));
  color: color-mix(in srgb, var(--brand-deep) 78%, #ffffff);
  font-size: 12px;
  font-weight: 800;
}

.discover-bars {
  display: grid;
  gap: 12px;
}

.discover-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(120px, 1fr) 56px;
  gap: 10px;
  align-items: center;
}

.discover-bar-copy strong,
.discover-bar-copy span {
  display: block;
}

.discover-bar-copy span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.discover-bar-track,
.discover-bucket-meter {
  height: 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}

.discover-bar-track span,
.discover-bucket-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.discover-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

.discover-bucket {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.discover-bucket strong,
.discover-bucket span,
.discover-bucket small {
  display: block;
}

.discover-bucket span,
.discover-bucket small {
  color: var(--muted);
  font-size: 12px;
}

.discover-plot {
  position: relative;
  min-height: 342px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(to right, transparent 49.5%, var(--border) 49.5%, var(--border) 50.5%, transparent 50.5%),
    linear-gradient(to bottom, transparent 49.5%, var(--border) 49.5%, var(--border) 50.5%, transparent 50.5%),
    var(--surface-soft);
  overflow: visible;
}

.discover-plot-axis {
  position: absolute;
  z-index: 1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.discover-plot-axis-y {
  left: 10px;
  top: 8px;
}

.discover-plot-axis-x {
  right: 10px;
  bottom: 8px;
}

.discover-plot-quadrant {
  position: absolute;
  color: color-mix(in srgb, var(--muted) 80%, transparent);
  font-size: 11px;
  line-height: 1.25;
  max-width: 120px;
}

.discover-plot-quadrant.q1 { left: 12px; top: 34px; }
.discover-plot-quadrant.q2 { right: 12px; top: 34px; text-align: right; }
.discover-plot-quadrant.q3 { left: 12px; bottom: 28px; }
.discover-plot-quadrant.q4 { right: 12px; bottom: 28px; text-align: right; }

.discover-plot-point {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: var(--brand-deep);
  color: var(--brand-off);
  border: 2px solid var(--surface);
  box-shadow: 0 4px 12px rgba(8, 28, 33, 0.18);
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  outline: none;
}

.discover-plot-point.strong {
  background: var(--accent);
  color: var(--brand-deep);
  width: 26px;
  height: 26px;
}

.discover-plot-point:hover,
.discover-plot-point:focus,
.discover-plot-point:focus-visible {
  z-index: 8;
  box-shadow: 0 8px 20px rgba(8, 28, 33, 0.22);
}

.discover-plot-point:focus,
.discover-plot-point:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 3px;
}

.discover-plot-point-label {
  position: relative;
  z-index: 2;
}

.discover-plot-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  z-index: 9;
  display: grid;
  gap: 10px;
  width: min(320px, 76vw);
  padding: 12px;
  transform: translate(-50%, 6px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 40px rgba(8, 28, 33, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.discover-plot-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.discover-plot-tooltip--left {
  right: 0;
  left: auto;
  transform: translate(0, 6px);
}

.discover-plot-tooltip--left::after {
  right: 8px;
  left: auto;
  transform: rotate(45deg);
}

.discover-plot-tooltip--right {
  left: 0;
  transform: translate(0, 6px);
}

.discover-plot-tooltip--right::after {
  left: 8px;
  transform: rotate(45deg);
}

.discover-plot-tooltip--below {
  top: calc(100% + 12px);
  bottom: auto;
}

.discover-plot-tooltip--below::after {
  top: -7px;
  bottom: auto;
  border: 0;
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.discover-plot-point:hover .discover-plot-tooltip,
.discover-plot-point:focus .discover-plot-tooltip,
.discover-plot-point:focus-visible .discover-plot-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.discover-plot-point:hover .discover-plot-tooltip--left,
.discover-plot-point:focus .discover-plot-tooltip--left,
.discover-plot-point:focus-visible .discover-plot-tooltip--left,
.discover-plot-point:hover .discover-plot-tooltip--right,
.discover-plot-point:focus .discover-plot-tooltip--right,
.discover-plot-point:focus-visible .discover-plot-tooltip--right {
  transform: translate(0, 0);
}

.discover-plot-profile {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.discover-plot-avatar-frame,
.discover-plot-profile img,
.discover-plot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
}

.discover-plot-profile img,
.discover-plot-avatar {
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.discover-plot-avatar-frame {
  display: block;
}

.discover-plot-profile img {
  display: block;
  object-fit: cover;
}

.discover-plot-avatar {
  display: grid;
  place-items: center;
  color: var(--brand-deep);
  font-size: 13px;
  font-weight: 800;
}

.discover-plot-avatar-frame .discover-plot-avatar {
  display: none;
}

.discover-plot-avatar-frame.is-fallback img {
  display: none;
}

.discover-plot-avatar-frame.is-fallback .discover-plot-avatar {
  display: grid;
}

.discover-plot-profile strong,
.discover-plot-profile small,
.discover-plot-tooltip-meta,
.discover-plot-tooltip-preview {
  display: block;
}

.discover-plot-profile strong {
  overflow: hidden;
  color: var(--text-heading);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discover-plot-profile small,
.discover-plot-tooltip-meta,
.discover-plot-tooltip-preview {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.discover-plot-profile small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.discover-plot-tooltip-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.discover-plot-tooltip-stats span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.discover-plot-tooltip-stats strong,
.discover-plot-tooltip-stats small {
  display: block;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discover-plot-tooltip-stats strong {
  color: var(--text-heading);
  font-size: 13px;
}

.discover-plot-tooltip-stats small {
  color: var(--muted);
  font-size: 10px;
}

.discover-plot-tooltip-preview {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.discover-splits {
  align-items: start;
}

.discover-card-list {
  display: grid;
  gap: 10px;
}

.discover-card-list--templates {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.discover-signal-card {
  padding: 14px;
}

.discover-signal-card strong {
  display: block;
  margin-bottom: 6px;
}

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

.discover-template-card-head strong {
  min-width: 0;
}

.discover-signal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.discover-template-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.discover-table-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.discover-table-toolbar .field {
  margin: 0;
  max-width: 320px;
}

.discover-table-wrap {
  overflow-x: hidden;
}

.discover-table th,
.discover-table td {
  vertical-align: top;
}

.discover-table td.discover-topic-cell {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
}

.discover-topic-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: normal;
}

.discover-topic-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-transform: capitalize;
}

.discover-topic-pill--more {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.data-table .cell-description.discover-post-preview {
  white-space: normal;
}

.discover-post-preview-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.cell-title small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

.discover-error {
  border-color: rgba(180, 52, 52, 0.25);
}

/* ─── Responsive ─── */
@media (max-width: 960px) {
  .shell-root {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(100%, 280px);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 1200;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.25);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(7, 43, 46, 0.55);
    z-index: 1100;
  }

  .content-topbar {
    display: flex;
  }

  .superadmin-form--workspace,
  .superadmin-form--member {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 768px) {
  .split,
  .metric-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  #superadmin .superadmin-metrics {
    grid-template-columns: 1fr;
  }

  .superadmin-toolbar {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .superadmin-analytics-header {
    flex-direction: column;
  }

  .superadmin-analytics-metrics {
    grid-template-columns: 1fr;
  }

  .goal-panel {
    grid-template-columns: 1fr;
  }

  .goal-settings-grid {
    grid-template-columns: 1fr;
  }

  .goal-action-panel {
    padding-left: 0;
    padding-top: 16px;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .goal-form {
    padding-left: 0;
    padding-top: 16px;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

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

  .dashboard-panel-stats {
    grid-template-columns: 1fr;
  }

  .daily-run {
    grid-template-columns: 1fr;
  }

  .daily-run-rail {
    display: none;
  }

  .daily-run-header {
    align-items: flex-start;
  }

  .daily-run-mode {
    flex: 0 1 auto;
  }

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

  .template-performance-grid,
  .template-performance-version {
    grid-template-columns: 1fr;
  }

  .template-performance-header,
  .template-performance-sample header {
    flex-direction: column;
    align-items: stretch;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .calendar-nav {
    flex-wrap: wrap;
  }

  .calendar-nav-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

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

  .llm-usage-chart-header {
    flex-direction: column;
    align-items: stretch;
  }

  .llm-usage-chart-legend {
    justify-content: flex-start;
    max-width: none;
  }

  .discover-header,
  .discover-table-toolbar,
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .posts-review-preview-header {
    flex-direction: column;
    align-items: stretch;
  }

  .posts-review-page {
    grid-template-columns: 1fr;
  }

  .posts-review-preview {
    min-height: 420px;
  }

  .posts-review-filters {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .posts-review-preview-actions {
    justify-content: flex-start;
    max-width: none;
  }

  .posts-review-preview-meta {
    grid-template-columns: 1fr;
  }

  .posts-review-control-grid {
    grid-template-columns: 1fr;
  }

  .posts-review-control-row {
    flex-direction: column;
    align-items: stretch;
  }

  .posts-review-image-header {
    flex-direction: column;
  }

  .posts-review-image-actions {
    justify-content: flex-start;
  }

  .table-search-field {
    width: 100%;
  }

  .table-select-field {
    width: 100%;
  }

  .discover-visual-grid {
    grid-template-columns: 1fr;
  }

  .discover-card-list--templates {
    grid-template-columns: 1fr;
  }

  .discover-actions {
    justify-content: flex-start;
  }

  .page-title {
    font-size: 26px;
  }

  .main-content {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .toolbar-row:not(.app-toolbar--posts) {
    flex-direction: column;
    align-items: stretch;
  }

  .app-toolbar--posts {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
  }

  .toolbar-actions,
  .actions--split,
  .actions--nested {
    flex-wrap: wrap;
  }
}
