:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #1d2327;
  --muted: #5f6b73;
  --line: #dcd8d0;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --ok: #2e7d4f;
  --ok-bg: #e5f2ea;
  --bad: #a3322a;
  --bad-bg: #f8e6e4;
  --warn-bg: #fdf1d6;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
code, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.9em; }
code { background: #efece6; padding: 0 4px; border-radius: 4px; }
code.builtin { background: var(--ok-bg); }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 12px 24px;
  background: var(--ink);
  color: #fff;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1em; letter-spacing: 0.02em; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.nav a { color: #d6dde1; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav a.active, .nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 0.9em; color: #d6dde1; }
.userbox .btn-link { color: #fff; }

.banner { background: var(--warn-bg); padding: 10px 24px; border-bottom: 1px solid var(--line); }

.main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }

.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-header h1 { margin: 0; font-size: 1.5em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2 { margin-top: 0; font-size: 1.1em; }
.card.narrow { max-width: 460px; margin: 40px auto; }
.card.highlight { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 93, 80, 0.15); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.92em; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 600; padding: 0 4px; }
input, select, textarea {
  font: inherit;
  font-weight: 400;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-block;
  font: inherit;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: var(--bad); border-color: #e3b8b4; }
.btn-link { background: none; border: none; padding: 0; text-decoration: underline; }
.btn-small { padding: 3px 10px; font-size: 0.85em; }
form.inline { display: inline; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 16px; }
.inline-form label { max-width: 260px; }
.filter { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.filter label { max-width: 220px; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card .table { border: none; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 0.85em; color: var(--muted); font-weight: 600; background: #faf9f6; }
.nowrap { white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 0.9em; }
.tile .num { font-size: 1.8em; font-weight: 700; color: var(--ink); }
.tile-bad .num { color: var(--bad); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.82em; background: #ecebe7; color: var(--ink); }
.pill-ok, .pill-sent { background: var(--ok-bg); color: var(--ok); }
.pill-failed { background: var(--bad-bg); color: var(--bad); }
.pill-queued, .pill-sending { background: var(--warn-bg); }
.pill-cancelled { color: var(--muted); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.ok { color: var(--ok); }
.error { color: var(--bad); }
.muted { color: var(--muted); font-size: 0.9em; }
.empty { color: var(--muted); font-style: italic; }
ul.plain { margin: 0; padding-left: 18px; }

pre.token, pre.code { background: #1d2327; color: #e9eef1; padding: 12px 14px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.copy { margin-top: -6px; margin-bottom: 8px; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .main { padding: 16px 12px 48px; }
  .table { display: block; overflow-x: auto; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: 6px; }
}
