@font-face {
  font-family: "Gilroy";
  src: url("/fonts/gilroy-regular.otf") format("opentype");
  font-weight: 400;
}

@font-face {
  font-family: "Gilroy";
  src: url("/fonts/gilroy-semibold.otf") format("opentype");
  font-weight: 650;
}

@font-face {
  font-family: "Gilroy";
  src: url("/fonts/gilroy-extrabold.otf") format("opentype");
  font-weight: 800;
}

:root {
  --bg: #f7f6f1;
  --paper: #ffffff;
  --ink: #0b0f14;
  --muted: #687383;
  --line: #deddd7;
  --soft: #f1f0ea;
  --accent: #1e5bff;
  --accent-soft: #eaf0ff;
  --success: #167647;
  --success-soft: #e7f6ee;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 18px 55px rgba(11, 15, 20, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

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

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

img {
  display: block;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.98;
  font-weight: 800;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 23px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

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

.auth-page {
  position: relative;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, var(--accent) 0 12px, transparent 12px),
    var(--bg);
}

.auth-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(11, 15, 20, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 15, 20, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

.auth-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  min-height: min(720px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.auth-brand {
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 46px;
  background: var(--ink);
  color: #fff;
  font-size: 25px;
  font-weight: 800;
}

.auth-brand img {
  filter: invert(1);
}

.auth-brand span span,
.portal-brand span span {
  color: var(--accent);
}

.login-panel {
  width: min(520px, 100%);
  align-self: center;
  justify-self: center;
  padding: 64px;
}

.login-copy {
  margin-bottom: 30px;
}

.login-panel h1 {
  margin-top: 14px;
}

.login-panel > p,
.login-copy p {
  max-width: 460px;
}

.section-label {
  display: block;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  text-transform: uppercase;
}

.stack-form {
  display: grid;
  gap: 18px;
}

.stack-form label,
.filter-bar label {
  display: grid;
  gap: 8px;
}

.stack-form label > span,
.filter-bar label > span,
.field-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: var(--paper);
  color: var(--ink);
  padding: 0 14px;
  font-size: 15px;
  font-weight: 650;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus,
textarea:focus,
.rich-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 91, 255, 0.13);
}

select {
  cursor: pointer;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 17px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

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

.button:focus-visible,
.link-button:focus-visible,
.text-link:focus-visible,
.row-link:focus-visible {
  outline: 3px solid rgba(30, 91, 255, 0.28);
  outline-offset: 3px;
}

.button-large {
  min-height: 52px;
  padding: 0 22px;
}

.button-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 25px rgba(30, 91, 255, 0.22);
}

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

.button-secondary {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.back-link,
.text-link,
.row-link {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

.login-panel .back-link {
  display: inline-block;
  margin-top: 24px;
}

.alert {
  margin-bottom: 22px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
}

.alert-error {
  border-color: #f0c0ba;
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-success {
  border-color: #acd9c0;
  background: var(--success-soft);
  color: var(--success);
}

.alert-warning {
  border-color: #e7cc82;
  background: #fff8df;
  color: #76580a;
}

.status-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 48px;
  box-shadow: var(--shadow);
  text-align: center;
}

.status-card img {
  margin: 0 auto 22px;
}

.status-card h1 {
  margin-top: 12px;
  font-size: 44px;
}

.status-card .button {
  margin-top: 8px;
}

.portal-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.portal-header-inner {
  width: min(1420px, calc(100% - 48px));
  min-height: 72px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 34px;
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.portal-nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 0 13px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.portal-nav a:hover,
.portal-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.account-menu {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.account-menu > span {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu form {
  margin: 0;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.account-menu a:hover,
.link-button:hover {
  color: var(--ink);
}

.portal-main {
  width: min(1420px, calc(100% - 48px));
  margin: 0 auto;
  padding: 54px 0 84px;
}

.page-heading {
  margin-bottom: 34px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.page-heading h1 {
  margin-top: 10px;
  font-size: clamp(36px, 5vw, 58px);
}

.page-heading p {
  margin-bottom: 0;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(420px, 1.08fr);
  align-items: start;
  gap: 24px;
}

.compose-fields,
.mail-preview-panel,
.table-panel,
.settings-panel,
.message-preview,
.success-panel,
.credential-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.compose-fields {
  overflow: hidden;
}

.sender-row,
.field-group {
  min-height: 84px;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 16px 22px;
}

.field-group input {
  min-height: 42px;
  border: 0;
  padding: 0;
  box-shadow: none;
  font-size: 16px;
}

.field-group input:focus {
  box-shadow: none;
}

.field-group small,
.field-error {
  grid-column: 2 / -1;
  color: var(--danger);
  font-size: 12px;
  font-weight: 650;
}

.field-group.has-error {
  background: var(--danger-soft);
}

.sender-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sender-identity div {
  display: grid;
  gap: 2px;
}

.sender-identity span {
  color: var(--muted);
  font-size: 13px;
}

.fixed-label,
.current-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--soft);
  padding: 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.editor-disclosure {
  border-bottom: 1px solid var(--line);
}

.editor-disclosure summary {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.editor-disclosure summary::-webkit-details-marker {
  display: none;
}

.editor-disclosure summary::after {
  content: "+";
  color: var(--accent);
  font-size: 24px;
}

.editor-disclosure[open] summary::after {
  content: "−";
}

.editor-disclosure summary small {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.editor-shell {
  margin: 0 22px 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  padding: 7px;
}

.editor-toolbar button {
  min-width: 36px;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  padding: 0 9px;
  cursor: pointer;
  font-size: 13px;
}

.editor-toolbar button:hover,
.editor-toolbar button:focus-visible {
  border-color: var(--line);
  background: var(--paper);
}

.rich-editor {
  min-height: 340px;
  max-height: 560px;
  overflow: auto;
  outline: none;
  padding: 20px;
  color: #4f5968;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.rich-editor h1 {
  color: var(--ink);
  font-size: 30px;
  line-height: 1.08;
}

.rich-editor h2 {
  margin-top: 24px;
  color: var(--ink);
  font-size: 19px;
}

.rich-editor ol,
.rich-editor ul {
  padding-left: 24px;
}

.rich-editor li {
  margin-bottom: 8px;
}

.editor-disclosure > .field-error {
  display: block;
  padding: 0 22px 18px;
}

.compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
}

.compose-actions p {
  max-width: 360px;
  margin: 0;
  font-size: 13px;
}

.mail-preview-panel {
  position: sticky;
  top: 96px;
  overflow: hidden;
  background: #eaf0ff;
}

.preview-heading,
.panel-heading {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  padding: 14px 18px;
}

.preview-heading > div {
  display: grid;
  gap: 5px;
}

.preview-heading strong {
  font-size: 14px;
}

.preview-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
}

.mail-preview-panel iframe {
  width: 100%;
  height: 760px;
  display: block;
  border: 0;
  background: #eaf0ff;
}

.success-panel {
  width: min(760px, 100%);
  margin: 20px auto;
  padding: 58px;
  text-align: center;
  box-shadow: var(--shadow);
}

.success-mark {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 34px;
  font-weight: 800;
}

.success-panel h1 {
  margin-top: 12px;
}

.confirmation-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 32px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
  text-align: left;
}

.confirmation-details div,
.detail-grid div {
  min-width: 0;
  background: var(--paper);
  padding: 16px;
}

dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 650;
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(210px, 0.8fr) 190px auto auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
}

.unsubscribe-hero {
  min-height: 150px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(30, 91, 255, 0.1), transparent 58%),
    var(--paper);
  padding: 24px;
}

.unsubscribe-visual {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
}

.unsubscribe-hero h2 {
  margin-bottom: 8px;
}

.unsubscribe-hero p {
  max-width: 760px;
  margin-bottom: 0;
}

.unsubscribe-filter {
  grid-template-columns: minmax(260px, 1fr) auto auto;
}

.table-panel {
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  vertical-align: middle;
}

th {
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.recipient-cell {
  min-width: 250px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.recipient-cell img {
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--accent-soft);
}

.recipient-cell small,
.muted-text {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfbf8;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800;
}

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

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

.status-sending {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-purged {
  background: var(--soft);
  color: var(--muted);
}

.mailbox-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 800;
}

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

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

.mailbox-status-pending {
  background: var(--accent-soft);
  color: var(--accent);
}

.mailbox-status-not_applicable {
  background: var(--soft);
  color: var(--muted);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 52px 28px;
  text-align: center;
}

.table-panel .empty-state {
  border: 0;
}

.empty-state h2 {
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 0;
}

.empty-state-image {
  margin: 0 auto 16px;
  opacity: 0.55;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.message-preview {
  overflow: hidden;
}

.message-preview iframe {
  width: 100%;
  height: 880px;
  display: block;
  border: 0;
  background: #eaf0ff;
}

.settings-panel {
  padding: 28px;
}

.settings-panel > h1 {
  margin-top: 12px;
  font-size: 44px;
}

.settings-panel > h2 {
  margin-top: 10px;
}

.portal-main > .settings-panel {
  width: min(620px, 100%);
  margin: 0 auto;
}

.credential-panel {
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-color: #acd9c0;
  background: var(--success-soft);
  padding: 22px;
}

.credential-panel h2 {
  margin: 7px 0;
}

.credential-panel p {
  margin-bottom: 0;
  font-size: 13px;
}

.credential-panel code {
  display: block;
  border: 1px solid #acd9c0;
  border-radius: 6px;
  background: var(--paper);
  padding: 14px 18px;
  font-family: Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  user-select: all;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.7fr) minmax(0, 1.3fr);
  align-items: start;
  gap: 22px;
}

.panel-heading h2 {
  margin: 5px 0 0;
}

.panel-heading > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.admin-list {
  display: grid;
}

.admin-item {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.admin-item:last-child {
  border-bottom: 0;
}

.admin-item > div:first-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.admin-item strong,
.admin-item span,
.admin-item small {
  overflow-wrap: anywhere;
}

.admin-item span {
  color: var(--muted);
  font-size: 13px;
}

.admin-item small {
  color: var(--muted);
  font-size: 11px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.inline-actions form {
  margin: 0;
}

.sessions-panel {
  margin-top: 22px;
}

@media (max-width: 1120px) {
  .portal-header-inner {
    grid-template-columns: auto 1fr;
  }

  .account-menu {
    grid-column: 1 / -1;
    min-height: 42px;
    border-top: 1px solid var(--line);
  }

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

  .mail-preview-panel {
    position: static;
  }

  .mail-preview-panel iframe {
    height: 700px;
  }
}

@media (max-width: 820px) {
  .auth-page {
    padding: 16px;
  }

  .auth-shell {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: auto;
    padding: 24px;
    background: var(--paper);
    color: var(--ink);
  }

  .auth-brand img {
    filter: none;
  }

  .login-panel {
    padding: 28px 24px 36px;
  }

  .portal-header-inner,
  .portal-main {
    width: min(100% - 28px, 1420px);
  }

  .portal-header-inner {
    min-height: 64px;
    gap: 16px;
  }

  .portal-nav {
    justify-content: flex-end;
    overflow-x: auto;
  }

  .account-menu > span {
    margin-right: auto;
  }

  .portal-main {
    padding-top: 36px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }

  .detail-grid,
  .confirmation-details {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 620px) {
  h1,
  .page-heading h1 {
    font-size: 38px;
  }

  .portal-header-inner {
    display: flex;
    flex-wrap: wrap;
    padding-top: 12px;
  }

  .portal-brand {
    margin-right: auto;
  }

  .portal-nav {
    width: 100%;
    order: 3;
    justify-content: flex-start;
    border-top: 1px solid var(--line);
    padding: 8px 0;
  }

  .account-menu {
    width: auto;
    min-height: auto;
    grid-column: auto;
    border: 0;
  }

  .account-menu > span,
  .account-menu > a {
    display: none;
  }

  .sender-row,
  .field-group {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .fixed-label {
    justify-self: start;
  }

  .field-group small {
    grid-column: auto;
  }

  .compose-actions,
  .credential-panel,
  .admin-item {
    align-items: stretch;
    flex-direction: column;
  }

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

  .mail-preview-panel iframe {
    height: 590px;
  }

  .filter-bar,
  .detail-grid,
  .confirmation-details {
    grid-template-columns: 1fr;
  }

  .filter-bar .button {
    width: 100%;
  }

  .button-row {
    flex-direction: column;
  }

  .success-panel,
  .status-card,
  .settings-panel {
    padding: 28px 22px;
  }

  .credential-panel code {
    overflow-x: auto;
  }

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