:root {
  --bg: #faf7f2;
  --paper: #ffffff;
  --ink: #1e2430;
  --muted: #5b6475;
  --grid-dot: #d6cfc2;
  --orange: #ff8a4c;
  --sky: #4ea8de;
  --mint: #38b28b;
  --lavender: #9b72cf;
  --butter: #ffd166;
  --coral: #ef6f6c;
  --border: 2px solid #1e2430;
  --shadow: 4px 4px 0 #1e2430;
  --shadow-sm: 2px 2px 0 #1e2430;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.4;
}

h1, h2, h3, h4, p {
  margin: 0;
}

.hidden {
  display: none !important;
}

/* Top Bar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: var(--paper);
  border-bottom: var(--border);
}

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

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--butter);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 16px;
}

.brand h1 {
  font-size: 1.2rem;
  font-weight: 800;
}

.subtitle {
  font-size: 0.84rem;
  color: var(--muted);
}

.hud-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--paper);
}

.pill-mint { background: #d4f5e9; }
.pill-butter { background: #fff1c2; }
.pill-coral { background: #ffe0df; }
.pill-sky { background: #dcf0fc; }
.pill-btn { cursor: pointer; }
.pill-btn:hover { transform: translate(-1px, -1px); }

/* Launch Bar */
.launch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 12px 22px;
  background: #f3ede2;
  border-bottom: var(--border);
}

.icp-field {
  flex: 1 1 360px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.limit-field {
  width: 84px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label, .field-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: var(--border);
  background: var(--paper);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--ink);
}

.launch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  padding: 9px 15px;
  border-radius: 11px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #1e2430;
}

.btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1e2430;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.btn-primary { background: var(--sky); color: #ffffff; }
.btn-butter { background: var(--butter); }
.btn-mint { background: var(--mint); color: #ffffff; }
.btn-coral { background: var(--coral); color: #ffffff; }
.btn-lavender { background: var(--lavender); color: #ffffff; }
.btn-ghost { background: var(--paper); }

.banner {
  margin: 12px 22px 0;
  padding: 10px 14px;
  border-radius: 12px;
  border: var(--border);
  background: #fff1c2;
  font-weight: 700;
  font-size: 0.9rem;
}

.banner.banner-error {
  background: #ffe0df;
}

.banner.banner-success {
  background: #d4f5e9;
}

/* Main Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 16px 22px;
}

@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.canvas-panel,
.inspector-card,
.radio-card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.canvas-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: var(--border);
  background: #fcfaf5;
}

.panel-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.canvas-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.concurrency-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  text-transform: none;
}

.workshop-canvas {
  position: relative;
  height: 520px;
  overflow: auto;
  background-color: #fbf8f1;
  background-image: radial-gradient(var(--grid-dot) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  user-select: none;
}

.wire-layer {
  position: absolute;
  inset: 0;
  width: 995px;
  height: 520px;
  pointer-events: none;
}

.bot-layer {
  position: relative;
  width: 995px;
  height: 520px;
}

.wire-path {
  fill: none;
  stroke: #b9b1a2;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 8 7;
}

.wire-path.active {
  stroke: var(--sky);
  animation: dash-flow 0.9s linear infinite;
}

.wire-path.paused {
  stroke: #d7d0c3;
  opacity: 0.5;
}

@keyframes dash-flow {
  to {
    stroke-dashoffset: -30;
  }
}

/* Cute Bot Node */
.bot-node {
  position: absolute;
  width: 176px;
  padding: 9px 9px 9px;
  border-radius: 18px;
  border: var(--border);
  background: var(--paper);
  box-shadow: var(--shadow);
  cursor: grab;
  transition: box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.bot-node:active {
  cursor: grabbing;
}

.bot-node.selected {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

.bot-node.paused {
  opacity: 0.68;
  background: #f4f1ea;
}

.bot-node.drop-target-hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 4px var(--butter), var(--shadow);
}

.bot-speech {
  font-size: 0.72rem;
  font-weight: 700;
  background: #fff7df;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  padding: 4px 7px;
  margin-bottom: 6px;
  min-height: 30px;
  display: flex;
  align-items: center;
}

.bot-head-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bot-svg-wrap {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  animation: bot-float 3s ease-in-out infinite;
}

.bot-node.working .bot-svg-wrap {
  animation: bot-bounce 0.55s ease-in-out infinite;
}

.bot-node.paused .bot-svg-wrap {
  animation: none;
}

@keyframes bot-float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-3px); }
}

@keyframes bot-bounce {
  0%, 100% { transform: translateY(0px) rotate(-2deg); }
  50% { transform: translateY(-5px) rotate(2deg); }
}

.bot-meta {
  min-width: 0;
  flex: 1;
}

.bot-title {
  font-size: 0.9rem;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-role {
  font-size: 0.73rem;
  color: var(--muted);
}

.bot-footer {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  background: #eef2f7;
}

.status-badge.working { background: #cbeafe; }
.status-badge.happy { background: #d4f5e9; }
.status-badge.waiting_approval { background: var(--butter); }
.status-badge.paused { background: #e8e2d7; }
.status-badge.error { background: #ffe0df; }

.bot-quick-btns {
  display: flex;
  gap: 4px;
}

.mini-btn {
  padding: 3px 7px;
  border-radius: 8px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
}

.mini-btn:hover {
  background: var(--butter);
}

/* Inspector & Radio */
.inspector-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inspector-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.inspector-avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
}

.inspector-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.booker-quick-panel {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1.5px dashed #cfc7b8;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.booker-quick-panel h3 {
  font-size: 0.84rem;
}

.radio-card {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 170px;
}

.radio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sse-pill {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: #d4f5e9;
}

.activity-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 175px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.activity-item {
  font-size: 0.78rem;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f7f3eb;
  border: 1px solid #dfd7c9;
}

.activity-item.error {
  background: #ffe7e6;
  border-color: var(--coral);
}

/* Conveyor / Kanban */
.conveyor-section {
  padding: 4px 22px 28px;
}

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

.reject-dropzone {
  padding: 9px 16px;
  border-radius: 12px;
  border: 2px dashed var(--coral);
  background: #fff2f1;
  font-size: 0.82rem;
  font-weight: 800;
  color: #a12f2d;
}

.reject-dropzone.drag-over {
  background: #ffd4d2;
  transform: scale(1.03);
}

.kanban-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
}

@media (max-width: 1020px) {
  .kanban-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 620px) {
  .kanban-grid {
    grid-template-columns: 1fr;
  }
}

.kanban-col {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 250px;
}

.col-header {
  padding: 10px 12px;
  border-bottom: var(--border);
  border-radius: 14px 14px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 900;
  font-size: 0.86rem;
}

.col-orange { background: #ffe3d1; }
.col-butter { background: #fff0bd; }
.col-mint { background: #d4f5e9; }
.col-lavender { background: #eadcf9; }

.col-count {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.76rem;
}

.col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.col-body.drag-over {
  background: #f5f9ff;
  outline: 2px dashed var(--sky);
  outline-offset: -4px;
}

.lead-card {
  padding: 10px;
  border-radius: 12px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  background: #fffdf9;
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lead-card:active {
  cursor: grabbing;
}

.card-title {
  font-weight: 900;
  font-size: 0.88rem;
}

.card-sub {
  font-size: 0.76rem;
  color: var(--muted);
}

.card-subject {
  font-size: 0.78rem;
  font-weight: 700;
  background: #f5f1e8;
  padding: 4px 6px;
  border-radius: 6px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.empty-col-msg {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-top: 24px;
}

/* Modals */
body.modal-open,
body:has(.modal-backdrop:not(.hidden)) {
  overflow: hidden;
  overscroll-behavior: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 36, 48, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-card {
  width: min(740px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  border: var(--border);
  border-radius: 18px;
  box-shadow: 8px 8px 0 #1e2430;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-card > * {
  flex-shrink: 0;
}

.modal-card-sm {
  width: min(520px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-signals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: #faf6ee;
  border: 1.5px solid #dcd3c2;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.82rem;
}

.modal-signals h4 {
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.modal-signals ul {
  margin: 0;
  padding-left: 18px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-copy {
  font-size: 0.88rem;
  color: var(--muted);
}

.preview-box {
  background: #faf6ee;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-line {
  font-size: 0.82rem;
  font-weight: 700;
}

.preview-body {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.82rem;
  max-height: 200px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.modal-footer-right {
  display: flex;
  gap: 8px;
}

.error-text {
  color: #b42318;
  font-size: 0.84rem;
  font-weight: 700;
}

/* Dedicated Outreach Draft Studio (/review) */
.link-pill {
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
}

.mini-link {
  font-size: 0.8rem;
  font-weight: 800;
  color: #185abc;
  text-decoration: none;
}

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

.studio-body {
  min-height: 100vh;
  background-color: #f6f2ea;
}

.studio-grid {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 22px 32px;
  align-items: start;
}

@media (max-width: 1060px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
}

.studio-left,
.studio-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.studio-card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.intel-block {
  background: #faf6ee;
  border: 1.5px solid #dfd7c7;
  border-radius: 12px;
  padding: 10px 12px;
}

.intel-scroll {
  max-height: 220px;
  overflow-y: auto;
}

.intel-block h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.intel-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.84rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coach-card {
  background: #fdfcff;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: #eef6ff;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
}

.chip-btn:hover {
  background: var(--butter);
}

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

.ai-suggestion {
  margin-top: 4px;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--sky);
  background: #f2f9ff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-suggestion-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-rationale {
  font-size: 0.8rem;
  color: var(--muted);
}

.composer-card {
  padding: 18px;
  gap: 14px;
}

.composer-topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.composer-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-tabs {
  display: inline-flex;
  border: var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #f4efe6;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 6px 11px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
}

.tab-btn.active {
  background: var(--butter);
}

.envelope-grid {
  border: var(--border);
  border-radius: 14px;
  background: #fcfaf5;
  overflow: hidden;
}

.env-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1.5px solid #e4dccd;
}

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

.env-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}

.env-static {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.env-row input {
  border: 1.5px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 700;
}

.env-row input:focus {
  outline: none;
  border-color: var(--sky);
  background: var(--paper);
}

.composer-panes {
  display: grid;
  gap: 14px;
}

.composer-panes.mode-split {
  grid-template-columns: 1fr 1fr;
}

.composer-panes.mode-write {
  grid-template-columns: 1fr;
}

.composer-panes.mode-write .preview-pane {
  display: none;
}

.composer-panes.mode-preview {
  grid-template-columns: 1fr;
}

.composer-panes.mode-preview .editor-pane {
  display: none;
}

@media (max-width: 900px) {
  .composer-panes.mode-split {
    grid-template-columns: 1fr;
  }
}

.editor-pane,
.preview-pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.email-body-textarea {
  height: 360px;
  min-height: 320px;
  line-height: 1.65;
  font-size: 0.96rem;
  padding: 14px;
  resize: vertical;
}

.inbox-preview-card {
  height: 460px;
  min-height: 340px;
  border: var(--border);
  border-radius: 14px;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.inbox-preview-head {
  flex-shrink: 0;
  padding: 12px 14px;
  background: #faf7f0;
  border-bottom: 1.5px solid #e4dccd;
}

.inbox-subject {
  font-weight: 900;
  font-size: 0.98rem;
  margin-bottom: 2px;
}

.inbox-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.inbox-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 18px;
  font-size: 0.94rem;
  line-height: 1.68;
  color: #1f2937;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.preview-para {
  margin: 0 0 12px;
}

.preview-para:last-child {
  margin-bottom: 0;
}

.studio-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  border-top: 1.5px dashed #d6cebe;
}

.studio-footer-right {
  display: flex;
  gap: 10px;
}

/* Lead & Draft Contact Email Visibility */
.conveyor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.card-contact-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-email-pill {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #144332;
  background: #d8f5ea;
  border: 1.5px solid #1e2430;
  border-radius: 8px;
  padding: 4px 8px;
  word-break: break-all;
}

.card-email-pill.role {
  background: #e5f3fc;
  color: #143d59;
}

.card-email-pill.missing {
  background: #fff3d6;
  color: #6b4700;
}

.email-tag {
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid #1e2430;
  background: #ffffff;
  color: #1e2430;
}

.card-contact-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.card-mini-link {
  font-size: 0.72rem;
  font-weight: 800;
  color: #185abc;
  text-decoration: none;
}

.card-mini-link:hover {
  text-decoration: underline;
}

.studio-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.to-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.to-input-wrap input {
  flex: 1 1 auto;
}

.contact-intel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 10px;
  background: #f5efe3;
  border-bottom: 1.5px solid #e4dccd;
  font-size: 0.78rem;
}

.confidence-pill {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  font-size: 0.7rem;
  font-weight: 800;
  background: #ffffff;
}

.confidence-pill.verified { background: #d4f5e9; }
.confidence-pill.role { background: #dcf0fc; }
.confidence-pill.missing { background: #fff1c2; }

.alt-email-group {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: #ffffff;
  overflow: hidden;
}

.alt-email-chip {
  padding: 3px 9px;
  border: none;
  background: #ffffff;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.alt-email-chip:hover:not(:disabled) {
  background: var(--butter);
}

.alt-email-chip.active-to {
  background: #d4f5e9;
  color: #0b4f3a;
}

.alt-email-cc-btn {
  padding: 3px 8px;
  border: none;
  border-left: 1px solid #cbd5e1;
  background: #f8fafc;
  font-family: inherit;
  font-size: 0.69rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--muted);
}

.alt-email-cc-btn:hover:not(:disabled) {
  background: #e0f2fe;
  color: #1e3a8a;
}

.alt-email-cc-btn.active-cc {
  background: #dbeafe;
  color: #1e3a8a;
}

.email-token-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  min-height: 38px;
  cursor: text;
}

.email-token-box:focus-within {
  border-color: var(--sky);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.16);
}

.email-token-list {
  display: contents;
}

.email-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #d4f5e9;
  border: 1px solid #6ee7b7;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0b4f3a;
  max-width: 100%;
  word-break: break-all;
}

.email-pill.email-pill-cc {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e3a8a;
}

.email-pill-remove {
  border: none;
  background: transparent;
  color: inherit;
  font-weight: 900;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.72;
}

.email-pill-remove:hover:not(:disabled) {
  opacity: 1;
}

.env-row .email-token-input,
.email-token-input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 3px 4px !important;
  flex: 1 1 160px;
  min-width: 130px;
  width: auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.test-alt-emails {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 0.74rem;
  border-radius: 9px;
}

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

/* Compact Test Email Drawer & Section */
.test-email-drawer {
  background: #faf6ee;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.test-drawer-head h3 {
  font-size: 0.88rem;
  font-weight: 800;
}

.test-drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 720px) {
  .test-drawer-grid {
    grid-template-columns: 1fr;
  }
}

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

.test-drawer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.smtp-subbox {
  margin-top: 6px;
  padding: 10px 12px;
  background: #faf6ee;
  border: 1.5px dashed #b9b09f;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.smtp-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
}

/* Branded Faktry AI Email Preview Card (CSP-safe) */
.branded-email-shell {
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.branded-email-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.branded-email-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.branded-email-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  object-fit: contain;
  background: #ffffff;
}

.branded-email-wordmark {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.branded-email-accent {
  color: #059669;
}

.branded-sidecar-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 3px 9px;
}

.branded-email-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.branded-test-note {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 9px 12px;
}

.branded-test-note-title {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #92400e;
  margin-bottom: 3px;
}

.branded-test-note-body {
  font-size: 0.8rem;
  color: #78350f;
  line-height: 1.45;
}

.brand-inline-link {
  color: #059669;
  font-weight: 600;
  word-break: break-all;
}

.branded-cta-wrap {
  margin: 4px 0;
}

.branded-cta-btn {
  display: inline-block;
  background: #059669;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 999px;
}

.branded-cta-btn:hover {
  background: #047857;
}

.branded-impact-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.branded-impact-cell {
  padding: 8px 6px;
  text-align: center;
  border-right: 1px solid #e2e8f0;
}

.branded-impact-cell:last-child {
  border-right: none;
}

.branded-impact-val {
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
}

.branded-impact-lbl {
  font-size: 0.68rem;
  color: #475569;
}

.branded-agents-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.branded-agents-heading {
  font-size: 0.78rem;
  font-weight: 800;
  color: #0f172a;
}

.branded-agents-sub {
  font-size: 0.72rem;
  color: #475569;
  line-height: 1.45;
}

.branded-orchestration-bar {
  font-size: 0.69rem;
  font-weight: 700;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 6px 9px;
}

.branded-agents-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.branded-agent-card {
  border-radius: 12px;
  padding: 9px 11px;
  border: 1px solid #e2e8f0;
  border-left-width: 4px;
}

.branded-agent-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.branded-agent-avatar {
  width: 44px;
  height: 48px;
  flex-shrink: 0;
  object-fit: contain;
}

.branded-agent-info {
  flex: 1 1 auto;
  min-width: 0;
}

.agent-tone-bom_guard { background: #ecfdf5; border-color: #a7f3d0; border-left-color: #10b981; }
.agent-tone-cost_sentry { background: #fffbeb; border-color: #fde68a; border-left-color: #f59e0b; }
.agent-tone-line_pulse { background: #eff6ff; border-color: #bfdbfe; border-left-color: #3b82f6; }
.agent-tone-quality_shield { background: #fff1f2; border-color: #fecdd3; border-left-color: #f43f5e; }
.agent-tone-plant_beacon { background: #eef2ff; border-color: #c7d2fe; border-left-color: #6366f1; }

.branded-agent-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.branded-agent-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f172a;
}

.branded-agent-code {
  color: #334155;
  font-weight: 700;
}

.branded-agent-cadence {
  font-size: 0.62rem;
  font-weight: 700;
  color: #475569;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 1px 6px;
  white-space: nowrap;
}

.branded-agent-desc {
  font-size: 0.72rem;
  line-height: 1.4;
  color: #334155;
}

.branded-email-footer {
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 0.74rem;
  color: #64748b;
}

.branded-email-footer strong {
  color: #0f172a;
}

.branded-unsub-row {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #e2e8f0;
  font-size: 0.7rem;
  color: #64748b;
}

.branded-unsub-btn {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: #475569;
  font-weight: 600;
}

.unsub-email-pill {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 12px;
  background: #f8fafc;
  border: var(--border);
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--ink);
}

.unsub-suppress-box {
  margin-top: 8px;
  padding: 8px 10px;
  background: #fff5f5;
  border: 1.5px solid #fecdd3;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.unsub-suppress-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #9f1239;
}

.unsub-suppress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.74rem;
  color: #881337;
}

.clean-email-shell {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #1f2937;
}

.clean-test-note {
  margin-bottom: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border-left: 3px solid #94a3b8;
  font-size: 0.8rem;
  color: #334155;
}

.clean-email-para {
  margin: 0 0 11px;
}

.clean-email-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  font-size: 0.74rem;
  color: #6b7280;
}

.clean-unsub-link {
  color: #4b5563;
  text-decoration: underline;
}

.test-modal-card {
  width: min(1140px, 100%);
  height: min(88vh, 840px);
  overflow: hidden;
}

.test-modal-card > .test-modal-split {
  flex: 1 1 auto;
  flex-shrink: 1;
  min-height: 0;
}

.test-modal-split {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(380px, 1.15fr);
  gap: 16px;
  overflow: hidden;
}

.test-modal-controls {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.test-modal-controls .test-drawer-grid {
  grid-template-columns: 1fr;
}

.test-modal-preview-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: var(--border);
  border-radius: 14px;
  background: #ffffff;
  overflow: hidden;
}

.test-preview-head {
  flex-shrink: 0;
}

.test-preview-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  background: #f8fafc;
}

@media (max-width: 860px) {
  .clean-email-shell {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #1f2937;
}

.clean-test-note {
  margin-bottom: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border-left: 3px solid #94a3b8;
  font-size: 0.8rem;
  color: #334155;
}

.clean-email-para {
  margin: 0 0 11px;
}

.clean-email-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  font-size: 0.74rem;
  color: #6b7280;
}

.clean-unsub-link {
  color: #4b5563;
  text-decoration: underline;
}

.test-modal-card {
    height: auto;
    max-height: 92vh;
    overflow-y: auto;
  }

  .test-modal-card > .test-modal-split {
    flex: 0 0 auto;
  }

  .test-modal-split {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .test-modal-controls {
    overflow: visible;
    padding-right: 0;
  }

  .test-modal-preview-pane {
    min-height: 360px;
  }

  .test-preview-scroll {
    max-height: 55vh;
  }
}

/* Sign-In Gate */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--paper);
  border: var(--border);
  border-radius: 18px;
  box-shadow: 8px 8px 0 #1e2430;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-logo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  object-fit: contain;
  background: #ffffff;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: #ffffff;
  color: var(--ink);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

.btn-google:hover {
  background: #f8fafc;
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #d6cfc2;
}

/* Delivery Response Banners & Log Card Badges */
.result-banner {
  padding: 10px 12px;
  border-radius: 12px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.4;
}

.result-sent {
  background: #d4f5e9;
  color: #0b4f3a;
}

.result-dryrun {
  background: #fff1c2;
  color: #6b4e00;
}

.result-failed {
  background: #ffe0df;
  color: #7f1d1d;
}

.lead-card.log-sent {
  border-left: 5px solid var(--mint);
}

.lead-card.log-dryrun {
  border-left: 5px solid var(--butter);
}

.lead-card.log-failed {
  border-left: 5px solid var(--coral);
}

.lead-card.log-hidden {
  opacity: 0.68;
  border-style: dashed;
}

.sent-log-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  padding-bottom: 4px;
  border-bottom: 1px dashed #d6cfc2;
}

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-time {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}

.hidden-pill {
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  background: #ede9fe;
  color: #4c1d95;
  border: 1px solid #c4b5fd;
  white-space: nowrap;
}

.schedule-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 8px;
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid #93c5fd;
}

.schedule-error-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--mint);
}

.studio-schedule-bar {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.studio-schedule-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.studio-schedule-controls input[type="datetime-local"] {
  width: auto;
  flex: 1 1 190px;
}

.result-scheduled {
  background: #dbeafe;
  color: #1e3a8a;
}

.test-schedule-box {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.test-schedule-box .checkbox-row {
  margin-top: 0;
}

.test-schedule-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.test-schedule-controls input[type="datetime-local"] {
  width: auto;
  flex: 1 1 180px;
}

.scheduled-test-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed #cbd5e1;
}

.scheduled-test-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.74rem;
}

.scheduled-test-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 600;
}
