:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #172026;
  --muted: #66737f;
  --line: #dbe2e8;
  --panel: #ffffff;
  --accent: #176b87;
  --accent-2: #d94f30;
  --good: #147a48;
  --warn: #8b5f00;
}

* {
  box-sizing: border-box;
}

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

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

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  max-width: 440px;
  padding: 28px;
  width: 100%;
}

.login-card h1 {
  color: var(--ink);
  font-size: 28px;
}

.hint,
.session-info {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

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

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

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #172026;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px;
}

.eyebrow {
  color: #77a9b9;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 31px;
  line-height: 1.1;
}

h2 {
  font-size: 24px;
}

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

.tab {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  color: #dbe2e8;
  justify-content: flex-start;
  text-align: left;
}

.tab.active {
  background: #fff;
  color: var(--ink);
}

.summary {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  margin-top: auto;
  padding-top: 22px;
}

.summary span {
  display: block;
  font-size: 38px;
  font-weight: 800;
}

.summary small {
  color: #b8c5cf;
}

.content {
  padding: 32px;
}

.company-chooser {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 22px;
  max-width: 420px;
  padding: 14px;
}

.panel {
  display: none;
  max-width: 1040px;
}

.panel.active {
  display: block;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

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

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

input,
textarea,
select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

input[type="checkbox"] {
  min-height: auto;
  width: auto;
}

.check-row {
  align-items: center;
  display: flex;
  font-weight: 700;
  gap: 10px;
  margin-top: 14px;
}

.message-field {
  display: grid;
  gap: 7px;
}

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

.template-picker {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto;
}

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

.editor-toolbar {
  align-items: center;
  background: #eef2f4;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
}

.editor-toolbar button {
  min-height: 34px;
  min-width: 36px;
  padding: 0 10px;
}

.editor-toolbar select {
  min-height: 34px;
  padding: 4px 8px;
  width: 140px;
}

.editor-toolbar input[type="color"] {
  cursor: pointer;
  min-height: 34px;
  padding: 3px;
  width: 42px;
}

.email-editor {
  line-height: 1.55;
  min-height: 330px;
  outline: none;
  overflow-wrap: anywhere;
  padding: 18px;
}

.email-editor:empty::before {
  color: #94a0a8;
  content: attr(data-placeholder);
  pointer-events: none;
}

.email-editor img,
.email-preview img {
  height: auto;
  max-width: 100%;
}

.variable-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.variable-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.variable-row button {
  min-height: 32px;
  padding: 0 10px;
}

textarea {
  line-height: 1.5;
  resize: vertical;
}

.import-box {
  margin-top: 22px;
}

.notice {
  background: #e9f4f7;
  border: 1px solid #c7e3eb;
  border-radius: 6px;
  color: #164f62;
  margin-top: 16px;
  padding: 12px 14px;
}

.notice.warning {
  background: #fff7df;
  border-color: #f0d891;
  color: var(--warn);
}

.notice.error {
  background: #ffece8;
  border-color: #f2b8aa;
  color: #96351f;
}

.hidden {
  display: none;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 22px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 680px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td:last-child {
  text-align: right;
  white-space: nowrap;
}

td button + button {
  margin-left: 6px;
}

.campaign-list {
  display: grid;
  gap: 10px;
}

.templates-list {
  display: grid;
  gap: 10px;
}

.template-item {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px;
}

.template-item strong,
.template-item small {
  display: block;
}

.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(23, 32, 38, 0.24);
  max-height: calc(100vh - 40px);
  max-width: 640px;
  padding: 0;
  width: calc(100% - 32px);
}

dialog::backdrop {
  background: rgba(23, 32, 38, 0.56);
}

.dialog-content {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 24px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.preview-dialog {
  max-width: 900px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  width: min(900px, calc(100vw - 32px));
}

.email-preview-frame {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: min(620px, 70vh);
  width: 100%;
}

.admin-block {
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  padding-bottom: 24px;
}

.admin-block h3 {
  font-size: 18px;
  margin: 0 0 16px;
}

.admin-lists {
  align-items: start;
  margin-top: 20px;
}

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

.campaign-item {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  padding: 14px;
}

.campaign-item strong {
  display: block;
}

.campaign-item small {
  color: var(--muted);
}

.status-ok {
  color: var(--good);
  font-weight: 700;
}

.status-fail {
  color: var(--accent-2);
  font-weight: 700;
}

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

  .sidebar {
    min-height: auto;
  }

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

  .content {
    padding: 20px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

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

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