/* FRG — оформление панели. Без внешних ресурсов: только системные шрифты. */

* { box-sizing: border-box; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --text: #101828;
  --muted: #667085;
  --accent: #2f5cff;
  --accent-hover: #1f4ae6;
  --accent-weak: #eef2ff;
  --ok: #067647;
  --ok-weak: #ecfdf3;
  --warn: #b54708;
  --warn-weak: #fffaeb;
  --danger: #b42318;
  --danger-weak: #fef3f2;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 1px 3px rgba(16, 24, 40, .05);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e12;
    --surface: #14171d;
    --surface-2: #191d24;
    --line: #242a34;
    --line-strong: #313846;
    --text: #e9ecf1;
    --muted: #98a1b0;
    --accent: #6f8dff;
    --accent-hover: #8aa2ff;
    --accent-weak: #1a2136;
    --ok: #4ade80;
    --ok-weak: #10231a;
    --warn: #fbbf24;
    --warn-weak: #241d0d;
    --danger: #f87171;
    --danger-weak: #2a1313;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- шапка ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  height: 60px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  color: #fff; font-size: 14px; font-weight: 700;
}

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 14px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-weak); color: var(--accent); }

.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; color: var(--muted); }

/* ---------- контейнер ---------- */

.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.container.narrow { max-width: 720px; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; font-weight: 650; }
.page-head .sub { margin-top: 6px; color: var(--muted); font-size: 14px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.back { display: inline-block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }

/* ---------- карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .hint { margin-left: auto; color: var(--muted); font-size: 13px; }

h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }

/* ---------- KPI ---------- */

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--muted); }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  height: 38px; padding: 0 15px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px; font-weight: 550;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--surface); }
.btn-danger:hover { background: var(--danger-weak); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- формы ---------- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; }
.field .help { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

input[type=text], input[type=password], input[type=number], input[type=email], textarea, select {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14.5px;
}
textarea { height: auto; min-height: 80px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input.mono { font-family: var(--mono); font-size: 13px; }
input[readonly] { background: var(--surface-2); color: var(--muted); }

.code-input { display: flex; gap: 8px; }
.code-input input { flex: 1; }

/* ---------- таблица ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); padding: 12px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table a.row { color: inherit; }
.table .num { text-align: right; white-space: nowrap; }

.identity { display: flex; align-items: center; gap: 12px; }
.identity .name { font-weight: 600; }
.identity .meta { color: var(--muted); font-size: 12.5px; font-family: var(--mono); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 650; font-size: 14px;
  background: var(--accent-weak); color: var(--accent);
}
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.avatar.a1 { background: #eef2ff; color: #3538cd; }
.avatar.a2 { background: #ecfdf3; color: #067647; }
.avatar.a3 { background: #fff6ed; color: #b93815; }
.avatar.a4 { background: #f4f3ff; color: #5925dc; }
.avatar.a5 { background: #fdf2fa; color: #c11574; }
.avatar.a6 { background: #f0f9ff; color: #026aa2; }

@media (prefers-color-scheme: dark) {
  .avatar.a1 { background: #1c2140; color: #a4b4ff; }
  .avatar.a2 { background: #10241a; color: #6ee7a8; }
  .avatar.a3 { background: #2a1a10; color: #f0a882; }
  .avatar.a4 { background: #241a3d; color: #b9a5ff; }
  .avatar.a5 { background: #2b1322; color: #f0a1cf; }
  .avatar.a6 { background: #0e2233; color: #7cc7ec; }
}

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

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 550;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-weak); color: var(--ok); }
.pill.off { background: var(--danger-weak); color: var(--danger); }
.pill.muted { background: var(--surface-2); color: var(--muted); }
.pill.muted::before { display: none; }

/* ---------- прогресс ---------- */

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progress.warn > i { background: #f79009; }
.progress.bad > i { background: var(--danger); }
.progress.thin { height: 6px; border: 0; }

/* ---------- прочее ---------- */

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.big { font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.alert { padding: 11px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.alert.error { background: var(--danger-weak); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.alert.ok { background: var(--ok-weak); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.alert.warn { background: var(--warn-weak); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }

.qr { background: #fff; padding: 12px; border-radius: 12px; border: 1px solid var(--line); display: inline-block; }
.qr img { display: block; width: 200px; height: 200px; }

.empty { text-align: center; padding: 48px 20px; }
.empty .icon {
  width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 14px;
  display: grid; place-items: center; background: var(--accent-weak); color: var(--accent);
}
.empty h3 { margin: 0 0 6px; font-size: 16px; }
.empty p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; align-items: start; }
.grid > .col { min-width: 0; }

dl.kv { margin: 0; display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

ol.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
ol.steps li { position: relative; padding-left: 34px; margin-bottom: 14px; font-size: 14px; }
ol.steps li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: -1px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 650;
  background: var(--accent-weak); color: var(--accent);
}
ol.steps li:last-child { margin-bottom: 0; }

details { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
details summary { cursor: pointer; font-size: 14px; font-weight: 550; }
details[open] summary { margin-bottom: 10px; }

.connect { display: grid; grid-template-columns: 190px 1fr; gap: 20px; align-items: start; }
.connect .qr img { width: 170px; height: 170px; }
.connect ol.steps li { font-size: 13.5px; margin-bottom: 10px; }
@media (max-width: 620px) {
  .connect { grid-template-columns: 1fr; }
  .connect .qr { margin: 0 auto; }
}

.server-list { display: grid; gap: 10px; }
.server {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13.5px;
}
.server .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.server .host { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 12.5px; }

.links { display: flex; gap: 8px; flex-wrap: wrap; }
.links a {
  padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 13px; color: var(--text); background: var(--surface-2);
}
.links a:hover { border-color: var(--line-strong); text-decoration: none; }

/* ---------- вход ---------- */

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 20px;
  background:
    radial-gradient(1000px 500px at 50% -180px, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-md); padding: 28px;
}
.auth-card .brand { justify-content: center; margin-bottom: 6px; }
.auth-card h1 { font-size: 20px; text-align: center; margin: 12px 0 6px; letter-spacing: -.01em; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.auth-card .qr { display: block; margin: 0 auto 14px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.code { font-family: var(--mono); font-size: 15px; letter-spacing: .08em; text-align: center;
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 9px; padding: 10px; }

/* ---------- приглашение ---------- */

.invite { max-width: 460px; margin: 0 auto; padding: 28px 20px 48px; }
.invite .hero { text-align: center; margin-bottom: 20px; }
.invite .hero h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -.02em; }
.invite .hero p { color: var(--muted); margin: 0; font-size: 14.5px; }
.invite .qr { display: block; text-align: center; }
.invite .qr img { width: 220px; height: 220px; margin: 0 auto; }

footer.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 0; }

/* ---------- адаптив ---------- */

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; gap: 10px; }
  .nav { display: none; }
  .container { padding: 20px 14px 48px; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 12px 14px; }
  .table td { border: 0; padding: 3px 0; }
  .table .num { text-align: left; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 8px; }
}
