:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --ink: #15233b;
  --muted: #6b7891;
  --line: #e1e7f0;
  --brand: #1c5fa8;      /* RealFast blue */
  --brand-dark: #16335c; /* navy */
  --accent: #3a9d3a;     /* green */
  --ok: #2e8b57;
  --err: #d23b2b;        /* maple red */
}

* { box-sizing: border-box; }

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

a { color: var(--brand); text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(21, 35, 59, .05);
}
.topbar .brand img { display: block; height: 34px; width: auto; }

.topbar nav { display: flex; align-items: center; gap: 16px; }
.who { color: var(--muted); font-size: 13px; }
.inline { display: inline; margin: 0; }
.linkbtn {
  background: none; border: 0; color: var(--brand);
  cursor: pointer; font: inherit; padding: 0; font-weight: 600;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 28px 22px; }
h1 { margin: 0 0 18px; font-size: 22px; color: var(--brand-dark); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat .num { font-size: 30px; font-weight: 700; color: var(--brand-dark); }
.stat .lbl { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }

/* Auth */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(28,95,168,.06), rgba(58,157,58,.06));
}
.card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 10px 30px rgba(21, 35, 59, .08);
}
.card .brandmark { display: block; width: 210px; max-width: 100%; margin: 4px auto 20px; }
.card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}
.card input:focus { outline: 2px solid rgba(28,95,168,.35); border-color: var(--brand); }
.card button, .wrap button[type="submit"] {
  width: 100%;
  padding: 11px;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.card button:hover, .wrap button[type="submit"]:hover { background: #17508d; }

/* Account / panels */
.wrap.narrow { max-width: 560px; }
.navlink { font-weight: 600; font-size: 14px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 17px; color: var(--brand-dark); }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.stack label { width: 100%; display: block; font-size: 13px; color: var(--muted); }
.stack input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); font: inherit;
}
.stack input:focus { outline: 2px solid rgba(28,95,168,.35); border-color: var(--brand); }
.stack button, .btn {
  padding: 10px 18px; background: var(--brand); color: #fff; border: 0;
  border-radius: 8px; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-block; width: auto;
}
.stack button:hover, .btn:hover { background: #17508d; }
.stack button.danger { background: var(--err); }
.stack button.danger:hover { background: #b5271a; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.on { background: #e9f6ee; color: #1d6b41; border: 1px solid var(--ok); }
.badge.off { background: #f1f4f9; color: var(--muted); border: 1px solid var(--line); }
.qr { display: block; margin: 6px 0 4px; border: 1px solid var(--line); border-radius: 8px; }
.center { text-align: center; }

/* Lists / tables */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagehead h1 { margin: 0; }
.pagehead .actions { display: flex; gap: 8px; align-items: center; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.ghost:hover { background: #f0f5fb; }
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.tbl th { background: #f6f8fb; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; }
.rowactions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.stack select {
  width: 100%; margin-top: 6px; padding: 10px 12px; background: #fbfcfe;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font: inherit;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.stack textarea {
  width: 100%; margin-top: 6px; padding: 10px 12px; background: #fbfcfe;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  font: inherit; resize: vertical;
}
.stack textarea:focus { outline: 2px solid rgba(28,95,168,.35); border-color: var(--brand); }
.checkrow { flex-direction: row; align-items: center; gap: 8px; width: auto; }
.checkrow input { width: auto; margin: 0; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.danger-zone { border-color: #f0c6c1; }
.danger-zone h2 { color: var(--err); }

/* SSO */
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn-google {
  display: block; text-align: center; text-decoration: none;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font-weight: 600;
}
.btn-google:hover { background: #f6f8fb; }

/* Flash */
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash-error { background: #fdecea; border: 1px solid var(--err); color: #8a201a; }
.flash-ok { background: #e9f6ee; border: 1px solid var(--ok); color: #1d6b41; }

/* Message logs (Phase E) */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.filters label { display: block; font-size: 13px; color: var(--muted); }
.filters select, .filters input {
  display: block; margin-top: 4px; padding: 8px 10px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: inherit;
}
.filters button[type="submit"] { padding: 9px 18px; width: auto; display: inline-block; }
.badge.in { background: #e8f0fb; color: #1c5fa8; border: 1px solid #b9d2ef; }
.badge.out { background: #f1f4f9; color: var(--muted); border: 1px solid var(--line); }
.tbl td.clip { max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl .nowrap { white-space: nowrap; }
.tbl td.num-col, .tbl th.num-col { text-align: right; width: 1%; }
.pager { display: flex; align-items: center; gap: 14px; margin-top: 16px; justify-content: center; }
