:root {
  --bg: #0b0f1a;
  --bg2: #111729;
  --card: #151c31;
  --card2: #1a2340;
  --line: #243055;
  --text: #e8ecf8;
  --muted: #8f9bbd;
  --accent: #6d6afe;
  --accent2: #22d3ee;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(109, 106, 254, .18), transparent 60%),
    radial-gradient(700px 400px at -10% 10%, rgba(34, 211, 238, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 5vw, 44px); }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mt2 { margin-top: 28px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 440px; margin: 0 auto; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(12px);
  background: rgba(11, 15, 26, .72);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; color: #fff; font-size: 16px;
}
.nav { display: flex; gap: 6px; align-items: center; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 10px; }
.nav a:hover, .nav a.on { color: var(--text); background: var(--card); text-decoration: none; }

main { padding: 28px 0 60px; }

/* Cards & grid */
.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--card2); }
.btn.danger { background: transparent; border-color: rgba(239, 68, 68, .5); color: #fca5a5; }
.btn.danger:hover { background: rgba(239, 68, 68, .12); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 200px; }
.inline { display: inline; }

.code-input { text-align: center; font-size: 28px !important; letter-spacing: 10px; font-weight: 700; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .35); color: #bbf7d0; }
.flash.err { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .35); color: #fecaca; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: #86efac; border-color: rgba(34, 197, 94, .4); background: rgba(34, 197, 94, .08); }
.badge.warn { color: #fcd34d; border-color: rgba(245, 158, 11, .4); background: rgba(245, 158, 11, .08); }
.badge.err { color: #fca5a5; border-color: rgba(239, 68, 68, .4); background: rgba(239, 68, 68, .08); }

/* Hero */
.hero { padding: 40px 0 20px; text-align: center; }
.hero p.lead { font-size: 18px; color: var(--muted); max-width: 620px; margin: 0 auto 24px; }
.grad { background: linear-gradient(135deg, #fff, #c7c6ff 40%, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.feature { display: flex; gap: 14px; align-items: flex-start; }
.feature .ic { flex: 0 0 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card2); font-size: 20px; }

/* Plans */
.plan { position: relative; display: flex; flex-direction: column; }
.plan .price { font-size: 32px; font-weight: 800; margin: 6px 0; }
.plan .per { color: var(--muted); font-size: 13px; }
.plan ul { list-style: none; padding: 0; margin: 14px 0 18px; color: var(--muted); }
.plan li { padding: 4px 0; }
.plan li::before { content: "✓"; color: var(--ok); margin-right: 8px; font-weight: 700; }
.plan form, .plan .btn { margin-top: auto; }

/* Status panel */
.status { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.status .big { font-size: 26px; font-weight: 800; }

/* Devices */
.dev { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.dev:last-child { border-bottom: 0; }
.dev .name { font-weight: 600; }

.qr { background: #fff; border-radius: 16px; padding: 16px; max-width: 300px; margin: 0 auto; }
.qr img { display: block; width: 100%; height: auto; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 40px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card2); font-weight: 700; font-size: 13px;
}

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: rgba(255, 255, 255, .02); }

.stat .num { font-size: 28px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13px; }

footer { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); font-size: 13px; }

/* Admin layout */
.admin { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 4px 10px 18px; }
.side a.item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; color: var(--muted); margin-bottom: 2px; }
.side a.item:hover, .side a.item.on { background: var(--card); color: var(--text); text-decoration: none; }
.admin main { padding: 24px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; margin: 0; }
@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: sticky; height: auto; padding: 8px; display: flex; gap: 4px; overflow-x: auto; z-index: 10; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { display: none; }
  .side a.item { white-space: nowrap; margin: 0; }
  .admin main { padding: 16px; }
}

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; }
@media (max-width: 620px) { .kv { grid-template-columns: 1fr; } .kv dt { color: var(--muted); font-size: 12px; } }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
