:root {
  --navy: #083B5C; --navy-2: #0B4A72; --blue: #047FB9; --blue-d: #036796;
  --ink: #0F2233; --mut: #5B6B7A; --line: #DCE3EA; --bg: #F3F6F9; --card: #FFFFFF;
  --ok: #1F8A4C; --warn: #B7791F; --bad: #C0392B;
  --r: 12px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
.noscript { padding: 24px; text-align: center; }

/* Splash + auth screens on navy */
.splash, .auth { min-height: 100vh; min-height: 100dvh; background: var(--navy); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.splash img { width: min(240px, 60vw); opacity: .9; }
.auth-box { width: 100%; max-width: 380px; }
.auth-logo { width: min(220px, 60vw); display: block; margin: 0 auto 28px; }
.auth-card { background: var(--card); border-radius: var(--r); padding: 24px 20px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.auth-card h1 { font-size: 20px; font-weight: 650; margin-bottom: 4px; }
.auth-card .sub { color: var(--mut); font-size: 14px; margin-bottom: 18px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--mut); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=search], select {
  width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(4,127,185,.15); }
input.code { font-size: 24px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  background: var(--blue); color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--blue-d); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; margin-top: 20px; }
.btn.ghost { background: transparent; color: var(--blue); border-color: var(--line); }
.btn.ghost:hover { background: #EEF5FA; }
.btn.danger { background: transparent; color: var(--bad); border-color: #F0C9C4; }
.btn.danger:hover { background: #FDF1EF; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 14px; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font-size: 14px; text-decoration: underline; }
.err { color: var(--bad); font-size: 14px; margin-top: 12px; min-height: 1em; }
.msg { color: var(--ok); font-size: 14px; margin-top: 12px; }
.hint { color: var(--mut); font-size: 13px; margin-top: 8px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.center { text-align: center; margin-top: 16px; }

/* QR + codes */
.qr { display: block; width: 200px; height: 200px; margin: 8px auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; background: var(--bg); padding: 8px 10px; border-radius: 8px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.codes span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); padding: 8px; border-radius: 8px; text-align: center; font-size: 15px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink); font-weight: 500; margin-top: 12px; }
.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; }

/* App shell */
.top { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 5; padding-top: env(safe-area-inset-top); }
.top-in { max-width: 1100px; margin: 0 auto; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.top img { height: 30px; width: auto; }
.top .sp { flex: 1; }
.top .who { font-size: 14px; color: rgba(255,255,255,.8); }
.top .btn { height: 36px; font-size: 14px; background: rgba(255,255,255,.12); }
.top .btn:hover { background: rgba(255,255,255,.2); }
.nav { background: var(--navy-2); }
.nav-in { max-width: 1100px; margin: 0 auto; display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; }
.nav a { color: rgba(255,255,255,.75); text-decoration: none; padding: 10px 12px; font-size: 14px; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a.on { color: #fff; border-color: #fff; }
main.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }
.page h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page .lead { color: var(--mut); margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 16px; margin-bottom: 16px; }
.card h3 { font-size: 16px; font-weight: 650; margin-bottom: 10px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.tile b { display: block; font-weight: 650; }
.tile small { color: var(--mut); }

.badge { display: inline-block; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--mut); }
.badge.admin { background: #E6F2FA; color: var(--blue-d); }
.badge.ok { background: #E7F5EC; color: var(--ok); }
.badge.warn { background: #FCF3E3; color: var(--warn); }
.badge.bad { background: #FBEAE8; color: var(--bad); }

/* Users list */
.ulist { display: grid; gap: 10px; }
.urow { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; cursor: pointer; text-align: left; width: 100%; }
.urow:hover { border-color: var(--blue); }
.urow .nm { flex: 1; min-width: 0; }
.urow .nm b { display: block; }
.urow .nm small { color: var(--mut); }
.urow .bs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Access grid */
.grid { width: 100%; border-collapse: collapse; }
.grid td { padding: 10px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.grid tr:first-child td { border-top: 0; }
.grid td:last-child { text-align: right; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--mut); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--blue); color: #fff; }
.seg button.on.h { background: #8A99A8; }
.seg.dis { opacity: .5; pointer-events: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.switch:first-of-type { border-top: 0; }
.switch small { display: block; color: var(--mut); font-size: 13px; }
.switch input { width: 22px; height: 22px; flex: none; }

.dev { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.dev:first-child { border-top: 0; }
.dev div { flex: 1; min-width: 0; font-size: 14px; }
.dev small { color: var(--mut); display: block; }

.log { width: 100%; border-collapse: collapse; font-size: 14px; }
.log th { text-align: left; color: var(--mut); font-weight: 600; font-size: 12px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.log td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.scroll { overflow-x: auto; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); }

@media (max-width: 560px) {
  .top .who { display: none; }
  .grid td { display: block; padding: 4px 0; border-top: 0; }
  .grid tr { display: block; padding: 8px 0; border-top: 1px solid var(--line); }
  .grid tr:first-child { border-top: 0; }
  .grid td:last-child { text-align: left; }
}
