:root {
  --bg: #eef1f4;
  --bg-elev: #ffffff;
  --bg-elev-2: #f4f6f8;
  --border: #e1e6ec;
  --text: #1a2332;
  --text-muted: #5c6b7c;
  --accent: #1a2332;
  --accent-2: #2c3b4e;
  --stamp: #9a6b2f;
  --mark: #c4a265;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --success: #1b6b45;
  --warn: #8a5a00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(18, 26, 36, 0.05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Source Sans 3", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

body {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

a { color: var(--accent); }

code {
  font-family: var(--mono);
  background: var(--bg-elev-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.sidebar {
  background: #121a24;
  color: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f3f5f7;
}

.brand {
  padding: 22px 16px 8px;
}

.product-name {
  font-family: var(--display);
  font-weight: 560;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
  color: #fff;
}

.desk-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 8px 0 24px;
}

.nav-label {
  margin: 16px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.55);
}

.nav-btn {
  appearance: none;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-btn.active {
  background: #1e2c3a;
  color: #fff;
  border-left-color: #fff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid #d8e0e6;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}

.page-title {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
  color: var(--text);
}

.banner {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
}

.banner-warn {
  background: #fff8e8;
  border-color: #ead7a1;
  color: #5c4310;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  max-height: min(560px, 70vh);
}

.table-wrap:empty { display: none; }

.canvas {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 20px 24px 40px;
  background: #f3f5f7;
}

.frame,
.sheet {
  background: #fff;
  border: 1px solid #d8e0e6;
  border-radius: 10px;
  padding: 16px;
  box-shadow: none;
}

.hero h1 {
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 8px 0 6px;
  color: var(--text);
}

.hero .lede {
  color: var(--text-muted);
  margin: 0 0 32px;
  font-size: 16px;
  max-width: 64ch;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.step {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  opacity: 0.55;
  transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.step.active {
  opacity: 1;
  border-color: var(--text);
}

.step-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
}

.step-head h2 { margin: 0; font-size: 16px; font-weight: 600; }

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
}

.step.active .step-num {
  background: var(--text);
  color: white;
  border-color: transparent;
}

.step-body { padding: 20px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--text);
  background: var(--bg);
}

.dz-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 12px;
}

.dz-text { font-size: 16px; }

.dz-hint { color: var(--text-muted); font-size: 13px; margin-top: 8px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  padding: 0 4px;
  text-decoration: underline;
  display: inline-flex;
  align-items: center;
}

.status {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: 14px;
}

.status.error {
  background: var(--danger-bg);
  border-color: var(--border);
  color: var(--text);
}

.status.success {
  background: #e8f5ee;
  border-color: var(--border);
  color: var(--text);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.summary-card .label {
  font-size: 14px;
  color: var(--text-muted);
}

.summary-card .value {
  font-size: 24px;
  font-weight: 600;
  margin-top: 4px;
}

.summary-card.danger .value { color: var(--danger); }
.summary-card.warn .value { color: var(--warn); }
.summary-card.muted .value { color: var(--text-muted); }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab .count {
  background: var(--bg-elev-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-family: var(--mono);
}

.tab-panel {
  display: none;
  margin-top: 14px;
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tab-panel.active { display: block; }

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

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f5f7;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

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

.data-table tbody tr { cursor: pointer; }

.data-table tbody tr:hover { background: var(--bg); }

.data-table tbody tr.is-selected td { background: #e7eef3; }

.data-table tbody tr.is-selected td:first-child { border-left: 3px solid #15202b; }

.data-table .mono {
  font-family: var(--mono);
  color: var(--text-muted);
  font-size: 12px;
}

.actions {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  min-height: 44px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s, opacity 0.15s, background 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:not(:disabled):hover { background: var(--accent-2); }

.btn-accent {
  background: var(--text);
  color: #fff;
  font-weight: 600;
}
.btn-accent:not(:disabled):hover { background: var(--accent-2); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:not(:disabled):hover { background: #a12020; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

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

.hidden { display: none !important; }

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 24px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 23, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.overlay-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result-success {
  background: #e8f5ee;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  color: var(--text);
}

.result-success h3 { margin: 0 0 6px; color: var(--text); }
.result-success .job-ids {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-all;
}

.result-error {
  background: var(--danger-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  color: var(--text);
}

/* ---------- tool selector ---------- */
.tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin: 0 0 28px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.tool-btn:hover { border-color: var(--accent); }
.tool-btn:active { transform: translateY(1px); }
.tool-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tool-btn.active {
  border-color: var(--text);
  background: var(--bg-elev);
  box-shadow: none;
}

.tool-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
}

.tool-label { display: flex; flex-direction: column; }
.tool-label strong { font-size: 14px; }
.tool-label small { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.tool-panel { display: none; }
.tool-panel.active { display: block; }

/* ---------- form fields (split tool) ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 6px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.field-hint { font-size: 12px; color: var(--text-muted); }
.muted-strong { color: var(--text); font-family: var(--mono); }

.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  transition: border-color 0.15s;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--text);
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.field select:disabled { opacity: 0.6; cursor: not-allowed; }

.checkbox-field {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.checkbox-field input { margin-top: 3px; }
.checkbox-field strong { font-size: 14px; }
.checkbox-field small { display: block; font-size: 12px; margin-top: 2px; }

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-field {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.radio-field:hover { border-color: var(--border-strong, var(--border)); }
.radio-field input { margin-top: 3px; }
.radio-field strong { font-size: 14px; }
.radio-field small { display: block; font-size: 12px; margin-top: 2px; }
.radio-field:has(input:checked) {
  border-color: var(--text);
  background: var(--bg);
}

/* ---------- stage list (split progress) ---------- */
.stages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.stage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.stage-row .stage-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

.stage-row.pending { color: var(--text-muted); }
.stage-row.pending .stage-icon { color: var(--text-muted); }
.stage-row.running { border-color: var(--text); }
.stage-row.running .stage-icon { background: var(--accent); border-color: transparent; color: white; }
.stage-row.done .stage-icon { background: var(--success); border-color: transparent; color: white; }
.stage-row.error { border-color: var(--border); color: var(--text); }
.stage-row.error .stage-icon { background: var(--danger); border-color: transparent; color: white; }

.stage-row .stage-text { flex: 1; }
.stage-row .stage-meta { color: var(--text-muted); font-family: var(--mono); font-size: 12px; }

.stage-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------- live log ---------- */
.log-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
}

.log {
  margin: 0;
  padding: 12px;
  max-height: 320px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.btn-sm { padding: 8px 12px; font-size: 16px; min-height: 44px; }

.result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.result-cards .card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
}

.result-cards .card .name { font-weight: 600; }
.result-cards .card .meta {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ---------- Check CSV tool ---------- */
.check-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  padding: 8px 14px;
  min-height: 44px;
  border-radius: 999px;
  font-size: 16px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.chip:hover { color: var(--text); border-color: var(--accent); }

.chip.active {
  color: #fff;
  border-color: var(--text);
  background: var(--text);
}

.search-box input {
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  width: 240px;
  max-width: 100%;
}

.search-box input:focus {
  border-color: var(--text);
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.table-scroll {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
}

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

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.badge-in_sendgrid { background: #e8f5ee; color: var(--text); border: 1px solid var(--border); }
.badge-new        { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }
.badge-invalid    { background: var(--danger-bg); color: var(--text); border: 1px solid var(--border); }
.badge-empty      { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-deleted    { background: var(--danger-bg); color: var(--text); border: 1px solid var(--border); text-decoration: line-through; }

.row-deleted td { color: var(--text-muted); }
.row-deleted td .badge-deleted { text-decoration: none; }

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

.actions-split .actions-left,
.actions-split .actions-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#check-delete-result:empty { display: none; }
#check-delete-result {
  margin-top: 18px;
}

#check-delete-result .delete-banner {
  background: #e8f5ee;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 14px 18px;
}

#check-delete-result .delete-banner.error {
  background: var(--danger-bg);
  border-color: var(--border);
  color: var(--text);
}

#check-delete-result .delete-banner h4 { margin: 0 0 4px; font-size: 14px; }
#check-delete-result .delete-banner p { margin: 0; font-size: 13px; }
#check-delete-result .job-ids {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.dup-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fff8e8;
  color: var(--text);
  font-size: 12px;
  border: 1px solid var(--border);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.pager button {
  appearance: none;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 16px;
}

.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager button:not(:disabled):hover { border-color: var(--accent); }

.detected-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 16px;
}

.detected-banner code {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
}

/* ---------- Add contacts wizard ---------- */
.dest-section {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

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

.section-title .muted-strong {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

.dest-sub {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 4px;
  cursor: pointer;
}

.radio-row input { margin-top: 3px; }
.radio-row span { font-size: 14px; }

.multi-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}

.multi-list input[type="search"] {
  appearance: none;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  min-height: 44px;
}

.multi-list input[type="search"]:focus {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

.multi-list-items {
  max-height: 220px;
  overflow: auto;
}

.multi-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
}

.multi-list-row:last-child { border-bottom: none; }
.multi-list-row:hover { background: var(--bg-elev-2); }
.multi-list-row .name { flex: 1; }
.multi-list-row .meta { color: var(--text-muted); font-family: var(--mono); font-size: 11px; }

.map-table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}

.map-table-wrap .data-table {
  table-layout: fixed;
  width: 100%;
}

.map-table-wrap th:nth-child(1),
.map-table-wrap td:nth-child(1) { width: 28%; }
.map-table-wrap th:nth-child(2),
.map-table-wrap td:nth-child(2) { width: 32%; }
.map-table-wrap th:nth-child(3),
.map-table-wrap td:nth-child(3) { width: 40%; }

.map-table-wrap td .map-csv-name { font-weight: 500; }

.map-table-wrap td select {
  appearance: none;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
  min-height: 44px;
}

.map-table-wrap td select:focus {
  border-color: var(--text);
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.map-table-wrap td.row-required {
  border-left: 2px solid var(--accent);
}

.map-table-wrap td.sample {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

@media (max-width: 799px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    width: 100%;
    z-index: 6;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .brand {
    position: sticky;
    left: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 0 16px;
    background: #15202b;
  }

  .product-name {
    font-size: 22px;
    white-space: nowrap;
  }

  .desk-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    width: max-content;
    gap: 4px;
    padding: 8px 12px 8px 0;
  }

  .nav-label {
    margin: 0 4px 0 12px;
    white-space: nowrap;
  }

  .nav-btn {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0 14px;
  }
}

@media (max-width: 720px) {
  .canvas { padding: 16px 14px 32px; }
  .topbar { padding: 12px 14px; }
  .hero h1 { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .search-box input { width: 100%; }
  .map-table-wrap th:nth-child(3),
  .map-table-wrap td:nth-child(3) { display: none; }
  .map-table-wrap th:nth-child(1),
  .map-table-wrap td:nth-child(1),
  .map-table-wrap th:nth-child(2),
  .map-table-wrap td:nth-child(2) { width: 50%; }
  .page-title { font-size: 24px; }
  .record-actions { width: 100%; }
}

body.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 16px;
  background: #d5dee6;
}

.login-card {
  width: 400px;
  max-width: calc(100vw - 32px);
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid #d8e0e6;
  border-radius: 12px;
  padding: 28px 28px 24px;
  box-shadow: 0 18px 50px rgba(21, 32, 43, 0.18);
}

.login-card .product-name {
  color: var(--text);
  font-size: 36px;
  margin-bottom: 8px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card .btn-primary {
  width: 100%;
}

.login-card input {
  font-size: 16px;
}

.desk-panel { display: none; }
.desk-panel.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.section-head h2 { margin: 0; }

.lookup {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 0 0 12px;
}

.lookup .field { flex: 1 1 240px; }

.quick-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.quick-add .field { flex: 1 1 140px; }

.add-plus {
  min-width: 52px;
  font-size: 28px;
  line-height: 1;
  padding: 0 14px;
}

.offer-line {
  margin: 0 0 8px;
  font-weight: 700;
}

.record-actions .offer-choice,
.draft-brand {
  min-width: 160px;
}

.draft-brand { margin: 0; }

.draft-view-bar .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.sheet ol.steps { margin: 0 0 16px; padding-left: 1.2rem; }
.sheet ol.steps li { margin: 6px 0; }

.sheet select {
  width: 100%;
}

.mail-folders {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.mail-folder {
  appearance: none;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #d8e0e6;
  border-radius: 8px;
  background: #fff;
  color: #15202b;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.mail-folder.active {
  background: #15202b;
  color: #fff;
  border-color: #15202b;
}

.mail-row.is-unread h3 { font-weight: 700; }

.mail-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sans);
  font-size: 16px;
  margin: 12px 0 0;
}

.mail-frame {
  width: 100%;
  height: 80vh;
  min-height: 640px;
  border: 0;
  background: #fff;
  margin-top: 12px;
}

.desk-panel h2 {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
}

.sheet {
  margin-top: 0;
}

.sheet h2 { margin-top: 0; }

.note {
  color: var(--text-muted);
  font-size: 16px;
  margin: 0 0 12px;
  max-width: 70ch;
}

.state-line {
  margin: 8px 0 14px;
  font-size: 16px;
  color: var(--text-muted);
}

.state-error {
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text);
  padding: 10px 12px;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.record {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 12px;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.record:hover { background: #f3f5f7; }

.record.is-selected {
  background: #e7eef3;
  border-left: 3px solid #15202b;
}

.stat-toggle { display: flex; gap: 8px; }
.stat-toggle .is-on { background: var(--ink, #1c1915); color: #fff; border-color: var(--ink, #1c1915); }

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border, #ddd4c4);
  border-radius: 14px;
  background: #fff;
}

.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stat-card-head h3 { margin: 0; }
.stat-card h3 { margin: 0; font-size: 22px; }
.stat-card .note { margin: 0; }

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

.stat-channel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #f7f8fa;
  border: 1px solid var(--border);
}

.stat-channel-head { display: flex; flex-direction: column; gap: 4px; }

.stat-channel h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-sent {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #5c564c;
  letter-spacing: 0.04em;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.stat-tile {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
}

.stat-tile span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-tile strong {
  display: block;
  margin-top: 2px;
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.stat-tile small {
  display: block;
  margin-top: 2px;
  color: #5c564c;
}

.sender-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-tile.is-bad { background: #fdecea; }
.stat-tile.is-bad strong { color: #a12020; }
.stat-tile.is-good { background: #eef6ef; }

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

.record h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
}

.record p { margin: 0 0 4px; font-size: 16px; }

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.record-actions .field { min-width: min(100%, 220px); }

.is-scheduled {
  color: #b45309;
  font-weight: 700;
}

.callback {
  font-family: var(--mono);
  font-size: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 16px;
}

.final-url { word-break: break-all; }

.payload {
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  background: var(--bg);
  border-radius: 6px;
  padding: 8px;
  max-width: 480px;
}

.result-list {
  margin: 12px 0 0;
  padding-left: 18px;
}

.result-list li { margin: 6px 0; font-size: 16px; }

.draft-view {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(21, 32, 43, 0.45);
}

.draft-view-card {
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  height: min(880px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.draft-view-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.draft-view-bar h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 560;
}

.draft-view-bar p {
  margin: 4px 0 0;
  color: var(--text-muted);
}

#draft-view-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.sidebar .nav-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

button:focus-visible,
.nav-btn:focus-visible,
.btn:focus-visible,
.chip:focus-visible,
.tab:focus-visible,
.link-btn:focus-visible,
.pager button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--mark);
  color: #1a2332;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 560;
  line-height: 1;
  flex: 0 0 auto;
}

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

.brand-copy { min-width: 0; }

.product-name {
  font-size: 22px;
  line-height: 1;
}

.product-kicker {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-label {
  margin: 18px 16px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin: 1px 8px;
  width: calc(100% - 16px);
  padding: 0 10px;
  border-radius: 8px;
  border-left: none;
  font-size: 14px;
  font-weight: 600;
}

.nav-btn.active {
  background: #243140;
  box-shadow: inset 3px 0 0 var(--mark);
}

.nav-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html, body { height: 100%; }
body { height: 100vh; overflow: hidden; }

.workspace {
  background: var(--bg);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  padding: 16px 28px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: static;
  flex: 0 0 auto;
  z-index: 2;
}

.topbar-title { min-width: 0; }

.page-title {
  font-size: 28px;
}

.page-kicker {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.canvas {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 4px 28px 48px;
}

.footer { flex: 0 0 auto; }

.frame,
.sheet {
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.desk-panel h2 {
  font-size: 16px;
  letter-spacing: -0.01em;
}

.note,
.state-line { font-size: 14px; }

.section-head { align-items: flex-start; }

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

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

.desk-fold {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.desk-fold summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
}

.desk-fold summary::-webkit-details-marker { display: none; }

.desk-fold summary::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  vertical-align: 1px;
}

.desk-fold[open] summary::before { transform: rotate(45deg); }

.fold-body { padding: 0 18px 16px; }

.board-group { margin-top: 8px; }

.group-toggle {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 2px;
  cursor: pointer;
}

.group-toggle[aria-expanded="false"] { opacity: 0.7; }

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

.stat-card h3 { font-size: 16px; font-weight: 700; }
.stat-card .actions { margin-top: 0; justify-content: flex-end; }
.stat-card .btn { min-height: 32px; padding: 6px 10px; }

.form-grid > .section-head,
.form-grid > .actions { grid-column: 1 / -1; }

.sender-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7f8fa;
}
.sender-card > h3,
.sender-card > .note,
.sender-card > .actions { grid-column: 1 / -1; margin-top: 0; }
.sender-card > h3 { margin: 0; font-size: 15px; }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
}

#add-contacts-panel h3 {
  margin: 18px 0 8px;
  font-size: 14px;
  font-weight: 700;
}
#add-contacts-panel form + form {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.maintenance-actions {
  justify-content: flex-start;
  margin-top: 0;
}

.data-table tbody td { font-size: 14px; }
.record-list .record:last-child { border-bottom: none; }

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #eef1f4;
  color: #3d4b5c;
}

.status-running { background: #e5f6ec; color: #146c43; }
.status-queueing { background: #e7f0fb; color: #1d4f91; }
.status-paused,
.status-scheduled { background: #fff4df; color: #8a5a00; }
.status-needs_review { background: #fdecea; color: #9f1d1d; }
.status-draft { background: #eef1f4; color: #3d4b5c; }

.stat-card {
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.stat-card .actions { margin-top: 0; }

.record {
  padding: 12px 8px;
  border-radius: 10px;
}

.record h3 { font-size: 16px; }
.record p { font-size: 14px; color: var(--text-muted); }

.mail-folders {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #e7ebf0;
  border-radius: 10px;
}

.mail-folder {
  min-height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
}

.mail-folder.active {
  background: #fff;
  color: var(--text);
  border-color: transparent;
  box-shadow: var(--shadow);
}

.data-table thead th {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #f7f8fa;
}

.btn { min-height: 36px; font-size: 14px; border-radius: 8px; }
.btn-primary { background: #1a2332; }
.btn-ghost { background: #fff; }

@media (max-width: 900px) {
  .tool-grid { grid-template-columns: 1fr; }
  .canvas { padding: 4px 16px 32px; }
  .topbar { padding: 14px 16px; }
  .nav-btn {
    width: auto;
    margin: 0;
    border-radius: 8px;
  }
}
