/* NinjaBot Web — «суми и ханко»: тушь ночи, киноварь печати, золото ключей.
   Unbounded (display) · Manrope (text) · JetBrains Mono (code/log) */

:root {
  --ink: #0c0f16;
  --ink-2: #0f1520;
  --panel: #131a26;
  --panel-2: #0b101a;
  --line: #26303f;
  --line-soft: #1b2330;
  --text: #eaedf3;
  --dim: #97a0b3;
  --shu: #e4593b;
  --shu-deep: #b93f26;
  --shu-soft: rgba(228, 89, 59, .14);
  --gold: #e2b15c;
  --gold-soft: rgba(226, 177, 92, .14);
  --green: #46c07a;
  --green-soft: rgba(70, 192, 122, .12);
  --red: #e5604c;
  --red-soft: rgba(229, 96, 76, .14);
  --r-card: 14px;
  --r-btn: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --font-display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html {
  background: var(--ink);
  min-height: 100%;
}

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 500px at 82% -10%, #1a2233 0%, transparent 55%),
    radial-gradient(900px 420px at -10% 8%, rgba(228, 89, 59, .07) 0%, transparent 50%)
    var(--ink);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* ---------------------------------------------------------------- icons */
.icon {
  width: 18px; height: 18px; flex: none;
  vertical-align: -3px;
}
.icon.mark { width: 64px; height: 64px; }
.icon.brand { width: 22px; height: 22px; color: var(--shu); }

/* ------------------------------------------------------------ utilities */
.mono { font-family: var(--font-mono); }
.dim { color: var(--dim); }
.small { font-size: 12.5px; }
.gold { color: var(--gold); }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--shu);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================================================================= GATE */
.gate-wrap {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 18px;
  gap: 18px;
}

.gate {
  width: 100%;
  max-width: 430px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 34px 26px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.gate::after { /* ghost shuriken watermark */
  content: '';
  position: absolute; right: -70px; top: -70px;
  width: 220px; height: 220px;
  background: radial-gradient(circle at center, transparent 58%, rgba(151, 160, 179, .05) 58.5%, rgba(151, 160, 179, .05) 60%, transparent 60.5%),
              radial-gradient(circle at center, rgba(151, 160, 179, .04) 0%, transparent 62%);
  border-radius: 50%;
  transform: rotate(20deg);
  pointer-events: none;
}

.gate-mark {
  color: var(--shu);
  animation: stamp-in .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
.gate-mark .icon { filter: drop-shadow(0 6px 22px rgba(228, 89, 59, .35)); }

@keyframes stamp-in {
  from { transform: scale(1.7) rotate(14deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.gate-title {
  font: 900 clamp(26px, 6vw, 36px)/1.15 var(--font-display);
  letter-spacing: .01em;
  margin: 14px 0 8px;
  overflow-wrap: anywhere;
}
.gate-title-sm { font-size: clamp(20px, 5vw, 26px); line-height: 1.25; }

.gate-sub { color: var(--dim); margin: 0 0 26px; }

.gate-form { display: flex; flex-direction: column; gap: 14px; }

.keybox { position: relative; }
.keybox .icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--dim); width: 20px; height: 20px;
}
.keybox input {
  width: 100%;
  padding: 14px 14px 14px 44px;
  font: 600 18px/1 var(--font-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: center;
}

.gate-err {
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid rgba(229, 96, 76, .35);
  border-radius: var(--r-btn);
  padding: 10px 14px;
  margin: 14px 0 0;
  font-size: 14px;
}

.gate-hint { color: var(--dim); font-size: 13px; margin: 22px 0 0; }

.gate-admin {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--dim); text-decoration: none; font-size: 13.5px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: color .15s, border-color .15s;
}
.gate-admin:hover { color: var(--text); border-color: var(--dim); }

/* --------------------------------------------------------------- fields */
input, select, textarea {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  color: var(--text);
  font: 500 14.5px/1.4 var(--font-body);
  padding: 10px 12px;
  transition: border-color .15s;
}
input:hover, select:hover { border-color: #334054; }
input:focus, select:focus { outline: none; border-color: var(--shu); }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--dim); letter-spacing: .02em; }
.field.grow { flex: 1; }
.field.w-narrow { width: 150px; }

.field-row { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; margin: 12px 0; }

.check {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 14.5px; cursor: pointer; user-select: none;
}
.check input { width: 17px; height: 17px; accent-color: var(--shu); cursor: pointer; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--ink-2); border: 1px solid var(--line);
  display: inline-flex; align-items: center;
  padding: 2px; transition: background .18s, border-color .18s;
}
.switch .thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--dim);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .18s, background .18s;
}
.switch .thumb .icon { width: 11px; height: 11px; color: var(--ink); }
.switch input:checked + .track { background: var(--shu-soft); border-color: var(--shu); }
.switch input:checked + .track .thumb { transform: translateX(18px); background: var(--shu); }
.switch input:checked + .track .thumb .icon { color: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--shu); outline-offset: 2px; }
.switch .lbl { font-size: 13.5px; font-weight: 600; color: var(--dim); }
.switch input:checked ~ .lbl { color: var(--text); }
.switch.master .track { width: 48px; height: 25px; }
.switch.master input:checked + .track .thumb { transform: translateX(23px); }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  padding: 10px 18px;
  font: 700 14.5px/1 var(--font-body);
  color: #fff;
  cursor: pointer;
  transition: filter .15s, border-color .15s, color .15s;
  user-select: none;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-lg { padding: 14px 20px; font-size: 15.5px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-primary {
  background: linear-gradient(180deg, var(--shu) 0%, var(--shu-deep) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 6px 18px rgba(228, 89, 59, .22);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--dim); }

.btn-danger { background: #6e2419; border-color: #8d2f20; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.15); }

.btn-icon {
  padding: 6px; background: transparent; border: none; color: var(--dim);
  border-radius: 7px;
}
.btn-icon:hover { color: var(--text); background: var(--line-soft); }
.btn-icon.danger:hover { color: var(--red); }

/* =============================================================== TOPBAR */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(12, 15, 22, .82);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 40;
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font: 700 17px/1 var(--font-display);
  color: var(--text); text-decoration: none;
}
.brand-tag {
  font: 600 11px/1 var(--font-body);
  color: var(--shu);
  border: 1px solid var(--shu);
  border-radius: 999px;
  padding: 4px 9px;
  transform: rotate(-4deg);
  font-style: normal;
}

.topbar-stats {
  margin-left: auto;
  display: flex; align-items: center; gap: 16px;
  font-size: 13.5px; color: var(--dim);
}
.topbar-stats b { color: var(--text); font-weight: 700; }
.topbar-stats .icon { width: 15px; height: 15px; }
.topbar-stats .sep { color: var(--line); }

/* =============================================================== LAYOUT */
.layout {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  gap: 0;
  max-width: 1160px;
  margin: 0 auto;
  min-height: calc(100vh - 62px);
}

.sidenav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 10px;
  border-right: 1px solid var(--line-soft);
}
.sidenav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px;
  border-radius: var(--r-btn);
  color: var(--dim);
  font-weight: 600; font-size: 14.5px;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  text-align: left;
  text-decoration: none;
  transition: color .15s, background .15s;
}
.sidenav a:hover { color: var(--text); background: var(--line-soft); }
.sidenav a.on {
  color: var(--text);
  background: var(--shu-soft);
  border-color: rgba(228, 89, 59, .3);
}
.sidenav a.on .icon { color: var(--shu); }
.sidenav .side-dim { margin-top: auto; }

.content { padding: 22px 24px 90px; min-width: 0; }

/* ----------------------------------------------------------------- tabs */
.tab { display: none; }
.tab.on { display: block; }

/* ---------------------------------------------------------------- cards */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card-title {
  display: flex; align-items: center; gap: 9px;
  font: 700 15px/1.3 var(--font-body);
  margin: 0 0 14px;
}
.card-title .icon { color: var(--shu); }
.card-head { display: flex; align-items: center; justify-content: space-between; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.grid-cards .card { margin-bottom: 0; }

.row3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}
.row-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 14px; }

/* ------------------------------------------------------- overview/stats */
.hero-line {
  font: 700 21px/1.25 var(--font-display);
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}
.stats { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 110px;
  background: var(--ink-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.stat-l {
  display: flex; align-items: center; gap: 6px;
  color: var(--dim); font-size: 12px; font-weight: 600;
  margin-bottom: 3px;
}
.stat-l .icon { width: 13px; height: 13px; }
.stat b { font-size: 17px; font-weight: 800; }

/* ---------------------------------------------------------------- chips */
.levels {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 4px 0 2px;
  min-height: 40px;
}
.chip {
  font: 600 13px/1 var(--font-mono);
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--dim);
  cursor: pointer;
  transition: border-color .12s, color .12s;
  position: relative;
}
.chip:hover { border-color: var(--dim); color: var(--text); }
.chip.done { color: var(--gold); border-color: rgba(226, 177, 92, .4); background: var(--gold-soft); }
.chip.sel { color: #fff; background: var(--shu); border-color: var(--shu); }
.chip.lock { opacity: .32; cursor: default; }
.chip.lock:hover { border-color: var(--line); color: var(--dim); }
.chip .star { color: var(--gold); margin-left: 4px; letter-spacing: 1px; }
.chip.sel .star { color: #ffe4c9; }

/* ------------------------------------------------------------------ log */
.log {
  background: #070a10;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font: 400 12.5px/1.7 var(--font-mono);
  color: #aebadb;
  height: 320px;
  overflow-y: auto;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.log.mini { height: 200px; }
.log .l-ok { color: var(--green); }
.log .l-err { color: var(--red); }
.log .t { color: #5b6580; margin-right: 8px; }

/* -------------------------------------------------------------- taskbar */
.taskbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--shu);
  border-radius: 10px;
  padding: 11px 16px;
  margin-bottom: 18px;
  font-weight: 600;
}
.taskbar #task-progress { color: var(--dim); font-weight: 500; }
.taskbar .btn { margin-left: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.run { background: var(--shu); animation: pulse 1.2s ease-in-out infinite; }
.dot.err { background: var(--red); }
.dot.ok { background: var(--green); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(228, 89, 59, .5); }
  50% { box-shadow: 0 0 0 6px rgba(228, 89, 59, 0); }
}

/* ================================================================ ADMIN */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  color: var(--dim); font-size: 12px; font-weight: 700;
  text-transform: none; letter-spacing: .03em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table .code { font: 600 13.5px/1 var(--font-mono); letter-spacing: .06em; }

/* hanko stamp badges — the signature of the admin panel */
.stamp {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid currentColor;
  transform: rotate(-8deg);
  flex: none;
}
.stamp .icon { width: 14px; height: 14px; }
.stamp.active { color: var(--shu); background: var(--shu-soft); }
.stamp.unused { color: var(--gold); background: var(--gold-soft); }
.stamp.expired, .stamp.revoked { color: #5b6580; background: rgba(91, 101, 128, .1); }
.stamp.paused { color: #5b6580; background: rgba(91, 101, 128, .1); }
.stamp.error { color: var(--red); background: var(--red-soft); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700;
  border-radius: 999px;
  padding: 4px 10px;
}
.badge.active { color: var(--green); background: var(--green-soft); }
.badge.running { color: var(--shu); background: var(--shu-soft); }
.badge.dimmed { color: var(--dim); background: var(--line-soft); }
.badge.err { color: var(--red); background: var(--red-soft); }
.badge.gold { color: var(--gold); background: var(--gold-soft); }

.onlinedot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.onlinedot.on { background: var(--green); box-shadow: 0 0 6px rgba(70, 192, 122, .8); }

.newkeys {
  margin-top: 14px;
  border: 1px dashed rgba(226, 177, 92, .5);
  background: var(--gold-soft);
  border-radius: 10px;
  padding: 14px 16px;
}
.newkeys h4 { margin: 0 0 10px; font-size: 13px; color: var(--gold); }
.newkeys .code-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
  font: 600 15px/1.4 var(--font-mono); letter-spacing: .08em;
}
.code-row .btn-icon { color: var(--gold); }

/* --------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    flex-direction: row; justify-content: space-around;
    border-right: none; border-top: 1px solid var(--line);
    background: rgba(12, 15, 22, .95);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .sidenav a {
    flex-direction: column; gap: 4px;
    font-size: 10.5px; padding: 7px 8px;
  }
  .sidenav a span { font-size: 10.5px; }
  .sidenav .side-dim { margin: 0; }
  .content { padding: 16px 14px 96px; }
  .row3 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .topbar-stats { gap: 10px; font-size: 12.5px; width: 100%; margin-left: 0; }
  .switch.master .lbl { display: none; }
  .card { padding: 16px; }
  .taskbar { flex-wrap: wrap; }
  .taskbar .btn { margin-left: 0; width: 100%; }
}

@media (max-width: 480px) {
  .gate { padding: 28px 18px 24px; }
  .gate-title { font-size: 30px; }
  .gate-title-sm { font-size: 21px; }
  .gate-sub { font-size: 14px; }
  .keybox input { font-size: 16px; letter-spacing: .08em; }
  .btn-lg { padding: 13px 16px; }
  .row-actions .field.w-narrow { width: 100%; }
  .row-actions { align-items: stretch; flex-direction: column; }
  .row-actions .btn { width: 100%; }
  .field-row { gap: 10px 14px; }
}
