:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #20231f;
  --muted: #697066;
  --line: #dfe4dc;
  --accent: #2f6f5e;
  --accent-dark: #204d42;
  --warn: #9a6a20;
  --good: #1f7a4c;
  --soft: #edf2ed;
}

* { box-sizing: border-box; }

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

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcf8;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.brand-title { font-weight: 760; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 3px; }

.nav { display: grid; gap: 4px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #3b4039;
  transition: background .18s ease, transform .18s ease;
}

.nav-link:hover {
  background: var(--soft);
  text-decoration: none;
}

.nav-link:active { transform: translateY(1px); }

.nav-link.active {
  background: #dfeae3;
  color: var(--accent-dark);
  font-weight: 700;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #aab3a7;
}

.nav-link.active .nav-dot { background: var(--accent); }

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.note-label {
  font-size: 12px;
  color: var(--accent-dark);
  font-weight: 800;
}

.sidebar-note p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  padding: 30px 34px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.alert {
  margin: -12px 0 20px;
  padding: 10px 12px;
  border: 1px solid #cdd8cf;
  border-radius: 8px;
  background: #f8fbf7;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 720;
}

.alert.warning {
  border-color: #e2c98e;
  background: #fff8e7;
  color: #7a5416;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: 30px; line-height: 1.1; margin-bottom: 0; }
h2 { font-size: 17px; margin-bottom: 4px; }
p { color: var(--muted); line-height: 1.6; }

.topbar-actions, .filters {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-form {
  margin: 0;
}

.button, button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 760;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  transition: transform .18s ease, background .18s ease;
}

.button:hover, button:hover { text-decoration: none; background: #f7faf6; }
.button:active, button:active { transform: translateY(1px); }
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { background: #fff; }

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

.metric-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
}

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

.metric-value {
  font-size: 30px;
  font-weight: 820;
  margin-top: 10px;
}

.metric-value.small {
  font-size: 22px;
}

.metric-delta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.metric-delta.positive { color: var(--good); }
.metric-delta.warning { color: var(--warn); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, .8fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

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

.panel-header, .toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel-header.compact {
  margin-top: 18px;
}

.toolbar {
  background: transparent;
}

.toolbar p { margin-bottom: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 760;
}

td {
  padding: 13px 8px;
  border-bottom: 1px solid #eef1ec;
  vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }
.number { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf2ed;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

.timeline { display: grid; gap: 14px; }
.timeline-item {
  border-left: 2px solid var(--line);
  padding-left: 12px;
}
.timeline-item span {
  display: block;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}
.timeline-item p { margin: 4px 0 0; font-size: 13px; }

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

textarea { min-height: 96px; resize: vertical; }

label {
  display: grid;
  gap: 8px;
  color: #343a33;
  font-weight: 740;
  margin-bottom: 16px;
}

.template-grid, .settings-grid, .detail-grid, .form-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.detail-grid, .form-panel {
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
}

.template-card h2 { margin-top: 18px; }
.card-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  font-weight: 760;
}
.subject {
  margin: 18px 0 12px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  background: #fbfcf8;
}
.muted { color: var(--muted); font-size: 13px; }

.send-test-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.send-test-form label {
  margin-bottom: 0;
}

.detail-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  margin: 0;
}
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 720; }

.check-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

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

.variable-list span {
  padding: 6px 8px;
  border-radius: 8px;
  background: #edf2ed;
  color: var(--accent-dark);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.email-preview {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.6;
}

.text-preview {
  white-space: pre-wrap;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #fbfcf8;
  border: 1px solid var(--line);
  color: var(--ink);
}

code {
  background: #edf2ed;
  padding: 2px 5px;
  border-radius: 5px;
  color: var(--accent-dark);
}

.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2ef;
}

.login-shell {
  width: min(440px, 100%);
}

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

.brand.compact {
  padding: 0 0 18px;
  margin-bottom: 20px;
}

.login-panel h1 {
  font-size: 26px;
  margin-bottom: 10px;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 22px 16px 36px; }
  .topbar, .toolbar { flex-direction: column; }
  .metric-grid, .content-grid, .template-grid, .settings-grid, .detail-grid, .form-panel {
    grid-template-columns: 1fr;
  }
}
