:root {
  --radius: 8px;
  --radius-sm: 6px;
  --radius-full: 9999px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Menlo", "Consolas", monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f19;
  --surface: #111827;
  --card: #1f2937;
  --card-hover: #374151;
  --border: #374151;
  --border-subtle: #1f2937;
  --text: #f9fafb;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --accent-dim: rgba(59, 130, 246, 0.12);
  --accent-border: rgba(59, 130, 246, 0.4);
  --accent-glow: transparent;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.15);
  --red: #f43f5e;
  --red-dim: rgba(244, 63, 94, 0.15);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --purple: #8b5cf6;
  --purple-dim: rgba(139, 92, 246, 0.15);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-dim: rgba(37, 99, 235, 0.08);
  --accent-border: rgba(37, 99, 235, 0.35);
  --accent-glow: transparent;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.08);
  --green: #059669;
  --green-dim: rgba(5, 150, 105, 0.1);
  --red: #e11d48;
  --red-dim: rgba(225, 29, 72, 0.1);
  --orange: #d97706;
  --orange-dim: rgba(217, 119, 6, 0.1);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.1);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: calc(76px + var(--safe-bottom));
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── HEADER ─── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px 8px;
  box-shadow: var(--shadow-sm);
}

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

.header-top h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-top h1 span {
  color: var(--text-muted);
  font-weight: 500;
}

.header-user {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 8px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  margin-left: 6px;
  letter-spacing: 0.02em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timestamp {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

#refresh-btn, .btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
}
#refresh-btn:hover, .btn-icon:hover {
  background: var(--card-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

/* ─── KPI STRIP ─── */
.kpi-strip {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  padding: 10px 0 4px;
  scrollbar-width: none;
}
.kpi-strip::-webkit-scrollbar { display: none; }

.kpi-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  flex-shrink: 0;
  font-size: 13px;
}
.kpi-item::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kpi-item:nth-child(1)::before { background: var(--blue); }
.kpi-item:nth-child(2)::before { background: var(--orange); }
.kpi-item:nth-child(3)::before { background: var(--accent); }
.kpi-item:nth-child(4)::before { background: var(--red); }
.kpi-item:nth-child(5)::before { background: var(--green); }
.kpi-item:nth-child(6)::before { background: var(--green); }

.kpi-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}

.kpi-item.target {
  background: var(--accent-dim);
  border-color: var(--accent-border);
}
.kpi-item.target::before { background: var(--accent); }

.kpi-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.kpi-val {
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ─── BOTTOM NAV BAR ─── */
nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 4px calc(8px + var(--safe-bottom));
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  border-top: 2px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px calc(6px + var(--safe-bottom));
  transition: all 0.15s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.tab .tab-icon {
  font-size: 20px;
  line-height: 1;
  display: flex;
}
.tab .tab-icon svg {
  width: 20px;
  height: 20px;
}
.tab.active {
  color: var(--accent);
  border-top-color: var(--accent);
}
.tab:hover { color: var(--text); }

.tab-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  margin-right: -20px;
  background: var(--red);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* ─── API BANNER ─── */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  margin: 10px 20px 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
  font-weight: 500;
}
.banner.hidden { display: none; }
.banner .btn { flex-shrink: 0; }

/* ─── VIEWS & LAYOUT ─── */
.view {
  display: none;
  padding: 20px 20px calc(80px + var(--safe-bottom));
  max-width: 720px;
  margin: 0 auto;
}
.view.active { display: block; }

.view-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.view-head h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.badge {
  background: var(--card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

/* ─── CARDS ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
@media (hover: hover) {
  .card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); }
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.card-meta {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  min-height: 42px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}
.btn:active { transform: translateY(1px); }
.btn-sm {
  padding: 8px 12px;
  min-height: 34px;
  font-size: 12px;
}
.btn.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 600;
}
.btn.danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: var(--red);
}
@media (hover: hover) {
  .btn:hover { background: var(--card-hover); border-color: var(--accent-border); }
  .btn.primary:hover { filter: brightness(1.1); }
  .btn.danger:hover { background: var(--red); color: #ffffff; }
}

/* ─── FORM ELEMENTS & LAYOUT ─── */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
    gap: 10px;
  }
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.add-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.notes-sub {
  font-style: italic;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input, .textarea, select.input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
.input:focus, .textarea:focus, select.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}
select.input {
  appearance: auto;
  -webkit-appearance: auto;
}

.field {
  margin-bottom: 14px;
}
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── SUB / EMPTY ─── */
.sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px 20px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.section-subtitle {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ─── DRAFT SPECIFIC ─── */
.draft-item {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}
.draft-item:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.orig { margin-bottom: 10px; }
.orig summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  font-weight: 500;
}
.orig-body {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 6px;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ─── THREAD ─── */
.thread-details { margin-bottom: 10px; }
.thread-details summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  font-weight: 500;
}
.thread-box {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
}
.msg-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
}
.msg-date { color: var(--text-muted); }
.msg-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.msg-body { white-space: pre-wrap; }

/* ─── PIPELINE & DEALS ─── */
.pipeline-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.deal-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); }

.deal-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.deal-state::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.deal-state.lead { background: var(--blue-dim); color: var(--blue); border-color: var(--blue); }
.deal-state.lead::before { background: var(--blue); }
.deal-state.pitched { background: var(--orange-dim); color: var(--orange); border-color: var(--orange); }
.deal-state.pitched::before { background: var(--orange); }
.deal-state.option { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.deal-state.option::before { background: var(--accent); }
.deal-state.hold { background: var(--red-dim); color: var(--red); border-color: var(--red); }
.deal-state.hold::before { background: var(--red); }
.deal-state.confirmed, .deal-state.played { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.deal-state.confirmed::before, .deal-state.played::before { background: var(--green); }

.deal-title {
  font-size: 16px;
  font-weight: 600;
}
.deal-details {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.deal-next {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  margin-top: 8px;
}

/* ─── DETAIL MODAL & SHEET ─── */
.deal-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.deal-detail-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px calc(24px + var(--safe-bottom));
}

/* ─── CONFIRM DIALOG ─── */
.confirm-dialog {
  border: none;
  padding: 0;
  background: transparent;
  overflow: visible;
}
.confirm-dialog:not([open]) { display: none !important; }
.confirm-dialog[open] {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.confirm-dialog::backdrop { background: transparent; }
.dialog-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  padding: 24px 24px calc(24px + var(--safe-bottom));
  box-shadow: var(--shadow-md);
}
@media (min-width: 768px) {
  .confirm-dialog[open] { align-items: center; }
  .dialog-body {
    max-width: 460px;
  }
}
.dialog-body h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
}
.dialog-lines {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
  white-space: pre-wrap;
}
.dialog-actions {
  display: flex;
  gap: 10px;
}
.dialog-actions .btn { flex: 1; }

/* ─── CALENDAR ─── */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0 14px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 0;
}
.cal-cell {
  aspect-ratio: 1;
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 6px;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.cal-empty { background: transparent; border-color: transparent; }
.cal-ring { border-color: var(--accent); }
.cal-today { background: var(--accent-dim); border-color: var(--accent); }
.cal-d {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.cal-daynum {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cal-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
}
.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.cal-more {
  font-size: 10px;
  color: var(--text-muted);
}
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 2px 16px;
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── OUTREACH & ACTIVITY ─── */
.body-pre {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 10px 0;
  max-height: 260px;
  overflow-y: auto;
}
.outbound-card summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  font-weight: 500;
}
.activity-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.activity-row {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.activity-row:last-child { border-bottom: none; }
.activity-ts {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.activity-event {
  font-weight: 600;
  flex-shrink: 0;
}
.activity-detail {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chip-active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent-border);
}

/* ─── STATE CHIPS ─── */
.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  background: var(--card-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
  text-transform: capitalize;
}
.state-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.state-chip.lead, .state-chip.nudge, .state-chip.sent, .state-chip.queued { background: var(--blue-dim); color: var(--blue); border-color: var(--blue); }
.state-chip.pitched, .state-chip.chase { background: var(--orange-dim); color: var(--orange); border-color: var(--orange); }
.state-chip.option { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.state-chip.hold, .state-chip.logistics { background: var(--purple-dim); color: var(--purple); border-color: var(--purple); }
.state-chip.confirmed, .state-chip.replied { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.state-chip.played { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.state-chip.declined, .state-chip.cancelled, .state-chip.lost, .state-chip.bounced, .state-chip.error { background: var(--red-dim); color: var(--red); border-color: var(--red); }
.state-chip.parked, .state-chip.other { background: var(--card-hover); color: var(--text-muted); }
.state-chip.priority-target { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.state-chip.priority-warm { background: var(--orange-dim); color: var(--orange); border-color: var(--orange); }
.state-chip.priority-cold { background: var(--card-hover); color: var(--text-muted); }
.state-chip.stale {
  background: transparent;
  border: 1px dashed var(--text-muted);
  color: var(--text-muted);
}
.state-chip.stale::before { display: none; }

/* ─── STATE TRANSITION BUTTONS ─── */
.btn-state-lead { background: var(--blue-dim); color: var(--blue); border-color: var(--blue); }
.btn-state-pitched { background: var(--orange-dim); color: var(--orange); border-color: var(--orange); }
.btn-state-option { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.btn-state-hold { background: var(--purple-dim); color: var(--purple); border-color: var(--purple); }
.btn-state-confirmed, .btn-state-played { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.btn-state-declined, .btn-state-lost, .btn-state-cancelled { background: var(--red-dim); color: var(--red); border-color: var(--red); }

/* ─── DRAFTING & SWITCHES ─── */
.followup-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 14px;
}
.followup-bar-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.switch {
  width: 48px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s, background 0.15s;
}
.switch.on { background: var(--accent-dim); border-color: var(--accent-border); }
.switch.on::after { transform: translateX(22px); background: var(--accent); }

.drafting-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0;
}
.drafting-warn { color: var(--red); }
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TOASTS ─── */
.toasts-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 440px;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.toast-action {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.toast-action:hover { background: var(--accent); color: #ffffff; }
.toast-success { border-color: var(--green); color: var(--green); }
.toast-error { border-color: var(--red); color: var(--red); }
.toast.fade-out { opacity: 0; transform: translateY(-8px); transition: all 0.2s; }

/* ─── OUTREACH & LINKS ─── */
.outreach-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}
.outreach-options .form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.outreach-options select.input {
  padding: 10px 12px;
  font-size: 13px;
}

.links-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.link-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.link-check input[type="checkbox"] { display: none; }
.link-check:has(input:checked) {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}

.picker-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  transition: all 0.12s ease;
}
.picker-item:hover { border-color: var(--accent-border); }
.picker-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.picker-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.picker-details strong { font-size: 14px; }
.picker-details .sub { font-size: 12px; }

.picker-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.picker-head .btn { align-self: flex-start; }

.picker-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.picker-tools .input { flex: 1 1 100%; }
.picker-tools .btn { flex: 1; }

.contact-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}
.contact-dot.replied { background: var(--green); }
.contact-dot.sent { background: var(--blue); }
.contact-dot.pipeline { background: var(--orange); }
.contact-dot.blocked { background: var(--red); }
.contact-status {
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
  text-transform: capitalize;
}
.contact-status.replied { color: var(--green); }
.contact-status.sent { color: var(--blue); }
.contact-status.pipeline { color: var(--orange); }
.contact-status.blocked { color: var(--red); }

.draft-fail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
}
.draft-fail .sub { color: var(--red); }
.draft-fail .btn { align-self: flex-start; }

.outbound-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
}
.outbound-subject { font-size: 13px; font-weight: 600; }
.outbound-preview-body {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.links-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 10px;
  flex-basis: 100%;
}
.link-check .link-desc { color: var(--text-muted); font-weight: 400; }

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.draft-progress {
  align-self: flex-start;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}

.outreach-options-details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 14px;
}
.outreach-options-details summary {
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 2px;
  color: var(--text);
  transition: color 0.15s ease;
}
@media (hover: hover) {
  .outreach-options-details summary:hover { color: var(--accent); }
}

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

/* ─── LOADING & ERROR ─── */
.loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px;
}

.error { color: var(--red); font-size: 13px; }

/* ─── GLOBAL SEARCH OVERLAY ─── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 20px 20px;
}
.search-overlay.hidden { display: none; }
.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.search-panel input {
  margin: 14px;
  flex-shrink: 0;
}
.search-results {
  overflow-y: auto;
  padding: 0 14px 14px;
}
.search-group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 12px 2px 6px;
}
.search-item {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
}
.search-item:hover { border-color: var(--accent); }
.search-item .sub { font-size: 12px; }

/* ─── MEDIA QUERIES ─── */
@media (max-width: 480px) {
  .timestamp { display: none; }
}
@media (max-width: 380px) {
  .tab { font-size: 9px; }
  .tab .tab-icon { font-size: 18px; }
  .view { padding: 12px 14px; }
}

@media (min-width: 768px) {
  nav { justify-content: center; }
  .tab {
    flex: 0 1 120px;
    max-width: 120px;
    font-size: 12px;
  }
}

@media (min-width: 1024px) {
  .view { max-width: 800px; }
  .view.wide { max-width: 1180px; }
  .two-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }
  .pane-detail {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
  }
}

/* ─── ACCESSIBILITY ─── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── SKELETON LOADING ─── */
.skeleton-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}
.skeleton-line {
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  margin-bottom: 10px;
}
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
