/* Sign-in gate, account menu and role pills (shared by index.html and users.html). */
:root {
  --ink: #111827;
  --muted: #4b5563;
  --line: #e5e7eb;
  --edge: rgba(17, 24, 39, 0.12);
  --card: rgba(255, 255, 255, 0.94);
  --accent: #ff6a1a;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --idle: #4b5563;
  --idle-bg: #f3f4f6;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- gate ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
  background:
    linear-gradient(rgba(17, 24, 39, 0.045) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(17, 24, 39, 0.045) 1px, transparent 1px) 0 0 / 32px 32px,
    #eef0f3;
  -webkit-user-select: text;
  user-select: text;
}
.gate-card {
  width: min(380px, 100%);
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 16px;
  padding: 24px 24px 20px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.14);
}
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.gate-logo { width: 40px; height: 40px; color: var(--ink); flex: none; }
.gate-brand strong { display: block; font-size: 16px; }
.gate-brand span { font-size: 12px; color: var(--muted); }
.gate h1 { font-size: 19px; margin: 0 0 6px; }
.gate-text { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.gate-text code { font-size: 12.5px; background: var(--idle-bg); padding: 1px 5px; border-radius: 4px; color: var(--ink); }

.gate-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--idle-bg);
  border-radius: 10px;
}
.gate-tabs button {
  border: 0;
  background: none;
  border-radius: 7px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.gate-tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12); }

.gate-form { display: grid; gap: 14px; }
.gate-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.gate-form small { font-weight: 400; color: var(--muted); font-size: 12px; }
.gate-form input {
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.gate-form input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.12); }

.gate-primary {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
}
.gate-primary:hover { background: #1f2937; }
.gate-primary:disabled { opacity: 0.6; cursor: progress; }
.gate-primary:focus-visible, .gate-link:focus-visible, .gate-tabs button:focus-visible {
  outline: 3px solid rgba(255, 106, 26, 0.5);
  outline-offset: 2px;
}
.gate-link {
  justify-self: center;
  border: 0;
  background: none;
  padding: 4px 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.gate-link:hover { color: var(--ink); }
.gate-fine { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); text-align: center; }

.gate-msg { margin: 0; padding: 9px 11px; border-radius: 9px; font-size: 13px; line-height: 1.4; }
.gate-msg.error { background: var(--bad-bg); color: var(--bad); }
.gate-msg.info { background: var(--info-bg); color: var(--info); }

.gate-state { display: grid; gap: 4px; text-align: center; }
.gate-state .gate-text { margin-bottom: 10px; }
.gate-state .gate-link { margin-top: 6px; }
.gate-state .gate-msg { margin-bottom: 10px; }
.gate-icon {
  width: 52px; height: 52px;
  margin: 4px auto 10px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 22px;
}
.gate-icon.wait { background: var(--warn-bg); color: var(--warn); }
.gate-icon.stop { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.gate-icon.info { background: var(--info-bg); color: var(--info); }
.gate-who { margin: 0 0 14px; font-size: 13px; color: var(--muted); word-break: break-word; }

.gate-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 26px 0; color: var(--muted); font-size: 14px; }
.gate-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: gate-spin 0.8s linear infinite;
}
@keyframes gate-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .gate-spinner { animation-duration: 2.4s; } }

/* ---------- role pills ---------- */
.role-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--idle-bg);
  color: var(--idle);
}
.role-pill.role-owner { background: #ffedd5; color: #c2410c; }
.role-pill.role-admin { background: #ede9fe; color: #6d28d9; }

/* ---------- account button + menu (simulator top bar) ---------- */
.acct { position: relative; }
.acct-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--edge);
  background: var(--card);
  border-radius: 10px;
  padding: 5px 10px 5px 5px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  max-width: 220px;
}
.acct-btn:hover { background: #fff; }
.acct-avatar {
  width: 26px; height: 26px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
}
.acct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-warn { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); white-space: nowrap; }
.acct-badge, .acct-count {
  min-width: 18px; height: 18px;
  padding: 0 5px;
  display: inline-grid; place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
}
.acct-badge[hidden], .acct-count[hidden] { display: none; }
.acct-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 250px;
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(17, 24, 39, 0.18);
  padding: 6px;
  z-index: 20;
  -webkit-user-select: text;
  user-select: text;
}
.acct-menu[hidden] { display: none; }
.acct-head { display: grid; gap: 3px; justify-items: start; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); }
.acct-head strong { font-size: 14px; }
.acct-head span:not(.role-pill) { font-size: 12px; color: var(--muted); word-break: break-all; }
.acct-head .role-pill { margin-top: 4px; }
.acct-access { padding: 10px; font-size: 12.5px; line-height: 1.5; border-bottom: 1px solid var(--line); }
.acct-access span { color: var(--muted); }
.acct-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 10px;
  margin-top: 4px;
  border-radius: 8px;
}
.acct-item:hover, .acct-item:focus-visible { background: var(--idle-bg); outline: none; }

@media (max-width: 760px) {
  .acct-name, .acct-warn { display: none; }
  .acct-btn { padding: 4px; }
}
