:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #e7eaf1;
  --panel: #ffffff;
  --page: #f7f8fb;
  --sidebar: #ffffff;
  --sidebar-2: #ffffff;
  --accent: #5b5cf6;
  --accent-dark: #4647df;
  --accent-soft: #eef0ff;
  --yellow: #ffb400;
  --warn: #9b2f24;
  --soft: #f8fafc;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

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

button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.strong {
  font-weight: 700;
}

button.danger {
  background: #9b2f24;
}

button.danger:hover {
  background: #7e261e;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 9px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: var(--ink);
  box-shadow: 12px 0 30px rgba(15, 23, 42, 0.12);
}

.brand-subtitle {
  color: var(--muted);
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.25;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
}

.nav-button {
  width: 100%;
  background: transparent;
  color: var(--ink);
  text-align: left;
  border-radius: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  min-width: 38px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.icon-button:hover {
  background: var(--soft);
  color: var(--ink);
}

.nav-button.active,
.nav-button:hover {
  background: var(--accent);
  color: #fff;
}

.login-panel,
.workspace {
  padding: 30px 34px;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.shell.login-mode {
  display: block;
}

.shell.login-mode .sidebar {
  display: none;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 6px;
  text-align: center;
}

.login-brand img {
  width: 150px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.login-brand h2 {
  font-size: 26px;
}

.panel {
  display: grid;
  gap: 16px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 16px;
  box-shadow: var(--shadow);
}

.compact {
  width: min(275px, 100%);
  max-width: 275px;
}

.workspace {
  display: grid;
  gap: 18px;
}

.topbar,
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

.stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

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

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

.actions,
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-tools {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-find {
  display: grid;
  grid-template-columns: auto minmax(240px, 340px);
  align-items: center;
  gap: 8px;
}

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

.send-grid {
  display: grid;
  grid-template-columns: 460px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: calc(100vh - 56px);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.dashboard-panel {
  max-width: 1220px;
}

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

.range-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.range-button {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0;
}

.range-button:hover {
  background: var(--soft);
}

.range-menu {
  position: absolute;
  top: 30px;
  left: 76px;
  z-index: 10;
  display: grid;
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
  box-shadow: var(--shadow);
}

.range-menu.hidden {
  display: none;
}

.range-menu button {
  justify-content: start;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.range-menu button:hover {
  background: var(--accent-soft);
}

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

.metric-card {
  display: grid;
  gap: 8px;
  border-left: 1px solid var(--line);
  padding: 6px 18px;
}

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

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

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.subscriber-stat {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 18px;
  box-shadow: var(--shadow);
}

.subscriber-stat span:not(.stat-icon) {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.subscriber-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
}

.subscriber-stat small {
  color: var(--muted);
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  font-weight: 800;
}

.stat-icon.blue {
  background: #eef0ff;
  color: #4647df;
}

.stat-icon.green {
  background: #e9fbf0;
  color: #16a34a;
}

.stat-icon.amber {
  background: #fff6db;
  color: #c47c00;
}

.stat-icon.red {
  background: #fff0f0;
  color: #dc2626;
}

.metric-card:first-child {
  border-left: 0;
}

.metric-card span {
  color: var(--muted);
  font-weight: 700;
}

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

.metric-card small {
  color: var(--muted);
}

.chart-panel canvas {
  width: 100%;
  height: 360px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.hidden {
  display: none;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(24, 33, 47, 0.44);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(24, 33, 47, 0.5);
  padding: 18px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-panel {
  display: grid;
  gap: 16px;
  width: min(1040px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 22px 60px rgba(24, 33, 47, 0.28);
}

.success-panel {
  display: grid;
  gap: 14px;
  justify-items: center;
  width: min(340px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
  text-align: center;
  box-shadow: 0 22px 60px rgba(24, 33, 47, 0.28);
}

.success-panel button {
  min-width: 90px;
}

.busy-overlay.hidden {
  display: none;
}

.busy-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  border-radius: 8px;
  background: #fff;
  padding: 24px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(24, 33, 47, 0.24);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #d8dde5;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.small {
  width: 22px;
  height: 22px;
  border-width: 3px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.message {
  min-height: 20px;
  color: var(--warn);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 3px 10px;
  font-weight: 700;
}

.table-panel {
  overflow: hidden;
  min-height: auto;
}

.subscribers-table {
  padding: 0;
}

.accordion {
  display: block;
  padding: 14px 16px;
}

.accordion summary {
  cursor: pointer;
  font-weight: 700;
}

.accordion[open] summary {
  margin-bottom: 14px;
}

.accordion:not([open]) > :not(summary) {
  display: none;
}

.table-wrap {
  position: relative;
  min-height: 520px;
  overflow: auto;
}

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

.search-box {
  display: grid;
  grid-template-columns: minmax(260px, 420px);
  gap: 0;
}

.search-box span {
  display: none;
}

.list-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-weight: 700;
}

.list-loading.hidden {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
  font-size: 12px;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 13px 18px;
  text-align: left;
  vertical-align: middle;
}

tbody tr.selected-row td {
  background: #fff7d6;
}

tbody tr:hover td {
  background: #f8fafc;
}

tbody tr.selected-row:hover td {
  background: #fff2b8;
}

th {
  color: #475467;
  font-size: 11px;
  text-transform: uppercase;
  background: #fbfcff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
}

.success-soft {
  background: #dcfce7;
  color: #16803c;
}

.danger-soft {
  background: #fee2e2;
  color: #b42318;
}

.empty-row {
  color: var(--muted);
  padding: 24px 8px;
  text-align: center;
}

.template-list {
  display: grid;
  gap: 8px;
}

.template-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
  text-align: left;
  color: var(--ink);
}

.template-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(255, 180, 0, 0.22);
}

.template-item:hover {
  border-color: var(--accent);
  background: #fff9e6;
}

.editor-panel {
  min-width: 0;
}

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

.toolbar select {
  width: auto;
  min-width: 130px;
}

.toolbar button {
  min-width: 42px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.editor {
  min-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 14px;
  line-height: 1.5;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - 68px);
  min-height: 420px;
  overflow: hidden;
  align-content: stretch;
}

.preview-panel iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.editor:focus {
  outline: 2px solid rgba(255, 180, 0, 0.28);
  border-color: var(--accent);
}

.editor img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
}

.editor h1,
.editor h2,
.editor h3,
.editor p,
.editor ul,
.editor ol {
  margin: 0 0 12px;
}

.source-toggle {
  display: grid;
  gap: 10px;
}

.source-toggle summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: 18px;
}

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

  .sidebar {
    min-height: auto;
  }

  .two,
  .template-grid,
  .send-grid,
  .edit-grid,
  .metric-grid,
  .subscriber-metrics {
    grid-template-columns: 1fr;
  }

  .page-heading,
  .subscriber-toolbar,
  .page-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-card {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 0 0;
  }

  .metric-card:first-child {
    border-top: 0;
  }

  table {
    min-width: 620px;
  }

  .table-header,
  .list-tools,
  .quick-find {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .table-header {
    display: grid;
  }

  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(7),
  td:nth-child(7),
  th:nth-child(5),
  td:nth-child(5) {
    display: none;
  }
}

@media (max-width: 640px) {
  .login-panel,
  .workspace {
    padding: 18px;
  }

  table {
    min-width: 720px;
  }

  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(5),
  td:nth-child(5),
  th:nth-child(7),
  td:nth-child(7) {
    display: none;
  }
}
