:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e7ee;
  --border-strong: #cfd6e0;
  --text: #0f1b2d;
  --muted: #607089;
  --accent: #1f4fd8;
  --accent-soft: #e8eefc;
  --accent-text: #ffffff;
  --brand-a: #1f3a8a;
  --brand-b: #14b8a6;

  --ok: #15803d;
  --ok-bg: #dcf5e4;
  --slow: #b45309;
  --slow-bg: #fdf0d2;
  --down: #c81e1e;
  --down-bg: #fde2e2;
  --wrong: #c2410c;
  --wrong-bg: #ffe8d6;
  --blocked: #6d28d9;
  --blocked-bg: #ece5fd;
  --pending: #8a96a8;
  --pending-bg: #eef1f5;
  --land: #dfe5ec;

  --ph-dns: #94a3b8;
  --ph-connect: #38bdf8;
  --ph-tls: #a78bfa;
  --ph-wait: #f59e0b;
  --ph-download: #22c55e;

  --series: #1f4fd8, #e11d48, #059669, #d97706, #7c3aed, #0891b2, #db2777, #65a30d, #ea580c, #475569, #0d9488, #9333ea;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.04), 0 1px 1px rgba(15, 27, 45, 0.03);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1018;
    --surface: #121a26;
    --surface-2: #0f1620;
    --border: #1f2a3a;
    --border-strong: #2c3a4e;
    --text: #e3e9f2;
    --muted: #8796ab;
    --accent: #5b8cff;
    --accent-soft: #1a2a4a;
    --accent-text: #0b1018;
    --ok: #4ade80;
    --ok-bg: rgba(34, 197, 94, 0.16);
    --slow: #fbbf24;
    --slow-bg: rgba(245, 158, 11, 0.16);
    --down: #f87171;
    --down-bg: rgba(239, 68, 68, 0.18);
    --wrong: #fb923c;
    --wrong-bg: rgba(249, 115, 22, 0.16);
    --blocked: #b794f6;
    --blocked-bg: rgba(139, 92, 246, 0.2);
    --pending: #64748b;
    --pending-bg: rgba(100, 116, 139, 0.14);
    --land: #1d2736;
    --series: #5b8cff, #fb7185, #34d399, #fbbf24, #a78bfa, #22d3ee, #f472b6, #a3e635, #fb923c, #94a3b8, #2dd4bf, #c084fc;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1 {
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 17px;
  margin: 0;
}
h3 {
  font-size: 15px;
  margin: 0;
}
p {
  margin: 0 0 10px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}
.break {
  word-break: break-all;
}
.nowrap {
  white-space: nowrap;
}
.ok-text {
  color: var(--ok);
}
.warn-text {
  color: var(--slow);
}
.down-text {
  color: var(--down);
}
.row {
  display: flex;
  align-items: center;
}
.gap {
  gap: 8px;
}
.wrap {
  flex-wrap: wrap;
}
.spacer {
  flex: 1;
}
[hidden] {
  display: none !important;
}

/* ---------- Форма и кнопки ---------- */

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
  width: 100%;
}
input[type='checkbox'],
input[type='radio'] {
  width: auto;
  accent-color: var(--accent);
  margin: 0;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
textarea {
  resize: vertical;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 550;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn:hover {
  border-color: var(--muted);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--surface-2);
  border-color: var(--border);
}
.btn.danger {
  color: var(--down);
}
.btn.small {
  padding: 4px 10px;
  font-size: 12.5px;
}
select.small {
  padding: 4px 8px;
  font-size: 12.5px;
  width: auto;
}
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.icon-btn:hover {
  background: var(--surface-2);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.field.inline select {
  width: auto;
}
.field-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
}
.field-hint {
  font-size: 12px;
  color: var(--muted);
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-error {
  background: var(--down-bg);
  color: var(--down);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.indent {
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---------- Каркас ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 16px;
  color: var(--text) !important;
  text-decoration: none !important;
  letter-spacing: -0.01em;
}
.brand.big {
  font-size: 22px;
  margin-bottom: 4px;
}
.logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: url('/favicon.svg') center / cover;
  flex: none;
}
.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar {
  display: none;
}
.nav a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 550;
  white-space: nowrap;
  text-decoration: none;
}
.nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}
.nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.me {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.me-name {
  display: flex;
  flex-direction: column;
  text-align: right;
  font-weight: 600;
  line-height: 1.2;
}
.me-name span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.page {
  padding: 20px 24px 60px;
  max-width: 1800px;
  margin: 0 auto;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.error-card {
  color: var(--down);
}
.hint-card {
  margin-top: 16px;
}
.loading,
.boot {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}
.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty .row {
  justify-content: center;
  margin-top: 12px;
}
.empty.small {
  padding: 20px;
  border: 0;
}
.empty-title {
  font-weight: 650;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 6px;
}
.notice {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  font-size: 13px;
}
.notice.warn {
  background: var(--slow-bg);
  border-color: transparent;
  color: var(--slow);
}

/* ---------- Вход ---------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
}

/* ---------- Статусы ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.st-ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.st-slow {
  background: var(--slow-bg);
  color: var(--slow);
}
.st-down {
  background: var(--down-bg);
  color: var(--down);
}
.st-wrong {
  background: var(--wrong-bg);
  color: var(--wrong);
}
.st-blocked {
  background: var(--blocked-bg);
  color: var(--blocked);
}
.st-pending {
  background: var(--pending-bg);
  color: var(--pending);
}
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 550;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  vertical-align: middle;
}
.tag.ref {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}
.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ---------- Главная ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
}
.tile:hover {
  border-color: var(--border-strong);
}
.tile.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.tile-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.tile-label {
  color: var(--muted);
  font-size: 12.5px;
}
.tile.ok .tile-value {
  color: var(--ok);
}
.tile.down .tile-value {
  color: var(--down);
}
.tile.slow .tile-value,
.tile.warn .tile-value {
  color: var(--slow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar .search {
  width: 280px;
}
.toolbar select {
  width: auto;
  max-width: 240px;
}
.bulkbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--accent-soft);
}

.matrix-wrap {
  overflow: auto;
  max-height: calc(100vh - 250px);
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.matrix {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
.matrix th,
.matrix td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
  background: var(--surface);
}
.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  vertical-align: bottom;
}
.matrix .col-link {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  min-width: 260px;
  max-width: 340px;
  border-right: 1px solid var(--border);
}
.matrix thead .col-link {
  z-index: 4;
}
.matrix thead .col-link input {
  margin-right: 8px;
  vertical-align: middle;
}
.matrix .col-status {
  text-align: left;
}
.matrix .col-up {
  color: var(--muted);
  font-size: 12.5px;
}
.matrix td.col-up.bad {
  color: var(--down);
  font-weight: 600;
}
.col-probe {
  min-width: 58px;
  line-height: 1.15;
}
.col-probe.offline {
  opacity: 0.45;
}
.col-probe.geo-warn .ph-code {
  color: var(--slow);
}
.ph-flag {
  font-size: 17px;
}
.ph-code {
  font-weight: 700;
  color: var(--text);
}
.ph-kind {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.link-row {
  cursor: pointer;
}
.link-row:hover td {
  background: var(--surface-2);
}
.link-row.selected td {
  background: var(--accent-soft);
}
.link-row.inactive td {
  opacity: 0.55;
}
.link-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.link-main {
  min-width: 0;
}
.link-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.link-url {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-chip {
  min-width: 46px;
  justify-content: center;
  cursor: help;
}
.group-row td {
  background: var(--surface-2) !important;
  text-align: left;
  font-weight: 650;
  font-size: 12.5px;
  padding: 6px 12px;
  position: sticky;
  left: 0;
}

/* ---------- Страница ссылки ---------- */

.back {
  display: inline-block;
  margin-bottom: 10px;
  font-weight: 550;
}
.info-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.info-row {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 12px;
  align-items: center;
}
.info-label {
  color: var(--muted);
  font-size: 12.5px;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 16px;
}
.map-card {
  padding: 10px 12px;
}
.worldmap {
  width: 100%;
  height: auto;
  display: block;
}
.worldmap .land {
  fill: var(--land);
  stroke: var(--surface);
  stroke-width: 0.5;
}
.worldmap .land.st-ok,
.worldmap .dot.st-ok {
  fill: var(--ok);
}
.worldmap .land.st-slow,
.worldmap .dot.st-slow {
  fill: var(--slow);
}
.worldmap .land.st-down,
.worldmap .dot.st-down {
  fill: var(--down);
}
.worldmap .land.st-wrong,
.worldmap .dot.st-wrong {
  fill: var(--wrong);
}
.worldmap .land.st-blocked,
.worldmap .dot.st-blocked {
  fill: var(--blocked);
}
.worldmap [class*='st-'] {
  background: none;
}
.worldmap .dot {
  stroke: var(--surface);
  stroke-width: 2;
}
.map-placeholder {
  height: 300px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.sw.st-ok {
  background: var(--ok);
}
.sw.st-slow {
  background: var(--slow);
}
.sw.st-down {
  background: var(--down);
}
.sw.st-wrong {
  background: var(--wrong);
}
.sw.st-blocked {
  background: var(--blocked);
}
.sw.st-none {
  background: var(--land);
}
.summary-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.big-status .chip {
  font-size: 15px;
  padding: 6px 12px;
}
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
}
.kv span {
  color: var(--muted);
}
.kv b {
  text-align: right;
}

.table-scroll {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr.inactive td {
  opacity: 0.55;
}
.table tr.clickable {
  cursor: pointer;
}
.table tr.clickable:hover td,
.table tr.open td {
  background: var(--surface-2);
}
.table td.actions {
  text-align: right;
  white-space: nowrap;
}
.country {
  white-space: nowrap;
}
.w-time {
  min-width: 200px;
}
.time-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.timebar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--pending-bg);
}
.timebar span {
  display: block;
  min-width: 2px;
}
.ph-dns {
  background: var(--ph-dns);
}
.ph-connect {
  background: var(--ph-connect);
}
.ph-tls {
  background: var(--ph-tls);
}
.ph-wait {
  background: var(--ph-wait);
}
.ph-download {
  background: var(--ph-download);
}
.ph-other {
  background: var(--border-strong);
}
.legend.phases {
  margin-top: 12px;
}
.chain-row td {
  background: var(--surface-2);
  padding: 12px 16px 16px;
}
.chain {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: hop;
}
.hop {
  border-left: 3px solid var(--border-strong);
  padding: 6px 0 6px 12px;
}
.hop-redirect {
  border-left-color: var(--accent);
}
.hop-ok {
  border-left-color: var(--ok);
}
.hop-down {
  border-left-color: var(--down);
}
.hop-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.hop-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  display: grid;
  place-items: center;
  font-weight: 650;
}
.hop-code {
  font-weight: 700;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
}
.hop-code.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.hop-code.down {
  background: var(--down-bg);
  color: var(--down);
}
.hop-via {
  color: var(--muted);
  font-size: 12.5px;
}
.hop-time {
  margin-left: auto;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.hop-url {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  margin: 4px 0;
}
.hop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--muted);
}
.hop-bar {
  margin-top: 6px;
  max-width: 520px;
}
.hop-phases {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.hop-phases span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}
.seg button {
  font: inherit;
  font-size: 12.5px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  padding: 5px 12px;
  cursor: pointer;
}
.seg button + button {
  border-left: 1px solid var(--border-strong);
}
.seg button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.chart-box {
  position: relative;
  height: 320px;
}

/* ---------- Точки проверки ---------- */

.explain {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.explain .card h3 {
  margin-bottom: 6px;
}
.explain .card p {
  margin: 0;
  font-size: 13px;
}
.gp-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-bottom: 12px;
}
.gp-stats div {
  display: flex;
  flex-direction: column;
}
.gp-stats span {
  font-size: 12px;
}
.gp-stats b {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.quick {
  margin: 10px 0;
}
.gp-countries {
  columns: 3 220px;
  column-gap: 20px;
  max-height: 46vh;
  overflow: auto;
  padding: 4px;
}
.gp-group {
  break-inside: avoid;
  margin-bottom: 12px;
}
.gp-group-title {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}
.gp-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  cursor: pointer;
  font-size: 13px;
}
.gp-item.disabled {
  opacity: 0.5;
  cursor: default;
}
.foot-note {
  margin-right: auto;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
}
.steps {
  padding-left: 20px;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cmd {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 6px;
}
.cmd code {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  flex: 1;
}

/* ---------- Сотрудники и настройки ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tabs button {
  font: inherit;
  font-weight: 550;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.role-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}
.role-card .card-head {
  margin: 0;
}
.perm-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  flex: 1;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.settings-grid .card {
  margin: 0;
}
.plain-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.plain-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.chat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Модальные окна и уведомления ---------- */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 26, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal.wide {
  max-width: 900px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-body {
  padding: 16px 18px;
  overflow: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.paste {
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 10px;
}
.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.preview {
  max-height: 260px;
  overflow: auto;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.preview td {
  font-size: 12px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.toast.error {
  background: var(--down);
  color: #fff;
}

/* ---------- Адаптивность ---------- */

@media (max-width: 1100px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .split,
  .settings-grid,
  .explain {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  .topbar {
    padding: 0 12px;
    gap: 12px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding-bottom: 6px;
  }
  .nav {
    order: 3;
    width: 100%;
  }
  .me-name {
    display: none;
  }
  .page {
    padding: 14px 12px 40px;
  }
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .toolbar .search {
    width: 100%;
  }
  .toolbar select {
    flex: 1 1 40%;
  }
  .tile {
    padding: 10px 12px;
  }
  .tile-value {
    font-size: 20px;
  }
  .page-head h1 {
    font-size: 19px;
  }
  .matrix .col-link {
    min-width: 170px;
    max-width: 200px;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .info-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .matrix-wrap {
    max-height: 75vh;
  }
}

.sel-cell {
  width: 28px;
  padding-right: 0 !important;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 6px;
}
.chip.removable {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
}
.gp-countries.short {
  max-height: 34vh;
  margin-top: 10px;
}

.tag.warn-tag {
  background: var(--slow-bg);
  border-color: transparent;
  color: var(--slow);
}

.plain-link {
  color: inherit;
}
.plain-link:hover {
  color: var(--accent);
}

/* Страны проверки у ссылки */
.mode-pick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-bottom: 6px;
}
.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.mode-card input {
  margin-top: 3px;
}
.mode-card > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mode-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.gp-group-title.gp-item {
  align-items: center;
  font-size: 12px;
}
.matrix td.cell.off {
  color: var(--muted);
  text-align: center;
  opacity: 0.6;
}

/* Проверка из одной страны */
.row-actions {
  white-space: nowrap;
  text-align: right;
}
.row-actions .btn + .btn {
  margin-left: 6px;
}
.btn.icon-only {
  padding-left: 9px;
  padding-right: 9px;
}
.check-wait {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 26px 6px;
}
.spinner {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}
.check-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.sub-head {
  margin: 6px 0 10px;
  font-size: 14px;
}
