:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2430;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --safe: #2ea043;
  --safe-dim: #1a5c2a;
  --warn: #d29922;
  --danger: #da3633;
  --accent: #1f6feb;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.wrap.wide { max-width: 1100px; }

/* --- Header --------------------------------------------------------------- */

header.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.bar .brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bar .who {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  line-height: 1.35;
}

.bar .who strong { color: var(--text); display: block; font-weight: 600; }

/* --- Panels --------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.panel.alert { border-color: var(--danger); }
.panel.exercise { border-color: var(--warn); }

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.recall-title { font-size: 22px; font-weight: 700; margin: 6px 0 2px; }
.recall-meta { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.recall-message { margin: 12px 0 0; line-height: 1.5; }

/* --- Buttons -------------------------------------------------------------- */

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 16px;
  transition: filter 0.12s ease;
}

button:hover:not(:disabled) { filter: brightness(1.15); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-huge {
  display: block;
  width: 100%;
  min-height: 96px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  border: none;
}

.btn-safe { background: var(--safe); color: #fff; }
.btn-assist { background: var(--danger); color: #fff; }
.btn-launch { background: var(--danger); color: #fff; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > button { flex: 1 1 140px; }

.btn-primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.btn-confirm { background: var(--safe); color: #fff; border-color: transparent; font-weight: 700; min-height: 60px; font-size: 18px; }
.btn-ghost { background: transparent; }
.btn-small { padding: 7px 12px; font-size: 13px; }

/* --- Forms ---------------------------------------------------------------- */

label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 13px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle button {
  flex: 1;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 11px 8px;
}

.toggle button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.toggle button[aria-pressed="true"].danger { background: var(--danger); }

/* --- Status / receipts ---------------------------------------------------- */

.receipt { text-align: center; padding: 8px 0 4px; }
.receipt .check { font-size: 44px; line-height: 1; color: var(--safe); }
.receipt .check.warn { color: var(--danger); }
.receipt .headline { font-size: 20px; font-weight: 700; margin: 10px 0 4px; }
.receipt .detail { color: var(--muted); font-family: var(--mono); font-size: 13px; }

.notice {
  padding: 11px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.notice.err { border-color: var(--danger); color: #ffb3b0; }
.notice.ok { border-color: var(--safe); color: #7ee2a0; }
.notice.warn { border-color: var(--warn); color: #e9c46a; }
.notice.hidden { display: none; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.center { text-align: center; }

/* --- Dashboard ------------------------------------------------------------ */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }

.stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.stat .n { font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 4px; font-weight: 600; }
.stat.safe .n { color: var(--safe); }
.stat.assist .n { color: var(--danger); }
.stat.none .n { color: var(--warn); }

.headline-count { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.headline-count .big { font-size: 30px; font-variant-numeric: tabular-nums; }

.progress { height: 12px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 14px; }
.progress > div { height: 100%; background: var(--safe); width: 0; transition: width 0.4s ease; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
td.time { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
tr.pending td { color: var(--muted); }

.pill { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; white-space: nowrap; }
.pill.safe { background: var(--safe-dim); color: #7ee2a0; }
.pill.assist { background: #5c1a18; color: #ff938f; }
.pill.unable { background: #4a3a12; color: #e9c46a; }
.pill.none { background: var(--panel-2); color: var(--muted); }

.table-scroll { overflow-x: auto; }

.log { font-family: var(--mono); font-size: 12px; line-height: 1.6; max-height: 340px; overflow-y: auto; }
.log div { padding: 3px 0; border-bottom: 1px solid rgba(48, 54, 61, 0.5); }
.log .t { color: var(--muted); }
.log .a { color: var(--accent); }

/* --- Outgoing messages ---------------------------------------------------- */

.messages { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }

.msg {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px 12px;
}

.msg.sms { border-left-color: var(--safe); }
.msg.push { border-left-color: var(--accent); }
.msg.failed { border-left-color: var(--danger); }

.msg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.msg-to { font-size: 13px; font-weight: 600; }
.msg-to .num { color: var(--muted); font-weight: 400; font-family: var(--mono); font-size: 11px; margin-left: 6px; }
.msg-when { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }

/* The message exactly as it lands on the phone, newlines preserved. */
.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
}

.msg-body .empty { color: var(--muted); font-style: italic; }

.msg-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 7px; }

.tag {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
}

.tag.ch-sms { color: #7ee2a0; border-color: var(--safe-dim); }
.tag.ch-push { color: #86b7ff; border-color: #1c3a63; }
.tag.st-sent { color: #7ee2a0; }
.tag.st-failed { color: #ff938f; border-color: #5c1a18; }
.tag.st-expired { color: #e9c46a; border-color: #4a3a12; }

.msg-error { font-size: 11px; color: #ff938f; margin-top: 6px; font-family: var(--mono); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { padding: 8px 14px; font-size: 13px; }
.tabs button[aria-selected="true"] { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }

@media (min-width: 860px) {
  .grid-2 { grid-template-columns: 3fr 2fr; align-items: start; }
}

.footnote { font-size: 11px; color: var(--muted); text-align: center; margin-top: 24px; line-height: 1.6; }

.hidden { display: none !important; }
