:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --card-soft: #fbfaf7;
  --border: #dcd8cf;
  --border-strong: #c7c1b5;
  --text: #2f2b24;
  --muted: #6c665c;
  --primary: #c27032;
  --primary-dark: #a2551c;
  --accent: #3d6ea8;
  --danger: #c75252;
  --success: #3d7a4e;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

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

body.theme {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8f7f3 0%, #efede6 65%, #e8e4da 100%);
  color: var(--text);
  line-height: 1.5;
}

body.theme.theme--test {
  background: linear-gradient(180deg, #fff7e0 0%, #ffe9b8 60%, #ffd57f 100%);
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2.5rem clamp(1.25rem, 3vw, 4rem) 2rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(63, 57, 49, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.brand-copy h1 {
  margin: 0.1rem 0 0;
  font-size: 1.5rem;
}

.brand-copy .eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-nav {
  display: flex;
  gap: 0.75rem;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.header-stat {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  min-width: 0;
  white-space: nowrap;
}

.header-stat--subscribers {
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
  background: color-mix(in srgb, var(--success) 10%, var(--card-soft));
}

.header-stat--unsubscribed {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--card-soft));
}

.header-stat__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}

.header-stat--subscribers .header-stat__label {
  color: color-mix(in srgb, var(--success) 65%, var(--muted));
}

.header-stat--unsubscribed .header-stat__label {
  color: color-mix(in srgb, var(--danger) 55%, var(--muted));
}

.header-stat__value {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.header-stat__sep {
  font-weight: 500;
  color: var(--muted);
  margin: 0 0.1rem;
}

.header-stat__num--emphasis {
  color: var(--success);
}

.header-stat__num--alert {
  color: color-mix(in srgb, var(--danger) 85%, var(--text));
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  color: var(--text);
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  border-color: var(--border-strong);
  background: rgba(50, 45, 38, 0.06);
}

.nav-link--active {
  background: var(--primary-dark);
  color: #fff;
  border-color: var(--primary-dark);
}

.nav-link--active:hover,
.nav-link--active:focus-visible {
  background: var(--primary-dark);
  color: #fff;
  border-color: var(--primary-dark);
}

.nav-link--ghost {
  border-color: var(--border);
  background: transparent;
}

.nav-link--ghost:hover,
.nav-link--ghost:focus-visible {
  border-color: var(--border-strong);
  background: rgba(47, 43, 36, 0.08);
}

.session-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.session-user {
  color: var(--muted);
  font-size: 0.9rem;
}

.header-add-user {
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.header-add-user:hover,
.header-add-user:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(61, 110, 168, 0.35);
}

.header-mode {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  font-size: 0.85rem;
}

.header-mode__label {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.header-mode__buttons {
  display: flex;
  gap: 0.35rem;
}

.header-mode__button {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.2rem 0.75rem;
  background: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.header-mode__button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.header-mode__button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.header-mode__status {
  font-size: 0.85rem;
  color: var(--muted);
}

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

.app-main {
  flex: 1;
  width: 100%;
  margin: 2rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.app-main--wide {
  width: 100%;
  max-width: none;
}

.flash-stack {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.flash {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 500;
}

.flash-success {
  border-color: rgba(61, 122, 78, 0.35);
}

.flash-error {
  border-color: rgba(199, 82, 82, 0.4);
}

.flash-dismiss {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.15rem;
  cursor: pointer;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  align-items: start;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(135deg, #ffffff, #f3f1eb);
  box-shadow: 0 18px 36px rgba(84, 78, 66, 0.08);
}

.hero-copy h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.hero-note {
  border-left: 1px solid var(--border);
  padding-left: 1.25rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
}

.hero-note code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--card-soft);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.hero-upload-button {
  align-self: flex-start;
}

.user-card__lead {
  margin: 0 0 1rem;
  color: var(--muted);
}

.user-card__current-admins {
  margin-bottom: 1rem;
}

.user-card__current-admins .eyebrow {
  margin-bottom: 0.5rem;
}

.user-card__table-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
}

.user-card__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.user-card__table th,
.user-card__table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.user-card__table th {
  font-weight: 600;
  color: var(--muted);
}

.user-card .status-active {
  color: var(--success, #0a0);
}

.user-card.workflow-modal {
  width: min(520px, 100%);
}

.user-form {
  width: 100%;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.confirm-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.confirm-hero {
  align-items: center;
}

.confirm-meta {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.confirm-meta__item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.7);
}

.confirm-meta__value {
  margin: 0.25rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  word-break: break-word;
}

.confirm-grid {
  display: grid;
  gap: 1.5rem;
}

.confirm-send-options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 2rem;
  margin-top: 0.5rem;
}

.confirm-send-options-row .tag-select-wrap {
  margin-top: 0;
}

.confirm-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 600px;
}

.confirm-form-grid--send-params {
  max-width: none;
  grid-template-columns: repeat(3, minmax(12rem, 1fr));
  min-width: 340px;
}

.confirm-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
}

.confirm-form-grid span {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.confirm-form-grid--send-params span {
  white-space: nowrap;
}

.confirm-preview .preview-frame.preview-frame--peek {
  height: 280px;
  min-height: 0;
}

.confirm-form-grid--restrict {
  grid-template-columns: repeat(2, 1fr);
}

.confirm-form-grid--restrict .eyebrow {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.restrict-time-select {
  max-width: 180px;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.confirm-recipients-choice {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.confirm-recipients-choice .eyebrow {
  margin-bottom: 0;
}

.confirm-recipients-choice .tag-select-wrap {
  max-width: 320px;
}

.confirm-recipients-choice .tag-select-wrap select[multiple] {
  width: 100%;
  max-width: 300px;
}

.tag-count-info {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.confirm-tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.confirm-tag-pill {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.confirm-tag-pill:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.confirm-tag-pill--selected,
.confirm-tag-pill[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.confirm-tag-pill--selected:hover,
.confirm-tag-pill[aria-selected="true"]:hover {
  filter: brightness(1.08);
}

.tag-pills-wrap .tag-pills-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.confirm-recipients-choice--in-section {
  margin-bottom: 1rem;
}

.confirm-restrict-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.confirm-restrict-heading__icon {
  display: inline-flex;
  color: var(--muted);
}

.confirm-restrict-heading__icon svg {
  display: block;
}

.confirm-recipients,
.confirm-send-log {
  grid-column: 1 / -1;
}

.confirm-lint-summary {
  margin: 0;
}

.recipient-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recipient-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.recipient-list__toggle {
  white-space: nowrap;
}

.recipient-table-scroll {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: auto;
  max-height: 360px;
}

.recipient-list table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.recipient-list th,
.recipient-list td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.recipient-list th {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.recipient-list tbody tr:nth-child(even) {
  background: rgba(47, 43, 36, 0.02);
}

.send-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.send-progress time {
  font-weight: 600;
}

.send-log__output {
  background: #111;
  color: #eee;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(17, 17, 17, 0.5);
  min-height: 40vh;
  max-height: 60vh;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
}

@media (min-width: 1100px) {
  .confirm-grid {
    grid-template-columns: minmax(0, 1.85fr) minmax(320px, 1fr);
    align-items: start;
  }
  .confirm-preview {
    grid-column: 1 / 2;
    grid-row: 1;
  }
  .confirm-lint-summary {
    grid-column: 1 / 2;
    grid-row: 2;
  }
  .confirm-recipients {
    grid-column: 1 / -1;
    grid-row: 3;
  }
  .confirm-send {
    grid-column: 1 / -1;
    grid-row: 4;
  }
  .confirm-send-log {
    grid-column: 1 / -1;
    grid-row: 5;
  }
}

.card {
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 1.5rem;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 12px 28px rgba(77, 71, 61, 0.07);
}

.workflow-actions {
  grid-column: 1 / -1;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .workflow-actions {
    grid-template-columns: 1fr;
  }
}

.workflow-actions .card {
  height: 100%;
}

.workflow-actions .card form {
  flex: 1;
}

.workflow-actions .form-grid {
  grid-template-columns: minmax(140px, auto) minmax(0, 1fr);
  column-gap: 1rem;
  align-items: center;
  height: 100%;
}

.workflow-actions .form-grid label {
  display: flex;
  align-items: center;
  margin: 0;
}

.workflow-actions .form-grid input,
.workflow-actions .form-grid select,
.workflow-actions .form-grid textarea {
  width: 100%;
}

.workflow-actions .form-grid button,
.workflow-actions .form-grid .lint-status {
  grid-column: 1 / -1;
}

.workflow-actions .form-grid button {
  margin-top: auto;
}

.workflow-actions .form-grid .lint-status {
  margin: 0;
  align-self: flex-start;
}

@media (max-width: 640px) {
  .workflow-actions .form-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .workflow-actions .form-grid button {
    margin-top: 0;
  }
}

.card.soft {
  background: var(--card-soft);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.badge {
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.upload-card {
  gap: 1.25rem;
}

.upload-card__lead {
  margin: 0;
  color: var(--muted);
}

.upload-card__form {
  margin-top: 0.4rem;
  gap: 0.85rem;
}

.upload-card input[type="file"] {
  border: 1.5px dashed var(--border-strong);
  padding: 1rem;
  border-radius: 12px;
  background: var(--card-soft);
  cursor: pointer;
}

.upload-card input[type="file"]:focus {
  border-color: var(--accent);
  background: #fff;
}

.upload-card input[type="file"]::file-selector-button,
.upload-card input[type="file"]::-webkit-file-upload-button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.upload-card input[type="file"]::file-selector-button:hover,
.upload-card input[type="file"]::-webkit-file-upload-button:hover {
  background: var(--card-soft);
}

.upload-card__note {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* ── manage-campaigns modal ───────────────────────────────── */

.manage-card {
  width: min(680px, 100%);
  gap: 1rem;
}

.manage-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.manage-section__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.manage-section__lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.manage-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

.manage-file-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
}

.manage-file-list__loading,
.manage-file-list__empty {
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.manage-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
}

.manage-file-item + .manage-file-item {
  border-top: 1px solid var(--border);
}

.manage-file-item__name {
  font-size: 0.9rem;
  word-break: break-all;
  min-width: 0;
}

.manage-file-item__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.manage-file-item__download {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.manage-file-item__download:hover {
  background: var(--card-soft);
  color: var(--accent-strong, var(--accent));
}

.manage-file-item__delete {
  flex-shrink: 0;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.manage-file-item__delete:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.manage-file-item__delete--confirm {
  background: #b91c1c;
  color: #fff;
  border-color: #b91c1c;
}

.manage-file-item__delete--confirm:hover {
  background: #991b1b;
  border-color: #991b1b;
  color: #fff;
}

.manage-status {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
}

.manage-status--info {
  color: var(--muted);
  background: var(--card-soft);
}

.manage-status--success {
  color: #15803d;
  background: #f0fdf4;
}

.manage-status--error {
  color: #b91c1c;
  background: #fef2f2;
}

.manage-card .upload-card__form {
  margin-top: 0;
  gap: 0.85rem;
}

.manage-card input[type="file"] {
  border: 1.5px dashed var(--border-strong);
  padding: 1rem;
  border-radius: 12px;
  background: var(--card-soft);
  cursor: pointer;
}

.manage-card input[type="file"]:focus {
  border-color: var(--accent);
  background: #fff;
}

.manage-card input[type="file"]::file-selector-button,
.manage-card input[type="file"]::-webkit-file-upload-button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.manage-card input[type="file"]::file-selector-button:hover,
.manage-card input[type="file"]::-webkit-file-upload-button:hover {
  background: var(--card-soft);
}

.manage-file-item__name {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: color 0.15s ease;
}

.manage-file-item__name:hover {
  color: var(--accent);
}

/* ── disk usage indicator ─────────────────────────────────── */

.disk-usage {
  padding: 0.75rem 1.5rem 0;
}

.disk-usage__label {
  font-size: 0.8rem;
  color: var(--text-muted, #6b7280);
  margin-bottom: 0.35rem;
}

.disk-usage__track {
  width: 100%;
  height: 6px;
  background: var(--card-soft, #f3f4f6);
  border-radius: 3px;
  overflow: hidden;
}

.disk-usage__fill {
  height: 100%;
  background: var(--accent, #2563eb);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.disk-usage__fill--warn {
  background: #f59e0b;
}

.disk-usage__fill--danger {
  background: #ef4444;
}

/* ── campaign image items ─────────────────────────────────── */

.manage-image-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.manage-image-item + .manage-image-item {
  border-top: 1px solid var(--border, #e5e7eb);
}

.manage-image-item__thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
}

.manage-image-item__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  color: var(--text, #1f2937);
}

.manage-image-item__actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.manage-image-item__copy {
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border-strong, #d1d5db);
  border-radius: 6px;
  background: #fff;
  color: var(--text, #1f2937);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.manage-image-item__copy:hover {
  background: var(--card-soft, #f3f4f6);
  border-color: var(--accent, #2563eb);
}

.manage-image-item__copy--success {
  background: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
}

.file-preview-modal {
  width: min(900px, calc(100vw - 3rem));
  height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.file-preview-modal__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.file-preview-modal__frame {
  width: 100%;
  flex: 1;
  border: none;
  display: block;
}

.file-preview-modal__loading,
.file-preview-modal__error {
  margin: 0;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.file-preview-modal__error {
  color: #b91c1c;
}

.workflow-modal-backdrop {
  position: fixed;
  inset: 0;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  z-index: 1600;
}

.workflow-modal {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  border-radius: 20px;
  padding: 2.25rem 1.75rem 1.75rem;
  box-shadow: 0 28px 65px rgba(35, 29, 22, 0.25);
  gap: 1.25rem;
}

.workflow-modal.file-preview-modal {
  width: min(900px, calc(100vw - 3rem));
  height: calc(100vh - 4rem);
  max-height: none;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.75rem 1.75rem;
}

.workflow-modal.manage-html-modal {
  width: min(720px, 100%);
}

.workflow-modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  outline: none;
  box-shadow: none;
}

.focus-card select {
  width: 100%;
}

.focus-card__form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.focus-card__preview {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-label {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.field-control {
  position: relative;
}

.field-control select {
  appearance: none;
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 1rem;
}

.field-control svg {
  position: absolute;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.form-group--recipients {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group--recipients .form-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}

.radio-label input {
  width: auto;
  margin: 0;
}

.tag-select-wrap {
  margin-top: 0.25rem;
}

.tag-select-wrap select[multiple] {
  min-width: 200px;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
}

.help-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.preview-panel {
  grid-column: 1 / -1;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.preview-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-placeholder,
.preview-error {
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--card-soft);
}

.preview-frame {
  width: 100%;
  height: 65vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.preview-frame--peek {
  height: 280px;
}

.lint-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lint-chip {
  border-radius: 999px;
  padding: 0.2rem 0.8rem;
  background: rgba(76, 143, 255, 0.12);
  color: var(--accent);
  font-size: 0.8rem;
}

.lint ul {
  margin: 0.25rem 0 0 1rem;
  color: var(--muted);
}

.lint-summary {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  background: var(--card-soft);
}

.lint-summary__status {
  margin: 0.5rem 0 0;
  font-weight: 500;
}

.lint-summary__status--error,
.lint-blocker,
.lint-status--error {
  color: var(--danger);
}

.lint-summary__status--warning,
.lint-warning,
.lint-status--warning {
  color: #a8731c;
}

.lint-summary__status--ok {
  color: var(--success);
}

.lint-status--info {
  color: var(--muted);
}

.lint-status {
  font-size: 0.9rem;
  margin: -0.2rem 0 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

input,
select,
textarea {
  font: inherit;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 110, 168, 0.15);
}

button,
.button {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  background: #fff;
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}

.button.accent {
  background: var(--accent);
  color: #fff;
  border-color: #2b5688;
}

.button.outline {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
}

.button.ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

.button.full-width {
  width: 100%;
  text-align: center;
}

.button--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
}

.button--danger {
  color: var(--danger);
  border-color: var(--danger);
}

.button--danger:hover {
  background: rgba(199, 82, 82, 0.1);
  border-color: var(--danger);
}

button:disabled,
.button:disabled {
  opacity: 0.5;
  pointer-events: none;
}

button:not(:disabled):hover,
.button:not(:disabled):hover {
  background: #f1eee7;
}

button:focus-visible,
.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(61, 110, 168, 0.2);
}

.card.muted {
  background: var(--card-soft);
}

.card.soft ul {
  padding-left: 1rem;
}

.button-link {
  color: var(--accent);
  font-weight: 600;
}

.app-main form button {
  margin-top: 0.5rem;
}

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

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

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 0.65rem 1.25rem;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn.danger {
  background: var(--danger);
  border-color: #a13b3b;
  color: #fff;
}

.btn:disabled,
.btn[data-loading="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:not(:disabled):hover,
.btn:not(:disabled):focus-visible {
  background: rgba(0, 0, 0, 0.04);
  outline: none;
  box-shadow: 0 0 0 3px rgba(61, 110, 168, 0.15);
}

.customer-manager__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.customer-manager__header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.customer-manager {
  width: 100%;
}

.customer-table-container {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card-soft);
  padding: 1rem;
}

.customer-table-container.is-loading .table-scroll {
  opacity: 0.5;
  pointer-events: none;
}

.customer-table-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.customer-stats-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-alt, #f5f5f5);
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

.customer-stat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.customer-stat__label {
  font-size: 0.8125rem;
  color: var(--muted, #777);
}

.customer-stat__value {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--heading, #222);
}

.customer-stat-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--border, #ddd);
}

.customer-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.btn.icon-btn-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
}

.btn.icon-btn-refresh:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--border);
}

.icon-btn-refresh .icon-refresh {
  flex-shrink: 0;
}

.page-size-control,
.customer-search-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
}

.page-size-control select,
.customer-search-field input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  background: #fff;
  color: var(--text);
  font-size: 0.95rem;
  min-height: 40px;
}

.page-size-control {
  min-width: 150px;
}

.customer-search-field {
  flex: 1;
  min-width: 240px;
}

.customer-tag-filter,
.customer-subscription-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
}

.customer-tag-filter select,
.customer-subscription-filter select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  background: #fff;
  color: var(--text);
  font-size: 0.95rem;
  min-height: 40px;
  min-width: 160px;
}

.customer-form-tags {
  grid-column: 1 / -1;
}

.customer-form-tags .form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  background: var(--border);
  font-size: 0.85rem;
  color: var(--text);
}

.tag-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 4px;
}

.tag-chip-remove:hover {
  color: var(--danger);
}

.tag-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tag-input-wrap {
  position: relative;
  flex: 1;
  max-width: 280px;
}

.tag-input-row input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
}

.tag-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  z-index: 100;
  list-style: none;
  padding: 0.35rem 0;
}

.tag-dropdown:empty {
  display: none;
}

.tag-dropdown-option {
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  display: block;
}

.tag-dropdown-option:hover,
.tag-dropdown-option[aria-selected="true"] {
  background: var(--border);
}

.tag-dropdown-option--create {
  color: var(--primary);
  font-weight: 500;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  padding-top: 0.5rem;
}

.customer-table-tags {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 180px;
}

.th-select,
.td-select {
  width: 2.5rem;
  text-align: center;
  vertical-align: middle;
}

.th-select input,
.td-select input {
  margin: 0;
  cursor: pointer;
}

.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--border);
  border-radius: 10px;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-strong);
}

.bulk-action-bar__count {
  font-weight: 600;
  font-size: 0.95rem;
}

.bulk-action-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
}

.bulk-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.bulk-modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.bulk-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.bulk-modal__header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.bulk-modal__body {
  padding: 1.25rem;
  overflow-y: auto;
}

.bulk-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.bulk-panel p.muted {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.bulk-panel--add-tags {
  min-height: 360px;
}

.bulk-tag-input-wrap {
  max-width: 100%;
}

.bulk-tag-input-wrap .tag-dropdown {
  z-index: 1001;
  max-height: 320px;
}

.bulk-remove-tags-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 200px;
  overflow-y: auto;
}

.bulk-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.bulk-panel--comment textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 80px;
}

.table-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: #fff;
}

.table-status.error {
  border-color: rgba(199, 82, 82, 0.4);
  background: rgba(199, 82, 82, 0.08);
  color: var(--danger);
}

.table-scroll {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.customer-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.customer-table th,
.customer-table td {
  padding: 0.9rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.customer-table th {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.customer-table tbody tr {
  cursor: pointer;
  transition: background 0.2s ease;
}

.customer-table tbody tr:nth-child(odd) {
  background: #fff;
}

.customer-table tbody tr:nth-child(even) {
  background: rgba(50, 45, 38, 0.03);
}

.customer-table tbody tr:hover {
  background: rgba(50, 45, 38, 0.04);
}

.table-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-weight: 600;
}

.pagination-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pager-button {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.pager-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pager-button:not(:disabled):hover,
.pager-button:not(:disabled):focus-visible {
  border-color: var(--primary);
  background: rgba(194, 112, 50, 0.15);
}

.pagination-info {
  font-weight: 600;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-pill.success {
  background: rgba(61, 122, 78, 0.15);
  color: var(--success);
}

.status-pill.muted {
  background: rgba(128, 128, 128, 0.15);
  color: var(--muted);
}

.customer-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21, 17, 12, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 2000;
}

.customer-modal {
  width: min(720px, 96vw);
  border-radius: 20px;
  background: #fff;
  padding: 1.5rem;
  box-shadow: 0 25px 60px rgba(36, 29, 20, 0.18);
}

.customer-modal-backdrop.email-mode .customer-modal {
  width: min(980px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.customer-modal-backdrop.email-mode .customer-modal__body {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.customer-modal__body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.customer-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.icon-button {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.customer-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.required {
  color: var(--danger);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.textarea-field textarea {
  min-height: 110px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
}

.checkbox-field input {
  width: auto;
  margin: 0;
}

.form-alert {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(199, 82, 82, 0.4);
  background: rgba(199, 82, 82, 0.08);
  color: var(--danger);
  font-weight: 600;
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-actions__group {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.modal__content {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.modal__title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.modal__desc {
  margin: 0 0 0.75rem;
  color: var(--text);
}

.modal__warning {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.customer-modal-backdrop[hidden] {
  display: none;
}

.tags-manager {
  max-width: 720px;
}

.tags-manager__header {
  margin-bottom: 1.5rem;
}

.tags-manager__header .eyebrow {
  margin-bottom: 0.25rem;
}

.tags-manager__header .muted {
  margin-top: 0.35rem;
}

.tags-manager__add {
  margin-bottom: 1.5rem;
}

.tags-manager__add-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.tags-manager__add-form input {
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
}

.tags-manager__add-error {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--danger);
}

.tags-manager__add-error[hidden] {
  display: none;
}

.tags-manager__list-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
}

.tags-manager__loading,
.tags-manager__error {
  padding: 1.5rem;
  text-align: center;
}

.tags-manager__empty {
  padding: 1.5rem;
  text-align: center;
}

.tags-table {
  width: 100%;
  border-collapse: collapse;
}

.tags-table th,
.tags-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tags-table th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--card-soft);
}

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

.tags-table .th-actions {
  width: 120px;
  text-align: right;
}

.tags-table td:last-child {
  text-align: right;
}

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

.individual-email-panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem;
  background: var(--card-soft);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.individual-email-panel[hidden] {
  display: none;
}

.individual-email-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.individual-email-panel__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.individual-email-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.individual-email-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.individual-email-grid input,
.individual-email-grid select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
}

.individual-email-preview {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  min-height: clamp(280px, 45vh, 520px);
}

.individual-email-preview iframe {
  width: 100%;
  border: none;
  min-height: 320px;
}

.individual-email-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.form-status {
  font-weight: 600;
  color: var(--muted);
}

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

.form-status.success {
  color: var(--success);
}

.individual-email-placeholder {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 1rem;
  margin-top: 1.5rem;
  text-align: center;
  background: #fff;
  color: var(--muted);
  font-weight: 600;
}

.individual-email-preview .preview-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--muted);
}

/* CSV Import */
.customer-manager__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.import-modal {
  max-width: 540px;
}

.customer-modal.manage-card {
  max-width: 540px;
}

.customer-modal.manage-card .customer-modal__body {
  gap: 0;
}

.customer-modal.manage-card .manage-section {
  padding: 0;
}

.customer-modal.manage-card .manage-divider {
  margin: 1rem 0;
}

.import-instructions {
  margin: 0 0 1rem;
  line-height: 1.6;
  color: var(--muted);
}

.import-instructions code {
  background: var(--bg-muted, rgba(0, 0, 0, 0.05));
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

.import-file-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1rem;
}

.import-file-area.drag-over {
  border-color: var(--accent, #4a7c59);
  background: rgba(74, 124, 89, 0.06);
}

.import-file-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
}

.import-file-icon {
  font-size: 2rem;
  line-height: 1;
}

.import-file-placeholder p {
  margin: 0;
}

.import-file-selected {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.import-file-name {
  font-weight: 600;
  word-break: break-all;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent, #4a7c59);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-button:hover {
  opacity: 0.8;
}

.link-button.danger {
  color: var(--danger, #c0392b);
}

.import-summary {
  margin-bottom: 1rem;
  line-height: 1.6;
}

.import-errors {
  margin-bottom: 1rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.import-errors__title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.import-errors ul {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
  font-size: 0.85rem;
  color: var(--muted);
}

.import-errors li + li {
  margin-top: 0.25rem;
}

.btn[data-loading="true"] {
  position: relative;
}

.btn[data-loading="true"]::after {
  content: "...";
  margin-left: 0.35rem;
}

.duplicate-existing-panel {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-muted, rgba(0, 0, 0, 0.04));
}

.duplicate-existing-panel .muted {
  margin: 0 0 0.75rem;
}

.form-csv-hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.import-on-duplicate-select {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font: inherit;
  background: var(--bg, #fff);
  color: inherit;
}

.import-modal-actions {
  margin-top: 1rem;
}

.import-skipped-block {
  margin-top: 0.75rem;
}

/* Clean Contacts */
.clean-modal {
  max-width: 680px;
}

.clean-description {
  margin: 0 0 1rem;
  line-height: 1.6;
  color: var(--muted);
}

.clean-summary {
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.clean-all-clear-message {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-weight: 600;
}

.clean-section-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.clean-section-lead {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

.clean-groups-scroll,
.clean-invalid-scroll {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.clean-group {
  border-bottom: 1px solid var(--border);
}

.clean-group:last-child {
  border-bottom: none;
}

.clean-group__header {
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--card-soft, rgba(0, 0, 0, 0.02));
  letter-spacing: 0.01em;
}

.clean-group__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.clean-group__table th {
  padding: 0.35rem 0.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--card-soft, rgba(0, 0, 0, 0.02));
  border-bottom: 1px solid var(--border);
}

.clean-group__table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.clean-group__table tbody tr:last-child td {
  border-bottom: none;
}

.clean-group__table input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.clean-invalid-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.clean-invalid-row:last-child {
  border-bottom: none;
}

.clean-invalid-row:hover {
  background: rgba(0, 0, 0, 0.02);
}

.clean-invalid-row input[type="checkbox"] {
  margin-top: 0.15rem;
  cursor: pointer;
  flex-shrink: 0;
}

.clean-invalid-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.clean-invalid-name {
  font-size: 0.85rem;
  color: var(--muted);
}

.clean-invalid-reason {
  font-size: 0.8rem;
  color: var(--danger, #c0392b);
}

.clean-done-summary {
  padding: 1rem 0;
  line-height: 1.6;
}

.clean-done-errors-title {
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
  color: var(--danger, #c0392b);
}

.clean-done-errors {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
  font-size: 0.85rem;
  color: var(--muted);
}

.clean-done-errors li + li {
  margin-top: 0.25rem;
}

[data-clean-duplicates-section] + [data-clean-invalid-section] {
  margin-top: 1.25rem;
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  width: min(420px, 100%);
  padding: 2.5rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 25px 45px rgba(63, 57, 49, 0.18);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-logo {
  width: 216px;
  height: 216px;
  object-fit: contain;
  margin: 0 auto;
}

.auth-title {
  margin: 0;
  font-size: 1.5rem;
}

.auth-subtitle {
  margin: -0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.auth-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.auth-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.65rem 0.8rem;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 110, 168, 0.2);
}

.auth-submit {
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-submit:hover,
.auth-submit:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(194, 112, 50, 0.35);
}

.auth-error {
  border-radius: 10px;
  border: 1px solid rgba(199, 82, 82, 0.35);
  background: rgba(199, 82, 82, 0.08);
  padding: 0.75rem 1rem;
  color: var(--danger);
  font-weight: 600;
}

.auth-meta {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── admin modal ─────────────────────────────────────────── */

.admin-card.workflow-modal {
  width: min(560px, 100%);
}

.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--card-soft);
}

.admin-user-list__loading,
.admin-user-list__empty {
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table thead {
  background: var(--card-soft);
}

.admin-table th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

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

.admin-table .status-active {
  color: var(--success, #2e7d32);
}

.admin-table .status-inactive {
  color: var(--error, #c62828);
}

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

/* ── Campaign history ──────────────────────────────────────────── */

.history-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.25rem;
}

.history-filter {
  display: flex;
  gap: 0.35rem;
}

.history-filter__button {
  font-size: 0.85rem;
  padding: 0.3rem 0.85rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-card {
  position: relative;
  padding: 1.25rem 1.5rem;
}

.history-card__link {
  display: block;
  text-decoration: none;
  color: inherit;
  margin: -1.25rem -1.5rem;
  padding: 1.25rem 1.5rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  border-radius: inherit;
}

.history-card__link:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(63, 57, 49, 0.12);
}

.history-card__archive {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 1;
  margin: 0;
}

.history-card__archive .button--small {
  padding: 0.35rem 0.6rem;
  font-size: 0.8125rem;
}

.history-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.history-card__title h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.history-card__subject {
  margin: 0.2rem 0 0;
  font-size: 0.875rem;
}

.history-card__badges {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.history-card__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.75rem;
}

.history-card__stat {
  display: flex;
  flex-direction: column;
}

.history-card__stat-value {
  font-weight: 600;
  font-size: 0.95rem;
}

.history-card__stat-value--sent {
  color: var(--success);
}

.history-card__stat-value--failed {
  color: var(--danger);
}

.history-card__stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.history-empty {
  padding: 2rem;
  text-align: center;
}

/* Badge variants for mode and status */

.badge--production {
  background: #e8f5e9;
  color: var(--success);
  border-color: #c8e6c9;
}

.badge--test {
  background: #fff8e1;
  color: #f57c00;
  border-color: #ffe082;
}

.badge--running {
  background: #e3f2fd;
  color: #1565c0;
  border-color: #90caf9;
}

.badge--completed {
  background: #e8f5e9;
  color: var(--success);
  border-color: #c8e6c9;
}

.badge--failed {
  background: #ffebee;
  color: var(--danger);
  border-color: #ef9a9a;
}

.badge--sent {
  background: #e8f5e9;
  color: var(--success);
  border-color: #c8e6c9;
}

/* ── History detail ───────────────────────────────────────────── */

.history-detail__grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.history-summary__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.history-summary__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.history-summary__legend-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--muted);
}

.history-summary__legend-dot--sent {
  background: var(--success);
}

.history-summary__legend-dot--failed {
  background: var(--danger);
}

.history-summary__legend-dot--pending {
  background: var(--muted);
}

.history-summary__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1.25rem;
  padding: 0.75rem 0 0;
}

.history-summary__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.history-summary__stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.history-summary__stat-value--sent {
  color: var(--success);
}

.history-summary__stat-value--failed {
  color: var(--danger);
}

.history-summary__stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.2rem;
}

.history-results .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.history-results__filter {
  display: flex;
  gap: 0.35rem;
}

.history-results__filter .button {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
}

.history-results__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.history-results__table thead {
  background: var(--card-soft);
}

.history-results__table th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.history-results__table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.history-results__table tbody tr:last-child td {
  border-bottom: none;
}

.history-results__error {
  color: var(--muted);
  font-size: 0.8rem;
  max-width: 300px;
  word-break: break-word;
}

.history-results__row--failed td:first-child {
  border-left: 3px solid var(--danger);
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-note {
    border-left: none;
    padding-left: 0;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .primary-nav {
    width: 100%;
  }
  .preview-panel {
    grid-column: span 1;
  }
  .history-card__header {
    flex-direction: column;
  }
  .history-card__stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
