:root {
  --bg: #0b0d13;
  --bg-elevated: #11141d;
  --panel: #151926;
  --panel-2: #1a1f2f;
  --border: #242a3a;
  --border-soft: #1d2230;
  --text: #e8ebf3;
  --muted: #8d95a9;
  --muted-2: #6b7385;
  --accent: #7c6cff;
  --accent-2: #9b8cff;
  --ok: #35d29b;
  --warn: #ffb454;
  --err: #ff6b81;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(1200px 600px at 15% -10%, rgba(124, 108, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(53, 210, 155, 0.08), transparent 55%);
  background-repeat: no-repeat;
  min-height: 100vh;
}

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

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

.wrap {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 6px 0 26px;
  flex-wrap: wrap;
}

.brand { display: flex; gap: 14px; align-items: center; }

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: #120f2b;
  background: linear-gradient(135deg, var(--accent-2), var(--ok));
  box-shadow: 0 8px 30px rgba(124, 108, 255, 0.35);
}

.brand h1 { font-size: 20px; }
.brand .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; font-family: var(--mono); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: #303850; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), #6a58f0);
  border-color: #8979ff;
  color: #fff;
  box-shadow: 0 6px 22px rgba(124, 108, 255, 0.32);
}
.btn.primary:hover { filter: brightness(1.08); background: linear-gradient(180deg, var(--accent), #6a58f0); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; }

.summary {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
  padding: 0 0 18px;
  flex-wrap: wrap;
}
.summary b { color: var(--text); font-weight: 600; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(26, 31, 47, 0.9), rgba(17, 20, 29, 0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 190px;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--border);
}
.card.ready::before { background: var(--ok); }
.card.error::before { background: var(--err); }
.card.building::before { background: var(--warn); }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-top h2 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  font-size: 11.5px;
  font-weight: 650;
  padding: 4px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.ok { color: var(--ok); background: rgba(53, 210, 155, 0.1); border-color: rgba(53, 210, 155, 0.3); }
.badge.err { color: var(--err); background: rgba(255, 107, 129, 0.1); border-color: rgba(255, 107, 129, 0.3); }
.badge.busy { color: var(--warn); background: rgba(255, 180, 84, 0.1); border-color: rgba(255, 180, 84, 0.3); }
.badge.idle { color: var(--muted); background: rgba(141, 149, 169, 0.1); border-color: rgba(141, 149, 169, 0.25); }

.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.meta dt { color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 2px; }
.meta dd { margin: 0; font-size: 13px; color: #cfd5e6; font-family: var(--mono); }

.error-text, .warn-text {
  margin: 0;
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 8px;
  font-family: var(--mono);
  overflow-wrap: anywhere;
  max-height: 84px;
  overflow: auto;
}
.error-text { color: #ffc2cc; background: rgba(255, 107, 129, 0.08); border: 1px solid rgba(255, 107, 129, 0.2); }
.warn-text { color: #ffe0b3; background: rgba(255, 180, 84, 0.07); border: 1px solid rgba(255, 180, 84, 0.2); }

.card-actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 34px;
  text-align: center;
  color: var(--muted);
  background: rgba(17, 20, 29, 0.5);
}
.empty h2 { color: var(--text); font-size: 18px; margin-bottom: 8px; }
.empty code { font-family: var(--mono); background: var(--panel-2); padding: 2px 7px; border-radius: 6px; color: #cfd5e6; }

.hint { margin-top: 26px; color: var(--muted); font-size: 13.5px; }
.hint summary { cursor: pointer; color: #cfd5e6; }
.hint ul { margin: 10px 0 0; padding-left: 20px; }
.hint li { margin: 5px 0; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-box {
  width: min(920px, 100%);
  max-height: 82vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-head h2 { font-size: 15px; }
.modal-body {
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #c7cedf;
}

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.center-box {
  width: min(720px, 100%);
  text-align: center;
  background: rgba(17, 20, 29, 0.7);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 42px 34px;
}
.center-box h1 { font-size: 22px; margin-bottom: 10px; }
.center-box .muted { color: var(--muted); }
.center-box .mono { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.center-box .btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.center-box pre {
  text-align: left;
  background: #0a0c11;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px;
  max-height: 300px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: #b9c0d4;
  margin-top: 18px;
}

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(124, 108, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin: 0 auto 22px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

/* ─────────────────────────── вход ─────────────────────────── */

.login-box { max-width: 420px; }
.login-logo { margin: 0 auto 18px; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.login-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0d1017;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.18); }
.login-form .btn { justify-content: center; }
.login-error {
  margin: 16px 0 0;
  padding: 9px 12px;
  border-radius: 9px;
  color: #ffc2cc;
  background: rgba(255, 107, 129, 0.1);
  border: 1px solid rgba(255, 107, 129, 0.25);
  font-size: 13px;
}

/* ─────────────────────────── доступы ─────────────────────────── */

.access {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(13, 16, 23, 0.55);
}
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.access-label { color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.access-form { display: flex; gap: 6px; }
.access-form input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1017;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.access-form input:focus { border-color: var(--accent); }
.token {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent-2);
  overflow-wrap: anywhere;
  text-align: right;
}

