:root {
  --font-body: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Avenir Next", sans-serif;
  --bg: #ecf3f8;
  --ink: #0f2a3f;
  --ink-soft: #374c5e;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-border: rgba(30, 74, 106, 0.16);
  --line: rgba(30, 74, 106, 0.15);
  --accent: #0d7c7a;
  --accent-strong: #095b59;
  --accent-soft: rgba(13, 124, 122, 0.14);
  --warn: #c66f1a;
  --danger: #b73737;
  --ok: #1f7a53;
}

html.dark {
  --bg: #0f1419;
  --ink: #e4e8ec;
  --ink-soft: #94a3b3;
  --panel: rgba(22, 29, 38, 0.95);
  --panel-border: rgba(200, 220, 240, 0.12);
  --line: rgba(200, 220, 240, 0.14);
  --accent: #2ec4b6;
  --accent-strong: #20a99c;
  --accent-soft: rgba(46, 196, 182, 0.14);
  --warn: #e09f3e;
  --danger: #e05858;
  --ok: #34d399;
}

html.dark body {
  background:
    radial-gradient(1600px 1000px at 0% 0%, rgba(160, 50, 100, 0.55), transparent 70%),
    radial-gradient(1400px 900px at 55% 0%, rgba(200, 140, 40, 0.4), transparent 60%),
    radial-gradient(1600px 1000px at 100% 100%, rgba(30, 160, 150, 0.55), transparent 70%),
    #0f1419;
}

html.dark .ambient-top { background: #1a6e66; opacity: 0.2; }
html.dark .ambient-bottom { background: #7a5c2e; opacity: 0.15; }

html.dark .panel {
  background: rgba(22, 29, 38, 0.92);
  border-color: rgba(200, 220, 240, 0.1);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
}

html.dark input,
html.dark select,
html.dark textarea {
  background: rgba(12, 18, 25, 0.9);
  color: var(--ink);
  border-color: rgba(200, 220, 240, 0.15);
}

html.dark .ghost-button {
  background: rgba(30, 40, 52, 0.9);
  color: var(--ink);
  border-color: rgba(200, 220, 240, 0.15);
}

html.dark .tiny-button {
  background: rgba(30, 40, 52, 0.9);
  color: var(--ink-soft);
  border-color: rgba(200, 220, 240, 0.15);
}

html.dark .pending-reply-toggle {
  background: rgba(46, 196, 182, 0.16);
  border-color: rgba(46, 196, 182, 0.3);
  color: #c6fff7;
}

html.dark .policy-step-index {
  border-color: rgba(46, 196, 182, 0.7);
  background: rgba(46, 196, 182, 0.16);
  color: #bffcf6;
}

html.dark .danger-button {
  border-color: rgba(224, 88, 88, 0.42);
  background: rgba(224, 88, 88, 0.18);
  color: #ffb4b4;
}

html.dark .danger-button:hover {
  background: rgba(224, 88, 88, 0.24);
}

html.dark .policy-modal {
  background: rgba(18, 25, 33, 0.98);
  border-color: rgba(200, 220, 240, 0.14);
  box-shadow: 0 24px 52px rgba(0, 0, 0, 0.45);
}

html.dark .policy-modal-danger {
  border-color: rgba(224, 88, 88, 0.32);
}

html.dark .policy-modal-status-live {
  border-color: rgba(224, 88, 88, 0.42);
  background: rgba(224, 88, 88, 0.18);
  color: #ffb8b8;
}

html.dark .policy-modal-status-ready {
  border-color: rgba(200, 220, 240, 0.22);
  background: rgba(200, 220, 240, 0.08);
  color: #d7e8fb;
}

html.dark .policy-modal-warning {
  border-color: rgba(224, 88, 88, 0.38);
  background: rgba(224, 88, 88, 0.16);
}

html.dark .policy-modal-warning p {
  color: #ffd3d3;
}

html.dark .policy-modal-rule {
  background: rgba(46, 196, 182, 0.12);
  border-color: rgba(200, 220, 240, 0.15);
}

html.dark .tabs,
html.dark .subtabs {
  background: rgba(18, 24, 32, 0.8);
  border-color: rgba(200, 220, 240, 0.1);
}

html.dark .tab {
  color: var(--ink-soft);
}

html.dark .tab.active {
  background: rgba(46, 196, 182, 0.15);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

html.dark .topic-row {
  background: rgba(22, 29, 38, 0.8);
  border-color: rgba(200, 220, 240, 0.1);
  color: var(--ink);
}
html.dark .topic-row:hover {
  background: rgba(46, 196, 182, 0.12);
}

html.dark .chip {
  background: rgba(22, 29, 38, 0.8);
  border-color: rgba(200, 220, 240, 0.12);
  color: var(--ink-soft);
}

html.dark .token-row {
  background: rgba(22, 29, 38, 0.8);
  border-color: rgba(200, 220, 240, 0.1);
}

html.dark .error-banner {
  background: rgba(224, 88, 88, 0.12);
  border-color: rgba(224, 88, 88, 0.3);
  color: #f09090;
}

html.dark .error-text { color: #f09090; }

html.dark .toast {
  background: rgba(46, 196, 182, 0.95);
  color: #0f1419;
}

html.dark .toast.toast--error {
  background: rgba(183, 28, 28, 0.92);
  color: #fff;
}

html.dark .toast--warning {
  background: rgba(200, 140, 30, 0.95);
}

html.dark .source-slack {
  color: #6cacff;
  background: rgba(34, 109, 255, 0.2);
  border-color: rgba(34, 109, 255, 0.3);
}

html.dark .source-instagram {
  color: #e88ac0;
  background: rgba(225, 76, 153, 0.2);
  border-color: rgba(225, 76, 153, 0.3);
}

html.dark .source-api,
html.dark .source-unknown {
  color: #94a3b3;
  background: rgba(139, 155, 171, 0.15);
  border-color: rgba(139, 155, 171, 0.22);
}

html.dark .status-sent,
html.dark .status-healthy {
  color: #34d399;
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.26);
}

html.dark .status-pending,
html.dark .status-expiring_soon,
html.dark .status-send_failed {
  color: #e09f3e;
  background: rgba(224, 159, 62, 0.16);
  border-color: rgba(224, 159, 62, 0.26);
}

html.dark .status-failed,
html.dark .status-dead_letter,
html.dark .status-expired {
  color: #e05858;
  background: rgba(224, 88, 88, 0.16);
  border-color: rgba(224, 88, 88, 0.26);
}

html.dark .category-fan_mail {
  color: #a78bfa;
  background: rgba(124, 58, 237, 0.2);
  border-color: rgba(124, 58, 237, 0.3);
}

html.dark .category-business {
  color: #e09f3e;
  background: rgba(224, 159, 62, 0.16);
  border-color: rgba(224, 159, 62, 0.26);
}

html.dark .category-meta_help {
  color: #5eead4;
  background: rgba(15, 118, 110, 0.24);
  border-color: rgba(45, 212, 191, 0.35);
}

html.dark .category-general_comments {
  color: #94a3b3;
  background: rgba(139, 155, 171, 0.15);
  border-color: rgba(139, 155, 171, 0.22);
}

html.dark .category-no_sources {
  color: #fbbf24;
  background: rgba(217, 119, 6, 0.2);
  border-color: rgba(217, 119, 6, 0.3);
}

html.dark .category-spam {
  color: #e05858;
  background: rgba(224, 88, 88, 0.16);
  border-color: rgba(224, 88, 88, 0.26);
}

html.dark .stat-card h3 {
  color: var(--ink-soft);
}

html.dark .login-panel {
  background: rgba(22, 29, 38, 0.95);
  border-color: rgba(200, 220, 240, 0.1);
}

html.dark th {
  color: var(--ink-soft);
}

html.dark td {
  border-color: rgba(200, 220, 240, 0.08);
}

html.dark th {
  border-color: rgba(200, 220, 240, 0.1);
}

.theme-toggle {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink-soft);
  border-radius: 11px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.15s ease;
}
.theme-toggle:hover { filter: brightness(0.97); }
.theme-toggle:active { transform: translateY(1px); }
html.dark .theme-toggle {
  background: rgba(28, 35, 43, 0.78);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  position: relative;
  background:
    radial-gradient(1600px 1000px at 0% 0%, rgba(180, 60, 120, 0.6), transparent 70%),
    radial-gradient(1400px 900px at 55% 0%, rgba(220, 150, 50, 0.45), transparent 60%),
    radial-gradient(1600px 1000px at 100% 100%, rgba(30, 180, 170, 0.6), transparent 70%),
    linear-gradient(165deg, #f8fbfd 0%, var(--bg) 56%, #e7eef4 100%);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.ambient {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(72px);
  pointer-events: none;
  opacity: 0.45;
  z-index: -1;
}

.ambient-top {
  background: #8ad7ca;
  top: -220px;
  right: -120px;
}

.ambient-bottom {
  background: #ffcf9e;
  bottom: -220px;
  left: -120px;
}

.reveal {
  animation: rise 0.34s ease both;
}

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

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  position: relative;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.8vw, 2.35rem);
  letter-spacing: -0.02em;
}

.app-header p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.96rem;
}

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

.account-menu {
  position: relative;
}

.account-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--ink);
}

.account-trigger:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.account-info {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.25;
}

.account-name {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink);
}

.account-domain {
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.account-chevron {
  font-size: 0.6rem;
  color: var(--ink-soft);
  margin-left: 2px;
  transition: transform 0.15s;
}

.account-menu.open .account-chevron {
  transform: rotate(180deg);
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(19, 57, 89, 0.14);
  backdrop-filter: blur(12px);
  padding: 6px;
  z-index: 100;
  animation: dropdown-appear 0.15s ease;
}

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

.account-dropdown-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.account-dropdown-header .account-name {
  font-size: 0.9rem;
}

.account-dropdown-header .account-slug {
  font-size: 0.76rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

.account-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
}

.account-dropdown-item:hover {
  background: var(--accent-soft);
}

.account-dropdown-item.danger {
  color: var(--danger);
}

.account-dropdown-item.danger:hover {
  background: rgba(183, 55, 55, 0.1);
}

html.dark .account-trigger {
  background: rgba(22, 29, 38, 0.9);
  border-color: rgba(200, 220, 240, 0.12);
}

html.dark .account-trigger:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

html.dark .account-dropdown {
  background: #161d26;
  border-color: rgba(200, 220, 240, 0.14);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

html.dark .account-dropdown-header {
  border-bottom-color: rgba(200, 220, 240, 0.1);
}

html.dark .account-dropdown-header .account-name {
  color: var(--ink);
}

html.dark .account-dropdown-header .account-slug {
  color: var(--ink-soft);
}

html.dark .account-dropdown-item {
  color: var(--ink);
}

html.dark .account-dropdown-item.danger {
  color: var(--danger);
}

html.dark .account-dropdown-item:hover {
  background: rgba(46, 196, 182, 0.14);
}

html.dark .account-dropdown-item.danger:hover {
  background: rgba(224, 88, 88, 0.16);
}

.account-view {
  display: grid;
  gap: 16px;
}

.account-back {
  justify-self: start;
}

/* ---- Channel Connection Grid ---- */

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.channel-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 20px 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.channel-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    168deg,
    rgba(255, 255, 255, 0.04) 0%,
    transparent 50%
  );
  pointer-events: none;
}

.channel-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

html.dark .channel-card {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

html.dark .channel-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

/* Connected cards get a subtle accent border + glow on hover */
.channel-card--connected {
  border-color: var(--accent-soft);
}

.channel-card--connected:hover {
  border-color: var(--accent);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.12),
    0 0 20px var(--accent-soft);
}

html.dark .channel-card--connected:hover {
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.28),
    0 0 20px var(--accent-soft);
}

.channel-card--unconnected {
  border-style: dashed;
  border-color: var(--line);
  color: var(--ink-soft);
}

.channel-card--unconnected:hover {
  border-color: var(--accent-soft);
}

html.dark .channel-card--unconnected {
  background: rgba(22, 29, 38, 0.5);
}

.channel-card--coming-soon {
  opacity: 0.3;
  pointer-events: none;
  box-shadow: none;
}

.channel-card--coming-soon::before {
  display: none;
}

/* Card header: icon + name side by side */
.channel-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.channel-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.channel-icon--instagram {
  background: linear-gradient(135deg, rgba(225, 76, 153, 0.22), rgba(252, 175, 69, 0.18));
  color: #e14c99;
  box-shadow: 0 2px 10px rgba(225, 76, 153, 0.12);
}

.channel-icon--messenger {
  background: linear-gradient(135deg, rgba(34, 109, 255, 0.22), rgba(0, 194, 255, 0.14));
  color: #4d9fff;
  box-shadow: 0 2px 10px rgba(34, 109, 255, 0.12);
}

.channel-icon--facebook {
  background: linear-gradient(135deg, rgba(66, 103, 178, 0.22), rgba(100, 140, 210, 0.14));
  color: #6e9de0;
  box-shadow: 0 2px 10px rgba(66, 103, 178, 0.12);
}

.channel-icon--tiktok {
  background: linear-gradient(135deg, rgba(255, 0, 80, 0.18), rgba(0, 242, 234, 0.12));
  color: #ff4d8a;
  box-shadow: 0 2px 10px rgba(255, 0, 80, 0.1);
}

.channel-card-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.channel-card-account {
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0 0;
  padding-left: 54px; /* align with name text (42px icon + 12px gap) */
  text-decoration: none;
  display: block;
}

a.channel-card-account:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Status row: badge + expiry grouped together */
.channel-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-left: 54px;
}

.channel-sync-summary {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-left: 54px;
}

.channel-sync-summary--placeholder {
  margin-top: 2px;
}

.channel-sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.channel-sync-pill--ready {
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.18);
}

.channel-sync-pill--queued {
  background: rgba(45, 143, 255, 0.1);
  color: #2d8fff;
  border-color: rgba(45, 143, 255, 0.16);
}

.channel-sync-pill--syncing {
  background: rgba(13, 124, 122, 0.12);
  color: var(--accent-strong);
  border-color: rgba(13, 124, 122, 0.18);
}

.channel-sync-pill--failed {
  background: rgba(224, 88, 88, 0.12);
  color: var(--danger);
  border-color: rgba(224, 88, 88, 0.18);
}

.channel-sync-pill--muted {
  background: rgba(148, 163, 184, 0.14);
  color: var(--ink-soft);
  border-color: rgba(148, 163, 184, 0.2);
}

.channel-sync-detail {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.channel-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 9999px;
  line-height: 1.4;
}

.channel-status-badge--connected {
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
  border: 1px solid rgba(52, 211, 153, 0.18);
}

.channel-status-badge--expiring {
  background: rgba(224, 159, 62, 0.12);
  color: var(--warn);
  border: 1px solid rgba(224, 159, 62, 0.18);
}

.channel-status-badge--expired {
  background: rgba(224, 88, 88, 0.12);
  color: var(--danger);
  border: 1px solid rgba(224, 88, 88, 0.18);
}

/* Green dot indicator for connected status */
.channel-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.channel-expiry-pill {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: 0;
}

.channel-expiry-pill--ok {
  color: var(--ok);
}

.channel-expiry-pill--warn {
  color: var(--warn);
}

.channel-expiry-pill--danger {
  color: var(--danger);
}

/* Coming soon badge -- dimmer, no border */
.channel-status-badge--soon {
  background: rgba(200, 220, 240, 0.06);
  color: var(--ink-soft);
  opacity: 0.7;
  font-weight: 600;
}

.channel-card-actions {
  margin-top: auto;
  padding-top: 10px;
}

.channel-card-actions button {
  font-size: 0.8rem;
  padding: 6px 14px;
  min-height: 34px;
  min-width: 44px;
  width: 100%;
}

.channel-empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.channel-empty-state p {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.channel-connect-chooser {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.channel-connect-chooser button {
  font-size: 0.78rem;
  padding: 5px 10px;
  min-height: 32px;
}

@media (max-width: 760px) {
  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .channel-card {
    padding: 18px 16px 16px;
  }
  .channel-card-account,
  .channel-status-row,
  .channel-sync-summary {
    padding-left: 0;
  }
  .channel-card-actions button {
    min-height: 44px;
    min-width: 44px;
  }
}

.account-card {
  padding: 28px;
}

.account-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.account-avatar--xl {
  width: 56px;
  height: 56px;
  font-size: 1.2rem;
}

.account-card-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.account-card-slug {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.account-status-badge {
  margin-left: auto;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.account-status-badge.active {
  background: rgba(31, 122, 83, 0.14);
  color: var(--ok);
  border: 1px solid rgba(31, 122, 83, 0.3);
}

.account-status-badge.inactive {
  background: rgba(183, 55, 55, 0.1);
  color: var(--danger);
  border: 1px solid rgba(183, 55, 55, 0.25);
}

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

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

.account-card-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.account-card-value {
  font-size: 0.94rem;
  color: var(--ink);
}

.account-card-mono {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.84rem;
}

.account-section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.account-section-desc {
  margin: 4px 0 18px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.account-templates {
  display: grid;
  gap: 14px;
}

.account-template-row {
  display: grid;
  gap: 6px;
}

.account-template-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.account-template-desc {
  font-size: 0.76rem;
  color: var(--ink-soft);
}

.account-template-value {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
}

.account-template-value.empty {
  color: var(--ink-soft);
  font-style: italic;
}

html.dark .account-template-value {
  background: rgba(255, 255, 255, 0.04);
}

.account-topics-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-topic-chip {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(13, 124, 122, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

html.dark .account-topic-chip {
  background: rgba(46, 196, 182, 0.12);
  color: var(--accent);
  border-color: rgba(46, 196, 182, 0.25);
}

/* Pinned chip: full-strength accent so it's visually distinct from
   regen-eligible chips. The leading pin glyph + accent-strong styling
   together make it obvious which topics survive the next regen. */
.account-topic-chip--pinned {
  background: rgba(13, 124, 122, 0.18);
  border-color: var(--accent);
}

html.dark .account-topic-chip--pinned {
  background: rgba(46, 196, 182, 0.22);
  border-color: var(--accent);
  color: var(--accent);
}

/* Stale pin: subtle warn-tone tinge on the chip — operator should
   notice but not alarm. The ⚠ glyph carries the actionable signal. */
.account-topic-chip--stale {
  border-color: rgba(198, 111, 26, 0.45);
}

html.dark .account-topic-chip--stale {
  border-color: rgba(224, 159, 62, 0.5);
}

/* The pin glyph button: invisible chrome, just a tap target around the
   SVG. In view mode the button is disabled (still shows the icon as
   state). In edit mode it becomes an unpin toggle. */
.account-topic-pin-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
  line-height: 0;
}

.account-topic-pin-toggle[disabled] {
  cursor: default;
}

.account-topic-pin-toggle--unpinned {
  opacity: 0.35;
}

.account-topic-pin-toggle--unpinned:hover {
  opacity: 0.7;
}

.account-topic-pin-glyph {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Stale glyph: warn-tone color, sits trailing the label so it scans as
   "this topic is OK in shape but the content's gone". */
.account-topic-stale {
  color: var(--warn, #c66f1a);
  font-size: 0.85rem;
  line-height: 1;
  cursor: help;
}

html.dark .account-topic-stale {
  color: rgba(224, 159, 62, 0.9);
}

/* Inline empty-state copy when topics.length === 0 so the panel is not
   a confusing blank space. */
.account-topic-empty {
  margin: 0;
  padding: 8px 0;
  color: var(--ink-soft, #555);
  font-size: 0.88rem;
  font-style: italic;
}

/* Edit-mode hint paragraph — sets operator's mental model BEFORE they
   make their first pin/edit (Don't-Make-Me-Think discoverability). */
.account-section-hint {
  margin: 4px 0 12px;
  font-size: 0.85rem;
  color: var(--ink-soft, #555);
  line-height: 1.4;
}

html.dark .account-section-hint,
html.dark .account-topic-empty {
  color: rgba(255, 255, 255, 0.62);
}

/* ============================================================
   Topic-change notification alert card
   ============================================================
   The alert-card is the operator's window into "what changed since I
   last looked." Anchored at the top of the per-creator account view,
   between the back button and the first panel. NOT the same primitive
   as `.toast` (a top-center pill for ephemeral confirmations) — alert
   cards persist across page navigations, span panel-width, and carry
   diff content + actions.
   ============================================================ */

.topic-alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 12px;
}

.topic-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

html.dark .topic-alert {
  background: rgba(46, 196, 182, 0.10);
  border-color: rgba(46, 196, 182, 0.30);
}

.topic-alert--warn {
  border-color: rgba(198, 111, 26, 0.45);
  background: rgba(198, 111, 26, 0.08);
}

html.dark .topic-alert--warn {
  border-color: rgba(224, 159, 62, 0.45);
  background: rgba(224, 159, 62, 0.10);
}

/* Muted variant for transient "polling offline" banners — desaturated
   alert without the accent color, so it reads as informational chrome
   rather than a state change. */
.topic-alert--muted {
  border-color: var(--border);
  background: var(--surface-2, var(--surface));
  color: var(--ink-soft);
}

html.dark .topic-alert--muted {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.topic-alert-body {
  flex: 1;
  min-width: 0;
}

.topic-alert-heading {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

html.dark .topic-alert-heading {
  color: var(--ink, #f3f4f6);
}

.topic-alert-row {
  margin: 4px 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--ink-soft, #555);
}

html.dark .topic-alert-row {
  color: rgba(255, 255, 255, 0.78);
}

.topic-alert-mark {
  display: inline-block;
  width: 12px;
  font-weight: 700;
  text-align: center;
}

/* + / − use semantic tokens, not raw red/green — matches the
   project palette and avoids the AI-slop traffic-light look. */
.topic-alert-mark--add {
  color: var(--ok, #2c8a4a);
}

.topic-alert-mark--remove {
  color: var(--ink-soft, #555);
}

html.dark .topic-alert-mark--add {
  color: rgba(72, 200, 120, 0.95);
}

html.dark .topic-alert-mark--remove {
  color: rgba(255, 255, 255, 0.62);
}

.topic-alert-dismiss {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--ink-soft, #555);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}

.topic-alert-dismiss:hover {
  background: rgba(0, 0, 0, 0.06);
}

html.dark .topic-alert-dismiss:hover {
  background: rgba(255, 255, 255, 0.08);
}

html.dark .account-status-badge.active {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--ok);
}

html.dark .account-status-badge.inactive {
  background: rgba(224, 88, 88, 0.14);
  border-color: rgba(224, 88, 88, 0.3);
  color: var(--danger);
}

/* --- Edit mode styles --- */

.account-edit-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.account-edit-btn {
  margin-left: auto;
  padding: 7px 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.account-edit-btn:hover {
  background: var(--accent);
  color: #fff;
}

.account-save-btn {
  padding: 7px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.account-save-btn:hover {
  opacity: 0.88;
}

.account-save-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.account-cancel-btn {
  padding: 7px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.account-cancel-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.account-cancel-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.account-field-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.94rem;
  background: #fff;
  color: var(--ink);
  box-sizing: border-box;
}

.account-field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 124, 122, 0.15);
}

.account-name-input {
  font-size: 1.2rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.account-field-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  background: #fff;
  color: var(--ink);
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  box-sizing: border-box;
}

.account-field-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 124, 122, 0.15);
}

.account-topic-chip.removable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
}

.account-topic-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  color: inherit;
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}

.account-topic-remove:hover {
  background: rgba(0, 0, 0, 0.2);
}

.account-topic-add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.account-topic-add input {
  flex: 1;
}

/* Profile links */

.account-profile-links {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.account-profile-links-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.account-profile-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(13, 124, 122, 0.2);
}

html.dark .account-profile-link-chip {
  background: rgba(46, 196, 182, 0.12);
  color: var(--accent);
  border-color: rgba(46, 196, 182, 0.25);
}

.account-profile-link-text {
  text-decoration: none;
  color: inherit;
}

a.account-profile-link-text:hover {
  text-decoration: underline;
}

.account-profile-link-add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Dark theme variants for edit mode */

html.dark .account-field-input {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

html.dark .account-field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(46, 196, 182, 0.2);
}

html.dark .account-field-textarea {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

html.dark .account-field-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(46, 196, 182, 0.2);
}

html.dark .account-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

html.dark .account-topic-remove {
  background: rgba(255, 255, 255, 0.12);
}

html.dark .account-topic-remove:hover {
  background: rgba(255, 255, 255, 0.22);
}

.login-shell {
  min-height: 58vh;
  display: grid;
  place-items: center;
}

.panel {
  border: 1px solid var(--panel-border);
  background: linear-gradient(178deg, rgba(255, 255, 255, 0.88), var(--panel));
  border-radius: 20px;
  box-shadow: 0 18px 48px rgba(19, 57, 89, 0.08);
  backdrop-filter: blur(8px);
}

.login-panel {
  width: min(460px, 100%);
  padding: 22px;
  display: grid;
  gap: 12px;
}

.login-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.login-panel label {
  display: grid;
  gap: 7px;
}

.login-panel label span {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(13, 124, 122, 0.18);
  border-color: rgba(13, 124, 122, 0.55);
}

.primary-button,
.ghost-button,
.tiny-button {
  border: 0;
  border-radius: 11px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
  line-height: 1.2;
}

.primary-button {
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: 0.9rem;
}

.primary-button:hover,
.ghost-button:hover,
.tiny-button:hover {
  filter: brightness(0.97);
}

.primary-button:active,
.ghost-button:active,
.tiny-button:active {
  transform: translateY(1px);
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
}

.tiny-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.78rem;
  padding: 4px 9px;
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.tabs,
.subtabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 5px 16px rgba(17, 61, 96, 0.12);
}

.error-banner {
  border: 1px solid rgba(183, 55, 55, 0.3);
  background: rgba(183, 55, 55, 0.08);
  color: #7a1d1d;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.dashboard-shell {
  display: grid;
  gap: 10px;
}

.dashboard-view {
  display: grid;
  gap: 16px;
}

.policy-rules-view {
  display: grid;
  gap: 24px;
}

.policy-workflow {
  display: grid;
  gap: 22px;
}

.policy-step {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.policy-step-index {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  color: var(--accent-strong);
  background: rgba(13, 124, 122, 0.08);
  font-weight: 800;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.policy-step-card {
  padding: 20px 22px;
  display: grid;
  gap: 14px;
  border: 1px solid rgba(30, 74, 106, 0.18);
  box-shadow: 0 10px 24px rgba(19, 57, 89, 0.06);
}

.policy-step-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.06rem;
  line-height: 1.25;
}

.policy-live-card,
.policy-compose-card,
.policy-test-card {
  padding: 20px 22px;
  display: grid;
  gap: 14px;
}

.policy-guide-card {
  padding: 20px 22px;
  display: grid;
  gap: 12px;
}

.policy-guide-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.06rem;
  line-height: 1.25;
}

.policy-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.policy-guide-toggle {
  white-space: nowrap;
}

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

.policy-guide-column {
  border: 1px solid rgba(30, 74, 106, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}

.policy-guide-title {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-soft);
}

.policy-guide-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.policy-guide-list li {
  line-height: 1.42;
}

.policy-live-card {
  background: linear-gradient(135deg, rgba(17, 67, 56, 0.98), rgba(22, 95, 78, 0.94));
  color: #e7f4ef;
}

.policy-live-card .muted {
  color: rgba(231, 244, 239, 0.85);
}

.policy-live-list,
.policy-staged-list {
  display: grid;
  gap: 12px;
}

.policy-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.policy-rule-card {
  position: relative;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 14px rgba(19, 57, 89, 0.06);
}

.policy-rule-live {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(231, 244, 239, 0.22);
}

.policy-rule-live .policy-rule-label,
.policy-rule-live .policy-rule-text {
  color: #e7f4ef;
}

.policy-rule-live .policy-rule-tag {
  background: rgba(231, 244, 239, 0.16);
  border-color: rgba(231, 244, 239, 0.2);
  color: #d9efe8;
}

.policy-rule-label {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}

.policy-rule-text {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.55;
}

.policy-rule-example-count {
  margin: -2px 0 0;
  font-size: 0.78rem;
}

.policy-rule-tag {
  justify-self: start;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid rgba(30, 74, 106, 0.2);
  background: rgba(255, 255, 255, 0.9);
  color: #244157;
}

.policy-rule-tag--forced_response {
  border-color: rgba(30, 98, 198, 0.28);
  background: rgba(53, 125, 230, 0.14);
  color: #1f4e8d;
}

.policy-rule-tag--topic_block {
  border-color: rgba(198, 111, 26, 0.3);
  background: rgba(198, 111, 26, 0.14);
  color: #8a4e10;
}

.policy-rule-tag--behavioral_modifier {
  border-color: rgba(31, 122, 83, 0.34);
  background: rgba(31, 122, 83, 0.14);
  color: #1d6647;
}

.policy-rule-tag--conditional_qa {
  border-color: rgba(24, 106, 147, 0.3);
  background: rgba(24, 106, 147, 0.14);
  color: #1a5878;
}

.policy-rule-tag--custom {
  border-color: rgba(54, 82, 107, 0.24);
  background: rgba(54, 82, 107, 0.12);
  color: #304a61;
}

.policy-rule-input {
  min-height: 110px;
}

.policy-example-editor {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.75);
  display: grid;
  gap: 10px;
}

.policy-example-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.policy-example-list {
  display: grid;
  gap: 10px;
}

.policy-example-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
  padding: 10px;
  border: 1px solid rgba(30, 74, 106, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
}

.policy-example-input,
.policy-example-output {
  min-height: 72px;
}

.policy-example-remove {
  justify-self: start;
}

.policy-preview-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.82);
  display: grid;
  gap: 12px;
}

.policy-preview-title {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  font-weight: 700;
}

.policy-preview-text {
  margin: 0;
  line-height: 1.5;
}

.policy-preview-grid {
  display: grid;
  gap: 8px;
}

.policy-preview-row {
  display: grid;
  grid-template-columns: minmax(140px, 170px) minmax(0, 1fr);
  align-items: start;
  column-gap: 12px;
  row-gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(30, 74, 106, 0.12);
}

.policy-preview-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.policy-preview-label {
  margin: 2px 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}

.policy-preview-highlight {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.policy-guardrail-reason {
  margin: 0;
}

.policy-guardrail-error {
  color: #b73737;
  font-weight: 500;
}

.policy-staged-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.policy-staged-head h4 {
  margin: 0;
  font-size: 0.9rem;
}

.policy-go-live-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.policy-go-live-row .primary-button {
  min-width: 220px;
}

.policy-test-scope {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.84);
}

.policy-test-scope-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.policy-test-scope-note {
  margin: 9px 0 0;
}

.policy-test-scope-inline-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}

.policy-test-scope-inline-list li {
  margin: 0;
  border: 1px solid rgba(30, 74, 106, 0.14);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.policy-scope-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 700;
}

.policy-scope-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.policy-scope-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 8px;
  font-size: 0.9rem;
  border: 1px solid rgba(30, 74, 106, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  padding: 10px 12px;
  line-height: 1.45;
}

.policy-scope-item-disabled {
  opacity: 0.68;
}

.policy-scope-item-hit {
  border-color: rgba(31, 122, 83, 0.26) !important;
  background: rgba(31, 122, 83, 0.1) !important;
}

.policy-scope-text-wrap {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.policy-scope-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.policy-scope-match {
  font-size: 0.8rem;
}

.policy-scope-chip {
  white-space: nowrap;
}

.policy-scope-chip-hit {
  border-color: rgba(31, 122, 83, 0.3);
  background: rgba(31, 122, 83, 0.14);
  color: #0f633f;
}

.policy-scope-actions {
  margin-left: 0;
  justify-self: end;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.policy-scope-toggle {
  margin-left: 0;
}

.policy-scope-empty {
  grid-template-columns: 1fr !important;
}

.policy-scope-remove {
  border-color: rgba(183, 55, 55, 0.28);
  color: #9b2a2a;
}

.policy-scope-remove-live {
  border-color: rgba(255, 255, 255, 0.66);
  background: rgba(255, 255, 255, 0.94);
  color: #8a2a2a;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(8, 26, 22, 0.16);
}

.policy-scope-remove-live:hover {
  background: #fff;
  border-color: rgba(255, 255, 255, 0.9);
  color: #742020;
  filter: none;
}

.policy-scope-edit {
  border-color: rgba(30, 98, 198, 0.28);
  color: #1f4e8d;
}

html.dark .policy-scope-remove {
  border-color: rgba(224, 88, 88, 0.36);
  color: #f0a0a0;
}

html.dark .policy-scope-remove-live {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.12);
  color: #ffd1d1;
  box-shadow: none;
}

html.dark .policy-scope-remove-live:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.48);
  color: #ffc2c2;
  filter: none;
}

html.dark .policy-editing-banner {
  border-color: rgba(96, 166, 255, 0.34);
  background: rgba(59, 130, 246, 0.2);
}

html.dark .policy-editing-title {
  color: #b8d8ff;
}

html.dark .policy-scope-edit {
  border-color: rgba(96, 166, 255, 0.34);
  color: #b8d8ff;
}

.scope-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  align-self: center;
}

.scope-live {
  background: #58c58a;
}

.scope-staged {
  background: #d9b84f;
}

.policy-config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
}

.controls label {
  display: grid;
  gap: 5px;
  width: min(280px, 100%);
}

.controls label span {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.inline-toggle {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.inline-toggle input {
  margin: 0;
}

.stamp {
  margin-left: auto;
  text-align: right;
}

.policy-settings-card {
  display: grid;
  gap: 14px;
  padding: 20px 22px;
}

.policy-side-stack {
  display: grid;
  gap: 14px;
}

.policy-help-text {
  margin: 0;
  line-height: 1.45;
}

.policy-editing-banner {
  border: 1px solid rgba(30, 98, 198, 0.26);
  background: rgba(53, 125, 230, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.policy-editing-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1f4e8d;
}

.policy-editing-text {
  margin: 0;
}

.policy-textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  border-radius: 12px;
  border: 1px solid rgba(30, 74, 106, 0.24);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  padding: 11px 12px;
  font: inherit;
  line-height: 1.45;
}

.policy-base-qa-input {
  min-height: 260px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
}

.policy-action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.policy-settings-meta {
  display: grid;
  gap: 4px;
}

.policy-test-result {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.policy-scenario-path-note {
  margin: 0;
  border: 1px solid rgba(30, 74, 106, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.policy-scenario-path-hit {
  border-color: rgba(31, 122, 83, 0.28);
  background: rgba(31, 122, 83, 0.1);
  color: #0f633f;
}

.policy-scenario-path-miss {
  border-color: rgba(30, 74, 106, 0.18);
  background: rgba(30, 74, 106, 0.08);
  color: var(--ink-soft);
}

.policy-feedback-box {
  border: 1px solid rgba(30, 74, 106, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px;
  display: grid;
  gap: 10px;
}

.policy-feedback-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.policy-feedback-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.policy-feedback-choice-active {
  border-color: rgba(31, 122, 83, 0.36) !important;
  background: rgba(31, 122, 83, 0.14);
  color: #0f633f;
}

.policy-feedback-note {
  min-height: 90px;
}

.policy-saved-scenarios {
  border-top: 1px solid rgba(30, 74, 106, 0.12);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

.policy-batch-progress {
  border: 1px solid rgba(30, 74, 106, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  padding: 9px 10px;
  display: grid;
  gap: 7px;
}

.policy-batch-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.policy-batch-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(30, 74, 106, 0.14);
}

.policy-batch-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f8f65 0%, #5db38d 100%);
  transition: width 180ms ease-out;
}

.policy-batch-progress-meta {
  margin: 0;
  font-size: 0.8rem;
}

.policy-saved-scenarios-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.policy-saved-scenarios-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.policy-scenario-list-note {
  margin: 0;
}

.policy-scenario-list {
  display: grid;
  gap: 8px;
}

.policy-scenario-item {
  border: 1px solid rgba(30, 74, 106, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 9px;
  display: grid;
  gap: 5px;
}

.policy-scenario-item-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.policy-scenario-item-clickable:hover {
  border-color: rgba(30, 98, 198, 0.32);
  box-shadow: 0 4px 14px rgba(19, 57, 89, 0.08);
}

.policy-scenario-item-clickable:focus-visible {
  outline: 2px solid rgba(30, 98, 198, 0.38);
  outline-offset: 2px;
}

.policy-scenario-item-active {
  border-color: rgba(31, 122, 83, 0.34);
  background: rgba(31, 122, 83, 0.1);
}

.policy-scenario-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.policy-scenario-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.policy-scenario-item-id {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.policy-scenario-text {
  margin: 0;
  line-height: 1.4;
}

.policy-scenario-text-compact {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.policy-scenario-item-active .policy-scenario-text-compact {
  display: block;
  -webkit-line-clamp: unset;
}

.policy-scenario-pair-label {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.policy-scenario-answer {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.policy-scenario-note {
  margin: 0;
  font-size: 0.86rem;
}

.policy-scenario-compare {
  border: 1px solid rgba(30, 74, 106, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  padding: 9px 10px;
  display: grid;
  gap: 7px;
}

.policy-diff-tokens {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px;
  line-height: 1.45;
}

.policy-diff-token {
  white-space: pre-wrap;
  word-break: break-word;
}

.policy-diff-token-added {
  background: rgba(31, 122, 83, 0.2);
  border-radius: 4px;
  padding: 0 2px;
}

.policy-diff-token-removed {
  background: rgba(183, 55, 55, 0.16);
  border-radius: 4px;
  padding: 0 2px;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.policy-scenario-compare-status {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.policy-scenario-compare-status.changed {
  color: #b24a1d;
}

.policy-scenario-compare-status.same {
  color: #1d6647;
}

.policy-scenario-compare-chip.changed {
  border-color: rgba(198, 111, 26, 0.34);
  background: rgba(198, 111, 26, 0.14);
  color: #8d4b12;
}

.policy-scenario-compare-chip.same {
  border-color: rgba(31, 122, 83, 0.3);
  background: rgba(31, 122, 83, 0.12);
  color: #0f633f;
}

.policy-feedback-chip {
  text-transform: none;
}

.policy-feedback-chip-ok {
  border-color: rgba(31, 122, 83, 0.32);
  background: rgba(31, 122, 83, 0.14);
  color: #0f633f;
}

.policy-feedback-chip-fix {
  border-color: rgba(198, 111, 26, 0.34);
  background: rgba(198, 111, 26, 0.14);
  color: #8d4b12;
}

.policy-feedback-chip-empty {
  border-color: rgba(30, 74, 106, 0.2);
  background: rgba(30, 74, 106, 0.08);
  color: var(--ink-soft);
}

.policy-lint-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.policy-lint-head {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.policy-lint-head-error {
  color: #9f2d2d;
}

.policy-lint-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.policy-lint-item {
  border: 1px solid rgba(30, 74, 106, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.policy-lint-item-error {
  border-color: rgba(183, 55, 55, 0.32);
  background: rgba(235, 76, 76, 0.08);
}

.policy-lint-item-warning {
  border-color: rgba(198, 111, 26, 0.3);
  background: rgba(198, 111, 26, 0.08);
}

.policy-lint-message,
.policy-lint-meta {
  margin: 0;
  line-height: 1.4;
}

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

.policy-test-answer {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.5;
}

.policy-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.prompt-limit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.override-chip-active {
  border-color: rgba(31, 122, 83, 0.3);
  color: var(--ok);
  background: rgba(31, 122, 83, 0.12);
}

.override-chip-inactive {
  border-color: rgba(183, 55, 55, 0.2);
  color: var(--ink-soft);
  background: rgba(183, 55, 55, 0.08);
}

.policy-scenario-input {
  min-height: 140px;
}

.policy-release-list,
.policy-routing-runs-list {
  display: grid;
  gap: 8px;
}

.policy-release-row {
  width: 100%;
  border: 1px solid rgba(30, 74, 106, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  text-align: left;
  padding: 9px 10px;
  display: grid;
  gap: 2px;
}

.policy-release-row:hover {
  border-color: rgba(27, 118, 199, 0.34);
}

.policy-release-row-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.policy-release-row-active {
  border-color: rgba(27, 118, 199, 0.45);
  background: rgba(27, 118, 199, 0.1);
}

.policy-release-detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.policy-inline-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.policy-inline-fields label {
  display: grid;
  gap: 5px;
}

.policy-inline-fields select {
  border-radius: 9px;
  border: 1px solid rgba(30, 74, 106, 0.22);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}

.policy-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.policy-checkbox-row input {
  margin: 0;
}

.policy-routing-list {
  display: grid;
  gap: 8px;
  border-top: 1px solid rgba(30, 74, 106, 0.12);
  padding-top: 10px;
}

.policy-routing-item {
  border: 1px solid rgba(30, 74, 106, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 10px;
  display: grid;
  gap: 5px;
}

.policy-routing-item-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.policy-routing-runs {
  border-top: 1px solid rgba(30, 74, 106, 0.12);
  padding-top: 10px;
  display: grid;
  gap: 8px;
}

html.dark .policy-step-card,
html.dark .policy-settings-card {
  border-color: rgba(200, 220, 240, 0.18);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.26);
}

html.dark .policy-guide-column {
  border-color: rgba(200, 220, 240, 0.2);
  background: rgba(16, 23, 30, 0.86);
}

html.dark .policy-rule-card,
html.dark .policy-scope-list li,
html.dark .policy-test-scope-inline-list li,
html.dark .policy-preview-box,
html.dark .policy-test-scope,
html.dark .policy-test-result,
html.dark .policy-test-answer,
html.dark .policy-feedback-box,
html.dark .policy-scenario-item,
html.dark .policy-lint-box,
html.dark .policy-lint-item,
html.dark .policy-release-row,
html.dark .policy-release-detail,
html.dark .policy-routing-item {
  border-color: rgba(200, 220, 240, 0.18);
  background: rgba(16, 23, 30, 0.86);
}

html.dark .policy-scope-item-hit {
  border-color: rgba(82, 207, 154, 0.42) !important;
  background: rgba(52, 211, 153, 0.16) !important;
}

html.dark .policy-scope-chip-hit {
  border-color: rgba(82, 207, 154, 0.38);
  background: rgba(52, 211, 153, 0.2);
  color: #b8f8dc;
}

html.dark .policy-scenario-path-hit {
  border-color: rgba(82, 207, 154, 0.42);
  background: rgba(52, 211, 153, 0.2);
  color: #b8f8dc;
}

html.dark .policy-scenario-path-miss {
  border-color: rgba(200, 220, 240, 0.24);
  background: rgba(200, 220, 240, 0.1);
  color: #c7d6e5;
}

html.dark .policy-lint-item-error {
  border-color: rgba(224, 88, 88, 0.4);
  background: rgba(224, 88, 88, 0.16);
}

html.dark .policy-lint-item-warning {
  border-color: rgba(238, 170, 89, 0.4);
  background: rgba(238, 170, 89, 0.16);
}

html.dark .policy-lint-head-error {
  color: #ffb2b2;
}

html.dark .policy-feedback-choice-active {
  border-color: rgba(82, 207, 154, 0.42) !important;
  background: rgba(52, 211, 153, 0.22);
  color: #b8f8dc;
}

html.dark .policy-feedback-chip-ok {
  border-color: rgba(82, 207, 154, 0.42);
  background: rgba(52, 211, 153, 0.22);
  color: #b8f8dc;
}

html.dark .policy-feedback-chip-fix {
  border-color: rgba(238, 170, 89, 0.44);
  background: rgba(238, 170, 89, 0.2);
  color: #ffd79f;
}

html.dark .policy-feedback-chip-empty {
  border-color: rgba(200, 220, 240, 0.3);
  background: rgba(100, 116, 139, 0.2);
  color: #d2dceb;
}

html.dark .policy-batch-progress,
html.dark .policy-scenario-compare {
  border-color: rgba(200, 220, 240, 0.18);
  background: rgba(16, 23, 30, 0.86);
}

html.dark .policy-batch-progress-track {
  background: rgba(200, 220, 240, 0.18);
}

html.dark .policy-scenario-item-clickable:hover {
  border-color: rgba(96, 166, 255, 0.42);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

html.dark .policy-scenario-item-clickable:focus-visible {
  outline: 2px solid rgba(96, 166, 255, 0.55);
}

html.dark .policy-scenario-compare-status.changed {
  color: #ffbb98;
}

html.dark .policy-scenario-compare-status.same {
  color: #b8f8dc;
}

html.dark .policy-scenario-compare-chip.changed {
  border-color: rgba(238, 170, 89, 0.44);
  background: rgba(238, 170, 89, 0.2);
  color: #ffd79f;
}

html.dark .policy-scenario-compare-chip.same {
  border-color: rgba(82, 207, 154, 0.42);
  background: rgba(52, 211, 153, 0.22);
  color: #b8f8dc;
}

html.dark .policy-diff-token-added {
  background: rgba(52, 211, 153, 0.24);
}

html.dark .policy-diff-token-removed {
  background: rgba(224, 88, 88, 0.22);
}

html.dark .policy-preview-row {
  border-bottom-color: rgba(200, 220, 240, 0.16);
}

html.dark .policy-rule-tag {
  border-color: rgba(200, 220, 240, 0.28);
  background: rgba(32, 43, 57, 0.9);
  color: #cbd8e6;
}

html.dark .policy-rule-tag--forced_response {
  border-color: rgba(96, 166, 255, 0.36);
  background: rgba(59, 130, 246, 0.2);
  color: #b8d8ff;
}

html.dark .policy-rule-tag--topic_block {
  border-color: rgba(238, 170, 89, 0.4);
  background: rgba(224, 159, 62, 0.2);
  color: #ffd79f;
}

html.dark .policy-rule-tag--behavioral_modifier {
  border-color: rgba(82, 207, 154, 0.4);
  background: rgba(52, 211, 153, 0.2);
  color: #b8f8dc;
}

html.dark .policy-rule-tag--conditional_qa {
  border-color: rgba(108, 208, 234, 0.4);
  background: rgba(34, 197, 246, 0.18);
  color: #b9eeff;
}

html.dark .policy-rule-tag--custom {
  border-color: rgba(166, 181, 199, 0.35);
  background: rgba(100, 116, 139, 0.2);
  color: #d2dceb;
}

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

.social-ingestion-card {
  padding: 16px;
}

.social-ingestion-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.social-ingestion-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.social-ingestion-item {
  min-width: 0;
}

.social-ingestion-value {
  margin: 6px 0 0;
  font-weight: 600;
  word-break: break-word;
}

.social-ingestion-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.social-ingestion-error {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.stat-card {
  padding: 18px;
}

.stat-card h3 {
  margin: 0;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.stat-card p {
  margin: 12px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.1vw, 2rem);
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 12px;
}

.bottom-grid {
  grid-template-columns: 1.15fr 0.85fr;
}

.chart-card,
.topics-card,
.token-panel,
.queries-view,
.pending-card {
  padding: 16px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.chart-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
}

.cluster-head {
  flex-direction: column;
  align-items: stretch;
}

.chart-host {
  height: 280px;
  width: 100%;
}

.bottom-grid .chart-host {
  height: 250px;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
}

.topics-card {
  display: grid;
  align-content: start;
  gap: 9px;
}

.topic-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  border-radius: 12px;
  padding: 9px 11px;
  cursor: pointer;
}

.topic-row:hover {
  background: rgba(13, 124, 122, 0.08);
}

.queries-view {
  display: grid;
  gap: 12px;
}

.clusters-view {
  display: grid;
  gap: 10px;
}

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

.cluster-card {
  cursor: pointer;
  padding: 20px;
  border-left: 4px solid var(--card-accent, var(--accent));
  transition: transform 0.15s;
}

.cluster-card:hover {
  transform: translateY(-2px);
}

.cluster-card .card-label {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
}

.cluster-card .card-count {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-display);
  margin: 8px 0 0;
}

.cluster-card .card-pct {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 2px 0 0;
}

.cluster-card .card-action {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  margin: 10px 0 0;
}

.cluster-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.cluster-breadcrumb button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0;
}

.cluster-breadcrumb button:hover {
  text-decoration: underline;
}

.cluster-breadcrumb .breadcrumb-title {
  font-weight: 700;
  font-size: 1.02rem;
  font-family: var(--font-display);
}

.cluster-breadcrumb .breadcrumb-count {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.cluster-bar-host {
  height: auto;
  min-height: 200px;
  width: 100%;
}

html.dark .cluster-card {
  border-left-color: var(--card-accent, var(--accent));
}

html.dark .cluster-breadcrumb button {
  color: var(--accent);
}

.cluster-stat-chips {
  display: inline-flex;
  gap: 8px;
}

.cluster-map-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.cluster-map-selects {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cluster-map-selects label {
  display: grid;
  gap: 4px;
}

.cluster-map-selects label span {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cluster-map-selects select {
  min-width: 138px;
}

.cluster-map-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.clusters-hint {
  margin: 0;
}

.query-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) repeat(5, minmax(120px, 1fr)) auto;
  gap: 8px;
}

.active-filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
  text-align: left;
  font-size: 0.84rem;
  line-height: 1.35;
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 700;
}

.empty-cell {
  text-align: center;
  padding: 18px;
}

.source-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.source-slack {
  color: #18499f;
  background: rgba(34, 109, 255, 0.15);
  border-color: rgba(34, 109, 255, 0.22);
}

.source-instagram {
  color: #993568;
  background: rgba(225, 76, 153, 0.16);
  border-color: rgba(225, 76, 153, 0.22);
}

.source-api,
.source-unknown {
  color: #36526b;
  background: rgba(54, 82, 107, 0.12);
  border-color: rgba(54, 82, 107, 0.2);
}

.status-sent,
.status-healthy {
  color: #1d6a46;
  background: rgba(31, 122, 83, 0.14);
  border-color: rgba(31, 122, 83, 0.22);
}

.status-pending,
.status-expiring_soon,
.status-send_failed {
  color: #9c5b11;
  background: rgba(198, 111, 26, 0.16);
  border-color: rgba(198, 111, 26, 0.26);
}

.status-failed,
.status-dead_letter,
.status-expired {
  color: #8f2424;
  background: rgba(183, 55, 55, 0.14);
  border-color: rgba(183, 55, 55, 0.24);
}

.pill-button {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: filter 0.15s;
}
.pill-button:hover {
  filter: brightness(1.2);
}

.topic-pill-button {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #1e40af;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.22);
}

.dark .topic-pill-button {
  color: #93bbfd;
  background: rgba(37, 99, 235, 0.22);
  border-color: rgba(37, 99, 235, 0.35);
}

.category-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.category-fan_mail {
  color: #5b21b6;
  background: rgba(124, 58, 237, 0.14);
  border-color: rgba(124, 58, 237, 0.24);
}

.category-business {
  color: #9c5b11;
  background: rgba(198, 111, 26, 0.16);
  border-color: rgba(198, 111, 26, 0.26);
}

.category-meta_help {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.12);
  border-color: rgba(15, 118, 110, 0.2);
}

.category-general_comments {
  color: #36526b;
  background: rgba(54, 82, 107, 0.12);
  border-color: rgba(54, 82, 107, 0.2);
}

.category-no_sources {
  color: #92400e;
  background: rgba(217, 119, 6, 0.14);
  border-color: rgba(217, 119, 6, 0.24);
}

.category-spam {
  color: #8f2424;
  background: rgba(183, 55, 55, 0.14);
  border-color: rgba(183, 55, 55, 0.24);
}

/* Priority sections — Pending tab grouped inbox */
.priority-section {
  margin-bottom: 24px;
}

.priority-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
  cursor: pointer;
  user-select: none;
}

.priority-section-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.priority-badge {
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 20px;
  padding: 2px 8px;
}

.priority-collapse-btn {
  margin-left: auto;
  font-size: 0.72rem;
  color: #888;
  cursor: pointer;
  background: #f2f2f2;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 10px;
}

.priority-collapse-btn:hover {
  background: #e5e5e5;
}

.priority-section-body.collapsed {
  display: none;
}

.priority-info {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 8px 0 4px;
}

/* Section color variants */
.section-nosources .priority-section-header {
  border-color: #d97706;
}

.section-nosources .priority-section-title {
  color: #d97706;
}

.section-nosources .priority-badge {
  background: #fef3c7;
  color: #d97706;
}

.section-business .priority-section-header {
  border-color: #0d9488;
}

.section-business .priority-section-title {
  color: #0d9488;
}

.section-business .priority-badge {
  background: #ccfbf1;
  color: #0d9488;
}

.section-fanmail .priority-section-header {
  border-color: #7c3aed;
}

.section-fanmail .priority-section-title {
  color: #7c3aed;
}

.section-fanmail .priority-badge {
  background: #ede9fe;
  color: #7c3aed;
}

.section-other .priority-section-header {
  border-color: #9ca3af;
}

.section-other .priority-section-title {
  color: #6b7280;
}

.section-other .priority-badge {
  background: #f3f4f6;
  color: #6b7280;
}

.priority-more-hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  padding: 4px 0 8px;
}

/* Dark mode for priority sections */
html.dark .section-nosources .priority-section-title {
  color: #fbbf24;
}

html.dark .section-nosources .priority-section-header {
  border-color: #fbbf24;
}

html.dark .section-nosources .priority-badge {
  background: rgba(217, 119, 6, 0.2);
  color: #fbbf24;
}

html.dark .priority-collapse-btn {
  background: rgba(30, 40, 52, 0.9);
  color: var(--ink-soft);
  border-color: rgba(200, 220, 240, 0.15);
}

html.dark .priority-collapse-btn:hover {
  background: rgba(46, 196, 182, 0.12);
}

html.dark .section-business .priority-section-title {
  color: #2dd4bf;
}

html.dark .section-business .priority-section-header {
  border-color: #2dd4bf;
}

html.dark .section-business .priority-badge {
  background: rgba(13, 148, 136, 0.2);
  color: #2dd4bf;
}

html.dark .section-fanmail .priority-section-title {
  color: #a78bfa;
}

html.dark .section-fanmail .priority-section-header {
  border-color: #a78bfa;
}

html.dark .section-fanmail .priority-badge {
  background: rgba(124, 58, 237, 0.2);
  color: #a78bfa;
}

html.dark .section-other .priority-section-title {
  color: #94a3b3;
}

html.dark .section-other .priority-section-header {
  border-color: rgba(200, 220, 240, 0.15);
}

html.dark .section-other .priority-badge {
  background: rgba(139, 155, 171, 0.15);
  color: #94a3b3;
}

html.dark .priority-info {
  color: var(--ink-soft);
}

.answer-text {
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  max-width: 420px;
}

.answer-text.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.answer-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

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

.pending-view {
  display: grid;
  gap: 16px;
}

.pending-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  max-width: 1040px;
  width: 100%;
}

.pending-card {
  display: grid;
  gap: 12px;
  transition: box-shadow 0.15s ease;
}

.pending-card-header {
  cursor: pointer;
}

.pending-card:not(.pending-card-expanded):hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

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

.pending-reply-toggle {
  flex-shrink: 0;
  border: 1px solid rgba(13, 124, 122, 0.3);
  background: rgba(13, 124, 122, 0.12);
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}

.pending-reply-toggle:hover {
  background: rgba(13, 124, 122, 0.18);
  transform: translateY(-1px);
}

.pending-reply-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pending-card-expanded {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.pending-card-body {
  display: grid;
  gap: 12px;
}

.pending-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--ink-soft);
}

.pending-time {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.pending-prompt {
  margin: 0;
  font-weight: 700;
  line-height: 1.45;
}

.pending-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.pending-details p {
  margin: 0;
}

.detail-key {
  font-weight: 700;
}

.reply-box {
  width: 100%;
  min-height: 38px;
  resize: vertical;
  transition: min-height 0.15s ease;
}

.reply-box:focus {
  min-height: 100px;
}

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

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

.token-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.84);
}

.muted {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.error-text {
  margin: 0;
  color: #9b2a2a;
  font-size: 0.85rem;
}

.danger-button {
  border: 1px solid rgba(183, 55, 55, 0.35);
  background: rgba(183, 55, 55, 0.12);
  color: #8e2020;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.danger-button:hover {
  background: rgba(183, 55, 55, 0.2);
}

.danger-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.policy-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 26, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 14px;
}

.policy-modal {
  width: min(480px, 100%);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 44px rgba(15, 31, 45, 0.22);
  padding: 16px;
  display: grid;
  gap: 10px;
}

.policy-modal-danger {
  border-color: rgba(183, 55, 55, 0.32);
  box-shadow: 0 24px 56px rgba(120, 30, 30, 0.24);
}

.policy-modal-head {
  display: grid;
  gap: 8px;
}

.policy-modal-status {
  justify-self: start;
  border-radius: 999px;
  border: 1px solid rgba(30, 74, 106, 0.18);
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.policy-modal-status-live {
  border-color: rgba(183, 55, 55, 0.34);
  background: rgba(183, 55, 55, 0.12);
  color: #962e2e;
}

.policy-modal-status-ready {
  border-color: rgba(30, 74, 106, 0.2);
  background: rgba(30, 74, 106, 0.08);
  color: var(--ink-soft);
}

.policy-modal-message {
  margin: 0;
}

.policy-modal-warning {
  border: 1px solid rgba(183, 55, 55, 0.3);
  background: rgba(183, 55, 55, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 8px;
}

.policy-modal-warning p {
  margin: 0;
  line-height: 1.4;
  color: #822323;
  font-weight: 600;
}

.policy-modal-warning-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.78rem;
  color: #fff;
  background: #b73737;
  margin-top: 1px;
}

.policy-modal h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
}

.policy-modal-rule {
  margin: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(13, 124, 122, 0.08);
  padding: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
}

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

.sent-response-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 12px;
}

.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: rgba(16, 74, 73, 0.95);
  color: #fff;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.83rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--error {
  background: rgba(183, 28, 28, 0.92);
}

.toast--warning {
  background: rgba(180, 120, 20, 0.94);
}

.toast-close {
  margin-left: 8px;
  font-weight: bold;
  opacity: 0.7;
}

.toast-close:hover {
  opacity: 1;
}

.toast.show {
  pointer-events: auto;
}

.disconnect-confirm-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: var(--font-mono, monospace);
  background: var(--bg);
  color: var(--fg);
  margin: 8px 0 4px;
  box-sizing: border-box;
}

.noscript {
  padding: 18px;
  margin: 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-family: var(--font-body);
}

@media (max-width: 1100px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .chart-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .query-filters {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .pending-details {
    grid-template-columns: 1fr;
  }

  .policy-config-grid {
    grid-template-columns: 1fr;
  }

  .policy-grid {
    grid-template-columns: 1fr;
  }

  .policy-step {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .policy-step-index {
    margin-top: 0;
  }

  .policy-preview-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .policy-guide-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 760px) {
  #app {
    padding: 18px 14px 40px;
  }

  .app-header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .header-actions > button {
    flex: 1;
  }

  .account-menu {
    width: 100%;
  }

  .account-trigger {
    width: 100%;
    justify-content: center;
  }

  .account-dropdown {
    left: 0;
    right: 0;
  }

  .tabs,
  .subtabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .query-filters {
    grid-template-columns: 1fr;
  }

  .cluster-cards-grid {
    grid-template-columns: 1fr;
  }

  .cluster-map-selects {
    width: 100%;
  }

  .cluster-map-selects label {
    width: 100%;
  }

  .cluster-map-selects select {
    min-width: 0;
    width: 100%;
  }

  .cluster-map-actions {
    width: 100%;
  }

  th,
  td {
    font-size: 0.78rem;
    padding: 8px;
  }

  .token-row {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .policy-step-card,
  .policy-live-card,
  .policy-settings-card {
    padding: 16px;
  }

  .policy-scope-list li {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }

  .policy-scope-chip {
    grid-column: 2;
    justify-self: start;
  }

  .policy-scope-actions {
    grid-column: 1 / -1;
    justify-self: start;
    padding-left: 18px;
  }
}

/* ---------------------------------------------------------------------------
   Super Admin Overview
   --------------------------------------------------------------------------- */

.super-admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  color: var(--ink);
}

/* --- Header --- */

.super-admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 2rem;
  position: relative;
  z-index: 10;
}

.super-admin-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}

.super-admin-header p {
  color: var(--ink-soft);
  margin: 6px 0 0;
  font-size: 0.9rem;
}

.header-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.stale-indicator {
  color: var(--warn);
  font-size: 0.75rem;
  padding: 4px 8px;
  border: 1px solid var(--warn);
  border-radius: 8px;
  font-weight: 600;
}

/* --- Metric Cards (4-column grid) --- */

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  border: 1px solid var(--panel-border);
  background: linear-gradient(178deg, rgba(255, 255, 255, 0.88), var(--panel));
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(19, 57, 89, 0.06);
  backdrop-filter: blur(8px);
  padding: 1.25rem 1rem;
  text-align: center;
}

html.dark .metric-card {
  background: rgba(22, 29, 38, 0.92);
  border-color: rgba(200, 220, 240, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  font-weight: 600;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.375rem;
  color: var(--ink);
}

@media (max-width: 900px) {
  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .metrics-row {
    grid-template-columns: 1fr;
  }
}

/* --- Overview Table --- */

.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.overview-table th {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 2px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-weight: 700;
}

.overview-table th:hover {
  color: var(--ink);
}

.overview-table th.num,
.overview-table td.num {
  text-align: right;
}

.overview-row {
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}

.overview-row:hover {
  background: var(--accent-soft);
}

.overview-row td {
  padding: 0.75rem;
}

.status-dot {
  font-size: 1rem;
}

.influencer-name {
  font-weight: 600;
  color: var(--ink);
}

.channel-type {
  color: var(--ink-soft);
}

.expand-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--ink-soft);
  font-size: 0.875rem;
  border-radius: 8px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.expand-btn:hover {
  background: var(--accent-soft);
  border-color: var(--line);
  color: var(--ink);
}

/* --- Expanded Row (recent messages) --- */

.expanded-row {
  padding: 1rem 1rem 1.25rem 2.75rem !important;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}

.recent-messages {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.recent-message {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

html.dark .recent-message {
  background: rgba(22, 29, 38, 0.7);
  border-color: rgba(200, 220, 240, 0.08);
}

.msg-status {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
  font-size: 0.9rem;
}

.msg-sender {
  flex-shrink: 0;
  width: 6rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.msg-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.msg-time {
  flex-shrink: 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

/* --- Loading & Utility --- */

.loading-state {
  text-align: center;
  padding: 3rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.super-admin-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.8rem;
  margin-right: 1rem;
  font-weight: 600;
  transition: color 0.15s ease;
}

.super-admin-back:hover {
  color: var(--ink);
}

/* --- Super Admin Dark Theme Overrides --- */

html.dark .super-admin-container {
  color: var(--ink);
}

html.dark .super-admin-header h1 {
  color: var(--ink);
}

html.dark .super-admin-header p {
  color: var(--ink-soft);
}

html.dark .overview-table th {
  color: var(--ink-soft);
  border-bottom-color: var(--line);
}

html.dark .overview-table th:hover {
  color: var(--ink);
}

html.dark .overview-row {
  border-bottom-color: var(--line);
}

html.dark .overview-row:hover {
  background: rgba(46, 196, 182, 0.1);
}

html.dark .overview-row td {
  color: var(--ink);
}

html.dark .influencer-name {
  color: var(--ink);
}

html.dark .channel-type {
  color: var(--ink-soft);
}

html.dark .expanded-row {
  background: rgba(46, 196, 182, 0.08);
  border-bottom-color: var(--line);
}

html.dark .expand-btn {
  color: var(--ink-soft);
}

html.dark .expand-btn:hover {
  background: rgba(46, 196, 182, 0.12);
  border-color: var(--line);
  color: var(--ink);
}

html.dark .stale-indicator {
  color: var(--warn);
  border-color: var(--warn);
}

html.dark .header-username {
  color: var(--ink);
}

html.dark .metric-label {
  color: var(--ink-soft);
}

html.dark .metric-value {
  color: var(--ink);
}

html.dark .msg-sender {
  color: var(--ink-soft);
}

html.dark .msg-text {
  color: var(--ink);
}

html.dark .msg-time {
  color: var(--ink-soft);
}

html.dark .loading-state {
  color: var(--ink-soft);
}

html.dark .super-admin-back {
  color: var(--ink-soft);
}

html.dark .super-admin-back:hover {
  color: var(--ink);
}

/* ── Data Sources Tab ── */

.data-sources-shell {
  display: grid;
  gap: 16px;
}

.ds-header h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.ds-header p {
  color: var(--text-secondary, #8a9bb0);
  font-size: 14px;
}

.ds-input-bar {
  position: sticky;
  top: 16px;
  z-index: 100;
  display: flex;
  gap: 12px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 20px;
  align-items: center;
}

.ds-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.ds-platform-icon {
  position: absolute;
  left: 14px;
  width: 24px;
  text-align: center;
  pointer-events: none;
  z-index: 1;
}

.ds-input-wrap input {
  width: 100%;
  padding: 12px 16px 12px 48px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.ds-input-wrap input:focus {
  border-color: var(--accent);
}

.ds-input-wrap input.platform-youtube {
  border-color: rgba(255, 68, 68, 0.5);
  box-shadow: 0 0 12px rgba(255, 68, 68, 0.1);
}

.ds-input-wrap input.platform-instagram {
  border-color: rgba(225, 48, 108, 0.5);
  box-shadow: 0 0 12px rgba(225, 48, 108, 0.1);
}

.ds-input-wrap input.platform-facebook {
  border-color: rgba(66, 103, 178, 0.5);
  box-shadow: 0 0 12px rgba(66, 103, 178, 0.1);
}

/* YouTube URL detected but ingestion not yet supported.
   Calm amber tone (shared with queued status) — not an error. */
.ds-input-wrap input.platform-youtube-soon {
  border-color: rgba(232, 169, 72, 0.55);
  box-shadow: 0 0 12px rgba(232, 169, 72, 0.12);
}

.ds-btn-add {
  background: linear-gradient(140deg, #0d7c7a, #095b59);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
}

.ds-btn-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(13, 124, 122, 0.35);
}

.ds-btn-add:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.ds-input-error {
  color: #f06060;
  font-size: 13px;
  margin-top: 6px;
  padding-left: 4px;
}

.ds-input-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
}

.ds-options-section {
  border-top: 1px solid var(--line);
  background: var(--accent-soft);
}

.ds-options-toggle {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  padding: 8px 16px 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.ds-options-toggle:hover {
  opacity: 1;
}

.ds-options-row {
  display: flex;
  gap: 16px;
  padding: 4px 16px 12px;
}

.ds-option-narrow {
  flex: 0 0 120px;
}

.ds-option-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.ds-option-field span {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ds-option-field input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.ds-option-field input:focus {
  border-color: var(--accent);
}
.ds-option-field input::placeholder {
  color: var(--ink-soft);
  opacity: 0.5;
}

.ds-filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.ds-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.ds-chip:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
}

.ds-chip.active {
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.ds-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ds-dot-ready {
  background: #1f7a53;
  box-shadow: 0 0 6px rgba(31, 122, 83, 0.5);
}

.ds-dot-syncing {
  background: #0d7c7a;
  box-shadow: 0 0 6px rgba(13, 124, 122, 0.5);
}

.ds-dot-queued {
  background: #c66f1a;
  box-shadow: 0 0 6px rgba(198, 111, 26, 0.4);
}

.ds-dot-failed {
  background: #b73737;
  box-shadow: 0 0 6px rgba(183, 55, 55, 0.5);
}

.ds-table-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.ds-table-scroll {
  overflow-x: auto;
}

.ds-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.ds-table thead th {
  text-align: left;
  padding: 14px 20px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.ds-table tbody td {
  padding: 16px 20px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

.ds-table tbody tr.ds-dimmed {
  opacity: 0.15;
}

.ds-platform-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.ds-platform-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.ds-badge-instagram {
  background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
}

.ds-badge-facebook {
  background: #4267b2;
}

.ds-badge-youtube {
  background: #ff0000;
}

.ds-platform-label {
  font-weight: 500;
}

.ds-source-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.ds-source-url {
  font-size: 12px;
  color: var(--text-secondary);
}

.ds-status-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ds-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.ds-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.ds-pill-ready {
  background: rgba(31, 122, 83, 0.15);
  color: #3cd9a0;
}

.ds-pill-syncing {
  background: rgba(13, 124, 122, 0.15);
  color: #2ec4b6;
}

.ds-pill-queued {
  background: rgba(198, 111, 26, 0.15);
  color: #e8a948;
}

.ds-pill-failed {
  background: rgba(183, 55, 55, 0.15);
  color: #f06060;
}

/* Muted amber for in-progress deletion. Distinct from teal syncing + red
   failed. Conveys "in-progress destructive action" without the alarm red. */
.ds-pill-deleting {
  background: rgba(217, 130, 43, 0.15);
  color: #d9822b;
}

/* Force-cancel is a step harder than regular deletion — slightly more
   saturated amber/orange to signal "escape hatch engaged". */
.ds-pill-force-cancelling {
  background: rgba(192, 80, 0, 0.18);
  color: #c05000;
}

.ds-dot-deleting {
  background: #d9822b;
}

.ds-dot-force-cancelling {
  background: #c05000;
}

/* ===================================================================== */
/* Logs tab — operator-facing ingestion runs view. All classes prefixed   */
/* with .logs- to keep search-time disambiguation clean from .ds-* Data   */
/* Sources classes. Color tokens come from the existing :root palette.    */
/* ===================================================================== */

.logs-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 32px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.logs-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.logs-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--ink);
}

.logs-header-summary {
  font-size: 14px;
  color: var(--ink-soft);
}

.logs-filters {
  display: flex;
  gap: 16px;
  align-items: end;
}

.logs-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--ink-soft);
}

.logs-filter select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
}

.logs-error-banner {
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(183, 55, 55, 0.12);
  color: var(--danger);
  font-size: 14px;
}

.logs-empty {
  padding: 40px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

/* ----- Table ----- */

.logs-table-panel {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

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

.logs-table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.02);
}

html.dark .logs-table thead th {
  background: rgba(255, 255, 255, 0.04);
}

.logs-row td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}

.logs-row:last-child td {
  border-bottom: none;
}

/* ----- Platform chip ----- */

.logs-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 24px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--accent-soft);
  color: var(--accent);
}

.logs-chip-instagram { background: rgba(225, 48, 108, 0.15); color: #c4396a; }
.logs-chip-facebook  { background: rgba(66, 103, 178, 0.15); color: #4267B2; }
.logs-chip-youtube   { background: rgba(255, 68, 68, 0.15);  color: #d93636; }

/* ----- Source label ----- */

.logs-source-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 360px;
}

.logs-source-name {
  font-weight: 500;
  color: var(--ink);
}

.logs-source-url {
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logs-source-url:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ----- Status pill ----- */

.logs-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
}

.logs-pill-success {
  background: rgba(31, 122, 83, 0.15);
  color: #3cd9a0;
}

.logs-pill-failed {
  background: rgba(183, 55, 55, 0.15);
  color: #f06060;
}

.logs-pill-fetching,
.logs-pill-ingesting {
  background: rgba(13, 124, 122, 0.15);
  color: #2ec4b6;
}

.logs-pill-cancelled {
  background: rgba(100, 116, 139, 0.18);
  color: #8a9bb0;
}

/* ----- Relative time ----- */

.logs-time {
  font-size: 13px;
  color: var(--ink-soft);
  cursor: default;
}

/* ----- Stage dots (compact, in row) ----- */

.logs-stage-dots {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.logs-stage-dot {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  position: relative;
}

.logs-stage-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(100, 116, 139, 0.45);
}

.logs-stage-dot-ok::before    { background: #3cd9a0; }
.logs-stage-dot-fail::before  { background: #f06060; }
.logs-stage-dot-skip::before  { background: rgba(100, 116, 139, 0.45); }
.logs-stage-dot-run::before   { background: #2ec4b6; animation: logs-stage-pulse 1.4s ease-in-out infinite; }

@keyframes logs-stage-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

.logs-stage-dot-label {
  font-size: 9.5px;
}

/* ----- Pagination ----- */

.logs-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 4px;
}

.logs-page-status {
  font-size: 13px;
  color: var(--ink-soft);
}

.logs-page-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}

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

.logs-page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

/* Reuse the syncing pulse for in-progress deletion so the UI communicates
   "this is still running, wait for it". */
.ds-pill-deleting .ds-pill-dot,
.ds-pill-force-cancelling .ds-pill-dot {
  animation: ds-pulse 1.8s ease-in-out infinite;
}

.ds-deletion-inflight {
  font-size: 13px;
  color: #d9822b;
  font-style: italic;
}

.ds-deletion-failed-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.ds-deletion-error {
  font-size: 12px;
  color: #f06060;
  max-width: 220px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Force-cancel button: styled like a destructive-but-less-alarming alt
   action. Inherits disabled behavior from ds-remove-btn. */
.ds-force-cancel-btn {
  border: 1px solid rgba(192, 80, 0, 0.4);
  background: rgba(192, 80, 0, 0.12);
  color: #c05000;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ds-force-cancel-btn:hover:not(:disabled) {
  background: rgba(192, 80, 0, 0.22);
  border-color: rgba(192, 80, 0, 0.6);
}

.ds-force-cancel-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


.ds-syncing-extra {
  font-size: 12px;
  color: #2ec4b6;
}

.ds-posts-syncing {
  color: #2ec4b6;
  font-style: italic;
  font-size: 13px;
}

.ds-posts-queued {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 13px;
}

.ds-synced-teal {
  color: #2ec4b6;
  font-size: 13px;
}

.ds-synced-grey {
  color: var(--text-secondary);
  font-size: 13px;
}

.ds-synced-red {
  color: #f06060;
  font-size: 13px;
}

.ds-actions-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ds-ghost-btn {
  padding: 6px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.ds-ghost-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.ds-ghost-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ds-remove-btn {
  background: none;
  border: none;
  color: #f06060;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.ds-remove-btn:hover {
  background: rgba(183, 55, 55, 0.12);
}

/* ----------------------------------------------------------------------------
 * Overflow menu (⋮) — rare row actions (Refetch everything, Remove source).
 * ---------------------------------------------------------------------------- */

.ds-overflow {
  position: relative;
  display: inline-block;
}

.ds-overflow-btn {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}

.ds-overflow-btn:hover,
.ds-overflow-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.ds-overflow-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ds-overflow-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--surface, #1a2030);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 4px;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

/* Portal variant: rendered into document.body to escape the table's
   overflow:hidden clipping. Positioned in viewport coords (top/right
   set inline from getBoundingClientRect). z-index lifted above any
   modal/sticky-header layer. */
.ds-overflow-menu--portal {
  position: fixed;
  top: auto;
  right: auto;
  z-index: 1000;
}

.ds-overflow-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.ds-overflow-item:hover:not(:disabled),
.ds-overflow-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.ds-overflow-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ds-overflow-item-danger {
  color: #f06060;
}

.ds-overflow-item-danger:hover:not(:disabled),
.ds-overflow-item-danger:focus-visible {
  background: rgba(183, 55, 55, 0.12);
}

/* Bottom-sheet variant on narrow viewports — easier to hit with a thumb.
   The .ds-overflow-menu--portal selector is included so that the portal
   variant also collapses to a bottom sheet on mobile (its desktop rules
   for top/right would otherwise win on specificity). The JS side suppresses
   inline top/right positioning on mobile so these declarations take effect. */
@media (max-width: 640px) {
  .ds-overflow-menu,
  .ds-overflow-menu--portal {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    min-width: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 12px 8px env(safe-area-inset-bottom, 12px);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
  }

  .ds-overflow-item {
    padding: 14px 12px;
    font-size: 15px;
    min-height: 44px;
  }
}

/* Refetch confirm inline row — mirrors the Remove confirm pattern but in teal
   (expensive action, not destructive). */
.ds-confirm-overlay-refetch {
  background: rgba(13, 124, 122, 0.08);
  border: 1px solid rgba(13, 124, 122, 0.3);
}

.ds-confirm-text-refetch {
  color: var(--text-primary);
}

.ds-confirm-refetch {
  background: #0d7c7a;
  color: #fff;
}

.ds-confirm-refetch:hover {
  background: #0b6968;
}

.ds-error-row td {
  padding: 0 20px 16px;
}

.ds-error-toggle {
  background: none;
  border: none;
  color: #f06060;
  font-size: 12px;
  font-family: inherit;
  padding: 0 0 4px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.75;
}

.ds-error-toggle:hover {
  opacity: 1;
}

.ds-error-banner {
  display: block;
  background: rgba(183, 55, 55, 0.08);
  border-left: 3px solid #b73737;
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin-top: 8px;
  color: #f06060;
  font-size: 12px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

@keyframes ds-row-flash {
  0% {
    background: rgba(13, 124, 122, 0.2);
  }
  100% {
    background: transparent;
  }
}

.ds-row-highlight {
  animation: ds-row-flash 1.5s ease-out forwards;
}

@keyframes ds-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.ds-pill-syncing .ds-pill-dot {
  animation: ds-pulse 1.8s ease-in-out infinite;
}

.ds-confirm-row td {
  padding-top: 0 !important;
  border-top: none !important;
}

.ds-confirm-overlay {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(183, 55, 55, 0.08);
  border: 1px solid rgba(183, 55, 55, 0.2);
  border-radius: 10px;
  padding: 12px 16px;
}

.ds-confirm-text {
  flex: 1;
  font-size: 13px;
  color: #f06060;
}

.ds-confirm-btn {
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.ds-confirm-remove {
  background: #b73737;
  color: #fff;
}

.ds-confirm-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.ds-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.ds-empty-state h3 {
  font-family: var(--font-display);
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.ds-empty-state p {
  font-size: 14px;
  line-height: 1.6;
}

.ds-empty-state-soon {
  margin-top: 10px;
  font-size: 13px;
  color: #e8a948;
  opacity: 0.85;
}

/* ── Supported-platforms chip row (sits below URL input) ── */

.ds-supported-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  background: transparent;
}

.ds-supported-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  opacity: 0.7;
  margin-right: 4px;
}

.ds-supported-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.ds-supported-chip-icon {
  display: inline-flex;
  align-items: center;
}

.ds-supported-chip-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.ds-supported-chip--soon {
  opacity: 0.6;
  color: var(--text-secondary);
  border-style: dashed;
}

.ds-supported-chip--soon .ds-supported-chip-icon {
  filter: grayscale(0.6);
}

.ds-supported-chip-tag {
  margin-left: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 6px;
  border-radius: 100px;
  background: rgba(232, 169, 72, 0.15);
  color: #e8a948;
}

/* ── Coming-soon hint shown under the input when a YouTube URL is detected ── */

.ds-coming-soon-hint {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 16px 14px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(232, 169, 72, 0.3);
  background: rgba(232, 169, 72, 0.08);
}

.ds-coming-soon-hint-title {
  font-size: 13px;
  font-weight: 600;
  color: #e8a948;
}

.ds-coming-soon-hint-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ── Paused treatment for existing YouTube rows in the table ── */

.ds-platform-badge--paused {
  opacity: 0.55;
  filter: saturate(0.7);
}

.ds-platform-soon-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(232, 169, 72, 0.15);
  color: #e8a948;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ---------------------------------------------------------------------------
   Test Chat (tc-* prefix)
   --------------------------------------------------------------------------- */

.test-chat-section {
  display: grid;
  gap: 14px;
}

/* Source pills */
.source-test-chat {
  background: rgba(124, 58, 237, 0.12);
  color: #7c3aed;
  border-color: rgba(124, 58, 237, 0.22);
}
html.dark .source-test-chat {
  background: rgba(167, 139, 250, 0.16);
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.28);
}
.source-messenger {
  background: rgba(0, 120, 212, 0.1);
  color: #0078d4;
  border-color: rgba(0, 120, 212, 0.2);
}
html.dark .source-messenger {
  background: rgba(96, 176, 255, 0.16);
  color: #60b0ff;
  border-color: rgba(96, 176, 255, 0.28);
}

/* Session bar */
.tc-session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  flex-wrap: wrap;
}
.tc-session-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tc-field-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted, var(--ink-soft));
}
.tc-field-value {
  font-size: 0.88rem;
  font-weight: 600;
}
.tc-mono {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.78rem;
  opacity: 0.7;
}
.tc-session-sep {
  width: 1px;
  height: 22px;
  background: var(--separator, var(--line));
  flex-shrink: 0;
}
.tc-tiny-button {
  border: 1px solid var(--separator, var(--line));
  background: #fff;
  color: var(--ink-muted, var(--ink-soft));
  font-size: 0.78rem;
  padding: 4px 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s;
}
html.dark .tc-tiny-button {
  background: rgba(30, 40, 52, 0.9);
  color: var(--ink-muted, var(--ink-soft));
  border-color: rgba(200, 220, 240, 0.15);
}

/* Chat window */
.tc-chat-window {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 280px);
  min-height: 400px;
  overflow: hidden;
}

/* Chat header */
.tc-chat-top {
  padding: 15px 22px;
  border-bottom: 1px solid var(--separator, var(--line));
  display: flex;
  align-items: center;
  gap: 13px;
  flex-shrink: 0;
}
.tc-chat-top-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  font-family: var(--font-display, "Space Grotesk", sans-serif);
}
.tc-chat-top-info {
  flex: 1;
}
.tc-chat-top-name {
  font-family: var(--font-display, "Space Grotesk", sans-serif);
  font-weight: 700;
  font-size: 0.95rem;
}
.tc-chat-top-meta {
  font-size: 0.75rem;
  color: var(--ink-muted, var(--ink-soft));
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tc-online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

/* Messages */
.tc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tc-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.tc-chat-messages::-webkit-scrollbar-thumb {
  background: var(--separator, var(--line));
  border-radius: 4px;
}
.tc-empty-state {
  text-align: center;
  color: var(--ink-muted, var(--ink-soft));
  font-size: 0.9rem;
  padding: 48px 24px;
  line-height: 1.6;
}

/* Bubble rows */
.tc-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}
.tc-bubble-row.tc-user {
  flex-direction: row-reverse;
}
.tc-bubble-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
.tc-bot-av {
  background: var(--accent);
}
.tc-bubble-col {
  display: flex;
  flex-direction: column;
  max-width: 60%;
}
.tc-bubble-col.tc-user {
  align-items: flex-end;
}
.tc-bubble {
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  line-height: 1.54;
  word-break: break-word;
  white-space: pre-wrap;
}
.tc-bubble-user {
  background: linear-gradient(140deg, var(--accent), var(--accent-dark, #095b59));
  color: #fff;
  border-bottom-right-radius: 5px;
}
.tc-bubble-bot {
  background: linear-gradient(178deg, rgba(255, 255, 255, 0.88), var(--panel-bg, var(--card-bg, rgba(255,255,255,0.8))));
  border: 1px solid var(--card-border, var(--line));
  color: var(--ink);
  border-bottom-left-radius: 5px;
}
html.dark .tc-bubble-bot {
  background: rgba(30, 38, 50, 0.9);
  border-color: rgba(200, 220, 240, 0.1);
}
.tc-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.tc-link:hover { opacity: 0.75; }
.tc-bubble-error {
  border-color: var(--danger) !important;
  color: var(--danger) !important;
}
.tc-bubble-meta {
  font-size: 0.68rem;
  color: var(--ink-muted, var(--ink-soft));
  margin-top: 4px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tc-user-meta {
  justify-content: flex-end;
}
.tc-latency {
  opacity: 0.6;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.65rem;
}

/* Typing indicator */
.tc-typing-bubble {
  background: linear-gradient(178deg, rgba(255, 255, 255, 0.88), var(--panel-bg, var(--card-bg, rgba(255,255,255,0.8))));
  border: 1px solid var(--card-border, var(--line));
  border-radius: 20px;
  border-bottom-left-radius: 5px;
  padding: 13px 17px;
  display: flex;
  gap: 5px;
  align-items: center;
}
html.dark .tc-typing-bubble {
  background: rgba(30, 38, 50, 0.9);
  border-color: rgba(200, 220, 240, 0.1);
}
.tc-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-muted, var(--ink-soft));
  animation: tc-bounce 1.2s infinite;
}
.tc-typing-dot:nth-child(2) {
  animation-delay: 0.18s;
}
.tc-typing-dot:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes tc-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Input bar */
.tc-chat-input-bar {
  padding: 13px 20px;
  border-top: 1px solid var(--separator, var(--line));
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
.tc-chat-input {
  flex: 1;
  resize: none;
  border-radius: 12px;
}
.tc-send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), var(--accent-dark, #095b59));
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: filter 0.15s, transform 0.1s;
}
.tc-send-btn:hover {
  filter: brightness(0.93);
}
.tc-send-btn:active {
  transform: scale(0.95);
}
.tc-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Logs tab — RunDetailCard + ErrorPanel + decorations ---------- */

.logs-row-expandable {
  cursor: pointer;
}

.logs-row-expandable:hover {
  background: rgba(13, 124, 122, 0.04);
}

html.dark .logs-row-expandable:hover {
  background: rgba(46, 196, 182, 0.06);
}

.logs-row-expanded td {
  border-bottom: none;
}

/* Chevron column — visible only on expandable rows; rotates 180° when open. */
.logs-row-chevron-cell {
  width: 28px;
  text-align: right;
  padding-right: 16px !important;
}

.logs-chevron {
  display: inline-block;
  font-size: 14px;
  line-height: 1;
  color: var(--ink-soft, rgba(255, 255, 255, 0.55));
  transition: transform 160ms ease-out, color 160ms ease-out;
  transform: rotate(0deg);
  user-select: none;
}

.logs-row-expandable:hover .logs-chevron {
  color: var(--ink, rgba(255, 255, 255, 0.85));
}

.logs-chevron-open {
  transform: rotate(180deg);
  color: var(--ink, rgba(255, 255, 255, 0.85));
}

.logs-detail-row td {
  padding: 0;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid var(--line);
}

html.dark .logs-detail-row td {
  background: rgba(255, 255, 255, 0.03);
}

.logs-detail-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 20px;
}

/* ----- Stage cells (large boxes with tooltips) ----- */

.logs-stage-cells {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.logs-stage-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: help;
}

.logs-stage-cell-name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
}

.logs-stage-cell-count {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.logs-stage-cell-duration {
  font-size: 12px;
  color: var(--ink-soft);
}

.logs-stage-cell-ok {
  border-color: rgba(31, 122, 83, 0.35);
}

.logs-stage-cell-fail {
  border-color: rgba(183, 55, 55, 0.5);
  background: rgba(183, 55, 55, 0.06);
}

.logs-stage-cell-run {
  border-color: rgba(13, 124, 122, 0.45);
  background: rgba(13, 124, 122, 0.06);
}

.logs-stage-cell-skip {
  opacity: 0.6;
}

/* ----- Error panel ----- */

.logs-error-panel {
  border: 1px solid rgba(183, 55, 55, 0.3);
  border-radius: 8px;
  background: rgba(183, 55, 55, 0.05);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logs-error-code {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--danger);
}

.logs-error-headline {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.logs-error-body,
.logs-error-summary {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.logs-error-summary {
  font-size: 12px;
  font-style: italic;
  opacity: 0.85;
}

/* ----- Trace preview (<details>) ----- */

.logs-trace-preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 8px 10px;
}

.logs-trace-preview > summary {
  cursor: pointer;
  list-style: none;
  outline: none;
}

.logs-trace-preview > summary::-webkit-details-marker {
  display: none;
}

.logs-trace-preview > summary::before {
  content: "▸ ";
  color: var(--ink-soft);
  margin-right: 4px;
}

.logs-trace-preview[open] > summary::before {
  content: "▾ ";
}

.logs-trace-summary,
.logs-trace-full {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 4px 0;
}

.logs-trace-full {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.logs-trace-empty {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
}

/* ----- Action buttons ----- */

.logs-error-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.logs-retry-btn,
.logs-copy-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.logs-retry-btn {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.logs-retry-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

.logs-copy-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.logs-copy-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.logs-retry-btn:disabled,
.logs-copy-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ----- Deletion-source row decorations ----- */

.logs-source-deleting-badge,
.logs-source-force-cancelling-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  vertical-align: middle;
}

.logs-source-deleting-badge {
  background: rgba(100, 116, 139, 0.18);
  color: #8a9bb0;
}

.logs-source-force-cancelling-badge {
  background: rgba(183, 55, 55, 0.18);
  color: var(--danger);
}

/* ----- Cancelling spinner overlay on the status pill ----- */

.logs-cancelling-overlay {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  margin-right: 6px;
  animation: logs-spin 0.9s linear infinite;
}

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

/* Live BrightData snapshot status surfaced under the syncing pill. Populated
   by the status_callback hook once syft_ingest 0.2.0+ is in use. */
.ds-bd-status {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Yellow banner shown next to a syncing row when its acquisition_updated_at
   hasn't advanced in >15 min (status_callback isn't firing). Time-since-last-
   change beats a status whitelist — BrightData may emit values we haven't
   enumerated, but a frozen timestamp is unambiguous. */
.ds-stuck-banner {
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  border-left: 3px solid #f59e0b;
}
