:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #22211f;
  --muted: #6d6862;
  --line: #ded9d1;
  --accent: #b3272a;
  --good: #197548;
  --warn: #956200;
  --bad: #a12424;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: 0;
}

main {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 40px;
  display: grid;
  gap: 18px;
}

.login, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.login {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

input {
  min-width: min(420px, 100%);
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #ece7df;
  color: var(--ink);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--bad);
}

.dot.good { background: var(--good); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 86px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  letter-spacing: 0;
}

.split {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.muted { color: var(--muted); }
.hidden { display: none; }
.events {
  max-height: 360px;
  overflow: auto;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head h2 { margin-bottom: 4px; }
.panel-head p { margin: 0; font-size: 13px; }
.table-scroll { overflow-x: auto; }
.chart-wrap { min-width: 0; }
#signupChart { display: block; width: 100%; height: 240px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: #ece7df;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.good { background: #e3f3ea; color: var(--good); }
.badge.bad { background: #fae7e7; color: var(--bad); }
.mail-health { display: grid; gap: 10px; margin: 0; }
.mail-health div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.mail-health dt { color: var(--muted); }
.mail-health dd { margin: 0; font-weight: 700; }
.signup-detail { margin-top: 18px; }
.signup-recent { margin-top: 20px; }
.chart-legend { display: flex; gap: 14px; margin: -4px 0 8px; color: var(--muted); font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; background: var(--good); }
.chart-legend .cancel i { background: var(--bad); }

@media (max-width: 860px) {
  header { align-items: flex-start; flex-direction: column; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
}
