:root {
  --navy: #2a2c91;
  --cyan: #00afef;
  --yellow: #fff212;
  --ink: #1c1d3a;
  --muted: #5c5e78;
  --line: #e4e6ef;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --side: #2a2c91;
  --side-2: #23257a;
  --accent: #2a2c91;
  --accent-2: #00afef;
  --ok: #1b7a42;
  --off: #8a5a20;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 29, 58, 0.05), 0 12px 32px rgba(42, 44, 145, 0.08);
  --font: "Nunito Sans", system-ui, sans-serif;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
h1, h2, h3 { font-family: var(--font); font-weight: 700; margin: 0; letter-spacing: -0.02em; }
button, input, select { font: inherit; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.brand-stripe {
  height: 6px;
  background: linear-gradient(90deg, var(--navy) 0 34%, var(--cyan) 34% 67%, var(--yellow) 67%);
}

.app-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background:
    radial-gradient(280px 200px at 0% 0%, rgba(0, 175, 239, 0.38), transparent 62%),
    var(--navy);
  color: #eef7ff;
  padding: 0 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 8px 0 32px rgba(42, 44, 145, 0.12);
}
.sidebar::before {
  content: "";
  display: block;
  height: 6px;
  margin: 0 -14px 18px;
  background: linear-gradient(90deg, var(--navy) 0 34%, var(--cyan) 34% 67%, var(--yellow) 67%);
}
.side-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 0 4px; }
.side-logo { height: 36px; width: auto; max-width: 180px; display: block; object-fit: contain; }
.side-brand small { display: block; opacity: .7; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--cyan); color: #fff; font-weight: 800; letter-spacing: .04em; font-size: 13px;
}
.logo-mark.lg { width: 48px; height: 48px; border-radius: 12px; margin-bottom: 14px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button {
  border: 0; background: transparent; color: rgba(255,255,255,.86); text-align: left;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 650; font-size: 14px;
}
.side-nav button:hover { background: rgba(255,255,255,.1); color: #fff; }
.side-nav button.active {
  background: var(--cyan);
  color: var(--navy);
}
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.side-user { font-size: 13px; opacity: .75; }

.main { padding: 28px 32px 56px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.page-head h1 { font-size: 28px; line-height: 1.15; font-weight: 800; }
.page-head p, .page-meta { color: var(--muted); font-size: 14.5px; max-width: 52ch; margin: 8px 0 0; line-height: 1.5; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.toast {
  background: #e7f6ee; color: var(--ok); border: 1px solid #c9ead5;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px;
}
.callout {
  background: #e8f6fc; color: var(--navy); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px;
}
.filters { margin-bottom: 14px; }
.filters-grid {
  display: grid; gap: 12px; grid-template-columns: 1.1fr 1.4fr .9fr auto; align-items: end;
}
.filters-grid label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.filters-actions { display: flex; gap: 8px; }
.field { display: grid; gap: 6px; margin: 14px 0; }
.field label { font-size: 13px; color: var(--muted); font-weight: 650; }
input, select {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 175, 239, 0.22);
}
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 11px 16px; cursor: pointer; font-weight: 700;
}
.btn:hover { background: #f6f7fb; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: #23257a; }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.38); }
.btn.ghost:hover { background: rgba(255,255,255,.1); }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn.danger { color: #9b1c1c; border-color: #f0c4c4; background: #fff7f7; }
.btn.danger:hover { background: #fde8e8; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.back { border: 0; background: transparent; color: var(--navy); cursor: pointer; font-weight: 700; margin-bottom: 12px; padding: 0; }
.callout.sync-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
}

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 13px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.muted { color: var(--muted); font-size: 12px; margin-top: 4px; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.link { border: 0; background: transparent; padding: 0; cursor: pointer; color: inherit; text-align: left; font: inherit; }
.link:hover { color: var(--cyan); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 3px 9px; font-size: 12px; font-weight: 800;
}
.badge.on { background: #e5f6ea; color: var(--ok); }
.badge.off { background: #f7efe3; color: var(--off); }

.toolbar { margin-bottom: 14px; }
.group-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.group-tile {
  text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 18px; cursor: pointer; box-shadow: var(--shadow); display: grid; gap: 6px;
}
.group-tile:hover { border-color: var(--cyan); }
.group-tile span, .group-tile em { color: var(--muted); font-style: normal; font-size: 13px; }

.tabs { display: flex; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px;
  cursor: pointer; color: var(--muted); font-weight: 700;
}
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.list-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.wallpaper-box {
  display: grid; gap: 10px; padding-bottom: 16px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.wp-preview {
  width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--line); background: var(--navy);
}
.wp-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.wp-actions label.btn { margin: 0; cursor: pointer; }
.switch {
  width: 46px; height: 28px; border-radius: 999px; border: 0; background: #cfd3dc; position: relative; cursor: pointer;
}
.switch::after {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .15s ease;
}
.switch.on { background: var(--navy); }
.switch.on::after { left: 21px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.stat strong { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.two-col { display: grid; gap: 14px; grid-template-columns: 1.1fr .9fr; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.stack { padding-top: 8px; padding-bottom: 8px; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) minmax(360px, 1fr);
  background: #fff;
}
.login-stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 0% -10%, rgba(0, 175, 239, 0.55), transparent 58%),
    var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px 48px 56px;
}
.login-stage .brand-stripe {
  position: absolute;
  top: 0; left: 0; right: 0;
}
.stage-radar {
  position: absolute;
  inset: -8% -20% auto auto;
  width: 140%;
  height: auto;
  opacity: .95;
  pointer-events: none;
}
.stage-radar circle,
.stage-radar line {
  stroke: rgba(0, 175, 239, 0.35);
  stroke-width: 1.25;
}
.stage-copy { position: relative; z-index: 1; max-width: 400px; }
.login-logo { height: 52px; width: auto; max-width: 280px; display: block; margin-bottom: 32px; object-fit: contain; }
.stage-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--yellow);
}
.stage-copy h1 {
  font-size: clamp(48px, 6vw, 72px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: .95;
  margin: 0 0 14px;
}
.stage-copy > p {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.78);
  max-width: 32ch;
  font-weight: 400;
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 40px 32px;
  background: #f4f6f8;
}
.login-card {
  width: min(400px, 100%);
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  color: var(--ink);
}
.login-card h2 { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.login-lead { color: var(--muted); margin: 8px 0 8px; font-size: 15px; }
.login-alt {
  display: block;
  text-align: center;
  margin-top: 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}
.login-card .btn.primary { padding: 13px 16px; font-size: 15px; }
.login-card input { background: #fff; }
.error { color: var(--danger); font-size: 14px; margin-top: 10px; }

.btn.ghost.on { background: rgba(255,255,255,.14); border-color: #fff; }
.profile-card { max-width: 760px; }
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.profile-grid label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.role-pick, .scope-pick { display: grid; gap: 8px; }
.role-opt, .scope-opt {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}
.role-opt:has(input:checked), .scope-opt:has(input:checked) {
  border-color: var(--cyan);
  background: #e8f6fc;
}
.role-opt small, .scope-opt small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  margin-top: 2px;
}
.group-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.group-checks label {
  display: flex; gap: 8px; align-items: center;
  font-weight: 650; font-size: 14px; color: var(--ink);
}
.readonly-line { margin: 0; font-size: 14px; }
input[readonly] { background: #f4f6f8; color: var(--muted); }
table.data tr.row-link { cursor: pointer; }
table.data tr.row-link:hover { background: #f6f8fc; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(42, 44, 145, .4);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal { width: min(440px, 100%); }

.tag {
  display: inline-flex; align-items: center; margin-left: 8px;
  font-size: 11px; font-weight: 800; border-radius: 999px;
  padding: 2px 8px; background: #e8f6fc; color: var(--navy); vertical-align: middle;
}
.tag.soft { background: #f0eee9; color: var(--muted); }
.tag.warn { background: #fff8c2; color: #6b6400; }
.tag.ok { background: #e5f6ea; color: #1b6b3a; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: #f3f5f9; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; color: var(--ink);
}
.chip.action {
  cursor: pointer; background: #fff; border-color: var(--cyan);
  color: var(--navy); font-weight: 700;
}
.chip.action:hover { background: #e8f6fc; }
.app-legend {
  display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0 14px; font-size: 13px;
}
.app-row { align-items: flex-start; gap: 12px; }
.app-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: flex-end;
  min-width: 220px;
}
.ctrl {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted); font-weight: 700;
}
.ctrl.disabled { opacity: .45; pointer-events: none; }
.catalog-box {
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.catalog-box h3 { margin: 0 0 4px; font-size: 16px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.activate-admin { display: grid; gap: 16px; }
.qr-hero {
  display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 28px; align-items: start;
}
.qr-img {
  width: 100%; max-width: 260px; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 12px; display: block;
}
.qr-img.lg { max-width: 280px; padding: 16px; }
.steps { margin: 12px 0 0; padding-left: 18px; color: var(--ink); }
.steps li { margin: 10px 0; }
.activate-page { min-height: 100vh; background: var(--bg); color: var(--ink); }
.activate-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  background: var(--navy);
  color: #eef7ff;
}
.activate-top .side-brand { flex-direction: row; align-items: center; gap: 14px; }
.activate-top .btn.ghost { color: #fff; }
.activate-main { max-width: 980px; margin: 0 auto; padding: 36px 20px 64px; display: grid; gap: 16px; }
.activate-hero {
  display: grid; grid-template-columns: 1.2fr auto; gap: 28px; align-items: center;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 800;
  color: var(--navy); margin: 0 0 8px;
}
.activate-hero h1 { font-size: 36px; margin-bottom: 10px; font-weight: 800; }
.activate-hero p { color: var(--muted); max-width: 46ch; margin: 0 0 16px; }
.activate-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 12px; }
.activate-grid p { margin: 6px 0 0; }
.prov-log p { color: var(--ink); }
.prov-checks { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.prov-checks li { color: var(--muted); display: flex; gap: 8px; align-items: start; }
.prov-checks li.ok { color: var(--navy); font-weight: 600; }
.prov-events { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.prov-events code { font-size: 12px; background: #eef2ff; color: var(--navy); padding: 2px 6px; border-radius: 4px; }
.prov-crash {
  white-space: pre-wrap; font-size: 12px; background: #fde8e8; color: #9b1c1c;
  border: 1px solid #f0c4c4; border-radius: 10px; padding: 12px; overflow: auto; max-height: 240px;
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; padding-top: 0; }
  .sidebar::before { width: 100%; margin: 0 -14px 0; }
  .side-nav { flex-direction: row; }
  .side-foot { margin-top: 0; margin-left: auto; display: flex; align-items: center; gap: 10px; }
  .filters-grid, .two-col { grid-template-columns: 1fr; }
  .login-screen { grid-template-columns: 1fr; }
  .login-stage { min-height: 240px; padding: 36px 24px 28px; justify-content: flex-end; }
  .stage-copy h1 { font-size: 40px; }
  .login-panel { padding: 32px 22px 48px; align-items: start; }
}
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
.manual-grid .eyebrow { color: var(--cyan); }
.bitrix-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0; }
.bitrix-id {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 8px;
  background: #eef9fe; border: 1px solid #b8e4f6; color: var(--navy); font-weight: 700;
}
code { font-family: ui-monospace, monospace; font-size: 12px; background: var(--bg); padding: 1px 6px; border-radius: 4px; }
@media (max-width: 800px) {
  .qr-hero, .activate-hero, .activate-grid, .profile-grid, .manual-grid, .bitrix-form { grid-template-columns: 1fr; }
  .activate-hero h1 { font-size: 28px; }
}
