:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --ink: #111827;
  --muted: #64748b;
  --subtle: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #ccfbf1;
  --blue: #4f46e5;
  --blue-soft: #eef2ff;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #a16207;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 8px;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body.dark-theme {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #111827;
  --surface-soft: #182235;
  --ink: #f8fafc;
  --muted: #cbd5e1;
  --subtle: #94a3b8;
  --line: #263244;
  --line-strong: #334155;
  --accent: #2dd4bf;
  --accent-dark: #5eead4;
  --accent-soft: #134e4a;
  --blue: #818cf8;
  --blue-soft: #312e81;
  --success: #86efac;
  --success-soft: #14532d;
  --warning: #facc15;
  --warning-soft: #713f12;
  --danger: #fca5a5;
  --danger-soft: #7f1d1d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 10px 28px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

h1 {
  font-size: 18px;
  line-height: 1.3;
  font-weight: 750;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 750;
}

h3 {
  font-size: 14px;
  line-height: 1.35;
  font-weight: 750;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

main {
  width: 100%;
}

.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;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand-lockup,
.topbar-actions,
.session,
.panel-heading,
.page-heading,
.page-actions,
.file-meta,
.table-toolbar,
.table-pagination,
.metric-row {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-lockup p {
  margin-top: 2px;
  font-size: 13px;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.session {
  gap: 8px;
}

.session input {
  width: min(320px, 42vw);
  margin: 0;
}

.user-chip,
.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.user-chip {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}

.status-pill.is-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.status-pill.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: transparent;
}

.status-pill.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.badge.neutral {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.success {
  background: var(--success-soft);
  color: var(--success);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.hidden,
.view {
  display: none;
}

.view.active {
  display: block;
}

.sidebar {
  position: sticky;
  top: 72px;
  align-self: start;
  height: calc(100vh - 72px);
  padding: 20px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.sidebar-section {
  display: grid;
  gap: 10px;
}

.sidebar-label,
.eyebrow {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tabs {
  display: grid;
  gap: 4px;
}

.tabs button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: flex-start;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  box-shadow: none;
}

.tabs button:hover {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--line);
}

.tabs button.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.sidebar-card {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.sidebar-card strong {
  display: block;
  font-size: 13px;
}

.sidebar-card p {
  margin-top: 2px;
  font-size: 12px;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  margin-top: 24px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--line);
  box-shadow: none;
}

.sidebar-logout:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.content-shell {
  min-width: 0;
  padding: 24px;
}

.page-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-heading p:not(.eyebrow) {
  margin-top: 6px;
}

.page-actions {
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.login-panel {
  width: min(420px, calc(100% - 32px));
  margin: 48px auto;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  font-size: 17px;
}

.panel-heading p:not(.eyebrow) {
  margin-top: 4px;
}

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

.import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.import-main,
.import-side {
  min-width: 0;
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0 0 18px;
  list-style: none;
}

.workflow-steps li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.workflow-steps span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.workflow-steps strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.workflow-steps li.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.workflow-steps li.active span,
.workflow-steps li.done span {
  background: var(--accent);
  color: #ffffff;
}

.workflow-steps li.done {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  color: var(--accent-dark);
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 12px;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-primary,
button:not(.btn-secondary):not(.btn-danger):not(.icon-button) {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover,
button:not(.btn-secondary):not(.btn-danger):not(.icon-button):hover {
  background: var(--accent-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: var(--surface-soft);
  border-color: var(--subtle);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.icon-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  background: var(--surface);
  color: var(--muted);
  border-color: var(--line);
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.danger-icon {
  color: var(--danger);
  border-color: var(--danger-soft);
  background: var(--danger-soft);
}

.danger-icon:hover {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.row-actions {
  width: 72px;
  text-align: center;
}

.row-actions .icon-button {
  width: 32px;
  min-height: 32px;
  font-size: 12px;
  line-height: 1;
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 184px;
  margin-bottom: 12px;
  padding: 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}

.upload-zone input {
  display: none;
}

.upload-zone svg {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

.upload-zone strong {
  color: var(--ink);
  font-size: 15px;
}

.upload-zone span {
  color: var(--muted);
  font-weight: 500;
}

.upload-zone.is-dragging,
.upload-zone.is-ready {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-meta {
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-actions,
.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-row {
  margin-bottom: 14px;
}

.action-row input,
.action-row select {
  width: min(360px, 100%);
  margin: 0;
}

.table-limit-note {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--warning-soft);
  border-radius: 8px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
}

.action-stack {
  display: grid;
  gap: 8px;
}

.action-stack button {
  width: 100%;
}

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

.card {
  position: relative;
  overflow: hidden;
  min-height: 104px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.card strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
  margin-bottom: 7px;
}

.card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  text-transform: capitalize;
}

.card small {
  display: block;
  margin-top: 10px;
  color: var(--subtle);
  font-size: 12px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mini-chart {
  min-height: 172px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.mini-chart h3 {
  margin-bottom: 12px;
}

.chart-placeholder {
  color: var(--muted);
  font-size: 13px;
}

.stacked-bar {
  display: flex;
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: var(--line);
  margin-bottom: 14px;
}

.bar-accepted {
  background: var(--success);
}

.bar-rejected {
  background: var(--danger);
}

.bar-created {
  background: var(--blue);
}

.metric-row {
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.metric-row:last-child {
  border-bottom: 0;
}

.metric-row strong {
  color: var(--ink);
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel > .panel-heading {
  padding: 16px 18px 0;
}

.table {
  min-width: 0;
}

.empty-state {
  margin: 0;
  padding: 22px 18px;
  color: var(--muted);
}

.data-grid {
  border-top: 1px solid var(--line);
}

.table-toolbar {
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.table-toolbar input {
  width: min(320px, 100%);
  margin: 0;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.table-scroll {
  max-height: 430px;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

th[data-grid-sort] {
  cursor: pointer;
}

tbody tr:hover {
  background: var(--surface-soft);
}

tbody tr.row-invalid {
  background: color-mix(in srgb, var(--danger-soft) 55%, transparent);
}

tbody tr.row-created {
  background: color-mix(in srgb, var(--success-soft) 45%, transparent);
}

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

.cell-json {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-badge.success {
  color: var(--success);
  background: var(--success-soft);
}

.status-badge.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-badge.neutral {
  color: var(--blue);
  background: var(--blue-soft);
}

.security-list {
  display: grid;
  gap: 12px;
}

.security-list div {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.security-list p {
  font-size: 13px;
}

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

.user-actions select {
  width: auto;
  min-width: 118px;
  margin: 0;
}

.user-actions button {
  min-height: 36px;
}

.table-pagination {
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
}

.table-pagination button {
  min-height: 30px;
  padding: 6px 10px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline p {
  font-size: 13px;
}

.timeline-item {
  position: relative;
  padding-left: 18px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.timeline-item strong {
  display: block;
  font-size: 13px;
}

.timeline-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.empty-timeline {
  color: var(--muted);
}

pre {
  white-space: pre-wrap;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  max-height: 420px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.response-panel summary {
  cursor: pointer;
  font-weight: 750;
}

.manual-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}

.manual-panel summary::-webkit-details-marker {
  display: none;
}

.manual-panel summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 800;
}

.manual-panel[open] summary {
  margin-bottom: 14px;
}

.manual-panel[open] summary::after {
  content: "-";
}

.manual-panel strong {
  display: block;
  margin-top: 4px;
}

.response-panel pre {
  margin-top: 12px;
}

.status {
  color: var(--warning);
  margin-top: 10px;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar-card {
    display: none;
  }

  .import-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .topbar,
  .page-heading,
  .panel-heading,
  .file-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .session {
    width: 100%;
  }

  .session input {
    width: 100%;
  }

  .content-shell {
    padding: 16px;
  }

  .tabs,
  .workflow-steps,
  .split,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .workflow-steps li {
    min-height: 42px;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .table-toolbar input {
    width: 100%;
  }
}

/* Production add-ons retained from the reviewed release */
#emailOpsStatus {
  margin: 0;
}
#integrationStatus, #outboxResult {
  min-height: 84px;
  margin-top: 12px;
}
#campaignPerformance, #outboxList, #replyQueue, #suppressionList {
  min-height: 42px;
}
