:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #18202a;
  --muted: #637083;
  --line: #d9dee7;
  --accent: #2368a2;
  --accent-ink: #ffffff;
  --good: #126c43;
  --warn: #946200;
  --bad: #a23333;
  --info: #365f91;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #111820; color: #f4f6f8; padding: 20px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 760; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: #d6e8f7; color: #0d3451; font-size: 13px; font-weight: 800; }
.nav { display: grid; gap: 4px; }
.nav a { color: #d7dee7; padding: 10px 12px; border-radius: 8px; font-weight: 620; }
.nav a.active, .nav a:hover { background: #24313f; color: #ffffff; text-decoration: none; }
.sidebar-logout { margin-top: auto; width: 100%; background: transparent; color: #d7dee7; border: 1px solid #405163; border-radius: 8px; padding: 10px 12px; cursor: pointer; }

.main { padding: 28px; display: grid; gap: 24px; align-content: start; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
h1, h2 { margin: 0; line-height: 1.1; }
h1 { font-size: 30px; letter-spacing: 0; }
h2 { font-size: 18px; margin-bottom: 14px; }
.muted { color: var(--muted); margin: 6px 0 0; }
.toast { background: #dff2e7; color: #0d5131; border: 1px solid #bddfc9; border-radius: 8px; padding: 11px 14px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 9px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font-size: 28px; }

section, .form-panel, .notice { background: transparent; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.stack { display: grid; gap: 12px; }
.row-between { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; justify-content: space-between; gap: 16px; }

.form-panel, .notice, .table-wrap, .login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: end; }
.grid-form.compact { gap: 11px; }
.span-2 { grid-column: span 2; }
.inline, .search, .upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
label { display: grid; gap: 6px; font-size: 13px; color: #344150; font-weight: 650; }
label.check { display: flex; align-items: center; gap: 8px; min-height: 38px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; color: #344150; font-weight: 650; }
.field-help { margin: 8px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
input, textarea, select {
  width: 100%;
  border: 1px solid #cbd3de;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  background: #ffffff;
  color: var(--ink);
}
textarea { min-height: 92px; resize: vertical; }
.search input { min-width: 260px; }
input[type="checkbox"] { width: auto; }
input[type="radio"] { width: auto; }

.status-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8fb;
  cursor: pointer;
}

.status-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.status-switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #c3ced8;
  transition: background-color 120ms ease;
}

.status-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(17, 24, 32, 0.18);
  transition: transform 120ms ease;
}

.status-switch-copy {
  display: grid;
  gap: 2px;
}

.status-switch-copy strong {
  font-size: 13px;
  line-height: 1.2;
  color: var(--ink);
}

.status-switch-copy small {
  font-size: 12px;
  line-height: 1.2;
  color: var(--muted);
}

.status-switch input[type="checkbox"]:checked + .status-switch-track {
  background: var(--accent);
}

.status-switch input[type="checkbox"]:checked + .status-switch-track .status-switch-thumb {
  transform: translateX(20px);
}

.status-switch input[type="checkbox"]:focus-visible + .status-switch-track {
  outline: 2px solid #8fb7da;
  outline-offset: 2px;
}

button, .primary, .secondary, .danger {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 720;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: #eef3f7; border-color: #cbd8e4; color: #17364f; }
.danger { background: #fff1f1; border-color: #e5baba; color: var(--bad); }
.small { padding: 6px 9px; min-height: 30px; border-radius: 6px; background: #eef3f7; border-color: #cbd8e4; }
.small-link { font-weight: 720; font-size: 13px; }
.as-button { background: transparent; border: 0; padding: 0; min-height: 0; color: var(--accent); }
.full { width: 100%; }
.icon-button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 24px; line-height: 1; }

.table-wrap { overflow-x: auto; padding: 0; }
.bulk-actions { display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 16px 14px 12px 18px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.bulk-check { margin: 0; }
.bulk-actions .danger { margin-left: 6px; margin-bottom: 2px; }
.check-col { width: 44px; text-align: center; }
.row-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.row-actions form { margin: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #4c5a6b; background: #f9fafc; font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
td.wide { min-width: 280px; }
.empty { color: var(--muted); text-align: center; padding: 20px; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 740; background: #eceff3; color: #465466; white-space: nowrap; }
.status-sent, .status-connected { background: #dff2e7; color: var(--good); }
.status-pending, .status-draft, .status-disconnected, .status-paused { background: #fff1ca; color: var(--warn); }
.status-failed, .status-bounced, .status-token_expired, .status-sync_error { background: #ffe1e1; color: var(--bad); }
.status-replied { background: #dbeaff; color: var(--info); }
.status-opted_out, .status-skipped { background: #eee8f6; color: #5e4978; }
.status-not_contacted { background: #edf1f5; color: #536170; }

.progress-row { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.progress { height: 10px; border-radius: 999px; background: #e7ebf0; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; background: var(--accent); }
.json { max-height: 260px; overflow: auto; white-space: pre-wrap; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 12px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 18px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 32, 0.55); display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal-backdrop.hidden { display: none; }
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; display: grid; gap: 12px; }
.preview-body { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-panel { width: min(420px, 100%); display: grid; gap: 16px; }
.login-brand { color: var(--ink); margin-bottom: 4px; }
.form-error { background: #ffe1e1; color: var(--bad); border: 1px solid #e5baba; border-radius: 8px; padding: 10px 12px; }

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 18px; }
  .metric-grid, .split, .grid-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .page-head { flex-direction: column; }
}
