:root {
  --ink: #20231f;
  --muted: #62675f;
  --paper: #f7f7f2;
  --surface: #fff;
  --line: #daddd3;
  --accent: #344e3e;
  --tint: #e8eee7;
  --danger: #a02f2f;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s6: 24px;
  --s8: 32px;
  --s12: 48px;
  --radius: 6px;
  --font: Arial, Helvetica, sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}
[hidden] {
  display: none !important;
}
a {
  color: var(--accent);
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
.button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--ink);
  color: white;
  padding: 10px 18px;
  min-height: 44px;
  line-height: 1.4;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
}
button:hover,
.button:hover {
  background: var(--accent);
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.secondary:hover {
  background: var(--tint);
}
.quiet {
  background: transparent;
  color: var(--ink);
  padding-inline: var(--s3);
}
.quiet:hover {
  background: var(--tint);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
header {
  padding: var(--s6) var(--s12);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--s4);
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -4px;
  text-decoration: none;
  color: var(--ink);
}
.brand span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.6px;
  line-height: 1.6;
  border-left: 1px solid var(--line);
  padding-left: var(--s4);
}
.brand small {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 1px;
  color: var(--muted);
}
.header-right {
  display: flex;
  align-items: center;
  gap: var(--s6);
  font-size: 13px;
  color: var(--muted);
}
main {
  max-width: 1440px;
  margin: auto;
  padding: var(--s12);
}
h1 {
  font-size: clamp(30px, 3.2vw, 46px);
  font-weight: 500;
  letter-spacing: -1.8px;
  line-height: 1.15;
  margin: var(--s3) 0 var(--s4);
}
h2 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.45px;
  margin: 0 0 var(--s4);
}
h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 var(--s6);
}
p {
  margin: 0 0 var(--s4);
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
}
.muted,
.footnote {
  color: var(--muted);
  font-size: 13px;
}
.footnote {
  font-size: 12px;
  margin: var(--s4) 0;
}
.page-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s6);
}
.page-heading {
  align-items: flex-end;
  margin: var(--s4) 0 var(--s8);
}
.period-controls {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-shrink: 0;
}
.period-controls label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
nav {
  display: flex;
  border-bottom: 1px solid var(--line);
  gap: var(--s6);
  margin-bottom: var(--s8);
}
nav button {
  background: none;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: var(--s4) 0;
}
nav button:hover {
  background: transparent;
  color: var(--ink);
}
nav button[aria-current] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--s6);
  margin: 0 0 var(--s8);
  padding: var(--s6) 0 var(--s8);
  border-bottom: 1px solid var(--line);
}
.metric .value {
  display: block;
  font-size: 36px;
  letter-spacing: -1px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin: var(--s3) 0;
}
.metric:first-child .value {
  font-size: 52px;
  line-height: 1;
}
.metric .label {
  font-size: 13px;
  color: var(--muted);
}
.metric .hint {
  font-size: 12px;
  color: var(--muted);
}
.split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--s6);
  margin-bottom: var(--s6);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s6);
  min-width: 0;
  margin-bottom: var(--s6);
}
.split .panel {
  margin-bottom: 0;
}
.chart {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.chart svg {
  width: 100%;
  height: 220px;
  display: block;
}
.short {
  min-height: 160px;
}
.short svg {
  height: 160px;
}
.empty {
  padding: var(--s8) var(--s4);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}
.topic {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.topic:last-child {
  border: 0;
}
.topic strong {
  font-variant-numeric: tabular-nums;
}
.funnel-row {
  display: flex;
  justify-content: space-between;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.badge {
  background: var(--tint);
  color: var(--accent);
  border-radius: var(--radius);
  padding: var(--s2) var(--s3);
  font-size: 12px;
  white-space: nowrap;
}
.badge.warning {
  background: #f6e9df;
  color: #834719;
}
label {
  display: block;
  font-size: 13px;
  margin-bottom: var(--s2);
}
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px var(--s3);
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
  max-width: 100%;
}
input,
textarea {
  width: 100%;
}
textarea {
  resize: vertical;
}
.filters {
  display: flex;
  gap: var(--s4);
  align-items: flex-end;
  margin: var(--s6) 0;
}
.grow {
  flex: 1;
}
.issue {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s6);
  margin-bottom: var(--s4);
}
.issue-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--s4);
  color: var(--muted);
  font-size: 12px;
  margin-bottom: var(--s3);
}
.issue-body {
  font-size: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 900px;
}
.issue-controls {
  display: grid;
  grid-template-columns: 150px 180px 1fr auto;
  gap: var(--s4);
  align-items: end;
  margin-top: var(--s6);
}
.compose {
  margin-top: var(--s6);
}
#campaign-form input,
#campaign-form textarea {
  margin-bottom: var(--s6);
}
.preview {
  background: var(--tint);
}
.telegram-message {
  background: white;
  padding: var(--s4);
  border-radius: var(--s3);
  max-width: 360px;
  min-height: 180px;
  margin: var(--s6) auto;
}
.sender-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
#message-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: var(--s3) 0 var(--s6);
}
.unsubscribe-preview {
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--accent);
  padding-top: var(--s3);
  font-size: 13px;
}
.campaign {
  border-top: 1px solid var(--line);
  padding: var(--s6) 0;
}
.campaign .section-heading {
  align-items: start;
}
.campaign h3 {
  margin-bottom: var(--s2);
}
.campaign-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s4);
}
.campaign-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4);
  font-size: 13px;
  color: var(--muted);
  margin-top: var(--s3);
}
.notice {
  padding: var(--s4);
  background: var(--tint);
  border-radius: var(--radius);
  margin-bottom: var(--s6);
}
.notice.error {
  color: var(--danger);
  background: #faeaea;
}
.error-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--s4);
  font-size: 14px;
}
dt {
  color: var(--muted);
}
dd {
  margin: 0;
  overflow-wrap: anywhere;
}
footer {
  margin-top: var(--s12);
  border-top: 1px solid var(--line);
  padding-top: var(--s6);
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
}
.login {
  padding: 64px 0;
  max-width: 440px;
}
.login h1 {
  font-size: 54px;
}
.login form {
  margin-top: var(--s8);
}
.login button {
  margin-top: var(--s4);
  width: 100%;
}
#login-error,
#launch-error {
  color: var(--danger);
  font-size: 14px;
  margin-top: var(--s4);
}
dialog {
  border: 1px solid var(--line);
  border-radius: var(--s3);
  padding: var(--s8);
  max-width: 540px;
  width: calc(100% - 32px);
  color: var(--ink);
}
dialog::backdrop {
  background: rgb(20 25 20 / 0.4);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s3);
  margin-top: var(--s6);
}
.skip {
  position: absolute;
  top: -60px;
  left: var(--s4);
  padding: var(--s3);
  background: white;
  z-index: 5;
}
.skip:focus {
  top: var(--s4);
}
@media (max-width: 1000px) {
  main {
    padding: var(--s8);
  }
  header {
    padding: var(--s6) var(--s8);
  }
  .page-heading {
    align-items: start;
    flex-direction: column;
  }
  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }
  .split {
    grid-template-columns: 1fr;
  }
  .issue-controls {
    grid-template-columns: 1fr 1fr;
  }
  .header-right #connection {
    display: none;
  }
}
@media (max-width: 600px) {
  main {
    padding: var(--s6) var(--s4);
  }
  header {
    padding: var(--s4);
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: var(--s6);
  }
  .metric .value {
    font-size: 30px;
  }
  .metric:first-child .value {
    font-size: 42px;
  }
  .section-heading {
    align-items: start;
    flex-wrap: wrap;
  }
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .filters .grow {
    grid-column: 1/-1;
  }
  .period-controls {
    width: 100%;
    flex-wrap: wrap;
  }
  nav {
    gap: var(--s4);
    overflow-x: auto;
    white-space: nowrap;
  }
  nav button {
    font-size: 14px;
  }
  .issue-controls {
    grid-template-columns: 1fr;
  }
  .panel,
  .issue {
    padding: var(--s4);
  }
  dl {
    grid-template-columns: 1fr;
    gap: var(--s2);
  }
  dd {
    margin-bottom: var(--s3);
  }
  footer span {
    display: none;
  }
  .login h1 {
    font-size: 44px;
  }
  .brand span {
    font-size: 10px;
  }
  .issue-meta {
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
