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

:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --border:    #e2e4e9;
  --muted:     #9ea3ae;
  --text:      #111318;
  --sub:       #5c6170;
  --accent:    #5a55f4;
  --accent-h:  #4740e8;
  --green:     #16a34a;
  --red:       #dc2626;
  --yellow:    #ca8a04;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar */
.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  box-shadow: var(--shadow);
}

.sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-brand h1 { font-size: 15px; font-weight: 700; letter-spacing: .3px; color: var(--text); }
.sidebar-brand span { font-size: 11px; color: var(--muted); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  cursor: pointer;
  color: var(--sub);
  border-left: 3px solid transparent;
  transition: all .12s;
  user-select: none;
  font-size: 13.5px;
}
.nav-item:hover { color: var(--text); background: var(--bg); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: #eeeeff; font-weight: 500; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }

/* ── Main */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 36px 40px;
  background: var(--bg);
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h2 { font-size: 20px; font-weight: 600; color: var(--text); }
.page-header p { color: var(--sub); font-size: 13px; margin-top: 4px; }

/* ── Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .12s, opacity .12s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-ghost {
  background: transparent;
  color: var(--sub);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: #c5c8d0; background: var(--bg); }
.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--border);
}
.btn-danger:hover:not(:disabled) { background: #fef2f2; border-color: #fca5a5; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 500;
}
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 8px; color: var(--text); }

/* ── Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }

.empty-row td { text-align: center; color: var(--muted); padding: 48px; }

/* ── Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active  { color: var(--green);  background: #dcfce7; }
.badge-error   { color: var(--red);    background: #fee2e2; }
.badge-warming { color: var(--yellow); background: #fef9c3; }
.badge-paused  { color: var(--muted);  background: #f1f5f9; }

/* ── Modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.modal .modal-sub { color: var(--sub); font-size: 12.5px; margin-bottom: 24px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 500; color: var(--sub); }
.field input, .field select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,85,244,.1);
}
.field input::placeholder { color: #c0c4ce; }
.field-hint { font-size: 11px; color: var(--muted); }

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 8px 0 0;
  grid-column: span 2;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Toast */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  z-index: 200;
  transform: translateY(80px);
  opacity: 0;
  transition: all .22s;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-left: 3px solid var(--green); }
#toast.error   { border-left: 3px solid var(--red); }

/* ── Test result inline */
.test-result {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  display: none;
}
.test-result.ok  { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; display: block; }
.test-result.err { background: #fef2f2; color: var(--red);   border: 1px solid #fecaca; display: block; }

/* ── Inbox actions */
.actions { display: flex; gap: 8px; }

/* ── Cap bar */
.cap-bar { display: flex; align-items: center; gap: 8px; }
.cap-bar-track { flex: 1; height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; min-width: 60px; }
.cap-bar-fill  { height: 100%; background: var(--accent); border-radius: 99px; }

/* ── Media grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.media-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 0;
  color: var(--muted);
  font-size: 14px;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.media-thumb {
  height: 140px;
  background: #f4f5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.media-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  padding: 12px;
}
.media-info {
  padding: 12px;
  flex: 1;
}
.media-info .media-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-info .media-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.media-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.media-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: #eeeeff;
  color: var(--accent);
  border-radius: 99px;
}
.media-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}

/* ── Logs */
.logs-filters {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-right: 2px;
}
.filter-btn {
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  color: var(--sub);
  cursor: pointer;
  transition: all .12s;
}
.filter-btn:hover  { color: var(--text); border-color: var(--muted); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.logs-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}
.logs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.logs-table th {
  position: sticky; top: 0; z-index: 1;
  background: #fafbfc;
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.logs-table td { padding: 9px 14px; border-bottom: 1px solid #f1f3f5; vertical-align: top; }
.logs-table tr:last-child td { border-bottom: none; }
.logs-table tr:hover td { background: #fafbff; }
.logs-empty { text-align: center; color: var(--muted); padding: 40px !important; }

.log-time  { font-size: 12px; color: var(--sub); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-source { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--sub); }
.log-msg { font-family: 'SF Mono', 'Fira Mono', monospace; font-size: 12.5px; word-break: break-word; }

.log-badge { padding: 2px 7px; border-radius: 99px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.log-badge-info  { background: #eff6ff; color: #2563eb; }
.log-badge-warn  { background: #fefce8; color: #b45309; }
.log-badge-error { background: #fef2f2; color: var(--red); }

.copy-row-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .12s;
}
.logs-table tr:hover .copy-row-btn { opacity: 1; }
.copy-row-btn:hover { background: var(--bg); color: var(--accent); }

/* ── Filter select */
.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); }

/* ── Sequence builder */
.seq-modal-wide { width: 700px; }

.seq-step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  background: #fafbfc;
  position: relative;
}
.seq-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.seq-step-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--accent);
}
.seq-step-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seq-step-fields .span-2 { grid-column: span 2; }
.seq-step-fields textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 120px;
  transition: border-color .12s, box-shadow .12s;
}
.seq-step-fields textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,85,244,.1);
}
.seq-step-fields input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color .12s;
}
.seq-step-fields input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(90,85,244,.1); }
.step-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--sub);
}
.step-count-badge strong { color: var(--text); }

/* ── Coming soon */
.coming-soon {
  text-align: center;
  padding: 80px 0;
  color: var(--muted);
}
.coming-soon .icon { font-size: 40px; margin-bottom: 16px; opacity: .4; }
.coming-soon p { font-size: 15px; }

/* ── Prospect batch cards */
.batches-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.batch-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  user-select: none;
}
.batch-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(90,85,244,.09); }
.batch-card .bc-date  { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.batch-card .bc-time  { font-size: 12px; color: var(--sub); font-weight: 400; margin-left: 10px; }
.batch-card .bc-count { font-size: 15px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.batch-card .bc-noun  { font-size: 13px; color: var(--sub); margin-left: 4px; white-space: nowrap; }
.batch-card .bc-link  { font-size: 14px; color: var(--sub); margin-left: 8px; }
