
:root {
  --bg: #f3f5fa; --surface: #ffffff; --surface2: #f7f8fc; --border: #e3e7f0; --border2: #d3d9e6;
  --text: #1c2333; --muted: #68728c; --hint: #8a93a6; --accent: #3d5afe; --accent2: #2c45d8;
  --accent-soft: #eef1fe; --ok: #2fb36d; --ok-soft: #e6f7ee; --warn: #e6a23c; --warn-soft: #fdf3e2;
  --danger: #e5484d; --danger-soft: #fdeeee; --header: #141a2e; --shadow: 0 1px 2px rgba(20,26,46,.06), 0 4px 16px rgba(20,26,46,.05);
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "DejaVu Sans Mono", Menlo, monospace;
}
:root[data-theme="dark"] {
  --bg: #0e1220; --surface: #161b2c; --surface2: #1a2033; --border: #252c42; --border2: #343d58;
  --text: #e6e9f2; --muted: #9aa3bd; --hint: #7a84a0; --accent: #5b74ff; --accent2: #6f85ff;
  --accent-soft: #1e2752; --ok-soft: #16352a; --warn-soft: #3a2e18; --danger-soft: #33191f; --header: #0a0d18;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--hint); }
.hidden { display: none !important; }
.i { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.pill .i { width: 13px; height: 13px; }
.secure-note .i { width: 16px; height: 16px; }
.card-head .i { color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hint { color: var(--hint); font-size: 12px; }

/* --- вход --- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% 10%, #2a3a8f 0%, transparent 60%), radial-gradient(900px 500px at 90% 90%, #1b4d8f 0%, transparent 60%), var(--header); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; padding: 34px 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .logo { width: 52px; height: 52px; }
.login-card h1 { margin: 16px 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.field { position: relative; margin-bottom: 14px; }
.field input { width: 100%; padding: 12px 44px 12px 14px; border: 1px solid var(--border2); border-radius: 10px; background: var(--surface); outline: none; font-size: 15px; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .eye { position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--muted); }
.field .eye:hover { background: var(--surface2); }
.login-error { color: var(--danger); min-height: 20px; margin: 4px 0 10px; font-size: 13px; }
.secure-note { display: flex; gap: 8px; align-items: center; margin-top: 18px; color: var(--hint); font-size: 12px; }

/* --- кнопки --- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border2);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface2); border-color: var(--hint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border2)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(255,255,255,.08); }

/* --- каркас --- */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 0 22px; height: 60px; background: var(--header); color: #fff; }
.top .logo { width: 32px; height: 32px; }
.top .brand { font-weight: 650; font-size: 17px; }
.top .brand small { color: #8f9bbf; font-weight: 400; font-size: 12px; margin-left: 8px; }
.top .chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 11px; border-radius: 999px; background: rgba(255,255,255,.08); color: #dfe4f5; font-size: 13px; }
.top .spacer { flex: 1; }
.top .btn { color: #dfe4f5; border-color: #2c3554; background: transparent; }
.top .btn:hover { background: #1f2742; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; flex: none; }
.dot.off { background: var(--hint); } .dot.bad { background: var(--danger); } .dot.warn { background: var(--warn); }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 60px); }
.nav { padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface); scrollbar-width: none;
       position: sticky; top: 60px; z-index: 4; align-self: start; height: calc(100vh - 60px); overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 500; margin-bottom: 2px; cursor: pointer; }
.nav a svg { width: 18px; height: 18px; color: var(--muted); }
.nav a:hover { background: var(--surface2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active svg { color: var(--accent); }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--hint); }
.nav a.active .count { color: var(--accent); }
.main { padding: 26px 30px 40px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head .grow { flex: 1; }

/* --- карточки и таблицы --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.stat .value { font-size: 28px; font-weight: 650; margin-top: 6px; }
.stat .value small { font-size: 15px; color: var(--hint); font-weight: 500; }
.stat .sub { color: var(--hint); font-size: 12px; margin-top: 2px; }
.stat.good .value { color: var(--ok); } .stat.bad .value { color: var(--danger); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .grow { flex: 1; }
.card-body { padding: 16px 18px; }
.card-body p { margin: 0 0 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--hint); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface2); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
.dev-name { font-weight: 600; }
.dev-id { font-family: var(--mono); color: var(--muted); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.off { background: var(--surface2); color: var(--muted); }
.pill.bad { background: var(--danger-soft); color: var(--danger); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.empty { padding: 36px 18px; text-align: center; color: var(--hint); }
.empty svg { width: 40px; height: 40px; color: var(--border2); display: block; margin: 0 auto 10px; }
.search { position: relative; }
.search input { padding: 8px 12px 8px 34px; border: 1px solid var(--border2); border-radius: 999px; background: var(--surface); width: 260px; outline: none; }
.search input:focus { border-color: var(--accent); }
.search svg { position: absolute; left: 11px; top: 9px; width: 16px; height: 16px; color: var(--hint); }
.seg { display: inline-flex; border: 1px solid var(--border2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.events li:last-child { border-bottom: 0; }
.events .time { color: var(--hint); font-size: 12px; white-space: nowrap; min-width: 104px; padding-top: 1px; font-family: var(--mono); }
.events .ico { width: 18px; height: 18px; flex: none; color: var(--accent); margin-top: 1px; }
.events li.warn .ico { color: var(--warn); }
.key-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px dashed var(--border2); border-radius: 10px; background: var(--surface2); font-family: var(--mono); font-size: 17px; letter-spacing: .5px; margin-bottom: 12px; overflow-wrap: anywhere; }
.key-box .grow { flex: 1; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; padding: 7px 0; align-items: flex-start; }
.checklist svg { width: 18px; height: 18px; color: var(--ok); flex: none; margin-top: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-grid input { width: 100%; padding: 9px 12px; border: 1px solid var(--border2); border-radius: 9px; background: var(--surface); outline: none; }
.form-grid input:focus { border-color: var(--accent); }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

/* --- окно подтверждения и уведомления --- */
.modal { position: fixed; inset: 0; background: rgba(10,13,24,.55); display: grid; place-items: center; z-index: 20; padding: 20px; }
.dialog { background: var(--surface); border-radius: 16px; max-width: 460px; width: 100%; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dialog h3 { margin: 0 0 8px; font-size: 18px; }
.dialog p { margin: 0 0 20px; color: var(--muted); }
.dialog .buttons { display: flex; justify-content: flex-end; gap: 10px; }
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 30; align-items: center; }
.toast { background: var(--header); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); border-left: 4px solid var(--accent); max-width: 560px; }
.toast.ok { border-left-color: var(--ok); } .toast.err { border-left-color: var(--danger); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .nav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; height: auto; }
  .nav a { margin: 0 2px; white-space: nowrap; }
  .nav a .count { display: none; }
  .main { padding: 18px 14px 30px; }
  .grid2, .form-grid { grid-template-columns: 1fr; }
  .top .chip.addr, .top .brand small { display: none; }
  .search, .search input { width: 100%; }
  .hide-sm { display: none; }
  .seg { max-width: 100%; overflow-x: auto; }
  td.actions .t { display: none; }
  td.actions .btn { padding: 6px 8px; }
  td, th { padding: 10px 10px; }
}
