:root {
  --bg: #f3f5fa; --panel: #ffffff; --panel2: #eef1f7; --line: #d9dfeb;
  --text: #1a2233; --muted: #5f6b82; --accent: #6747f0; --accent2: #0e8aa6;
  --ok: #0f8a5f; --bad: #c93c3c; --warn: #a66b00;
  --ok-bg: #e3f6ee; --ok-line: #9fd8c0; --bad-bg: #fcebeb; --bad-line: #f0b3b3; --warn-bg: #fff4d9; --warn-line: #ecd08a;
  --secret-bg: #ece8ff; --glow1: #d9d1ff; --glow2: #c8ecf5;
  color-scheme: light;

  --qr-bg: #fff;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; min-height: 100vh; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
h2 { margin: .6rem 0 1rem; }
h3 { margin: 0 0 .8rem; font-size: 1.05rem; }
code { background: var(--panel2); padding: .1em .4em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); } .sm { font-size: .85rem; } .tc { text-align: center; } .right { float: right; } .nw { white-space: nowrap; }

/* brand */
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand.big { justify-content: center; font-size: 1.4rem; margin-bottom: .5rem; }
.logo { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }

/* buttons + forms */
.btn { display: inline-block; background: var(--accent); color: #fff; border: 1px solid transparent; padding: .55rem 1.1rem;
  border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--panel2); }
.btn.sm { padding: .3rem .7rem; font-size: .85rem; } .btn.xs { padding: .2rem .5rem; font-size: .78rem; font-weight: 500; }
.btn.lg { padding: .8rem 2rem; font-size: 1.05rem; } .btn.block { display: block; width: 100%; margin-top: 1rem; }
label { display: block; margin: .8rem 0 0; color: var(--muted); font-size: .85rem; }
input, select, textarea { width: 100%; margin-top: .3rem; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .6rem .75rem; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
input:disabled { opacity: .6; }
input.code { text-align: center; font-size: 1.6rem; letter-spacing: .4em; font-family: ui-monospace, Consolas, monospace; }
label.check { display: flex; align-items: center; gap: .6rem; color: var(--text); font-size: .95rem; }
label.check input { width: auto; margin: 0; }
.form { max-width: 520px; } .form .btn { margin-top: 1rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 160px; margin: 0; }
.inline-form .btn { flex: 0 0 auto; }
.form .inline-form { max-width: none; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side { width: 240px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 1.2rem 1rem;
  display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; }
.side nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; overflow: auto; }
.side nav a { color: var(--muted); padding: .5rem .75rem; border-radius: 8px; }
.side nav a:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.side nav a.on { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 var(--accent); }
.nav-h { margin: 1rem .75rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.me { display: flex; justify-content: space-between; align-items: center; gap: .5rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.me small { display: block; color: var(--muted); font-size: .75rem; }
.main { flex: 1; min-width: 0; padding: 1.6rem clamp(1rem, 3vw, 2.4rem); max-width: 1200px; }
body.center { display: grid; place-items: center; padding: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem 1.4rem; margin: 1rem 0; }
.card.narrow { width: min(100%, 420px); margin: 0; }
.scroll { overflow-x: auto; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin: 1rem 0; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.two .card { margin: 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.2rem; }
.stat span { color: var(--muted); font-size: .85rem; } .stat b { display: block; font-size: 2rem; line-height: 1.2; }
.stat small { color: var(--muted); } .stat.warn b { color: var(--warn); }

/* tables */
.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
.t th { text-align: left; color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.t th, .t td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .8rem; }
.acts { display: flex; flex-wrap: wrap; gap: .3rem; min-width: 260px; } .acts form { margin: 0; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .76rem; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: var(--ok-line); background: var(--ok-bg); }
.pill.fail { color: var(--bad); border-color: var(--bad-line); background: var(--bad-bg); }
.pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; overflow-x: auto; font-size: .82rem; margin: 0; }

/* flash, tabs, misc */
.flash { padding: .7rem 1rem; border-radius: 8px; margin: .6rem 0; border: 1px solid var(--line); background: var(--panel2); word-break: break-word; }
.flash.ok { border-color: var(--ok-line); background: var(--ok-bg); } .flash.error { border-color: var(--bad-line); background: var(--bad-bg); }
.flash.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.flash.secret { border-color: var(--accent); background: var(--secret-bg); font-family: ui-monospace, Consolas, monospace; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-top: 1rem; flex-wrap: wrap; }
.tabs a { padding: .55rem 1rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.qr { display: grid; place-items: center; margin: 1rem 0; } .qr img { background: var(--qr-bg); padding: 8px; border-radius: 10px; }
.secret { word-break: break-all; letter-spacing: .1em; }
.pager { display: flex; gap: .5rem; margin-top: 1rem; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: .6rem; height: 160px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: .3rem; font-size: .75rem; color: var(--muted); }
.stack { flex: 1; width: 100%; max-width: 38px; display: flex; flex-direction: column; justify-content: flex-end; }
.stack i { display: block; width: 100%; }
.stack .ok { background: var(--accent2); } .stack .bad { background: var(--bad); }
.legend { font-size: .8rem; color: var(--muted); margin: .8rem 0 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 .3rem 0 .6rem; }
.okc { background: var(--accent2); } .badc { background: var(--bad); }

/* public page */
body.public { background: radial-gradient(900px 500px at 70% -10%, var(--glow1) 0%, transparent 60%), radial-gradient(700px 400px at 0% 10%, var(--glow2) 0%, transparent 60%), var(--bg); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem clamp(1rem, 5vw, 3rem); }
.hero { text-align: center; padding: clamp(3rem, 12vh, 7rem) 1.2rem 3rem; max-width: 760px; margin: 0 auto; }
.hero h1 { font-size: clamp(2.2rem, 7vw, 3.8rem); line-height: 1.1; margin-bottom: 1rem; }
.hero p { color: var(--muted); font-size: 1.1rem; }
.grad { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.center-row { display: flex; justify-content: center; margin: 2rem 0; }
.pub-stats { display: flex; justify-content: center; gap: clamp(1rem, 5vw, 3rem); flex-wrap: wrap; margin-top: 2rem; }
.pub-stats b { display: block; font-size: 1.8rem; } .pub-stats span { color: var(--muted); font-size: .85rem; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .side nav { flex-direction: row; flex-wrap: wrap; } .nav-h { display: none; }
}

.sep { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* one-time code entry */
.otp { position: relative; margin-top: .6rem; }
.otp .otp-real { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0;
  border: 0; font-size: 16px; cursor: text; z-index: 2; }
.otp-boxes { display: flex; gap: clamp(.3rem, 1.6vw, .55rem); justify-content: center; }
.otp-box { position: relative; width: clamp(38px, 12vw, 50px); height: clamp(48px, 14vw, 60px); display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  font: 700 1.6rem ui-monospace, Consolas, monospace; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s; }
.otp-ch { opacity: .28; color: var(--muted); animation: otpRun .26s linear infinite; }
.otp-box.filled .otp-ch { opacity: 1; color: var(--text); animation: otpPop .24s cubic-bezier(.2, 1.7, .4, 1); }
.otp-box.filled { background: var(--panel2); }
.otp-box.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(103, 71, 240, .2); }
.otp-box.active .otp-ch { opacity: 0; }
.otp-box.active::after { content: ""; position: absolute; width: 2px; height: 1.6rem; background: var(--accent);
  animation: otpBlink 1s steps(2, start) infinite; }
.otp.complete .otp-box { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(15, 138, 95, .15);
  animation: otpWave .55s ease both; animation-delay: calc(var(--i) * 70ms); }
.otp-status { min-height: 1.5rem; margin-top: .7rem; text-align: center; color: var(--muted); font-size: .9rem; }
.otp-status .dots { display: inline-flex; gap: 4px; margin-left: .35rem; vertical-align: middle; }
.otp-status .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: otpDot 1s infinite ease-in-out both; }
.otp-status .dots i:nth-child(2) { animation-delay: .15s; } .otp-status .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes otpRun { 0% { transform: translateY(-5px); } 100% { transform: translateY(5px); } }
@keyframes otpPop { 0% { transform: scale(.2); } 100% { transform: scale(1); } }
@keyframes otpBlink { to { visibility: hidden; } }
@keyframes otpWave { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-9px); } }
@keyframes otpDot { 0%, 80%, 100% { transform: scale(.4); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .otp-ch, .otp-box, .otp-status .dots i { animation: none !important; } }
