:root {
  --bg: #070d18;
  --bg-2: #0c1628;
  --panel: #101b2e;
  --card: #14233c;
  --line: #24364f;
  --text: #eef3fc;
  --muted: #8b9bb5;
  --accent: #3b9eff;
  --accent-2: #2563eb;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  --radius: 16px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); }
body.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
button { font: inherit; cursor: pointer; border: 0; }
aside {
  background: linear-gradient(180deg, #0d1729, #0a1322);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { letter-spacing: .28em; font-weight: 800; color: var(--accent); font-size: 15px; }
.brand small { display: block; letter-spacing: 0; font-weight: 500; color: var(--muted); margin-top: 6px; font-size: 12px; }
nav { display: flex; flex-direction: column; gap: 4px; }
nav button {
  background: transparent;
  color: #c5d2e8;
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 14px;
}
nav button.active, nav button:hover { background: #173056; color: #fff; }
nav button.active { box-shadow: inset 3px 0 0 var(--accent); }
.aside-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 13px; }
.ghost { background: #15243c; color: var(--text); padding: 9px 12px; border-radius: 10px; text-align: center; }
main { padding: 28px 32px 56px; overflow: auto; background: radial-gradient(1200px 400px at 100% -10%, #12305a 0%, transparent 55%), var(--bg); }
.top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; }
h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.03em; }
h2, h3 { margin: 0 0 10px; }
#subtitle, .muted, .hint { color: var(--muted); }
.primary, button.primary {
  background: linear-gradient(180deg, #4aa8ff, var(--accent-2));
  color: #04101f;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  text-align: center;
}
.primary:hover, button.primary:hover { filter: brightness(1.06); }
button.danger { background: #7f1d1d; color: #fecaca; padding: 9px 12px; border-radius: 10px; }
button.ok { background: #064e3b; color: #a7f3d0; padding: 9px 12px; border-radius: 10px; }
button.warn { background: #78350f; color: #fde68a; padding: 9px 12px; border-radius: 10px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.card {
  background: linear-gradient(180deg, #172844, #13233d);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.card b { display: block; font-size: 22px; margin-top: 6px; }
.table { width: 100%; border-collapse: collapse; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table th, .table td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table tr:hover td { background: rgba(255,255,255,.02); }
.badge { padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.on { background: #064e3b; color: #a7f3d0; }
.off { background: #3f1d1d; color: #fecaca; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { background: #1c3258; color: var(--text); padding: 8px 10px; border-radius: 10px; }
input[type="checkbox"] { width: auto; margin: 0 8px 0 0; padding: 0; }
.sheet .toolbar { margin-top: 8px; }
input, textarea, select {
  width: 100%;
  background: #0b172c;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  margin: 6px 0 14px;
  font: inherit;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,158,255,.18); }
label { font-size: 13px; color: var(--muted); }
.search { max-width: 320px; }
.tabs { display: flex; gap: 8px; margin: 12px 0 16px; flex-wrap: wrap; }
.tabs button { background: #1c3258; color: var(--text); padding: 8px 12px; border-radius: 10px; }
.tabs button.active { background: var(--accent); color: #04101f; font-weight: 700; }
.files { display: grid; grid-template-columns: 280px 1fr; gap: 12px; min-height: 420px; }
.file-list { background: #0b172c; border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.file-list button { width: 100%; border-radius: 0; border-bottom: 1px solid #1a2a45; background: transparent; color: var(--text); text-align: left; padding: 10px 12px; }
.file-list button:hover { background: #173056; }
.editor { min-height: 380px; font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.modal { position: fixed; inset: 0; background: rgba(3,8,18,.66); place-items: center; z-index: 40; backdrop-filter: blur(6px); }
.modal:not([hidden]) { display: grid; }
.modal[hidden], .toast[hidden] { display: none !important; }
.sheet { width: min(560px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.error { color: var(--bad); }
.toast { position: fixed; right: 18px; bottom: 18px; background: #13243f; border: 1px solid var(--line); padding: 12px 16px; border-radius: 12px; z-index: 50; box-shadow: var(--shadow); }
.bar { height: 10px; background: #0b172c; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #38bdf8); }
.clicks { display: flex; flex-direction: column; gap: 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: linear-gradient(180deg, #173154, #12243f); }
.kpi::after { content: ""; position: absolute; right: -24px; top: -28px; width: 110px; height: 110px; border-radius: 50%; opacity: .18; }
.kpi-blue::after { background: #38bdf8; }
.kpi-mint::after { background: #34d399; }
.kpi-violet::after { background: #a78bfa; }
.kpi-gold::after { background: #fbbf24; }
.kpi-label { display: block; color: var(--muted); font-size: 13px; }
.kpi strong { display: block; margin: 8px 0 4px; font-size: 30px; letter-spacing: -.03em; line-height: 1.1; }
.kpi-sub { color: #7b8aa8; font-size: 12px; }
.clicks-board { background: #101d35; border: 1px solid var(--line); border-radius: 20px; padding: 8px 8px 12px; }
.clicks-head { padding: 14px 16px 8px; }
.clicks-head h3 { margin: 0 0 4px; font-size: 16px; }
.rank-list { list-style: none; margin: 0; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 10px; }
.rank-card { display: grid; grid-template-columns: 36px 44px minmax(160px, 1.2fr) auto minmax(180px, 1fr); gap: 12px; align-items: center; background: #13243f; border: 1px solid #243656; border-radius: 16px; padding: 14px 16px; }
.rank-card.is-lead { border-color: #3b82f6; background: linear-gradient(90deg, #16345c, #13243f 42%); }
.rank-no { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: #0b172c; color: #93a0bb; }
.rank-card.is-lead .rank-no { background: #fbbf24; color: #1f2937; }
.rank-avatar { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; background: #1d4ed8; color: #dbeafe; }
.rank-meta b { display: block; font-size: 15px; }
.rank-meta a { color: #7dd3fc; font-size: 12px; text-decoration: none; }
.rank-stats { display: flex; gap: 16px; }
.rank-stats em { display: block; font-style: normal; font-size: 18px; font-weight: 800; }
.rank-stats span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.rank-bar-wrap small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.rank-bar { height: 9px; background: #0b172c; border-radius: 99px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2563eb, #38bdf8); }
.clicks-empty { text-align: center; padding: 40px; color: var(--muted); }
code { color: #7dd3fc; }
.hint { font-size: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.preview { width: 100%; min-height: 280px; border: 0; background: #fff; border-radius: 12px; }

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  grid-template-columns: 1fr;
  background:
    radial-gradient(900px 420px at 50% -10%, #1a3f73 0%, transparent 55%),
    linear-gradient(180deg, #0a1424, #070d18);
}
.login-card {
  width: min(400px, 92vw);
  background: linear-gradient(180deg, #173054, #12233d);
  padding: 32px 28px 28px;
  border-radius: 22px;
  border: 1px solid #2b4568;
  box-shadow: var(--shadow);
}
.login-mark { letter-spacing: .32em; font-weight: 800; color: var(--accent); font-size: 13px; }
.login-card h1 { font-size: 26px; margin: 10px 0 6px; }
.login-card input { margin-bottom: 16px; }
.login-submit { width: 100%; padding: 12px 16px; margin-top: 4px; font-size: 15px; }
.login-card .error { margin: 12px 0 0; font-size: 13px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .rank-card { grid-template-columns: 36px 1fr; }
  .rank-stats, .rank-bar-wrap { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  body.app { grid-template-columns: 1fr; height: auto; }
  aside { flex-direction: row; align-items: center; overflow: auto; }
  .grid, .files { grid-template-columns: 1fr; }
  nav { flex-direction: row; }
}
