:root {
  --bg: #070a12;
  --bg-2: #0a0f1c;
  --panel: rgba(16, 23, 40, .78);
  --panel-strong: #111a2e;
  --border: rgba(148, 163, 184, .14);
  --text: #f5f7fb;
  --muted: #8d99ad;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --good: #35d49a;
  --bad: #ff6079;
  --warn: #f4b84a;
  --shadow: 0 22px 70px rgba(0,0,0,.35);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(79,140,255,.17), transparent 60%),
    radial-gradient(700px 420px at -10% 90%, rgba(124,92,255,.10), transparent 60%),
    var(--bg);
}
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.glass {
  background: linear-gradient(180deg, rgba(18,27,47,.86), rgba(12,18,32,.82));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(460px, 100%);
  border-radius: 26px;
  padding: 34px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-center { margin-bottom: 34px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center; font-weight: 900; font-size: 21px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 28px rgba(79,140,255,.25);
}
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: .2px; }
.brand-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.login-copy h1 { font-size: 30px; margin: 0 0 10px; }
.login-copy p { color: var(--muted); line-height: 1.55; margin: 0 0 26px; }
.login-form label, .field-label { display: block; color: #cbd5e1; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.input-with-button { display: flex; gap: 8px; margin-bottom: 14px; }
input {
  width: 100%; border: 1px solid var(--border); outline: none; color: var(--text);
  background: rgba(7,10,18,.68); border-radius: 12px; padding: 12px 14px;
  transition: border .2s, box-shadow .2s;
}
input:focus { border-color: rgba(79,140,255,.65); box-shadow: 0 0 0 3px rgba(79,140,255,.1); }
.form-error { color: #ff9dad; font-size: 13px; margin-top: 12px; line-height: 1.4; }

.btn {
  border: 1px solid transparent; border-radius: 11px; padding: 10px 14px;
  color: var(--text); font-weight: 750; transition: transform .16s, background .16s, border .16s, opacity .16s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #6d6cff); box-shadow: 0 8px 22px rgba(79,140,255,.18); }
.btn-secondary { background: rgba(148,163,184,.08); border-color: var(--border); }
.btn-ghost { background: transparent; border-color: var(--border); color: #c5cede; }
.btn-danger { background: rgba(255,96,121,.12); color: #ff9aab; border-color: rgba(255,96,121,.22); }
.btn-wide { width: 100%; }
.icon-btn {
  min-width: 44px; border-radius: 11px; border: 1px solid var(--border);
  background: rgba(148,163,184,.06); color: #d7deea;
}
.link-btn { border: 0; background: none; color: #8fb7ff; font-weight: 700; padding: 4px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 18px;
  border-right: 1px solid var(--border);
  background: rgba(7,10,18,.82);
  backdrop-filter: blur(18px);
  display: flex; flex-direction: column;
}
.sidebar .brand { padding: 4px 8px 24px; }
.nav { display: grid; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  border: 1px solid transparent; border-radius: 11px; padding: 11px 12px;
  background: transparent; color: #9da9bd; font-weight: 700;
}
.nav-item:hover { background: rgba(148,163,184,.05); color: #e9eef7; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(79,140,255,.14), rgba(79,140,255,.04));
  border-color: rgba(79,140,255,.16); color: #dce8ff;
}
.nav-item span { width: 20px; text-align: center; color: #8fb7ff; }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.api-state { display: flex; gap: 8px; align-items: center; padding: 0 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 10px currentColor; }
.status-dot.good { background: var(--good); }
.status-dot.bad { background: var(--bad); }

.main { min-width: 0; padding: 28px clamp(18px, 3vw, 44px) 44px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin: 3px 0 0; font-size: clamp(28px, 3vw, 38px); }
.eyebrow { color: #71829d; font-size: 11px; font-weight: 900; letter-spacing: 1.4px; }
.topbar-actions { display: flex; gap: 10px; }

.page { display: none; }
.active-page { display: block; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat-card { border-radius: var(--radius); padding: 20px; min-height: 132px; }
.stat-label { color: #9eabc0; font-size: 13px; font-weight: 700; }
.stat-value { font-size: 34px; font-weight: 900; margin-top: 12px; letter-spacing: -1px; }
.stat-hint { color: #687892; font-size: 12px; margin-top: 5px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { border-radius: var(--radius); overflow: hidden; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 19px 20px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0 0 4px; font-size: 17px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 12px; }
.toolbar-head { align-items: flex-end; }
.toolbar { display: flex; gap: 9px; }
.search { width: min(260px, 40vw); padding: 10px 12px; }

.mini-list { min-height: 230px; }
.mini-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 20px; border-bottom: 1px solid rgba(148,163,184,.08);
}
.mini-row:last-child { border-bottom: 0; }
.mini-main { min-width: 0; }
.mini-title { font-weight: 760; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.skeleton-block:empty::after {
  content: "Загрузка…"; display: grid; place-items: center; min-height: 230px; color: var(--muted);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { padding: 13px 18px; text-align: left; border-bottom: 1px solid rgba(148,163,184,.08); vertical-align: middle; }
th { color: #71819a; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; font-weight: 850; }
td { color: #dce3ef; font-size: 13px; }
tr:hover td { background: rgba(148,163,184,.025); }
.right { text-align: right; }
.actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.action-btn {
  border: 1px solid var(--border); border-radius: 9px; background: rgba(148,163,184,.05);
  color: #cbd5e1; padding: 7px 9px; font-size: 12px; font-weight: 700;
}
.action-btn:hover { border-color: rgba(79,140,255,.35); color: #eaf1ff; }
.action-btn.danger { color: #ff9aab; border-color: rgba(255,96,121,.16); }
.action-btn.good { color: #7ce5be; border-color: rgba(53,212,154,.16); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 8px;
  font-size: 11px; font-weight: 850; border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-good { color: #66dbb1; background: rgba(53,212,154,.06); }
.badge-bad { color: #ff8da0; background: rgba(255,96,121,.06); }
.badge-warn { color: #f3c76a; background: rgba(244,184,74,.06); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.empty { padding: 36px; text-align: center; color: var(--muted); }

.timeline { padding: 6px 20px 16px; }
.log-row { display: grid; grid-template-columns: 13px 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid rgba(148,163,184,.08); }
.log-dot { width: 9px; height: 9px; border-radius: 50%; background: #6c91d9; margin-top: 5px; }
.log-text { font-size: 13px; line-height: 1.45; }
.log-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }

.setting-row { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting-title { font-weight: 800; margin-bottom: 5px; }
.danger-panel { border-color: rgba(255,96,121,.11); }

.modal {
  border: 0; padding: 0; background: transparent; color: var(--text);
}
.modal::backdrop { background: rgba(1,3,8,.72); backdrop-filter: blur(7px); }
.modal-card {
  width: min(480px, calc(100vw - 28px)); border: 1px solid var(--border);
  background: linear-gradient(180deg, #121b2e, #0b111f); border-radius: 22px; padding: 24px;
  box-shadow: 0 32px 90px rgba(0,0,0,.55);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.modal-head h2, .success-card h2 { margin: 4px 0 0; font-size: 24px; }
.duration-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 18px; }
.duration {
  border: 1px solid var(--border); color: #c9d2e1; background: rgba(148,163,184,.045);
  border-radius: 12px; padding: 12px 8px; display: grid; gap: 3px;
}
.duration b { font-size: 18px; }
.duration span { color: var(--muted); font-size: 11px; }
.duration.active { border-color: rgba(79,140,255,.65); background: rgba(79,140,255,.1); color: #fff; }
.duration-wide { grid-column: span 4; }
.success-card { text-align: center; }
.success-card p { color: var(--muted); line-height: 1.5; font-size: 13px; }
.success-icon {
  width: 56px; height: 56px; display: grid; place-items: center; margin: 0 auto 14px;
  border-radius: 17px; background: rgba(53,212,154,.12); color: #6ee2b8; font-size: 28px; font-weight: 900;
}
.license-output {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  margin: 18px 0; padding: 10px; background: #070b14; border: 1px solid var(--border); border-radius: 13px;
}
.license-output code { overflow-wrap: anywhere; font-size: 15px; color: #d9e7ff; }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: min(420px, calc(100vw - 44px));
  background: #121b2d; border: 1px solid var(--border); border-radius: 13px; padding: 12px 15px;
  box-shadow: var(--shadow); color: #e8eef8; font-size: 13px;
}
.toast.error { border-color: rgba(255,96,121,.25); color: #ffb0bd; }

@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar .brand { padding-bottom: 14px; }
  .nav { grid-template-columns: repeat(5, minmax(0, 1fr)); overflow-x: auto; }
  .nav-item { justify-content: center; font-size: 0; padding: 10px; }
  .nav-item span { font-size: 17px; }
  .sidebar-footer { display: none; }
  .main { padding-top: 18px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; }
}
@media (max-width: 520px) {
  .login-card { padding: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 112px; padding: 16px; }
  .stat-value { font-size: 28px; }
  .toolbar-head { align-items: stretch; flex-direction: column; }
  .toolbar { width: 100%; }
  .search { width: 100%; }
  .topbar-actions .btn-secondary { display: none; }
  .duration-grid { grid-template-columns: repeat(2, 1fr); }
  .duration-wide { grid-column: span 2; }
}
