:root {
  --bg: #0b0e14;
  --bg-2: #0f1320;
  --surface: #151a28;
  --surface-2: #1b2233;
  --border: #262d40;
  --text: #e7ebf3;
  --muted: #8b93a7;
  --accent: #6d5efc;
  --accent-2: #9a6bff;
  --accent-ink: #ffffff;
  --green: #2fbf71;
  --red: #ef4d5a;
  --amber: #f5a524;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --grad: linear-gradient(135deg, #6d5efc 0%, #9a6bff 100%);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 100% -10%, #17203a 0%, transparent 55%), var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 10px; color: var(--text); }

/* ---------- buttons ---------- */
.btn-primary, .btn-ghost, .btn-sm {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid transparent; padding: 11px 18px; transition: .15s; white-space: nowrap;
}
.btn-primary { background: var(--grad); color: var(--accent-ink); box-shadow: 0 6px 18px rgba(109,94,252,.35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn-primary.block { width: 100%; display: block; padding: 13px; font-size: 15px; text-align: center; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-sm { background: var(--surface-2); color: var(--text); border-color: var(--border); padding: 7px 12px; font-size: 13px; }
.btn-sm:hover { border-color: var(--accent); text-decoration: none; }
.btn-sm.danger, .btn-ghost.danger { color: var(--red); border-color: rgba(239,77,90,.4); background: transparent; }
.btn-sm.danger:hover, .btn-ghost.danger:hover { background: rgba(239,77,90,.12); border-color: var(--red); }
.btn-sm.copied { color: var(--green); border-color: var(--green); }
.inline { display: inline; margin: 0; }

/* ---------- auth ---------- */
.authwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.authcard { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 30px 26px; box-shadow: var(--shadow); }
.authcard.center { text-align: center; }
.authlogo { width: 56px; height: 56px; border-radius: 16px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; color: #fff; margin: 0 auto 16px; box-shadow: 0 8px 22px rgba(109,94,252,.4); }
.authcard h1 { text-align: center; font-size: 21px; margin-bottom: 14px; }
.steps { display: flex; align-items: center; justify-content: center; gap: 0; margin: 6px 0 20px; }
.steps span { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.steps span.on { background: var(--grad); color: #fff; border-color: transparent; }
.steps span.done { background: rgba(47,191,113,.15); color: var(--green); border-color: rgba(47,191,113,.4); }
.steps i { width: 26px; height: 2px; background: var(--border); }
.steps i.f { background: var(--green); }
.authnote { text-align: center; color: var(--muted); font-size: 12.5px; margin: 16px 0 0; }
.who-hint { text-align: center; color: var(--muted); font-size: 13px; margin: -4px 0 16px; }
.who-hint b { color: var(--text); }

/* ---------- fields ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
input:not([type=radio]):not([type=checkbox]):not([type=hidden]):not([type=submit]):not([type=button]),
textarea, select {
  width: 100%; font: inherit; font-size: 15px; color: var(--text);
  background: var(--bg-2); -webkit-appearance: none; appearance: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 13px; outline: none; transition: .15s;
}
input:not([type=radio]):not([type=checkbox]):not([type=hidden]):focus,
textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.18); background: var(--bg-2); }
input::placeholder, textarea::placeholder { color: #5b6478; opacity: 1; }
/* убираем светлый автозаполнитель Chrome/Android */
input:-webkit-autofill, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset;
  caret-color: var(--text); border: 1px solid var(--border);
}
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 17px; padding: 6px; opacity: .7; }

/* pin pad */
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 8px 0 22px; min-height: 16px; }
.pin-dots i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border); }
.pin-dots i.f { background: var(--accent); border-color: var(--accent); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pk { font: inherit; font-size: 22px; font-weight: 600; aspect-ratio: 1.6/1; border-radius: 14px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); cursor: pointer; transition: .1s; -webkit-user-select: none; user-select: none; }
.pk:active { transform: scale(.96); background: var(--surface); }
.pk-fn { font-size: 20px; color: var(--muted); }
.pk-ok { background: var(--grad); color: #fff; border-color: transparent; }
.pk-ok:disabled { opacity: .4; }

/* ---------- app shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top)); background: rgba(11,14,20,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
/* icons */
.ic { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.ic-sm { width: 16px; height: 16px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: #fff; }
.brand-name { font-weight: 700; letter-spacing: -.01em; }
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav a { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); padding: 8px 13px; border-radius: 9px; font-weight: 600; font-size: 14px; }
.topnav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.topnav a.on { color: var(--text); background: var(--surface-2); }
.topnav a.on .ic { color: var(--accent-2); }
.topright { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; padding: 6px 10px; border-radius: 9px; }
.who:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.who .ic { color: var(--muted); }
.who:hover .ic { color: var(--accent-2); }
.who-name { font-weight: 600; }
.btn-icon { display: inline-flex; align-items: center; gap: 6px; }

.wrap { max-width: 900px; margin: 0 auto; padding: 22px 16px 96px; }
.wrap.narrow { max-width: 640px; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.sub { color: var(--muted); font-size: 13.5px; margin: 0; }
.sub b { color: var(--text); }
.crumbs { margin: 0 0 12px; font-size: 13.5px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.card.soft { background: var(--surface-2); display: flex; align-items: flex-start; gap: 9px; }
.card.soft .ic { width: 17px; height: 17px; color: var(--muted); margin-top: 1px; }
.createform { border-color: rgba(109,94,252,.4); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.formactions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.hint { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.hint .ic { width: 15px; height: 15px; }

.proto-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.proto { display: block; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--bg-2); transition: .15s; }
.proto input { display: none; }
.proto b { display: block; font-size: 14px; }
.proto small { color: var(--muted); font-size: 12px; }
.proto.on { border-color: var(--accent); background: rgba(109,94,252,.12); box-shadow: 0 0 0 3px rgba(109,94,252,.14); }

/* key cards */
.keylist { display: flex; flex-direction: column; gap: 12px; }
.keycard { display: flex; align-items: center; gap: 14px; justify-content: space-between; margin: 0; }
.keycard.off { opacity: .62; }
.kc-main { min-width: 0; flex: 1; }
.kc-name { font-weight: 700; font-size: 16px; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
a.kc-name:hover { color: var(--accent-2); }
.kc-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.kc-comment { display: flex; align-items: flex-start; gap: 6px; color: var(--text); font-size: 13.5px; margin: 5px 0; }
.kc-comment .ic { width: 15px; height: 15px; color: var(--muted); margin-top: 2px; }
.kc-comment span { min-width: 0; }
.kc-sub { color: var(--muted); font-size: 12.5px; }
.kc-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }

.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip-vmess { background: rgba(80,160,255,.14); color: #6db1ff; border-color: transparent; }
.chip-reality { background: rgba(154,107,255,.16); color: #b79bff; border-color: transparent; }
.chip-dim { background: transparent; }
.chip.bad, .badge.bad { background: rgba(239,77,90,.15); color: var(--red); border-color: transparent; }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 20px; margin-left: 6px; }

/* online highlight */
.keycard.online { border-color: rgba(47,191,113,.45); box-shadow: 0 0 0 1px rgba(47,191,113,.22), 0 6px 22px rgba(47,191,113,.10); }
.chip.online { background: rgba(47,191,113,.16); color: #4fd88f; border-color: transparent; display: inline-flex; align-items: center; gap: 5px; }
.chip.online .dot { width: 7px; height: 7px; border-radius: 50%; background: #2fbf71; animation: pulse 1.9s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,191,113,.5); } 70% { box-shadow: 0 0 0 6px rgba(47,191,113,0); } 100% { box-shadow: 0 0 0 0 rgba(47,191,113,0); } }
.on-now { color: #4fd88f; font-weight: 600; }

/* ---------- stats ---------- */
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.card.metric { padding: 16px 16px 14px; }
.m-lbl { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.m-val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 10px; line-height: 1; }
.m-val small { font-size: 15px; color: var(--muted); font-weight: 600; }
.m-val.net { font-size: 15px; font-weight: 700; }
.m-sub { color: var(--muted); font-size: 12px; margin-top: 8px; }
.bar { height: 7px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--grad); transition: width .4s; }
.bar i.warn { background: var(--amber); }
.bar i.crit { background: var(--red); }
.tablewrap { overflow-x: auto; margin: 6px -6px 0; }
.stattable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.stattable th { cursor: pointer; user-select: none; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.stattable th:hover { color: var(--text); }
.stattable td { padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.stattable th.num, .stattable td.num { text-align: right; }
.stattable tr.ur-on td { background: rgba(47,191,113,.06); }
.stattable tr.ur-off { opacity: .5; }
.stattable .ar { font-size: 9px; opacity: .8; }
.dim { color: var(--muted); }
@media (max-width: 720px) { .statgrid { grid-template-columns: repeat(2, 1fr); } }

/* security section (fail2ban + panel logins) */
.secgrid { align-items: start; }
.secgrid h3 { display: flex; align-items: center; gap: 7px; }
.secbody { margin-top: 4px; }
.stattable.mini { margin-top: 4px; }
.stattable.mini th, .stattable.mini td { padding: 6px 9px; font-size: 12.5px; }
.stattable.mini td.mono { font-size: 12px; }
.ipchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.authnums { display: flex; gap: 20px; margin: 2px 0 10px; }
.authnums span { display: inline-flex; flex-direction: column; color: var(--muted); font-size: 11.5px; }
.authnums b { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.02em; line-height: 1.1; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-ico { margin-bottom: 12px; color: var(--muted); opacity: .75; }
.empty-ico .ic { width: 46px; height: 46px; }

/* qr + link */
.qrcard { text-align: center; }
.qr { width: 280px; max-width: 78vw; height: auto; border-radius: 14px; background: #fff; padding: 10px; }
.qrhint { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }
.linkbox textarea { resize: none; }
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.params { width: 100%; border-collapse: collapse; }
.params td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.params td:first-child { color: var(--muted); width: 42%; font-size: 13px; }
.params td.mono { font-size: 12px; }

/* alerts */
.alert { border-radius: 12px; padding: 12px 15px; margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert.err { background: rgba(239,77,90,.12); color: #ff8b95; border-color: rgba(239,77,90,.35); }
.alert.ok { background: rgba(47,191,113,.12); color: #62d99a; border-color: rgba(47,191,113,.35); }

/* ---------- bottom nav (mobile) ---------- */
.bottomnav { display: none; }
@media (max-width: 720px) {
  .topnav { display: none; }
  .brand-name { display: none; }
  .keycard { flex-direction: column; align-items: stretch; }
  .kc-actions { justify-content: flex-start; }
  .grid2, .proto-pick { grid-template-columns: 1fr; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(11,14,20,.92); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a, .bottomnav button { flex: 1; background: none; border: none; color: var(--muted); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; text-decoration: none; }
  .bottomnav a.on { color: var(--accent-2); }
  .bn-ico { line-height: 0; }
  .bn-ico .ic { width: 23px; height: 23px; }
  .bn-lbl { font-size: 11px; font-weight: 600; }
  .lo-lbl { display: none; }
  .pagehead { flex-direction: column; }
  .pagehead .btn-primary { width: 100%; }
}
@media (min-width: 721px) { .bottomnav { display: none !important; } }
