:root {
  --bg: #0f1419;
  --panel: #171d24;
  --panel2: #1d252e;
  --line: #2a3542;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #4da3ff;
  --ok: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text);
  text-decoration: none;
}
.brand span { color: var(--accent); }

.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
}
.top nav a:hover { background: var(--panel2); color: var(--text); }
.top nav a.active { background: var(--panel2); color: var(--text); }

.inline { display: inline; }
.link {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}
.link:hover { color: var(--text); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 22px; margin: 14px 0 18px; }
h2 { font-size: 16px; margin: 0 0 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card.warning { border-color: var(--warn); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row.tight { gap: 6px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  min-width: 120px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.pw { min-width: 110px; width: 130px; }

.btn {
  display: inline-block;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn.danger { color: var(--bad); border-color: #44262a; }
.btn.danger:hover { border-color: var(--bad); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.break { word-break: break-all; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 4px 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

.flashes { margin-bottom: 14px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
}
.flash.error { border-color: #5a2a2a; color: #ffb4b0; }
.flash.ok { border-color: #1e4a2a; color: #9be3a8; }

pre.config {
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  font-size: 12.5px;
  max-height: 420px;
}

.login-card {
  max-width: 380px;
  margin: 9vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
}
.login-card h1 { margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; }

/* ---------- мобильная раскладка ---------- */
@media (max-width: 760px) {
  body { overflow-x: hidden; }
  .wrap { padding: 14px 10px 44px; }
  h1 { font-size: 20px; margin: 10px 0 14px; }

  .top {
    padding: 8px 10px;
    gap: 6px 10px;
    align-items: center;
  }
  .top nav {
    order: 3;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0 0;
    scrollbar-width: none;
  }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { white-space: nowrap; padding: 6px 9px; }
  .top form.inline { margin-left: auto; }

  .row { flex-direction: column; align-items: stretch; gap: 12px; }
  .row > label { width: 100%; }
  .row input, .row select { width: 100%; min-width: 0; }
  .row .btn { width: 100%; }

  /* таблица → карточки */
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tbody { display: block; }
  tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel2);
    padding: 8px 12px;
    margin-bottom: 10px;
  }
  tr:last-child { margin-bottom: 0; }
  td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 5px 0;
    border: 0;
    text-align: right;
    font-size: 14px;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .4px;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 auto;
  }
  td[data-label=""]::before { content: none; display: none; }
  td:empty { display: none; }
  td.mono, td .mono { word-break: break-word; text-align: right; }

  td.right, td.actions {
    display: block;
    text-align: left;
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px solid var(--line);
  }
  td.right form, td.actions form {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  td.right .pw, td.right .btn,
  td.actions .pw, td.actions .btn { width: 100%; min-width: 0; }

  .card { padding: 14px 12px; }
  .login-card { margin-top: 4vh; padding: 20px; }
  pre.config { font-size: 11.5px; }
  .chips { gap: 4px; }
}
