/* Admin panel — mobile first.
 *
 * Built narrow and widened with min-width queries, because this is the thing
 * most likely to be opened on a phone: a suspicious sign-in at 11pm gets
 * checked from a pocket, not a desk.
 */

:root {
  --bg: #0b0f16;
  --surface: #121823;
  --surface-2: #17202d;
  --surface-3: #1e2836;
  --line: #27323f;
  --ink: #e9eff7;
  --ink-2: #9fb0c3;
  --ink-3: #66788c;
  --accent: #5b8cff;
  --accent-dim: #1d3050;
  --good: #3fc98d;
  --warn: #e8a84c;
  --bad: #f4697a;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* =============================================================== sign in */

.auth-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 22px 18px calc(22px + var(--safe-b));
}

.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
}

.brandmark {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), #8b5cf6);
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
  margin-bottom: 16px;
}

h1 { font-size: 21px; margin: 0 0 6px; letter-spacing: -.3px; }
.sub { color: var(--ink-3); font-size: 13.5px; margin: 0 0 22px; line-height: 1.55; }

.f { margin-bottom: 15px; }
.f label {
  display: block; font-size: 12px; color: var(--ink-3);
  margin-bottom: 6px; font-weight: 500;
}
.f input {
  width: 100%;
  background: #0d131c;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  font: inherit; font-size: 16px;   /* 16px stops iOS zooming on focus */
  padding: 12px 13px;
  outline: none;
}
.f input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.14); }
.f .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.5; }

.cap-row { display: flex; gap: 12px; align-items: flex-end; }
.cap-row .f { flex: 1; margin-bottom: 0; }
.cap-img {
  height: 48px; width: 140px; border-radius: 8px;
  border: 1px solid var(--line); background: #0d131c; display: block;
}
.cap-new {
  background: none; border: 0; color: var(--ink-3);
  font-size: 11px; padding: 4px 0 0; cursor: pointer; width: 140px;
}

button.go {
  width: 100%; border: 0; border-radius: 10px;
  padding: 14px; margin-top: 20px;
  font: inherit; font-size: 15.5px; font-weight: 600; color: #fff;
  background: linear-gradient(100deg, var(--accent), #7c5cff);
  cursor: pointer;
}
button.go:disabled { opacity: .5; }

.otp { display: flex; gap: 8px; justify-content: space-between; }
.otp input {
  width: 100%; aspect-ratio: 3/4; text-align: center;
  font-family: var(--mono); font-size: 20px; font-weight: 600;
  background: #0d131c; border: 1px solid var(--line);
  border-radius: 9px; color: var(--ink); outline: none; padding: 0;
}
.otp input:focus { border-color: var(--accent); }

.msg {
  border-radius: 9px; padding: 11px 13px; font-size: 13px;
  line-height: 1.55; margin-bottom: 16px; display: none;
}
.msg.show { display: block; }
.msg.err  { background: #2e1219; border: 1px solid #5c2733; color: #ffc3cc; }
.msg.ok   { background: #0f2a1e; border: 1px solid #1f5c41; color: #a6efc9; }
.msg.warn { background: #2b2210; border: 1px solid #5c4820; color: #f8dba2; }
.msg.info { background: #141d2b; border: 1px solid #27364a; color: var(--ink-2); }
.msg code { font-family: var(--mono); background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 4px; }

.step { display: none; }
.step.on { display: block; }

/* ================================================================== app */

.app { display: none; padding-bottom: calc(76px + var(--safe-b)); }
.app.on { display: block; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(11,15,22,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 11px;
}
.topbar .mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(140deg, var(--accent), #8b5cf6);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff;
}
.topbar .t { font-size: 14.5px; font-weight: 600; letter-spacing: -.2px; }
.topbar .who { font-size: 11px; color: var(--ink-3); }
.topbar .right { margin-left: auto; display: flex; gap: 8px; }

.icon-btn {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink-2); padding: 7px 11px;
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.icon-btn:active { background: var(--surface-3); }

main { padding: 16px; }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 14px;
}
.card .k {
  font-size: 10.5px; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600;
}
.card .v { font-family: var(--mono); font-size: 25px; margin-top: 4px; line-height: 1.1; }
.card .n { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.card.warn .v { color: var(--warn); }
.card.bad  .v { color: var(--bad); }
.card.good .v { color: var(--good); }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); margin-top: 14px; overflow: hidden;
}
.panel > h2 {
  margin: 0; padding: 12px 14px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 9px;
}
.panel > h2 .c {
  margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.pad { padding: 14px; }

/* list rows read better than tables on a phone */
.row {
  display: block; width: 100%; text-align: left;
  padding: 12px 14px; border-bottom: 1px solid #1b2431;
  background: none; border-left: 0; border-right: 0; border-top: 0;
  color: inherit; font: inherit; cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--surface-2); }
.row .l1 { display: flex; align-items: center; gap: 8px; }
.row .nm { font-weight: 600; font-size: 14px; }
.row .l2 { font-size: 12px; color: var(--ink-3); margin-top: 3px; word-break: break-all; }
.row .l3 { font-size: 11px; color: var(--ink-3); margin-top: 4px; font-family: var(--mono); }

.pill {
  font-size: 10px; font-family: var(--mono); padding: 2px 6px;
  border-radius: 20px; border: 1px solid; white-space: nowrap;
}
.pill.active    { color: var(--good); border-color: #1f5c41; background: #0f2a1e; }
.pill.pending   { color: var(--warn); border-color: #5c4820; background: #2b2210; }
.pill.suspended { color: var(--bad);  border-color: #5c2733; background: #2e1219; }
.pill.admin     { color: var(--accent); border-color: var(--accent-dim); background: #131d2e; }
.pill.locked    { color: var(--bad);  border-color: #5c2733; background: #2e1219; }

.search {
  width: 100%; background: #0d131c; border: 1px solid var(--line);
  border-radius: 9px; color: var(--ink); font: inherit; font-size: 16px;
  padding: 11px 13px; outline: none; margin-bottom: 12px;
}
.search:focus { border-color: var(--accent); }

.kv { display: grid; grid-template-columns: 128px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-size: 12px; }
.kv dd { margin: 0; word-break: break-word; font-family: var(--mono); font-size: 12.5px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions button {
  flex: 1 1 auto; min-width: 120px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; color: var(--ink); font: inherit; font-size: 13px;
  padding: 11px; cursor: pointer;
}
.actions button.danger { color: #ffb3bd; border-color: #4a222b; background: #23141a; }
.actions button:active { background: var(--surface-3); }

.log {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  padding: 12px 14px; max-height: 420px; overflow: auto;
}
.log div { padding: 5px 0; border-bottom: 1px solid #18212d; word-break: break-word; }
.log .t { color: var(--ink-3); }
.log .ok { color: var(--good); }
.log .no { color: var(--bad); }

/* bottom navigation, thumb-reachable */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(11,15,22,.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs button {
  background: none; border: 0; color: var(--ink-3);
  font: inherit; font-size: 11px; padding: 11px 4px 10px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tabs button svg { width: 20px; height: 20px; }
.tabs button.on { color: var(--accent); }

.view { display: none; }
.view.on { display: block; }

.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.6);
  display: none; align-items: flex-end;
}
.sheet.on { display: flex; }
.sheet-inner {
  width: 100%; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line);
  padding: 8px 16px calc(24px + var(--safe-b));
}
.grab { width: 38px; height: 4px; border-radius: 3px; background: #33404f; margin: 8px auto 14px; }

.empty { padding: 28px 14px; text-align: center; color: var(--ink-3); font-size: 13px; }

.install {
  margin: 14px 16px 0; padding: 12px 14px;
  background: var(--accent-dim); border: 1px solid #2c4a7a;
  border-radius: var(--r); font-size: 13px; display: none;
  align-items: center; gap: 12px;
}
.install.on { display: flex; }
.install button {
  margin-left: auto; background: var(--accent); border: 0; color: #fff;
  border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}

/* ------------------------------------------------------------- widescreen */

@media (min-width: 760px) {
  main { max-width: 1100px; margin: 0 auto; padding: 22px; }
  .cards { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .app { padding-bottom: 24px; }
  .tabs {
    position: sticky; top: 55px; bottom: auto;
    max-width: 1100px; margin: 0 auto; border-top: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: repeat(4, minmax(0, 160px));
    justify-content: start; background: transparent; backdrop-filter: none;
  }
  .tabs button { flex-direction: row; gap: 8px; font-size: 13px; padding: 12px 10px; }
  .sheet { align-items: center; justify-content: center; padding: 24px; }
  .sheet-inner { max-width: 640px; border-radius: 14px; border: 1px solid var(--line); }
  .grab { display: none; }
}
