:root {
  --bg: #020407;
  --bg-soft: #05080f;
  --sidebar: #05070d;
  --panel: #060a11;
  --panel-soft: #0b1018;
  --line: #161b24;
  --line-strong: #232a36;
  --text: #eceff4;
  --muted: #949cab;
  --muted-soft: #707785;
  --pill: #141a24;
  --pill-hover: #1b2330;
  --white-btn: #f8f8fa;
  --white-btn-ink: #131821;
  --green: #45d39a;
  --green-bg: #0b2b22;
  --blue: #77a6ff;
  --blue-bg: #132238;
  --orange: #f1b14f;
  --orange-bg: #36280f;
  --red: #f58f8f;
  --red-bg: #36191e;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
  --sans: 'IBM Plex Sans', 'Sora', 'Segoe UI', sans-serif;
  --control-h: 42px;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  overflow-x: hidden;
}

body {
  background: #030507;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(38, 84, 178, 0.12), transparent 36%),
    radial-gradient(circle at bottom, rgba(33, 159, 120, 0.1), transparent 34%),
    #030507;
}

.login-card {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, #090d15 0%, #06090f 100%);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
  padding: 30px 28px;
  display: grid;
  gap: 18px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand-dot {
  width: 42px;
  height: 42px;
  font-size: 18px;
}

.login-eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-card h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 620;
}

.login-copy {
  margin: 0;
  color: #c8cfda;
  font-size: 15px;
  line-height: 1.5;
}

.login-allowed {
  border: 1px solid #1d2430;
  border-radius: 16px;
  background: #0b111a;
  padding: 14px 16px;
}

.login-allowed-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-allowed strong {
  display: block;
  font-size: 18px;
  font-weight: 600;
  word-break: break-word;
}

.login-actions {
  display: grid;
  justify-items: start;
}

#loginGoogleButton {
  min-height: 42px;
}

#loginGoogleButton > div {
  width: 100% !important;
}

.login-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

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

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

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 350, 'GRAD' 0, 'opsz' 20;
  line-height: 1;
  font-size: 21px;
}

.app-shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.sidebar {
  background: linear-gradient(180deg, #05070d 0%, #05070c 100%);
  border-right: 1px solid var(--line);
  padding: 12px 10px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

.workspace-row {
  display: flex;
  align-items: center;
  gap: 11px;
}

.workspace-chip {
  flex: 1;
  border: 1px solid var(--line);
  background: #0b111a;
  color: var(--text);
  border-radius: var(--radius-md);
  min-height: 42px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, #27b490 0%, #1f8e74 100%);
  color: #e6fff6;
  font-size: 14px;
  font-weight: 700;
  display: grid;
  place-items: center;
  text-transform: uppercase;
}

.workspace-name {
  font-size: 14px;
  font-weight: 500;
}

.nav-list {
  display: grid;
  align-content: start;
  gap: 3px;
  overflow: auto;
  min-height: 0;
}

#mainNav [data-view='tickets'] {
  display: none;
}

.nav-link {
  border: 1px solid transparent;
  background: transparent;
  color: #9ca5b5;
  border-radius: var(--radius-sm);
  min-height: 38px;
  padding: 7px 10px;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.nav-link:hover {
  background: #111722;
  color: #e9edf4;
}

.nav-link.active {
  background: #141b27;
  border-color: #232d40;
  color: #f2f6fd;
}

.nav-glyph {
  font-size: 15px;
  color: #9ca5b5;
}

.nav-link.active .nav-glyph,
.nav-link:hover .nav-glyph {
  color: inherit;
}

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

.google-auth {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0c121c;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.google-auth .muted {
  margin: 0;
  line-height: 1.35;
}

#googleLoginButton > div {
  width: 100% !important;
}

.auth-fallback-btn {
  width: 100%;
  justify-content: center;
}

.auth-fallback-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.mode-badge {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0c121c;
  color: var(--muted);
  font-size: 13px;
  padding: 9px 11px;
}

#modeBadge,
#refreshButton {
  display: none;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0a1018;
  color: #a4adbc;
  font-size: 13px;
  padding: 9px 11px;
  white-space: nowrap;
  overflow: hidden;
}

.account-chip span:last-child {
  text-overflow: ellipsis;
  overflow: hidden;
}

.account-dot {
  flex: 0 0 22px;
  background: #111a24;
  color: #c8d0de;
}

.main {
  padding: 0 22px 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100dvh;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.main-header,
.view {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  min-width: 0;
}

.main-header {
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  z-index: 4;
  background: transparent;
}

#viewTitle {
  margin: 0;
  font-size: 44px;
  letter-spacing: -0.018em;
  font-weight: 600;
}

#viewSubtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #b4bcc9;
  font-size: 13px;
}

.header-links a:hover {
  color: #f0f4fb;
}

.feedback-link {
  border: 1px solid #202839;
  border-radius: 999px;
  background: #0d141f;
  padding: 6px 11px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding-top: 7px;
  min-height: 0;
  overflow: hidden;
}

.view.active {
  display: flex;
  overflow: hidden;
}

.view > .page-head-row > h2 {
  display: none;
}

.view > .page-head-row {
  position: relative;
  z-index: 3;
  padding: 2px 0 4px;
  background: transparent;
}

.view > .toolbar {
  position: relative;
  z-index: 3;
  padding: 0;
  background: transparent;
}

.page-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.action-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-head-row h2,
.page-head-row h3,
.page-head-row h4 {
  margin: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(170px, auto));
  gap: 10px;
  min-width: 0;
}

.view[data-view='emails'] .toolbar {
  grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(170px, auto)) auto;
}

.view > .page-head-row,
.view > .toolbar,
.view > .segmented,
.view > .audience-metrics {
  flex: 0 0 auto;
}

.view-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 4px;
}

.compact-toolbar {
  display: flex;
  align-items: center;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.segmented-btn {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #a1a9b7;
  min-height: 38px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

.segmented-btn:hover {
  color: #f0f3f8;
  background: var(--pill);
}

.segmented-btn.active {
  color: #f5f7fc;
  background: #1a212f;
  border-color: #293446;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #1f2633;
  border-radius: var(--radius-sm);
  background: #121823;
  color: #e9edf4;
  min-height: var(--control-h);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #6f7889;
}

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

.pill-btn,
.icon-btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: var(--control-h);
  padding: 8px 12px;
  font-size: 13px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pill-btn {
  background: var(--white-btn);
  color: var(--white-btn-ink);
  font-weight: 600;
}

.pill-btn:hover {
  background: #ffffff;
}

.icon-btn {
  background: var(--pill);
  color: #e9edf4;
  border-color: #232c3d;
  font-weight: 500;
}

.icon-btn:hover {
  background: var(--pill-hover);
}

.icon-only {
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  display: grid;
  place-items: center;
}

.icon-ghost {
  min-height: 40px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  padding: 0;
  background: #151b26;
  border-color: #232d40;
  color: #d6ddea;
}

.icon-ghost:hover {
  background: #1a2332;
}

.icon-btn[title='Delete'],
#domainDeleteSelected {
  color: #ffc8c8;
  background: #2a1318;
  border-color: #4a2029;
}

.muted-btn {
  background: #303947;
  color: #f3f6fd;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #070b12 0%, #06090f 100%);
  padding: 12px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
}

#emailsTablePanel .table-wrap,
#ticketsTablePanel .table-wrap,
#broadcastsTablePanel .table-wrap,
#templatesTablePanel .table-wrap,
#audienceTablePanel .table-wrap,
#domainsTablePanel .table-wrap,
#logsTablePanel .table-wrap,
#apiKeysTablePanel .table-wrap,
#webhooksTablePanel .table-wrap {
  max-height: min(58vh, 680px);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pager .muted {
  min-width: 180px;
  text-align: right;
}

.pager-btn {
  min-height: 36px;
  padding: 6px 11px;
}

.pager-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

#audiencePager {
  grid-column: 1 / -1;
}

#ticketsPager {
  grid-column: 1 / 2;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  table-layout: fixed;
}

th,
td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid #181f2b;
  font-size: 13px;
  vertical-align: top;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th {
  color: #8f98a8;
  font-weight: 600;
  background: #101722;
  position: sticky;
  top: 0;
}

td .mono,
.mono {
  font-family: var(--mono);
  font-size: 13px;
  color: #c4cddd;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.clip-inline {
  display: inline-block;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
  white-space: nowrap;
}

#emailsTablePanel {
  padding: 0;
}

#emailsTablePanel .table-wrap {
  max-height: min(62vh, 760px);
}

#emailsTablePanel table {
  min-width: 0;
  table-layout: fixed;
}

#emailsTablePanel th:nth-child(1),
#emailsTablePanel td:nth-child(1) {
  width: 30%;
}

#emailsTablePanel th:nth-child(2),
#emailsTablePanel td:nth-child(2) {
  width: 11%;
}

#emailsTablePanel th:nth-child(3),
#emailsTablePanel td:nth-child(3) {
  width: 43%;
}

#emailsTablePanel th:nth-child(4),
#emailsTablePanel td:nth-child(4) {
  width: 14%;
}

#emailsTablePanel th:nth-child(5),
#emailsTablePanel td:nth-child(5) {
  width: 48px;
  text-align: right;
}

#emailsRows tr {
  cursor: pointer;
}

#emailsRows tr td {
  transition: background-color 0.14s ease;
}

#emailsRows tr:hover td {
  background: #0d141f;
}

#emailsRows tr.is-selected td {
  background: #111b2a;
}

.email-row-recipient {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.email-row-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #2b3648;
  background: #121827;
  color: #9facc4;
  flex: 0 0 30px;
}

.email-row-icon .material-symbols-outlined {
  font-size: 16px;
}

.email-row-icon-delivered,
.email-event-icon-delivered,
.email-status-delivered {
  color: #67e4b1;
  border-color: #28523f;
  background: linear-gradient(180deg, #163126 0%, #0f231c 100%);
}

.email-row-icon-opened,
.email-event-icon-opened,
.email-status-opened {
  color: #88b6ff;
  border-color: #264267;
  background: linear-gradient(180deg, #13273f 0%, #101d2f 100%);
}

.email-row-icon-clicked,
.email-event-icon-clicked,
.email-status-clicked {
  color: #c7a2ff;
  border-color: #4b3473;
  background: linear-gradient(180deg, #2d2046 0%, #211734 100%);
}

.email-row-icon-failed,
.email-event-icon-failed,
.email-status-failed,
.email-row-icon-cancelled,
.email-event-icon-cancelled,
.email-status-cancelled,
.email-row-icon-suppressed,
.email-event-icon-suppressed,
.email-status-suppressed {
  color: #f6a5a5;
  border-color: #5a2e36;
  background: linear-gradient(180deg, #381f24 0%, #29161b 100%);
}

.email-row-icon-retry,
.email-event-icon-retry,
.email-status-retry,
.email-row-icon-sending,
.email-event-icon-sending,
.email-status-sending,
.email-row-icon-pending,
.email-event-icon-pending,
.email-status-pending {
  color: #f3c06a;
  border-color: #5a4422;
  background: linear-gradient(180deg, #352911 0%, #2a210f 100%);
}

.email-row-address {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-row-more {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 10px;
  border-color: #263145;
  background: #121a26;
}

.email-row-more .material-symbols-outlined {
  font-size: 17px;
}

.email-detail {
  display: grid;
  gap: 14px;
  border-radius: 18px;
  padding: 14px;
}

.email-detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.email-recipient-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.email-recipient-avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 1px solid #2b3648;
  background: #121827;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.email-recipient-avatar .material-symbols-outlined {
  font-size: 29px;
}

.email-kicker {
  margin: 0;
  color: #95a0b4;
  font-size: 12px;
}

.email-recipient-card h3 {
  margin: 2px 0 0;
  font-size: 40px;
  line-height: 1.05;
  font-weight: 620;
  letter-spacing: -0.02em;
}

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

.email-meta-grid article {
  border: 1px solid #1c2533;
  border-radius: 13px;
  background: #0b111b;
  padding: 10px;
  min-width: 0;
}

.email-meta-grid p {
  margin: 0;
  color: #8590a2;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.email-meta-grid h4 {
  margin: 7px 0 0;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-events-wrap {
  border: 1px solid #1a2332;
  border-radius: 14px;
  padding: 10px;
  background:
    radial-gradient(circle at 1px 1px, rgba(122, 146, 181, 0.18) 1px, transparent 0) 0 0 / 8px 8px,
    #090e16;
}

.email-events-wrap > .muted {
  margin-bottom: 8px;
  color: #8f9ab0;
  letter-spacing: 0.03em;
}

.email-events-track {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.email-event-item {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 92px;
}

.email-event-icon {
  width: 33px;
  height: 33px;
  border-radius: 11px;
  border: 1px solid #2b3648;
  background: #111825;
  color: #9facc4;
  display: grid;
  place-items: center;
}

.email-event-icon .material-symbols-outlined {
  font-size: 18px;
}

.email-event-pill {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid #2a3447;
  background: #121a28;
  color: #d7deea;
  padding: 2px 8px;
  font-size: 12px;
}

.email-event-time {
  color: #a2acbc;
  font-size: 12px;
  text-align: center;
  line-height: 1.2;
}

.email-event-line {
  width: 44px;
  height: 1px;
  background: #2a3447;
  flex: 0 0 44px;
}

.email-content-shell {
  border: 1px solid #1d2636;
  border-radius: 16px;
  background: #080d15;
  overflow: hidden;
}

.email-content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #182131;
  padding: 9px 10px;
}

.email-content-head .segmented-btn {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.email-insight-count {
  margin-left: 4px;
  border-radius: 999px;
  border: 1px solid #4d3d1b;
  background: #2b210d;
  color: #f4c56f;
  padding: 0 6px;
  font-size: 11px;
}

.email-content-body {
  min-height: 460px;
}

.email-content-pane {
  display: none;
}

.email-content-pane.active {
  display: block;
}

.email-preview-box {
  background: #d7d7d7;
  padding: 14px;
}

.email-preview-frame {
  width: 100%;
  min-height: 520px;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

.email-preview-fallback {
  margin: 0;
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: #d6deec;
  white-space: pre-wrap;
}

.email-text-pre {
  margin: 0;
  padding: 14px;
  min-height: 520px;
  max-height: min(62vh, 820px);
  overflow: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: #dbe3f0;
}

.email-insights {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.email-insight-group {
  border: 1px solid #1d2636;
  border-radius: 12px;
  background: #0d131d;
  overflow: hidden;
}

.email-insight-group h4 {
  margin: 0;
  padding: 9px 11px;
  border-bottom: 1px solid #1a2230;
  color: #9aa4b7;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.email-insight-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 10px 11px;
  border-top: 1px solid #151d2a;
}

.email-insight-group .email-insight-row:first-of-type {
  border-top: 0;
}

.email-insight-row p {
  margin: 0;
  color: #d7dfee;
  font-size: 13px;
}

.email-insight-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-top: 5px;
}

.email-insight-dot-warn {
  background: #f1b14f;
}

.email-insight-dot-neutral {
  background: #87a0cc;
}

.email-insight-dot-good {
  background: #57d8a6;
}

.view[data-view='emails'].email-detail-mode > .page-head-row,
.view[data-view='emails'].email-detail-mode > .toolbar {
  display: none;
}

#domainDetailPanel .table-wrap:first-of-type table,
#domainDetailPanel .table-wrap:last-of-type table {
  min-width: 0;
  table-layout: fixed;
}

#domainDetailPanel .table-wrap:first-of-type th:nth-child(1),
#domainDetailPanel .table-wrap:first-of-type td:nth-child(1) {
  width: 84px;
}

#domainDetailPanel .table-wrap:first-of-type th:nth-child(2),
#domainDetailPanel .table-wrap:first-of-type td:nth-child(2) {
  width: 96px;
}

#domainDetailPanel .table-wrap:first-of-type td:nth-child(3),
#domainDetailPanel .table-wrap:last-of-type td:nth-child(3) {
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 52px 20px;
}

.empty-state h3 {
  margin: 0;
  font-size: 38px;
  line-height: 1.2;
  font-weight: 620;
  letter-spacing: -0.02em;
}

.empty-state p {
  margin: 16px 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.empty-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  text-transform: none;
  border: 1px solid transparent;
}

.status-delivered,
.status-sent,
.status-verified,
.status-pass,
.status-enabled,
.status-published,
.status-subscribed {
  color: var(--green);
  border-color: #1f5d4a;
  background: var(--green-bg);
}

.status-pending,
.status-sending,
.status-opened,
.status-not_started,
.status-manual,
.status-queued,
.status-draft,
.status-string,
.status-number,
.status-boolean,
.status-date {
  color: var(--blue);
  border-color: #2f4668;
  background: var(--blue-bg);
}

.status-retry,
.status-clicked,
.status-scheduled {
  color: var(--orange);
  border-color: #5b441f;
  background: var(--orange-bg);
}

.status-failed,
.status-suppressed,
.status-cancelled,
.status-fail,
.status-disabled,
.status-unsubscribed {
  color: var(--red);
  border-color: #5b2a31;
  background: var(--red-bg);
}

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

.audience-metrics article {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  background: #0c121b;
}

.audience-metrics p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.audience-metrics h4 {
  margin: 6px 0 0;
  font-size: 22px;
}

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

.topic-preview {
  display: grid;
  align-content: start;
  gap: 8px;
  background: radial-gradient(circle at 20% 0, #0e1932 0%, #070c14 60%);
}

.topic-preview h3 {
  margin: 0;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-card h3 {
  margin: 8px 0 0;
  font-size: 30px;
}

.chart-panel h3 {
  margin: 0 0 14px;
  font-size: 19px;
}

.sparkline {
  min-height: 220px;
  border: 1px dashed #253045;
  border-radius: var(--radius-md);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
}

.sparkline-bar {
  border-radius: 4px 4px 0 0;
  min-height: 10px;
  background: linear-gradient(180deg, #4d7ddd 0%, #263f70 100%);
}

.domain-detail h4 {
  margin: 2px 0 12px;
}

.tickets-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  gap: 12px;
  align-items: start;
}

.tickets-grid > .panel {
  min-height: 220px;
}

#ticketsRows tr.is-selected td {
  background: #11192a;
}

.ticket-thread,
.ticket-thread-empty {
  display: grid;
  align-content: start;
  gap: 14px;
}

.ticket-thread h3,
.ticket-thread-empty h3 {
  margin: 0;
}

.ticket-messages {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.ticket-message {
  border: 1px solid #202839;
  border-radius: var(--radius-md);
  background: #0d131d;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.ticket-message header {
  display: grid;
  gap: 2px;
}

.ticket-message header strong {
  font-size: 13px;
}

.ticket-message header span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.ticket-message pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.ticket-message-agent {
  border-color: #2a446f;
  background: #10192a;
}

.ticket-message-customer {
  border-color: #26423a;
  background: #0d1816;
}

.settings-pane {
  display: none;
  gap: 10px;
}

.settings-pane.active {
  display: grid;
}

.form-card h3 {
  margin: 0 0 5px;
  font-size: 23px;
}

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

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

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

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

.settings-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.doc-card h3 {
  margin: 0 0 5px;
  font-size: 23px;
}

.api-docs-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 5, 10, 0.72);
  z-index: 32;
}

.api-docs-panel {
  position: fixed;
  top: 0;
  right: -980px;
  width: min(900px, 96vw);
  height: 100dvh;
  border-left: 1px solid var(--line);
  background: #060a11;
  z-index: 33;
  transition: right 0.22s ease;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.api-docs-panel.open {
  right: 0;
}

.api-docs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid #1a2331;
}

.api-docs-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-docs-title-wrap h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 620;
}

.api-docs-badge {
  border: 1px solid #2d384a;
  border-radius: 10px;
  background: #171f2d;
  color: #aeb8cb;
  font-size: 12px;
  padding: 2px 8px;
}

.api-docs-body {
  overflow: auto;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.api-docs-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.api-docs-tabs .segmented-btn {
  min-height: 34px;
  padding: 6px 12px;
}

.api-docs-section {
  border: 1px solid #1c2636;
  border-radius: 16px;
  background: #090f19;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.api-docs-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.api-docs-section-head h4 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 620;
}

.api-docs-ext {
  color: #aab5c8;
  font-size: 18px;
}

.api-docs-method {
  color: #8f9ab1;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.api-docs-code {
  margin: 0;
  border: 1px solid #1e2738;
  border-radius: 14px;
  background: #060b13;
  padding: 13px;
  overflow: auto;
  min-height: 152px;
  max-height: 460px;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  color: #d9e1ee;
}

.drawer {
  position: fixed;
  top: 0;
  right: -760px;
  width: min(720px, 96vw);
  height: 100vh;
  background: #090d15;
  border-left: 1px solid var(--line);
  transition: right 0.22s ease;
  z-index: 30;
  display: grid;
  grid-template-rows: auto 1fr;
}

.drawer.open {
  right: 0;
}

.drawer-head {
  border-bottom: 1px solid var(--line);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.drawer-head h3 {
  margin: 0;
}

.drawer-body {
  padding: 14px;
  overflow: auto;
  display: grid;
  gap: 14px;
}

.detail-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #0d131d;
  padding: 12px;
}

.detail-block h4 {
  margin: 0 0 10px;
}

.detail-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 13px;
  color: #dce3f0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.78);
  display: grid;
  place-items: center;
  z-index: 40;
}

.modal-card {
  width: min(720px, 94vw);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: #090d15;
}

.modal-form {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.modal-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.modal-error {
  margin: 0;
  color: #f8a0a0;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions .ghost-btn {
  border: 1px solid #2a3548;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #d2dbee;
  min-height: var(--control-h);
  padding: 9px 13px;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  z-index: 50;
  border-radius: 999px;
  padding: 10px 15px;
  background: #edf1f8;
  color: #10151f;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}

.toast.show {
  opacity: 1;
}

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

  #emailsTablePanel table {
    min-width: 760px;
  }

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

  .email-recipient-card h3 {
    font-size: 31px;
  }

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

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

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

  .readonly-grid,
  .form-grid,
  .settings-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  html,
  body {
    overflow: auto;
  }

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

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

  .nav-list {
    display: grid;
    overflow: visible;
    padding-bottom: 2px;
  }

  .nav-link {
    min-width: 0;
  }

  .main {
    padding: 0 14px 20px;
    height: auto;
    overflow: visible;
    grid-template-rows: auto;
  }

  .main-header {
    min-height: 70px;
    position: static;
  }

  .view,
  .view.active {
    overflow: visible;
  }

  .view-scroll {
    overflow: visible;
    padding-right: 0;
  }

  .view > .page-head-row {
    position: static;
    background: transparent;
    padding: 0;
  }

  .view > .toolbar {
    position: static;
    top: auto;
    background: transparent;
    padding: 0;
  }

  #viewTitle {
    font-size: 32px;
  }

  #viewSubtitle,
  .header-links {
    display: none;
  }

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

  .email-content-body,
  .email-text-pre,
  .email-preview-frame {
    min-height: 420px;
  }

  .api-docs-panel {
    width: 100vw;
  }
}
