/* One screen John can read from across the room: the only colour that means
   anything is red, and it only ever means "a lead is waiting". */
:root {
  --bg: #0d1117; --card: #161b22; --elev: #1c2230; --line: #262d3a;
  --txt: #e6edf3; --dim: #8b949e; --faint: #6a737d;
  --ok: #2ea043; --warn: #d29922; --bad: #f85149; --acc: #388bfd;
}
* { box-sizing: border-box; }

/* 🔴 `hidden` must actually hide. The HTML attribute works through the UA
   stylesheet's `display: none`, so ANY author rule that sets `display` beats it
   — and .login/.modal below both set `display: grid`. The result shipped as an
   invisible full-screen modal sitting on top of the login form: the page looked
   right in the DOM and was unusable on screen. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; cursor: pointer; }

/* login */
.login { display: grid; place-items: center; min-height: 100vh; }
.login form {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px; width: 320px; display: grid; gap: 12px;
}
.login h1 { margin: 0; font-size: 20px; }
.login p { margin: 0 0 8px; color: var(--dim); font-size: 13px; }
.login input, .addbar input {
  background: var(--elev); border: 1px solid var(--line); color: var(--txt);
  padding: 10px 12px; border-radius: 8px; font: inherit;
}
.login button, .addbar button {
  background: var(--acc); border: 0; color: #fff; padding: 10px; border-radius: 8px; font-weight: 600;
}
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* chrome */
header {
  display: flex; align-items: center; gap: 20px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: .3px; }
nav { display: flex; gap: 4px; }
.tab {
  background: transparent; border: 0; color: var(--dim); padding: 7px 12px;
  border-radius: 7px; display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--txt); background: var(--elev); }
.tab.active { color: var(--txt); background: var(--elev); }
.pill {
  background: var(--bad); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.pill.zero { background: var(--line); color: var(--faint); }
.clock { margin-left: auto; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.totals { display: flex; gap: 10px; padding: 14px 20px 0; flex-wrap: wrap; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; min-width: 118px;
}
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.stat.bad b { color: var(--bad); }
.stat.ok b { color: var(--ok); }

main { padding: 16px 20px 60px; }
.hint { color: var(--dim); font-size: 13px; margin: 0 0 14px; max-width: 760px; }

/* agent cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
}
.card.alarm { border-color: var(--bad); box-shadow: 0 0 0 1px rgba(248,81,73,.25); }
.card.offline { opacity: .62; }
.card h3 { margin: 0 0 2px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(46,160,67,.18); }
.dot.off { background: var(--faint); }
.dot.err { background: var(--bad); box-shadow: 0 0 0 3px rgba(248,81,73,.18); }
.card .num { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin-top: 12px; font-size: 13px; }
.kv span { color: var(--dim); }
.kv b { font-variant-numeric: tabular-nums; font-weight: 600; }
.kv b.bad { color: var(--bad); }
.kv b.ok { color: var(--ok); }
.state {
  margin-top: 11px; font-size: 12px; padding: 6px 9px; border-radius: 7px;
  background: var(--elev); color: var(--dim);
}
.state.bad { background: rgba(248,81,73,.13); color: #ffa198; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:hover td { background: var(--card); }
.wait { font-variant-numeric: tabular-nums; font-weight: 700; }
.wait.bad { color: var(--bad); }
.wait.warn { color: var(--warn); }
.msg { color: var(--dim); max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: var(--acc); padding: 0; }
.empty { color: var(--faint); padding: 34px 10px; text-align: center; }

/* accounts / QR */
.addbar { display: flex; gap: 8px; margin-bottom: 4px; }
.addbar input { flex: 1; max-width: 380px; }
.acct {
  display: flex; align-items: center; gap: 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px;
}
.acct .who { flex: 1; }
.acct .who b { display: block; }
.acct .who span { color: var(--faint); font-size: 12px; }
.acct button {
  background: var(--elev); border: 1px solid var(--line); color: var(--txt);
  padding: 7px 11px; border-radius: 7px;
}
.acct button.danger { color: #ffa198; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--elev); color: var(--dim); }
.badge.connected { background: rgba(46,160,67,.16); color: #7ee787; }
.badge.logged_out, .badge.disconnected { background: rgba(248,81,73,.16); color: #ffa198; }
.badge.qr { background: rgba(56,139,253,.16); color: #79c0ff; }
.qrbox { background: #fff; padding: 10px; border-radius: 10px; display: inline-block; }
.qrwrap { display: flex; gap: 16px; align-items: center; padding: 12px 14px; }
.qrwrap p { margin: 0; color: var(--dim); font-size: 13px; max-width: 320px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(1,4,9,.72); display: grid; place-items: center; z-index: 20; }
.modal-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  width: min(680px, 92vw); max-height: 82vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.modal-head button { background: none; border: 0; color: var(--dim); font-size: 16px; }
.modal-body { overflow: auto; padding: 14px 16px; display: grid; gap: 8px; }
.bub { padding: 8px 11px; border-radius: 10px; max-width: 78%; font-size: 13px; }
.bub.in { background: var(--elev); justify-self: start; }
.bub.out { background: #123d21; justify-self: end; }
.bub time { display: block; color: var(--faint); font-size: 10px; margin-top: 4px; }

/* daily report — deliberately monospace: it is the same text that goes out to
   the alert channel, so what you read here is exactly what gets sent. */
.report {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--txt); white-space: pre-wrap; overflow-x: auto; margin: 0;
}
.rank { color: var(--faint); font-variant-numeric: tabular-nums; }
.flag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(248,81,73,.16); color: #ffa198; }
.flag.quiet { background: var(--elev); color: var(--faint); }
