:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --sidebar: #121b18;
  --sidebar-soft: #22312c;
  --surface: #ffffff;
  --surface-alt: #f8faf9;
  --surface-strong: #eef4f2;
  --line: #e1e8e5;
  --line-strong: #c6d3ce;
  --text: #151f1b;
  --muted: #66756e;
  --accent: #0d8b72;
  --accent-strong: #076d59;
  --accent-soft: #e4f5ef;
  --blue: #2e63a8;
  --blue-soft: #e9f1ff;
  --danger: #b33a3a;
  --danger-soft: #fff0f0;
  --warning: #9a6812;
  --warning-soft: #fff4dc;
  --shadow: 0 18px 50px rgba(22, 33, 29, 0.08);
  --shadow-soft: 0 8px 22px rgba(22, 33, 29, 0.05);
  --shadow-focus: 0 0 0 4px rgba(13, 139, 114, 0.13);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

.hidden,
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

button:hover {
  border-color: var(--accent);
}

button:active {
  transform: translateY(1px);
}

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

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button.secondary {
  background: var(--surface-alt);
}

button.icon-button {
  width: 34px;
  min-height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.ui-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
}

.ui-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

body.locked .app-shell {
  display: none;
}

body:not(.locked) .auth-screen {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 16%, rgba(13, 139, 114, 0.13), transparent 30%),
    linear-gradient(180deg, #f8fbfa, #eef4f2);
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 16px;
}

.auth-card .brand-block {
  margin-bottom: 4px;
}

.auth-card button {
  min-height: 42px;
}

.app-sidebar {
  background: var(--sidebar);
  color: #f4fbf8;
  min-height: 100vh;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.06);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.brand-block h1,
.brand-block p,
.page-heading h2,
.page-heading p,
.monitor-header h3,
.monitor-header p,
.step-label h3,
.pane-header h3,
.modal-header h2,
.modal-header p {
  margin: 0;
}

.brand-block h1 {
  font-size: 18px;
  line-height: 1.1;
}

.brand-block p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.main-nav {
  display: grid;
  gap: 10px;
}

.main-nav button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d6e2dc;
  min-height: 62px;
  padding: 12px;
  text-align: left;
  display: grid;
  gap: 3px;
}

.main-nav button:hover,
.main-nav button.active {
  background: var(--sidebar-soft);
  color: #fff;
  box-shadow: inset 3px 0 var(--accent);
}

.main-nav span {
  font-weight: 800;
}

.main-nav small {
  color: #99aaa2;
  font-size: 12px;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.connection-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 13px;
  display: grid;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.connection-card span {
  color: #9dafaa;
  font-size: 12px;
}

.connection-card strong {
  font-size: 13px;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  min-height: 76px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.top-brand {
  min-width: 220px;
}

.top-nav {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 22px;
}

.top-nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  position: relative;
  padding: 12px 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.top-nav .ui-icon {
  width: 17px;
  height: 17px;
}

.top-nav a:hover,
.top-nav a.active {
  color: var(--accent-strong);
}

.top-nav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
}

.topbar-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  padding: 0 11px;
  white-space: nowrap;
}

.logout-button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.logout-button:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.settings-button {
  width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 900;
  padding: 0;
  line-height: 1;
}

.settings-button .ui-icon {
  width: 28px;
  height: 28px;
}

.settings-button:hover {
  border-color: transparent;
  background: var(--surface-alt);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.app-status-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

.section-shell {
  flex: 1;
  min-width: 0;
}

.app-section {
  display: none;
  padding: 28px;
  width: min(100%, 1500px);
  margin: 0 auto;
}

.app-section.active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.page-heading h2 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.page-heading p,
.monitor-header p,
.modal-header p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-tile,
.campaign-monitor,
.builder-section,
.editor-pane,
.preview-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-tile {
  min-height: 86px;
  padding: 15px;
  display: grid;
  align-content: space-between;
  box-shadow: var(--shadow-soft);
}

.metric-tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-tile span::before {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 14px;
  line-height: 1;
}

.metric-tile:nth-child(1) span::before {
  content: "∑";
}

.metric-tile:nth-child(2) span::before {
  content: "▶";
}

.metric-tile:nth-child(3) span::before {
  content: "◷";
}

.metric-tile:nth-child(4) span::before {
  content: "✓";
}

.metric-tile:nth-child(5) span::before {
  content: "!";
  background: var(--danger-soft);
  color: var(--danger);
}

.metric-tile strong {
  font-size: 32px;
  line-height: 1;
}

.campaign-monitor {
  overflow: visible;
}

.user-admin {
  padding: 0;
  overflow: hidden;
}

.users-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.users-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.users-table th,
.users-table td {
  height: 58px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  background: #fff;
}

.users-table th {
  height: 44px;
  background: #f7faf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1) {
  width: 30%;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  width: 24%;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3) {
  width: 16%;
}

.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  width: 18%;
}

.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  width: 132px;
  text-align: right;
}

.users-table tbody tr:hover td {
  background: #fbfdfc;
}

.user-name {
  display: block;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-login {
  display: inline-flex;
  max-width: 100%;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 12px;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.users-table .campaign-actions {
  min-width: 0;
  justify-content: flex-end;
  gap: 6px;
}

.users-table .row-action.icon-only {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  background: #fff;
}

.users-table .row-action.icon-only .ui-icon {
  width: 16px;
  height: 16px;
}

.users-table input,
.users-table select {
  min-height: 34px;
  padding: 0 9px;
  font-size: 13px;
}

.editing-row td {
  background: var(--accent-soft) !important;
}

.inline-switch {
  padding: 0;
  border: 0;
  background: transparent;
  justify-content: flex-start;
  white-space: nowrap;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 900;
  background: var(--surface-alt);
  color: var(--muted);
}

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

.role-badge.user {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.monitor-header {
  min-height: 72px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  align-items: center;
  gap: 16px;
}

.monitor-header h3,
.pane-header h3,
.step-label h3 {
  font-size: 15px;
  line-height: 1.2;
}

progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
  appearance: none;
}

progress::-webkit-progress-bar {
  background: var(--surface-alt);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.campaign-table-wrap {
  overflow: visible;
  max-width: 100%;
}

.campaign-table,
#recipientsTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.campaign-table {
  min-width: 760px;
}

.campaign-table th,
.campaign-table td,
#recipientsTable th,
#recipientsTable td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.campaign-table th,
#recipientsTable th {
  color: var(--muted);
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.campaign-table td {
  min-width: 110px;
  background: var(--surface);
}

.campaign-table th:nth-child(4),
.campaign-table th:nth-child(5),
.campaign-table th:nth-child(6),
.campaign-table td:nth-child(4),
.campaign-table td:nth-child(5),
.campaign-table td:nth-child(6) {
  display: none;
}

.campaign-table th:last-child,
.campaign-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 220px;
  box-shadow: -12px 0 18px rgba(255, 255, 255, 0.92);
}

.campaign-table th:last-child {
  z-index: 3;
}

.campaign-row {
  cursor: pointer;
}

.campaign-row.active td {
  background: var(--accent-soft);
}

.campaign-row:focus-visible td {
  outline: 2px solid rgba(15, 143, 114, 0.35);
  outline-offset: -2px;
}

.campaign-row.menu-open td {
  position: relative;
  z-index: 30;
}

.campaign-row.menu-open td:last-child {
  z-index: 60;
}

.campaign-row:hover td {
  background: #fbfdfc;
}

.campaign-row.active td:last-child,
.campaign-row:hover td:last-child {
  box-shadow: -12px 0 18px rgba(251, 253, 252, 0.96);
}

.campaign-title {
  min-width: 300px;
  display: grid;
  gap: 4px;
}

.campaign-title strong {
  font-size: 14px;
}

.campaign-title span,
.campaign-date,
.muted,
.summary {
  color: var(--muted);
  font-size: 12px;
}

.campaign-title .row-error {
  color: var(--danger);
}

.campaign-status {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  background: var(--surface-alt);
  color: var(--muted);
}

.campaign-status.running,
.campaign-status.queued {
  background: var(--blue-soft);
  color: var(--blue);
}

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

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

.campaign-status.completed {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.campaign-status.failed,
.campaign-status.completed_with_errors {
  background: var(--danger-soft);
  color: var(--danger);
}

.campaign-status.canceled {
  background: #eceff1;
  color: #59656f;
}

.campaign-progress {
  min-width: 165px;
  display: grid;
  gap: 6px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.campaign-counts {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.campaign-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 200px;
}

.row-action {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.row-action .ui-icon {
  width: 15px;
  height: 15px;
}

.row-action.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.row-action.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.row-action.ghost {
  background: transparent;
  border-color: var(--line);
}

.row-action.danger {
  color: var(--danger);
}

.action-menu {
  position: relative;
}

.action-menu-trigger {
  width: 34px;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 0;
  font-size: 12px;
  font-weight: 800;
  user-select: none;
}

.action-menu-trigger .ui-icon {
  width: 18px;
  height: 18px;
}

.action-menu.open .action-menu-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 114, 0.1);
}

.action-menu-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 20;
  width: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  gap: 4px;
}

.action-menu.open .action-menu-panel {
  display: grid;
}

.action-menu-panel .row-action {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.action-menu-panel .row-action:hover {
  background: var(--surface-alt);
  border-color: transparent;
}

.action-menu-panel .row-action.danger:hover {
  background: var(--danger-soft);
}

.campaign-toolbar {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  align-items: end;
  gap: 12px;
  background: #fbfdfc;
}

.search-field {
  display: grid;
  gap: 6px;
}

.search-field span {
  margin: 0;
}

.filter-tabs {
  display: inline-flex;
  justify-content: flex-end;
  justify-self: end;
  gap: 2px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  padding: 4px;
}

.filter-tabs button {
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12px;
  padding: 0 12px;
  color: var(--muted);
}

.filter-tabs button.active {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.empty-state {
  display: none;
  padding: 54px 16px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

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

.campaign-table-wrap.empty .empty-state {
  display: block;
}

.campaign-builder {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  min-width: 0;
}

#newCampaignSection {
  width: min(100%, 1500px);
}

#newCampaignSection .page-heading {
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

#newCampaignSection .page-heading h2 {
  font-size: 24px;
}

.composer-actions {
  gap: 10px;
  align-items: center;
}

.composer-actions button {
  min-height: 38px;
}

.builder-rail {
  display: grid;
  grid-template-columns: minmax(300px, 0.76fr) minmax(460px, 1.24fr);
  gap: 16px;
  align-items: stretch;
}

.builder-section {
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
  box-shadow: var(--shadow-soft);
}

.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.step-label > span {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.sender-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.mini-summary {
  min-height: 42px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.mini-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin: 0;
}

.mini-summary strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 560px;
  resize: vertical;
  padding: 15px;
  line-height: 1.5;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 13px;
  tab-size: 2;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 114, 0.12);
}

.dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  min-height: 96px;
  display: grid;
  place-items: center;
  gap: 5px;
  text-align: center;
  background: var(--surface-alt);
  color: var(--muted);
  cursor: pointer;
  padding: 16px;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone input {
  display: none;
}

.dropzone strong {
  color: var(--text);
  font-size: 14px;
}

.dropzone-icon {
  width: 30px;
  height: 30px;
  color: var(--accent-strong);
}

.recipient-line {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: #fff;
}

.recipient-line span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

#recipientBadge {
  color: var(--accent-strong);
  font-size: 18px;
}

.summary.error {
  color: var(--danger);
}

.summary.ok {
  color: var(--accent-strong);
}

.table-wrap {
  max-height: 176px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

#recipientsTable td {
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#recipientsTable tbody tr {
  cursor: pointer;
}

#recipientsTable tbody tr:hover,
#recipientsTable tbody tr.selected {
  background: var(--accent-soft);
}

.builder-workspace {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.message-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.editor-preview {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(460px, 1fr);
  gap: 16px;
  min-width: 0;
  align-items: stretch;
}

.editor-pane,
.preview-pane {
  padding: 14px;
  min-width: 0;
  box-shadow: var(--shadow-soft);
}

.editor-pane,
.preview-pane {
  display: grid;
  grid-template-rows: auto minmax(560px, 1fr);
}

.pane-header {
  min-height: 34px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.placeholder-list {
  display: flex;
  gap: 6px;
  overflow: visible;
  justify-content: flex-end;
  min-width: 0;
  max-width: min(60%, 520px);
  padding-bottom: 2px;
}

.placeholder {
  min-width: 0;
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  display: inline-block;
}

.placeholder-menu {
  position: relative;
}

.placeholder-menu summary {
  min-height: 28px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.placeholder-menu summary::-webkit-details-marker {
  display: none;
}

.placeholder-menu[open] summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 114, 0.1);
}

.placeholder-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: min(360px, calc(100vw - 48px));
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 8px;
}

.placeholder-menu-panel .placeholder {
  width: 100%;
  max-width: none;
  text-align: left;
  border-radius: 8px;
  padding: 7px 9px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  border: 0;
  border-radius: 0;
  min-height: 32px;
  padding: 0 10px;
  gap: 6px;
}

.segmented .ui-icon {
  width: 16px;
  height: 16px;
}

.segmented button.active {
  background: var(--text);
  color: #fff;
}

.mail-client {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f9fbfa;
  min-height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(552px, 1fr);
}

.mail-toolbar {
  min-height: 66px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
}

.mail-toolbar strong,
.mail-toolbar span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-toolbar span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.preview-frame-wrap {
  background: #e8eeeb;
  min-height: 552px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  overflow: auto;
}

.preview-frame-wrap.mobile iframe {
  width: 390px;
}

.preview-frame-wrap.desktop iframe {
  width: min(760px, 100%);
}

iframe {
  border: 0;
  min-height: 100%;
  background: #fff;
  box-shadow: 0 8px 26px rgba(22, 32, 28, 0.12);
}

.settings-modal {
  width: min(780px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.settings-modal::backdrop {
  background: rgba(15, 25, 20, 0.42);
}

.settings-dialog {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-header h2 {
  font-size: 20px;
}

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

.switch-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.switch span {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.switch input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.modal-actions {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.launch-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.launch-summary div {
  min-height: 42px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.launch-summary div:last-child {
  border-bottom: 0;
}

.launch-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.launch-summary strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.confirm-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface-alt);
}

.confirm-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 1px;
  accent-color: var(--accent);
}

.confirm-row span {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.draft-state {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
  white-space: nowrap;
}

.draft-state.saving {
  background: var(--blue-soft);
  border-color: #c9daf8;
  color: var(--blue);
}

.draft-state.saved {
  background: var(--accent-soft);
  border-color: #c3e6da;
  color: var(--accent-strong);
}

.draft-state.error {
  background: var(--danger-soft);
  border-color: #f0c6c6;
  color: var(--danger);
}

.view-mode-notice {
  margin: -4px 0 18px;
  border: 1px solid #d8e0ea;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #f5f8fc;
  color: var(--text);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
}

.view-mode-notice.hidden {
  display: none;
}

.app-section.readonly input[readonly],
.app-section.readonly textarea[readonly] {
  background: #f7f8f8;
  color: var(--muted);
  cursor: default;
}

.dropzone.disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.dropzone.disabled * {
  pointer-events: none;
}

/* Product polish */
.topbar {
  min-height: 72px;
  padding: 12px 36px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 rgba(18, 31, 26, 0.04), 0 10px 28px rgba(18, 31, 26, 0.05);
}

.brand-mark {
  background: linear-gradient(145deg, var(--accent), #1aa387);
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.08);
}

.brand-block h1 {
  font-size: 19px;
}

.brand-block p {
  color: #718079;
}

.top-nav a {
  color: #53625b;
  letter-spacing: 0;
}

.top-nav a.active::after {
  bottom: 2px;
  height: 3px;
}

.settings-button {
  border-radius: 10px;
  color: #2b3732;
}

.settings-button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

button {
  box-shadow: 0 1px 1px rgba(16, 24, 20, 0.04);
}

button.primary {
  box-shadow: 0 10px 22px rgba(13, 139, 114, 0.2);
}

button.primary:hover {
  box-shadow: 0 12px 26px rgba(13, 139, 114, 0.24);
}

.app-section {
  padding: 32px 36px;
}

.page-heading {
  margin-bottom: 22px;
}

.page-heading h2 {
  font-size: 30px;
}

.page-heading p {
  max-width: 760px;
}

.metric-tile,
.campaign-monitor,
.builder-section,
.editor-pane,
.preview-pane,
.message-settings {
  border-color: rgba(198, 211, 206, 0.82);
  box-shadow: var(--shadow-soft);
}

.metric-tile {
  min-height: 96px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fff, #fbfdfc);
}

.metric-tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent);
}

.metric-tile strong {
  font-size: 34px;
  letter-spacing: 0;
}

.campaign-monitor {
  border-radius: 10px;
}

.monitor-header {
  padding: 18px 20px;
  background: #fff;
}

.campaign-toolbar {
  background: #fbfcfc;
  padding: 14px 20px;
}

.filter-tabs {
  border-color: var(--line);
  background: #fff;
}

.filter-tabs button.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.campaign-table th {
  background: #f7faf9;
}

.campaign-table td {
  transition: background 0.14s ease;
}

.campaign-title strong {
  color: var(--text);
}

.campaign-status {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 900;
}

#newCampaignSection {
  width: min(100%, 1500px);
}

#newCampaignSection .page-heading {
  padding: 16px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
}

.composer-actions {
  flex-wrap: nowrap;
}

.draft-state {
  border-color: transparent;
  background: #eef4f2;
}

.builder-rail {
  grid-template-columns: minmax(320px, 0.72fr) minmax(520px, 1.28fr);
}

.builder-section,
.editor-pane,
.preview-pane,
.message-settings {
  border-radius: 10px;
}

.step-label > span {
  background: #10231d;
  color: #fff;
}

.step-label h3,
.pane-header h3 {
  font-size: 16px;
}

input,
select,
textarea {
  border-color: #cbd7d2;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #adbfba;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.dropzone {
  border-color: #b8c8c2;
  background: #f8fbfa;
}

.dropzone:hover {
  border-color: var(--accent);
  background: #f2faf7;
}

.recipient-line,
.mini-summary,
.table-wrap,
.mail-client,
.preview-frame-wrap,
.launch-summary,
.confirm-row {
  border-color: var(--line);
}

.message-settings {
  background: #fff;
}

.editor-preview {
  gap: 18px;
}

.editor-pane textarea {
  background: #fcfefd;
}

.pane-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.placeholder {
  background: #f8fbfa;
  border-color: #d8e2de;
}

.placeholder:hover {
  background: var(--blue-soft);
  border-color: #bfd2f1;
}

.segmented {
  border-color: var(--line);
}

.segmented button.active {
  background: #111c18;
}

.mail-toolbar {
  background: #fff;
}

.preview-frame-wrap {
  background: #eef3f1;
}

iframe {
  border-radius: 4px;
}

.settings-modal {
  border-radius: 10px;
}

.settings-dialog {
  padding: 22px;
}

.modal-actions {
  justify-content: flex-end;
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .campaign-builder,
  .builder-rail,
  .editor-preview,
  .message-settings,
  .campaign-toolbar {
    grid-template-columns: 1fr;
  }

  .filter-tabs {
    justify-content: flex-start;
  }

  textarea {
    min-height: 420px;
  }

  .editor-pane,
  .preview-pane {
    grid-template-rows: auto minmax(420px, 1fr);
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .top-brand,
  .topbar-actions,
  .top-nav {
    justify-self: stretch;
  }

  .top-nav {
    justify-self: start;
    gap: 18px;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .page-heading,
  .monitor-header {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  #newCampaignSection .page-heading {
    align-items: stretch;
  }

  .composer-actions {
    justify-content: stretch;
  }

  .composer-actions button,
  .composer-actions .draft-state {
    width: 100%;
    justify-content: center;
  }

  .app-section {
    padding: 16px;
  }

  .metrics-grid,
  .message-settings,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .section-actions {
    justify-content: flex-start;
  }

  .draft-state {
    width: 100%;
    justify-content: center;
  }

  .campaign-table th:nth-child(4),
  .campaign-table th:nth-child(5),
  .campaign-table th:nth-child(6),
  .campaign-table td:nth-child(4),
  .campaign-table td:nth-child(5),
  .campaign-table td:nth-child(6) {
    display: none;
  }

  .preview-frame-wrap.mobile iframe,
  .preview-frame-wrap.desktop iframe {
    width: 100%;
  }

  .campaign-table {
    min-width: 820px;
  }

  .campaign-table-wrap {
    overflow: auto;
  }

  .campaign-table th:last-child,
  .campaign-table td:last-child {
    min-width: 220px;
  }

  .campaign-actions {
    min-width: 200px;
  }
}
