:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #64748b;
  --line: #dce3ec;
  --line-soft: #edf1f5;
  --accent: #176b87;
  --accent-strong: #0f5067;
  --accent-soft: #e9f5f8;
  --sidebar: #16202d;
  --sidebar-ink: #e8eef5;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 16px;
  background: var(--sidebar);
  color: var(--sidebar-ink);
}

.brand {
  display: block;
  margin-bottom: 28px;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  padding: 10px 12px;
  border-radius: 6px;
  color: #cbd5e1;
  text-decoration: none;
}

.nav-list a.active,
.nav-list a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.app-main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar-label,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.user-chip {
  display: grid;
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.user-chip small,
.muted {
  color: var(--muted);
}

.logout-form {
  margin: 0;
}

.sidebar-account {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding: 18px 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-user-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-user-text {
  display: grid;
  min-width: 0;
}

.sidebar-user-text strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-text small {
  overflow: hidden;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: transparent;
  color: #dbe7f3;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.logout-button:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.content {
  width: min(1120px, calc(100vw - 320px));
  margin: 0 auto;
  padding: 28px;
}

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

.page-heading h1,
.auth-panel h1 {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.2;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.dashboard-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.dashboard-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.dashboard-filters select,
.dashboard-filters input[type="text"] {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1.1;
}

.dashboard-panel {
  display: grid;
  gap: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.chart-wrap {
  overflow-x: auto;
}

#dashboard-chart {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
}

.flash {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f3fbf7;
}

.flash-error {
  border-color: #e4b8b8;
  background: #fff4f4;
  color: #8a2525;
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.form-stack label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.form-stack input,
.form-stack textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
}

.form-stack textarea {
  resize: vertical;
}

.compact-form {
  max-width: 460px;
  margin-top: 0;
}

.primary-button {
  min-height: 42px;
  padding: 9px 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

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

.mail-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.mail-panel {
  display: grid;
  gap: 18px;
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-list a {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.tab-list a.active,
.tab-list a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.mail-filters-dense {
  grid-template-columns: 1.1fr 1.2fr 1.2fr 1.2fr 1fr 1fr 0.7fr auto;
  align-items: end;
}

.mail-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mail-filters input,
.mail-filters select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.mail-filter-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.compose-panel {
  max-width: 980px;
}

.compose-form {
  margin-top: 0;
}

.compose-workbench {
  padding: 0;
}

.compose-workbench .compose-form {
  gap: 0;
}

.compose-section {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.compose-section:last-of-type {
  border-bottom: 0;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-title span,
.attachment-help {
  color: var(--muted);
  font-size: 13px;
}

.form-stack label b {
  color: #b53131;
}

.body-editor {
  min-height: 360px;
  font-family: Arial, Helvetica, sans-serif;
}

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

.compose-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compose-actions {
  padding: 20px;
  justify-content: flex-end;
}

.attachment-error {
  padding: 10px 12px;
  border: 1px solid #e4b8b8;
  border-radius: 6px;
  background: #fff4f4;
  color: #8a2525;
  font-size: 14px;
}

.attachment-preview {
  display: grid;
  gap: 8px;
}

.attachment-table {
  min-width: 620px;
}

.attachment-table th:last-child,
.attachment-table td:last-child {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.attachment-row-error td {
  background: #fff4f4;
  color: #8a2525;
}

.attachment-row-error td:first-child {
  font-weight: 700;
}

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

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.subject-link {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outbox-table {
  min-width: 1080px;
}

.outbox-table th:nth-child(1) {
  width: 42%;
}

.outbox-table th:nth-child(2) {
  width: 17%;
}

.outbox-table th:nth-child(3) {
  width: 18%;
}

.outbox-table th:nth-child(5) {
  width: 1%;
}

.mail-info-cell {
  min-width: 380px;
}

.subject-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-note-muted {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.recipient-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
}

.email-badge {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  min-height: 24px;
  padding: 3px 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #eef1f5;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.small-button {
  min-height: 34px;
  padding: 6px 10px;
  white-space: nowrap;
}

.error-cell {
  max-width: 260px;
  color: #8a2525;
  font-size: 13px;
}

.table-note {
  display: block;
  max-width: 360px;
  overflow: hidden;
  color: #8a2525;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.row-actions form {
  margin: 0;
}

.danger-button:hover {
  border-color: #b53131;
  color: #8a2525;
}

.danger-primary-button {
  border-color: #b53131;
  background: #b53131;
}

.danger-primary-button:hover {
  background: #8a2525;
  box-shadow: 0 10px 22px rgba(181, 49, 49, 0.18);
}

.field-error {
  margin-top: 3px;
  color: #b53131;
  font-size: 12px;
  font-weight: 700;
}

.form-stack input[aria-invalid="true"],
.form-stack textarea[aria-invalid="true"],
.blacklist-field input[aria-invalid="true"],
.blacklist-field textarea[aria-invalid="true"],
.mail-filters input[aria-invalid="true"],
.mail-filters select[aria-invalid="true"],
.dashboard-filters input[aria-invalid="true"],
.dashboard-filters select[aria-invalid="true"] {
  border-color: #d45a5a;
  background: #fff8f8;
}

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

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.confirm-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  width: min(420px, 100%);
  padding: 20px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff4f4;
  color: #b53131;
  font-size: 20px;
  font-weight: 900;
}

.confirm-copy h2 {
  margin: 0;
  font-size: 19px;
}

.confirm-copy p {
  margin: 6px 0 0;
  color: var(--muted);
}

.confirm-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.view-button {
  gap: 6px;
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.button-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-SENT {
  border-color: #b7dec8;
  background: #eefaf3;
  color: #236c45;
}

.status-FAILED {
  border-color: #e4b8b8;
  background: #fff4f4;
  color: #8a2525;
}

.status-PENDING {
  border-color: #c8d7e8;
  background: #f1f6fc;
  color: #315b86;
}

.status-PROCESSING {
  border-color: #f1c27d;
  background: #fff8ed;
  color: #8a551c;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
}

.pagination div {
  display: flex;
  gap: 10px;
}

.mail-detail iframe {
  display: block;
  width: 100%;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.app-dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.app-dialog form {
  margin: 0;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-heading h2 {
  margin: 0;
  font-size: 18px;
}

.icon-close,
.icon-remove {
  min-width: 34px;
  min-height: 34px;
  padding: 4px 8px;
}

.icon-close {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.recipient-dialog-list {
  display: grid;
  gap: 6px;
  max-height: 50vh;
  overflow: auto;
  padding: 18px;
}

.recipient-dialog-item {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(32, 36, 44, 0.08);
}

.auth-link {
  justify-self: center;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.auth-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.account-panel {
  display: grid;
  gap: 18px;
}

.account-panel .form-stack {
  margin-top: 0;
}

.account-panel input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
}

.account-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--surface-soft);
}

.account-meta div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

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

.account-meta strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: none;
  width: 40px;
  height: 40px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.icon-button span {
  display: block;
  height: 2px;
  margin: 4px 0;
  background: var(--ink);
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 5;
    width: 248px;
    transform: translateX(-100%);
    transition: transform 160ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .icon-button {
    display: block;
  }

  .content {
    width: 100%;
    padding: 20px;
  }

  .dashboard-heading,
  .panel-heading,
  .mail-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-filters {
    justify-content: stretch;
  }

  .dashboard-filters select,
  .dashboard-filters input[type="text"],
  .dashboard-filters .primary-button,
  .dashboard-filters .secondary-button {
    flex: 1 1 140px;
  }

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

  .mail-filters {
    grid-template-columns: 1fr;
  }

  .mail-filters-dense {
    grid-template-columns: 1fr;
  }

  .mail-filter-actions,
  .compose-grid,
  .compose-grid-three,
  .account-grid,
  .pagination {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .account-meta {
    grid-template-columns: 1fr;
  }
}

/* Mail dashboard refresh */
.app-shell {
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  padding: 22px 16px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  font-size: 19px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #ffffff;
  color: var(--accent-strong);
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.nav-list {
  gap: 8px;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-radius: 10px;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-list a.active {
  box-shadow: inset 3px 0 0 #7dd3fc;
}

.nav-list a:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  font-size: 15px;
  line-height: 1;
}

.topbar {
  padding: 0 32px;
  border-bottom-color: var(--line-soft);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
}

.user-chip {
  border-radius: 10px;
  background: var(--surface-soft);
}

.content {
  width: min(1280px, calc(100vw - 320px));
  padding: 32px;
}

.page-heading h1,
.auth-panel h1 {
  font-size: 32px;
  letter-spacing: 0;
}

.page-subtitle {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
}

.panel {
  border-color: var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.primary-button,
.secondary-button {
  border-radius: 10px;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease, transform 150ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  text-decoration: none;
}

.primary-button:hover {
  box-shadow: 0 10px 22px rgba(23, 107, 135, 0.18);
}

.secondary-button {
  cursor: pointer;
}

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

.primary-button:focus-visible,
.secondary-button:focus-visible,
.link-button:focus-visible,
.icon-button:focus-visible,
.icon-close:focus-visible,
.mail-filters input:focus,
.mail-filters select:focus,
.form-stack input:focus,
.form-stack textarea:focus,
.dashboard-filters select:focus,
.dashboard-filters input[type="text"]:focus {
  outline: 3px solid rgba(23, 107, 135, 0.18);
  outline-offset: 2px;
  border-color: var(--accent);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.mail-panel {
  gap: 20px;
}

.mail-filters-dense {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--surface-soft);
}

.mail-filters input,
.mail-filters select,
.form-stack input,
.form-stack textarea,
.dashboard-filters select,
.dashboard-filters input[type="text"] {
  border-radius: 10px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.mail-filter-actions {
  grid-column: span 4;
  justify-content: flex-end;
}

.compose-workbench {
  overflow: hidden;
}

.compose-section {
  padding: 22px;
}

.table-wrap {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--surface);
}

.data-table th,
.data-table td {
  padding: 16px 14px;
  border-bottom-color: var(--line-soft);
}

.data-table th {
  background: var(--surface-soft);
}

.data-table tbody tr {
  transition: background 150ms ease;
}

.data-table tbody tr:hover {
  background: #fbfcfe;
}

.subject-link {
  max-width: 420px;
  color: var(--ink);
  text-decoration: none;
}

.subject-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.subject-line {
  align-items: center;
  gap: 8px;
}

.sender-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.email-badge {
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
}

.link-button {
  text-decoration: none;
}

.link-button:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.small-button {
  min-height: 36px;
  padding: 7px 12px;
}

.status-badge {
  padding: 4px 10px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 34px 18px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-size: 17px;
}

.pagination {
  font-size: 14px;
}

.mail-detail iframe,
.app-dialog,
.recipient-dialog-item,
.icon-button,
.icon-close {
  border-radius: 10px;
}

@media (max-width: 1180px) {
  .content {
    width: 100%;
  }

  .mail-filters-dense {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mail-filter-actions {
    grid-column: span 2;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: 264px;
  }

  .topbar {
    min-height: 66px;
    padding: 0 16px;
  }

  .user-chip {
    display: none;
  }

  .sidebar-user-chip {
    display: grid;
  }

  .logout-form .secondary-button {
    min-height: 38px;
    padding: 7px 10px;
  }

  .content {
    padding: 22px 16px;
  }

  .page-heading h1,
  .auth-panel h1 {
    font-size: 26px;
  }

  .mail-filters-dense {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .mail-filter-actions {
    grid-column: auto;
  }

  .mail-filter-actions .primary-button,
  .mail-filter-actions .secondary-button,
  .compose-actions .primary-button,
  .compose-actions .secondary-button {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .outbox-table,
  .outbox-table thead,
  .outbox-table tbody,
  .outbox-table tr,
  .outbox-table th,
  .outbox-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .outbox-table thead {
    display: none;
  }

  .outbox-table tr {
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
  }

  .outbox-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-soft);
  }

  .outbox-table td:last-child {
    border-bottom: 0;
  }

  .mail-info-cell {
    min-width: 0;
  }

  .subject-link {
    max-width: calc(100vw - 116px);
  }

  .email-badge {
    max-width: 100%;
  }

  .pagination div {
    width: 100%;
  }

  .pagination .secondary-button {
    flex: 1;
  }
}

/* Compose page stabilization */
.compose-panel {
  width: min(100%, 1040px);
  max-width: 1040px;
  margin-inline: auto;
}

.compose-workbench {
  padding: 0;
  overflow: hidden;
}

.compose-workbench .compose-form {
  display: block;
  margin-top: 0;
}

.compose-section {
  display: grid;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--line-soft);
}

.compose-section:last-of-type {
  border-bottom: 0;
}

.compose-section .section-title {
  align-items: flex-start;
}

.compose-section .section-title span {
  max-width: 520px;
  text-align: right;
}

.compose-section label {
  min-width: 0;
}

.compose-section textarea,
.compose-section input[type="text"] {
  max-width: 100%;
}

.compose-section textarea {
  line-height: 1.45;
}

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

.body-editor {
  min-height: 420px;
}

.compose-workbench .tox,
.compose-workbench .tox-tinymce {
  max-width: 100%;
  border-color: var(--line);
  border-radius: 10px;
}

.compose-workbench .tox .tox-toolbar__primary,
.compose-workbench .tox .tox-menubar {
  white-space: normal;
}

.file-picker input[type="file"] {
  min-height: auto;
  padding: 10px;
  background: var(--surface);
}

.attachment-preview {
  overflow-x: auto;
  padding-bottom: 2px;
}

.attachment-preview .data-table,
.attachment-table {
  min-width: 0;
}

.attachment-table {
  table-layout: fixed;
}

.attachment-table th:first-child,
.attachment-table td:first-child {
  width: 46%;
  word-break: break-word;
}

.attachment-table th:nth-child(2),
.attachment-table td:nth-child(2) {
  width: 18%;
  white-space: nowrap;
}

.attachment-table th:nth-child(3),
.attachment-table td:nth-child(3) {
  width: 24%;
  word-break: break-word;
}

.attachment-table th:last-child,
.attachment-table td:last-child {
  width: 56px;
}

.compose-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px 24px;
  background: var(--surface-soft);
  border-top: 1px solid var(--line-soft);
}

@media (max-width: 760px) {
  .compose-panel {
    width: 100%;
  }

  .compose-section {
    padding: 18px;
  }

  .compose-section .section-title {
    display: grid;
    gap: 6px;
  }

  .compose-section .section-title span {
    max-width: none;
    text-align: left;
  }

  .compose-grid {
    grid-template-columns: 1fr;
  }

  .body-editor {
    min-height: 320px;
  }

  .compose-actions {
    align-items: stretch;
    flex-direction: column;
    padding: 16px 18px 18px;
  }

  .compose-actions .primary-button,
  .compose-actions .secondary-button {
    width: 100%;
  }
}

/* Blacklist form polish */
.blacklist-form-panel {
  width: min(100%, 760px);
  margin-inline: auto;
  padding: 0;
  overflow: hidden;
}

.blacklist-form {
  display: grid;
  gap: 0;
}

.blacklist-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.blacklist-field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.blacklist-field input,
.blacklist-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.blacklist-field textarea {
  resize: vertical;
  line-height: 1.45;
}

.blacklist-field input:focus,
.blacklist-field textarea:focus {
  outline: 3px solid rgba(23, 107, 135, 0.18);
  outline-offset: 2px;
  border-color: var(--accent);
}

.blacklist-form > .blacklist-field,
.blacklist-form-grid {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.blacklist-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: end;
  gap: 16px;
}

.blacklist-toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
}

.blacklist-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.blacklist-toggle span {
  display: grid;
  gap: 2px;
}

.blacklist-toggle strong {
  font-size: 14px;
  line-height: 1.25;
}

.blacklist-toggle small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.blacklist-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px 22px;
  background: var(--surface-soft);
}

@media (max-width: 760px) {
  .blacklist-form-panel {
    width: 100%;
  }

  .blacklist-form > .blacklist-field,
  .blacklist-form-grid {
    padding: 18px;
  }

  .blacklist-form-grid {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .blacklist-form-actions {
    flex-direction: column-reverse;
    padding: 16px 18px 18px;
  }

  .blacklist-form-actions .primary-button,
  .blacklist-form-actions .secondary-button {
    width: 100%;
  }
}

/* Glassmorphism + Neumorphism refresh */
:root {
  --bg: #edf3f7;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #fbfdff;
  --surface-soft: rgba(246, 250, 252, 0.78);
  --ink: #172033;
  --muted: #627085;
  --line: rgba(124, 148, 167, 0.28);
  --line-soft: rgba(255, 255, 255, 0.66);
  --accent: #227a8c;
  --accent-strong: #145c6d;
  --accent-soft: rgba(213, 241, 244, 0.88);
  --accent-warm: #e06f5f;
  --sidebar: rgba(246, 250, 252, 0.62);
  --sidebar-ink: #1f2a3a;
  --glass-blur: blur(22px) saturate(135%);
  --shadow: 18px 18px 42px rgba(119, 139, 154, 0.22), -16px -16px 38px rgba(255, 255, 255, 0.78);
  --shadow-soft: 10px 10px 26px rgba(119, 139, 154, 0.16), -10px -10px 24px rgba(255, 255, 255, 0.72);
  --shadow-inset: inset 6px 6px 14px rgba(119, 139, 154, 0.16), inset -6px -6px 14px rgba(255, 255, 255, 0.72);
}

html {
  background: #edf3f7;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(226, 239, 246, 0.78) 44%, rgba(239, 246, 242, 0.86)),
    linear-gradient(45deg, rgba(34, 122, 140, 0.08), rgba(224, 111, 95, 0.07));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.38) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.32) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), transparent 76%);
}

.app-shell {
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  top: 14px;
  min-height: calc(100dvh - 28px);
  margin: 14px 0 14px 14px;
  padding: 18px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
}

.brand {
  min-height: 54px;
  margin-bottom: 18px;
  padding: 8px;
  border-radius: 18px;
  color: var(--ink);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  background: linear-gradient(145deg, #ffffff, #dbeaf0);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.nav-list {
  gap: 10px;
}

.nav-list a {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  color: #4a596b;
  font-weight: 750;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease;
}

.nav-list a:hover {
  border-color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.54);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.nav-list a.active {
  border-color: rgba(255, 255, 255, 0.88);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(220, 239, 244, 0.76));
  color: var(--accent-strong);
  box-shadow: var(--shadow-inset);
}

.nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.52);
  color: currentColor;
  box-shadow: inset 2px 2px 5px rgba(119, 139, 154, 0.12), inset -2px -2px 5px rgba(255, 255, 255, 0.72);
}

.nav-icon svg,
.button-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.sidebar-account {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(124, 148, 167, 0.18);
}

.sidebar-user {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.44);
}

.sidebar-user-avatar {
  border: 1px solid rgba(255, 255, 255, 0.84);
  background: linear-gradient(145deg, #ffffff, #d9ebef);
  color: var(--accent-strong);
}

.sidebar-user-text strong,
.sidebar-user-text small {
  color: var(--ink);
}

.logout-button {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.46);
  color: #435266;
  box-shadow: var(--shadow-soft);
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
}

.app-main {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 4;
  min-height: 70px;
  margin: 14px 20px 0;
  padding: 0 24px;
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
}

.topbar strong {
  color: var(--ink);
  font-size: 18px;
}

.content {
  width: min(1320px, calc(100vw - 340px));
  padding: 30px 34px 42px;
}

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

.page-heading h1,
.auth-panel h1 {
  color: #132233;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 800;
}

.eyebrow,
.topbar-label {
  color: var(--accent-strong);
  font-size: 12px;
}

.page-subtitle {
  color: #536275;
}

.panel,
.metric-card,
.auth-panel,
.table-wrap,
.app-dialog,
.confirm-card,
.blacklist-form-panel {
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
}

.panel {
  padding: 22px;
}

.metric-grid {
  gap: 18px;
}

.metric-card {
  position: relative;
  min-height: 124px;
  overflow: hidden;
  padding: 20px;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(34, 122, 140, 0.22), rgba(224, 111, 95, 0.18));
  box-shadow: var(--shadow-inset);
}

.metric-card span {
  color: #526174;
}

.metric-card strong {
  color: #132233;
  font-size: 36px;
}

.dashboard-filters select,
.dashboard-filters input[type="text"],
.mail-filters input,
.mail-filters select,
.form-stack input,
.form-stack textarea,
.blacklist-field input,
.blacklist-field textarea {
  min-height: 46px;
  border: 1px solid rgba(124, 148, 167, 0.24);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-inset);
}

.form-stack textarea,
.blacklist-field textarea {
  padding-block: 12px;
}

.primary-button,
.secondary-button,
.small-button,
.icon-button,
.icon-close {
  min-height: 44px;
  border-radius: 15px;
  font-weight: 800;
  touch-action: manipulation;
}

.primary-button {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: linear-gradient(145deg, #2a91a4, #17697c);
  box-shadow: 8px 8px 18px rgba(23, 105, 124, 0.22), -6px -6px 16px rgba(255, 255, 255, 0.64);
}

.primary-button:hover {
  background: linear-gradient(145deg, #32a0b5, #145d70);
  box-shadow: 10px 12px 22px rgba(23, 105, 124, 0.26), -7px -7px 16px rgba(255, 255, 255, 0.7);
}

.secondary-button,
.icon-button,
.icon-close {
  border: 1px solid rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.56);
  color: #39485b;
  box-shadow: var(--shadow-soft);
}

.secondary-button:hover,
.icon-close:hover {
  border-color: rgba(34, 122, 140, 0.28);
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-strong);
}

.tab-list a,
.status-badge,
.email-badge {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 2px 2px 5px rgba(119, 139, 154, 0.1), inset -2px -2px 5px rgba(255, 255, 255, 0.66);
}

.tab-list a.active,
.tab-list a:hover {
  border-color: rgba(34, 122, 140, 0.28);
  background: var(--accent-soft);
}

.mail-panel,
.dashboard-panel,
.account-panel {
  gap: 22px;
}

.mail-filters-dense {
  grid-template-columns: repeat(4, minmax(158px, 1fr));
  padding: 18px;
  border-color: rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow-inset);
}

.mail-filters label,
.form-stack label,
.blacklist-field label {
  color: #536275;
}

.data-table {
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  background: rgba(255, 255, 255, 0.46);
  color: #526174;
}

.data-table th,
.data-table td {
  border-bottom-color: rgba(124, 148, 167, 0.16);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.36);
}

.subject-link {
  color: #172033;
}

.sender-avatar {
  border: 1px solid rgba(255, 255, 255, 0.78);
  background: linear-gradient(145deg, #ffffff, #dbeef2);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.status-SENT {
  border-color: rgba(70, 151, 103, 0.22);
  background: rgba(226, 248, 235, 0.76);
}

.status-FAILED {
  border-color: rgba(181, 49, 49, 0.22);
  background: rgba(255, 235, 235, 0.8);
}

.status-PENDING {
  border-color: rgba(49, 91, 134, 0.22);
  background: rgba(231, 240, 250, 0.82);
}

.status-PROCESSING {
  border-color: rgba(224, 111, 95, 0.28);
  background: rgba(255, 239, 232, 0.82);
}

.compose-section,
.dialog-heading,
.dialog-actions,
.compose-actions {
  border-color: rgba(124, 148, 167, 0.16);
}

.compose-actions,
.blacklist-form-actions {
  background: rgba(255, 255, 255, 0.36);
}

.compose-workbench .tox,
.compose-workbench .tox-tinymce,
.mail-detail iframe {
  border-color: rgba(124, 148, 167, 0.24);
  border-radius: 18px;
  box-shadow: var(--shadow-inset);
}

.empty-state {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.34);
}

.pagination {
  min-height: 54px;
  padding: 8px 2px 0;
}

.app-dialog::backdrop,
.confirm-backdrop {
  background: rgba(23, 32, 51, 0.42);
  backdrop-filter: blur(8px);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.link-button:focus-visible,
.icon-button:focus-visible,
.icon-close:focus-visible,
.logout-button:focus-visible,
.nav-list a:focus-visible,
.mail-filters input:focus,
.mail-filters select:focus,
.form-stack input:focus,
.form-stack textarea:focus,
.dashboard-filters select:focus,
.dashboard-filters input[type="text"]:focus,
.blacklist-field input:focus,
.blacklist-field textarea:focus {
  outline: 3px solid rgba(34, 122, 140, 0.22);
  outline-offset: 3px;
  border-color: rgba(34, 122, 140, 0.48);
}

@media (max-width: 1180px) {
  .content {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    top: 0;
    width: min(292px, calc(100vw - 28px));
    min-height: calc(100dvh - 28px);
    margin: 14px;
    transform: translateX(calc(-100% - 28px));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    top: 10px;
    margin: 10px 12px 0;
    padding: 0 14px;
  }

  .content {
    padding: 24px 14px 34px;
  }

  .panel {
    padding: 16px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .mail-filters-dense {
    grid-template-columns: 1fr;
  }

  .mail-filter-actions {
    grid-column: auto;
  }

  .outbox-table tr {
    border-color: rgba(255, 255, 255, 0.76);
    background: rgba(255, 255, 255, 0.68);
    box-shadow: var(--shadow-soft);
    backdrop-filter: var(--glass-blur);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Dark mode refinement */
:root {
  color-scheme: dark;
  --bg: #0d1420;
  --surface: rgba(18, 28, 42, 0.9);
  --surface-solid: #121c2a;
  --surface-soft: rgba(25, 38, 55, 0.92);
  --ink: #edf6ff;
  --muted: #a8b7c8;
  --line: rgba(148, 163, 184, 0.24);
  --line-soft: rgba(255, 255, 255, 0.1);
  --accent: #5fd2df;
  --accent-strong: #a6f3fa;
  --accent-soft: rgba(95, 210, 223, 0.16);
  --accent-warm: #ff9a84;
  --sidebar: rgba(13, 20, 32, 0.92);
  --sidebar-ink: #edf6ff;
  --glass-blur: blur(14px) saturate(125%);
  --shadow: 16px 18px 40px rgba(0, 0, 0, 0.42), -8px -8px 22px rgba(255, 255, 255, 0.035);
  --shadow-soft: 10px 12px 26px rgba(0, 0, 0, 0.34), -6px -6px 16px rgba(255, 255, 255, 0.03);
  --shadow-inset: inset 6px 6px 14px rgba(0, 0, 0, 0.34), inset -5px -5px 12px rgba(255, 255, 255, 0.035);
}

html {
  background: var(--bg);
}

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(95, 210, 223, 0.18), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(255, 154, 132, 0.12), transparent 26%),
    linear-gradient(135deg, #0d1420 0%, #101a29 48%, #09111d 100%);
  color: var(--ink);
}

body::before {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), transparent 78%);
}

.sidebar,
.topbar,
.panel,
.metric-card,
.auth-panel,
.table-wrap,
.app-dialog,
.confirm-card,
.blacklist-form-panel {
  border-color: var(--line-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar,
.topbar {
  background: rgba(13, 20, 32, 0.88);
}

.brand,
.topbar strong,
.page-heading h1,
.auth-panel h1,
.metric-card strong,
.subject-link,
.empty-state strong,
.account-meta strong,
.section-title h2,
.panel-heading h2 {
  color: var(--ink);
}

.brand-mark,
.sender-avatar,
.sidebar-user-avatar {
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(145deg, #1b2b3f, #0c1421);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.nav-list a {
  color: #bfd0df;
}

.nav-list a:hover {
  border-color: rgba(95, 210, 223, 0.22);
  background: rgba(95, 210, 223, 0.09);
  color: var(--accent-strong);
}

.nav-list a.active {
  border-color: rgba(95, 210, 223, 0.28);
  background: linear-gradient(145deg, rgba(95, 210, 223, 0.16), rgba(18, 28, 42, 0.9));
  color: var(--accent-strong);
  box-shadow: var(--shadow-inset);
}

.nav-icon,
.tab-list a,
.status-badge,
.email-badge {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: var(--shadow-inset);
}

.sidebar-user,
.mail-filters-dense,
.empty-state {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.045);
}

.sidebar-user-text strong,
.sidebar-user-text small {
  color: var(--ink);
}

.logout-button,
.secondary-button,
.icon-button,
.icon-close {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.055);
  color: #d8e4ef;
  box-shadow: var(--shadow-soft);
}

.logout-button:hover,
.secondary-button:hover,
.icon-close:hover {
  border-color: rgba(95, 210, 223, 0.32);
  background: rgba(95, 210, 223, 0.11);
  color: var(--accent-strong);
}

.primary-button {
  border-color: rgba(166, 243, 250, 0.18);
  background: linear-gradient(145deg, #36b7c7, #167487);
  color: #061019;
  box-shadow: 9px 10px 22px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.primary-button:hover {
  background: linear-gradient(145deg, #67dce8, #19869a);
  color: #061019;
}

.eyebrow,
.topbar-label,
.auth-link,
.link-button {
  color: var(--accent-strong);
}

.page-subtitle,
.muted,
.metric-card span,
.table-note-muted,
.field-label,
.mail-filters label,
.form-stack label,
.blacklist-field label,
.section-title span,
.attachment-help,
.pagination,
.dashboard-filters select,
.dashboard-filters input[type="text"],
.mail-filters input,
.mail-filters select,
.form-stack input,
.form-stack textarea,
.blacklist-field input,
.blacklist-field textarea {
  color: var(--muted);
}

.dashboard-filters select,
.dashboard-filters input[type="text"],
.mail-filters input,
.mail-filters select,
.form-stack input,
.form-stack textarea,
.blacklist-field input,
.blacklist-field textarea,
.file-picker input[type="file"] {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(7, 12, 20, 0.54);
  color: var(--ink);
  box-shadow: var(--shadow-inset);
}

.dashboard-filters select option,
.mail-filters select option {
  background: #111b2a;
  color: var(--ink);
}

.data-table th {
  background: rgba(255, 255, 255, 0.045);
  color: #b8c6d5;
}

.data-table th,
.data-table td {
  border-bottom-color: rgba(148, 163, 184, 0.14);
}

.data-table tbody tr:hover {
  background: rgba(95, 210, 223, 0.055);
}

.email-badge {
  color: #d8e4ef;
}

.status-SENT {
  border-color: rgba(86, 211, 132, 0.24);
  background: rgba(42, 133, 78, 0.18);
  color: #baf7cf;
}

.status-FAILED {
  border-color: rgba(255, 128, 128, 0.26);
  background: rgba(161, 54, 54, 0.2);
  color: #ffc7c7;
}

.status-PENDING {
  border-color: rgba(125, 184, 255, 0.26);
  background: rgba(55, 105, 163, 0.18);
  color: #c8ddff;
}

.status-PROCESSING {
  border-color: rgba(255, 175, 106, 0.28);
  background: rgba(168, 94, 39, 0.2);
  color: #ffd7b1;
}

.compose-actions,
.blacklist-form-actions,
.account-meta,
.recipient-dialog-item,
.blacklist-toggle {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.045);
}

.compose-workbench .tox,
.compose-workbench .tox-tinymce,
.mail-detail iframe {
  border-color: rgba(148, 163, 184, 0.22);
  background: #ffffff;
}

.flash {
  border-color: rgba(95, 210, 223, 0.24);
  background: rgba(95, 210, 223, 0.1);
  color: var(--ink);
}

.flash-error,
.attachment-error,
.attachment-row-error td {
  border-color: rgba(255, 128, 128, 0.28);
  background: rgba(161, 54, 54, 0.2);
  color: #ffc7c7;
}

.confirm-backdrop,
.app-dialog::backdrop {
  background: rgba(3, 7, 12, 0.68);
}

@media (max-width: 760px) {
  .outbox-table tr {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(18, 28, 42, 0.9);
  }
}

/* Bright polished theme */
:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-soft: rgba(244, 249, 252, 0.92);
  --ink: #122033;
  --muted: #607086;
  --line: rgba(116, 139, 160, 0.26);
  --line-soft: rgba(255, 255, 255, 0.78);
  --accent: #0d8ba0;
  --accent-strong: #075f70;
  --accent-soft: rgba(213, 245, 248, 0.92);
  --accent-warm: #ef7a62;
  --sidebar: rgba(255, 255, 255, 0.78);
  --sidebar-ink: #122033;
  --glass-blur: blur(12px) saturate(125%);
  --shadow: 16px 18px 42px rgba(91, 113, 132, 0.18), -12px -12px 30px rgba(255, 255, 255, 0.88);
  --shadow-soft: 9px 10px 24px rgba(91, 113, 132, 0.14), -8px -8px 20px rgba(255, 255, 255, 0.86);
  --shadow-inset: inset 5px 5px 12px rgba(91, 113, 132, 0.13), inset -5px -5px 12px rgba(255, 255, 255, 0.82);
}

html {
  background: var(--bg);
}

body {
  background:
    radial-gradient(circle at 8% 8%, rgba(13, 139, 160, 0.18), transparent 28%),
    radial-gradient(circle at 86% 12%, rgba(239, 122, 98, 0.16), transparent 26%),
    radial-gradient(circle at 78% 88%, rgba(88, 118, 255, 0.12), transparent 30%),
    linear-gradient(135deg, #fbfdff 0%, #edf6f9 46%, #f8fbff 100%);
  color: var(--ink);
}

body::before {
  background-image:
    linear-gradient(rgba(13, 139, 160, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 139, 160, 0.045) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.58), transparent 76%);
}

.sidebar,
.topbar,
.panel,
.metric-card,
.auth-panel,
.table-wrap,
.app-dialog,
.confirm-card,
.blacklist-form-panel {
  border-color: var(--line-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar,
.topbar {
  background: rgba(255, 255, 255, 0.78);
}

.brand,
.topbar strong,
.page-heading h1,
.auth-panel h1,
.metric-card strong,
.subject-link,
.empty-state strong,
.account-meta strong,
.section-title h2,
.panel-heading h2 {
  color: var(--ink);
}

.brand-mark,
.sender-avatar,
.sidebar-user-avatar {
  border-color: rgba(255, 255, 255, 0.92);
  background: linear-gradient(145deg, #ffffff, #d8f3f7);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.nav-list a {
  color: #43536a;
}

.nav-list a:hover {
  border-color: rgba(13, 139, 160, 0.18);
  background: rgba(255, 255, 255, 0.76);
  color: var(--accent-strong);
}

.nav-list a.active {
  border-color: rgba(13, 139, 160, 0.24);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(213, 245, 248, 0.86));
  color: var(--accent-strong);
  box-shadow: var(--shadow-inset);
}

.nav-icon,
.tab-list a,
.status-badge,
.email-badge {
  border-color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 2px 2px 5px rgba(91, 113, 132, 0.1), inset -2px -2px 5px rgba(255, 255, 255, 0.78);
}

.sidebar-user,
.mail-filters-dense,
.empty-state,
.compose-actions,
.blacklist-form-actions,
.account-meta,
.recipient-dialog-item,
.blacklist-toggle {
  border-color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.52);
}

.sidebar-user-text strong {
  color: var(--ink);
}

.sidebar-user-text small,
.page-subtitle,
.muted,
.metric-card span,
.table-note-muted,
.field-label,
.mail-filters label,
.form-stack label,
.blacklist-field label,
.section-title span,
.attachment-help,
.pagination {
  color: var(--muted);
}

.logout-button,
.secondary-button,
.icon-button,
.icon-close {
  border-color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.7);
  color: #39495e;
  box-shadow: var(--shadow-soft);
}

.logout-button:hover,
.secondary-button:hover,
.icon-close:hover {
  border-color: rgba(13, 139, 160, 0.26);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.primary-button {
  border-color: rgba(255, 255, 255, 0.82);
  background: linear-gradient(145deg, #16a7ba, #087489);
  color: #ffffff;
  box-shadow: 9px 10px 22px rgba(8, 116, 137, 0.24), -7px -7px 18px rgba(255, 255, 255, 0.82);
}

.primary-button:hover {
  background: linear-gradient(145deg, #21b9cc, #076b7d);
  color: #ffffff;
}

.eyebrow,
.topbar-label,
.auth-link,
.link-button {
  color: var(--accent-strong);
}

.dashboard-filters select,
.dashboard-filters input[type="text"],
.mail-filters input,
.mail-filters select,
.form-stack input,
.form-stack textarea,
.blacklist-field input,
.blacklist-field textarea,
.file-picker input[type="file"] {
  border-color: rgba(116, 139, 160, 0.24);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  box-shadow: var(--shadow-inset);
}

.dashboard-filters select option,
.mail-filters select option {
  background: #ffffff;
  color: var(--ink);
}

.data-table th {
  background: rgba(244, 249, 252, 0.86);
  color: #5c6b7d;
}

.data-table tbody tr:hover {
  background: rgba(213, 245, 248, 0.34);
}

.email-badge {
  color: #344255;
}

.metric-card:nth-child(1)::after {
  background: linear-gradient(145deg, rgba(13, 139, 160, 0.26), rgba(88, 118, 255, 0.16));
}

.metric-card:nth-child(2)::after {
  background: linear-gradient(145deg, rgba(42, 167, 111, 0.24), rgba(13, 139, 160, 0.16));
}

.metric-card:nth-child(3)::after {
  background: linear-gradient(145deg, rgba(239, 122, 98, 0.26), rgba(255, 180, 102, 0.18));
}

.metric-card:nth-child(4)::after {
  background: linear-gradient(145deg, rgba(88, 118, 255, 0.2), rgba(13, 139, 160, 0.16));
}

.status-SENT {
  border-color: rgba(42, 167, 111, 0.25);
  background: rgba(225, 249, 235, 0.9);
  color: #216b45;
}

.status-FAILED {
  border-color: rgba(181, 49, 49, 0.22);
  background: rgba(255, 236, 234, 0.94);
  color: #8a2525;
}

.status-PENDING {
  border-color: rgba(88, 118, 255, 0.24);
  background: rgba(235, 239, 255, 0.94);
  color: #354b99;
}

.status-PROCESSING {
  border-color: rgba(239, 122, 98, 0.3);
  background: rgba(255, 241, 235, 0.94);
  color: #9a4b2f;
}

.flash {
  border-color: rgba(42, 167, 111, 0.22);
  background: rgba(231, 250, 239, 0.92);
  color: var(--ink);
}

.flash-error,
.attachment-error,
.attachment-row-error td {
  border-color: rgba(181, 49, 49, 0.22);
  background: rgba(255, 236, 234, 0.94);
  color: #8a2525;
}

.confirm-backdrop,
.app-dialog::backdrop {
  background: rgba(18, 32, 51, 0.42);
}

@media (max-width: 760px) {
  .outbox-table tr {
    border-color: rgba(255, 255, 255, 0.82);
    background: rgba(255, 255, 255, 0.86);
  }
}

.chart-wrap {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(213, 245, 248, 0.28)),
    rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow-inset);
}

#dashboard-chart {
  border-radius: 14px;
}

/* Modern SaaS Bento theme */
:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-soft: #f3f7fb;
  --ink: #101828;
  --muted: #667085;
  --line: #d9e2ec;
  --line-soft: #eef2f6;
  --accent: #0e9384;
  --accent-strong: #0b6f66;
  --accent-soft: #e6f8f5;
  --accent-warm: #f97066;
  --sidebar: #111827;
  --sidebar-ink: #f8fafc;
  --glass-blur: none;
  --shadow: 0 18px 44px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 10px 28px rgba(16, 24, 40, 0.06);
  --shadow-inset: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

html,
body {
  background: var(--bg);
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(247, 249, 252, 0.9) 34%, #f7f9fc 100%),
    radial-gradient(circle at 20% 0%, rgba(14, 147, 132, 0.16), transparent 30%),
    radial-gradient(circle at 86% 4%, rgba(99, 102, 241, 0.13), transparent 28%);
  color: var(--ink);
}

body::before {
  background-image:
    linear-gradient(rgba(16, 24, 40, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 24, 40, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 70%);
}

.app-shell {
  grid-template-columns: 272px minmax(0, 1fr);
}

.sidebar {
  top: 16px;
  min-height: calc(100dvh - 32px);
  margin: 16px 0 16px 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0)),
    #111827;
  color: var(--sidebar-ink);
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.18);
  backdrop-filter: none;
}

.brand {
  min-height: 56px;
  margin-bottom: 18px;
  padding: 8px;
  border-radius: 18px;
  color: #ffffff;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: linear-gradient(135deg, #2dd4bf, #6366f1);
  color: #ffffff;
  box-shadow: 0 14px 32px rgba(45, 212, 191, 0.2);
}

.nav-list {
  gap: 8px;
}

.nav-list a {
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: #cbd5e1;
  font-weight: 750;
  box-shadow: none;
}

.nav-list a:hover {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-list a.active {
  border-color: rgba(45, 212, 191, 0.24);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.18), rgba(99, 102, 241, 0.12));
  color: #ffffff;
  box-shadow: inset 3px 0 0 #2dd4bf;
}

.nav-icon {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.sidebar-user {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: none;
}

.sidebar-user-avatar {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(45, 212, 191, 0.16);
  color: #99f6e4;
}

.sidebar-user-text strong {
  color: #ffffff;
}

.sidebar-user-text small {
  color: #cbd5e1;
}

.logout-button {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  box-shadow: none;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.topbar {
  top: 16px;
  min-height: 68px;
  margin: 16px 24px 0;
  padding: 0 24px;
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.topbar strong,
.page-heading h1,
.auth-panel h1,
.metric-card strong,
.subject-link,
.empty-state strong,
.account-meta strong,
.section-title h2,
.panel-heading h2 {
  color: var(--ink);
}

.content {
  width: min(1360px, calc(100vw - 336px));
  padding: 32px 36px 44px;
}

.page-heading h1,
.auth-panel h1 {
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 850;
}

.eyebrow,
.topbar-label,
.auth-link,
.link-button {
  color: var(--accent-strong);
}

.page-subtitle,
.muted,
.metric-card span,
.table-note-muted,
.field-label,
.mail-filters label,
.form-stack label,
.blacklist-field label,
.section-title span,
.attachment-help,
.pagination {
  color: var(--muted);
}

.panel,
.metric-card,
.auth-panel,
.table-wrap,
.app-dialog,
.confirm-card,
.blacklist-form-panel {
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  backdrop-filter: none;
}

.panel {
  padding: 24px;
}

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

.metric-card {
  min-height: 128px;
  padding: 20px;
  overflow: hidden;
}

.metric-card::after {
  right: 16px;
  bottom: 16px;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  opacity: 0.95;
  box-shadow: none;
}

.metric-card:nth-child(1) {
  background: linear-gradient(135deg, #ffffff 0%, #ecfdf9 100%);
}

.metric-card:nth-child(2) {
  background: linear-gradient(135deg, #ffffff 0%, #effdf4 100%);
}

.metric-card:nth-child(3) {
  background: linear-gradient(135deg, #ffffff 0%, #fff4f2 100%);
}

.metric-card:nth-child(4) {
  background: linear-gradient(135deg, #ffffff 0%, #f2f4ff 100%);
}

.metric-card strong {
  font-size: 38px;
  letter-spacing: 0;
}

.dashboard-panel {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94)),
    #ffffff;
}

.chart-wrap {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(236, 253, 249, 0.62), rgba(242, 244, 255, 0.5)),
    #ffffff;
  box-shadow: none;
}

.mail-filters-dense,
.sidebar-user,
.empty-state,
.compose-actions,
.blacklist-form-actions,
.account-meta,
.recipient-dialog-item,
.blacklist-toggle {
  border-color: var(--line-soft);
  background: #f8fafc;
}

.dashboard-filters select,
.dashboard-filters input[type="text"],
.mail-filters input,
.mail-filters select,
.form-stack input,
.form-stack textarea,
.blacklist-field input,
.blacklist-field textarea,
.file-picker input[type="file"] {
  min-height: 46px;
  border: 1px solid #d7e0ea;
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
}

.dashboard-filters select:focus,
.dashboard-filters input[type="text"]:focus,
.mail-filters input:focus,
.mail-filters select:focus,
.form-stack input:focus,
.form-stack textarea:focus,
.blacklist-field input:focus,
.blacklist-field textarea:focus {
  border-color: rgba(14, 147, 132, 0.55);
  box-shadow: 0 0 0 4px rgba(14, 147, 132, 0.12);
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, #0e9384, #2563eb);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(14, 147, 132, 0.22);
}

.primary-button:hover {
  background: linear-gradient(135deg, #0b8275, #1d4ed8);
  color: #ffffff;
}

.secondary-button,
.icon-button,
.icon-close {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #344054;
  box-shadow: none;
}

.secondary-button:hover,
.icon-close:hover {
  border-color: rgba(14, 147, 132, 0.32);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.table-wrap {
  overflow: hidden;
}

.data-table th {
  background: #f8fafc;
  color: #667085;
}

.data-table th,
.data-table td {
  border-bottom-color: #edf2f7;
}

.data-table tbody tr:hover {
  background: #f6fbfb;
}

.email-badge,
.status-badge,
.tab-list a {
  border-color: var(--line-soft);
  background: #ffffff;
  box-shadow: none;
}

.sender-avatar {
  border: 1px solid #ccfbf1;
  background: #ecfdf9;
  color: #0b6f66;
  box-shadow: none;
}

.status-SENT {
  border-color: #b8ead1;
  background: #ecfdf3;
  color: #067647;
}

.status-FAILED {
  border-color: #ffd0ca;
  background: #fff3f1;
  color: #b42318;
}

.status-PENDING {
  border-color: #d8ddff;
  background: #f2f4ff;
  color: #3538cd;
}

.status-PROCESSING {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.flash {
  border-color: #b8ead1;
  background: #ecfdf3;
  color: var(--ink);
}

.flash-error,
.attachment-error,
.attachment-row-error td {
  border-color: #ffd0ca;
  background: #fff3f1;
  color: #b42318;
}

@media (max-width: 1180px) {
  .content {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    top: 0;
    width: min(292px, calc(100vw - 28px));
    min-height: calc(100dvh - 28px);
    margin: 14px;
    transform: translateX(calc(-100% - 28px));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    top: 10px;
    margin: 10px 12px 0;
    padding: 0 14px;
  }

  .content {
    padding: 24px 14px 34px;
  }

  .panel {
    padding: 16px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .outbox-table tr {
    border-color: var(--line-soft);
    background: #ffffff;
    box-shadow: var(--shadow-soft);
  }
}

/* Minimal Swiss Admin theme */
:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-soft: #f5f7fa;
  --ink: #111827;
  --muted: #6b7280;
  --line: #d8dee8;
  --line-soft: #e8edf4;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-warm: #dc2626;
  --sidebar: #ffffff;
  --sidebar-ink: #111827;
  --glass-blur: none;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.04);
  --shadow-soft: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-inset: none;
}

html,
body {
  background: var(--bg);
}

body {
  background:
    linear-gradient(180deg, #ffffff 0, #f8fafc 260px),
    #f8fafc;
  color: var(--ink);
}

body::before {
  display: none;
}

.app-shell {
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  top: 0;
  min-height: 100dvh;
  margin: 0;
  padding: 18px 14px;
  border: 0;
  border-right: 1px solid var(--line-soft);
  border-radius: 0;
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
}

.brand {
  min-height: 48px;
  margin-bottom: 18px;
  padding: 6px;
  border-radius: 10px;
  color: var(--ink);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #111827;
  color: #ffffff;
  box-shadow: none;
}

.nav-list {
  gap: 4px;
}

.nav-list a {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #4b5563;
  font-weight: 700;
  box-shadow: none;
}

.nav-list a:hover {
  border-color: var(--line-soft);
  background: #f8fafc;
  color: var(--ink);
}

.nav-list a.active {
  border-color: #dbeafe;
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.nav-icon {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: currentColor;
  box-shadow: none;
}

.sidebar-account {
  border-top-color: var(--line-soft);
}

.sidebar-user {
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #f8fafc;
  box-shadow: none;
}

.sidebar-user-avatar {
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: var(--accent-strong);
  box-shadow: none;
}

.sidebar-user-text strong {
  color: var(--ink);
}

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

.logout-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  color: #374151;
  box-shadow: none;
}

.logout-button:hover {
  border-color: #bfdbfe;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.topbar {
  position: sticky;
  top: 0;
  min-height: 64px;
  margin: 0;
  padding: 0 28px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: none;
  backdrop-filter: blur(10px);
}

.topbar strong,
.page-heading h1,
.auth-panel h1,
.metric-card strong,
.subject-link,
.empty-state strong,
.account-meta strong,
.section-title h2,
.panel-heading h2 {
  color: var(--ink);
}

.topbar strong {
  font-size: 17px;
}

.content {
  width: min(1280px, calc(100vw - 300px));
  padding: 30px 32px 42px;
}

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

.page-heading h1,
.auth-panel h1 {
  font-size: clamp(28px, 2.5vw, 38px);
  font-weight: 800;
}

.eyebrow,
.topbar-label,
.auth-link,
.link-button {
  color: var(--accent-strong);
}

.page-subtitle,
.muted,
.metric-card span,
.table-note-muted,
.field-label,
.mail-filters label,
.form-stack label,
.blacklist-field label,
.section-title span,
.attachment-help,
.pagination {
  color: var(--muted);
}

.panel,
.metric-card,
.auth-panel,
.table-wrap,
.app-dialog,
.confirm-card,
.blacklist-form-panel {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  backdrop-filter: none;
}

.panel {
  padding: 22px;
}

.metric-grid {
  gap: 14px;
}

.metric-card {
  min-height: 112px;
  padding: 18px;
  background: #ffffff;
}

.metric-card::after {
  display: none;
}

.metric-card strong {
  font-size: 34px;
}

.dashboard-panel,
.metric-card:nth-child(1),
.metric-card:nth-child(2),
.metric-card:nth-child(3),
.metric-card:nth-child(4) {
  background: #ffffff;
}

.chart-wrap {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fbfdff;
  box-shadow: none;
}

.mail-filters-dense,
.empty-state,
.compose-actions,
.blacklist-form-actions,
.account-meta,
.recipient-dialog-item,
.blacklist-toggle {
  border-color: var(--line-soft);
  background: #f8fafc;
}

.dashboard-filters select,
.dashboard-filters input[type="text"],
.mail-filters input,
.mail-filters select,
.form-stack input,
.form-stack textarea,
.blacklist-field input,
.blacklist-field textarea,
.file-picker input[type="file"] {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
}

.dashboard-filters select:focus,
.dashboard-filters input[type="text"]:focus,
.mail-filters input:focus,
.mail-filters select:focus,
.form-stack input:focus,
.form-stack textarea:focus,
.blacklist-field input:focus,
.blacklist-field textarea:focus {
  outline: 0;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.primary-button {
  min-height: 42px;
  border: 1px solid #1d4ed8;
  border-radius: 10px;
  background: #2563eb;
  color: #ffffff;
  box-shadow: none;
}

.primary-button:hover {
  border-color: #1e40af;
  background: #1d4ed8;
  color: #ffffff;
}

.secondary-button,
.icon-button,
.icon-close {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: #374151;
  box-shadow: none;
}

.secondary-button:hover,
.icon-close:hover {
  border-color: #bfdbfe;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.data-table th {
  background: #f8fafc;
  color: #6b7280;
}

.data-table th,
.data-table td {
  border-bottom-color: var(--line-soft);
}

.data-table tbody tr:hover {
  background: #f8fbff;
}

.email-badge,
.status-badge,
.tab-list a {
  border-color: var(--line-soft);
  background: #ffffff;
  box-shadow: none;
}

.sender-avatar {
  border: 1px solid #dbeafe;
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.status-SENT {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.status-FAILED {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.status-PENDING {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.status-PROCESSING {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.flash {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--ink);
}

.flash-error,
.attachment-error,
.attachment-row-error td {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

@media (max-width: 1180px) {
  .content {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    width: 260px;
    min-height: 100dvh;
    margin: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    min-height: 64px;
    padding: 0 16px;
  }

  .content {
    padding: 22px 16px 34px;
  }

  .panel {
    padding: 16px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .outbox-table tr {
    border-color: var(--line-soft);
    background: #ffffff;
    box-shadow: var(--shadow-soft);
  }
}

/* Active UI refresh: bright command center */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f2f6fb;
  --ink: #172033;
  --muted: #687386;
  --line: #d8e0eb;
  --line-soft: #e9eef5;
  --accent: #087f8c;
  --accent-strong: #075e68;
  --accent-soft: #e8f7f7;
  --sidebar: #ffffff;
  --sidebar-ink: #172033;
  --shadow: 0 18px 48px rgba(32, 47, 72, 0.09);
  --shadow-soft: 0 8px 24px rgba(32, 47, 72, 0.07);
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0, rgba(246, 248, 251, 0.94) 310px, #f6f8fb 100%),
    radial-gradient(circle at 12% 4%, rgba(8, 127, 140, 0.12), transparent 30%),
    radial-gradient(circle at 78% 0%, rgba(228, 95, 79, 0.1), transparent 25%);
  color: var(--ink);
}

body::before {
  display: none;
}

.app-shell {
  grid-template-columns: 276px minmax(0, 1fr);
}

.sidebar {
  top: 18px;
  min-height: calc(100dvh - 36px);
  margin: 18px 0 18px 18px;
  padding: 16px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(8, 127, 140, 0.08), rgba(255, 255, 255, 0) 34%),
    #ffffff;
  color: var(--sidebar-ink);
  box-shadow: var(--shadow-soft);
}

.brand {
  min-height: 58px;
  margin-bottom: 18px;
  padding: 8px;
  border-radius: 16px;
  color: var(--ink);
  font-weight: 850;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #087f8c, #315fd6 58%, #e45f4f);
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(8, 127, 140, 0.24);
}

.nav-list a,
.nav-logout-button {
  min-height: 44px;
  border-radius: 12px;
  color: #536071;
  font-weight: 750;
}

.nav-logout-form {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.nav-logout-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  appearance: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.nav-list a:hover,
.nav-logout-button:hover,
.nav-logout-button:focus-visible {
  border-color: #dce8ef;
  background: #f7fafc;
  color: var(--ink);
  outline: 0;
}

.nav-list a.active {
  border-color: rgba(8, 127, 140, 0.22);
  background: linear-gradient(135deg, #e8f7f7, #f6f8ff);
  color: var(--accent-strong);
  box-shadow: inset 4px 0 0 var(--accent);
}

.nav-icon,
.nav-logout-button .nav-icon {
  width: 30px;
  height: 30px;
  border: 1px solid #e7edf4;
  border-radius: 10px;
  background: #ffffff;
  color: currentColor;
  box-shadow: 0 1px 2px rgba(32, 47, 72, 0.04);
}

.nav-logout-button:hover,
.nav-logout-button:focus-visible {
  border-color: #dce8ef;
  background: #f7fafc;
  color: var(--ink);
}

.sidebar-user {
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: #f8fbfd;
}

.sidebar-user-avatar {
  border: 1px solid #ccebed;
  background: #e8f7f7;
  color: var(--accent-strong);
}

.sidebar-user-text strong,
.topbar strong,
.page-heading h1,
.auth-panel h1,
.metric-card strong,
.subject-link,
.empty-state strong,
.account-meta strong,
.section-title h2,
.panel-heading h2 {
  color: var(--ink);
}

.sidebar-user-text small,
.page-subtitle,
.muted,
.metric-card span,
.table-note-muted,
.field-label,
.mail-filters label,
.form-stack label,
.blacklist-field label,
.section-title span,
.attachment-help,
.pagination {
  color: var(--muted);
}

.topbar {
  min-height: 70px;
  padding: 0 34px;
  border-bottom: 1px solid rgba(216, 224, 235, 0.8);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
}

.content {
  width: min(1340px, calc(100vw - 334px));
  padding: 34px 38px 46px;
}

.page-heading h1,
.auth-panel h1 {
  font-size: clamp(30px, 2.7vw, 40px);
  font-weight: 850;
}

.eyebrow,
.topbar-label,
.auth-link,
.link-button {
  color: var(--accent-strong);
}

.panel,
.metric-card,
.auth-panel,
.table-wrap,
.app-dialog,
.confirm-card,
.blacklist-form-panel {
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.metric-card {
  min-height: 126px;
  padding: 20px;
}

.metric-card::after {
  display: block;
  border-radius: 16px;
}

.metric-card strong {
  font-size: 38px;
  font-weight: 850;
}

.chart-wrap {
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(232, 247, 247, 0.76), rgba(248, 250, 255, 0.9)),
    #ffffff;
}

.dashboard-filters,
.mail-filters-dense,
.empty-state,
.compose-actions,
.blacklist-form-actions,
.account-meta,
.recipient-dialog-item,
.blacklist-toggle {
  border-color: var(--line-soft);
  background: #f8fbfd;
}

.dashboard-filters select,
.dashboard-filters input[type="text"],
.mail-filters input,
.mail-filters select,
.form-stack input,
.form-stack textarea,
.blacklist-field input,
.blacklist-field textarea,
.file-picker input[type="file"] {
  border-color: #d7e1eb;
  border-radius: 12px;
}

.dashboard-filters select:focus,
.dashboard-filters input[type="text"]:focus,
.mail-filters input:focus,
.mail-filters select:focus,
.form-stack input:focus,
.form-stack textarea:focus,
.blacklist-field input:focus,
.blacklist-field textarea:focus {
  border-color: rgba(8, 127, 140, 0.56);
  box-shadow: 0 0 0 4px rgba(8, 127, 140, 0.12);
}

.primary-button {
  border-color: #075e68;
  border-radius: 12px;
  background: linear-gradient(135deg, #087f8c, #315fd6);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(8, 127, 140, 0.2);
}

.primary-button:hover {
  border-color: #064f57;
  background: linear-gradient(135deg, #075e68, #284fb4);
}

.secondary-button,
.icon-button,
.icon-close {
  border-radius: 12px;
}

.secondary-button:hover,
.icon-close:hover,
.tab-list a.active,
.tab-list a:hover {
  border-color: rgba(8, 127, 140, 0.32);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tab-list a {
  border-radius: 999px;
}

.data-table th {
  background: #f7fafc;
  color: #667386;
}

.data-table tbody tr:hover {
  background: #f4fbfb;
}

.sender-avatar {
  border-color: #ccebed;
  background: #e8f7f7;
  color: var(--accent-strong);
}

@media (max-width: 1180px) {
  .content {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    width: min(286px, calc(100vw - 28px));
    min-height: calc(100dvh - 28px);
    margin: 14px;
    transform: translateX(calc(-100% - 28px));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    min-height: 64px;
    padding: 0 16px;
  }

  .content {
    padding: 24px 14px 36px;
  }

  .panel {
    padding: 16px;
  }
}
