:root {
  --bg: #0b0f17; --panel: #131a26; --panel-2: #192233; --line: #25314a;
  --text: #e6ebf5; --muted: #8b97ad; --accent: #4f8cff; --accent-2: #7c5cff;
  --ok: #2fd08a; --bad: #ff5d6c; --warn: #f5b942; --radius: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f5fa; --panel: #fff; --panel-2: #eef1f8; --line: #dbe1ee;
    --text: #1a2234; --muted: #62708a; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3f5fa; --panel: #fff; --panel-2: #eef1f8; --line: #dbe1ee;
  --text: #1a2234; --muted: #62708a; color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0; font-weight: 600; }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p { color: var(--muted); margin: 0 0 20px; }

/* Каркас */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 0 10px 16px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 var(--accent); }
.side .spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; padding: 0 10px 8px; }
.main { padding: 28px clamp(16px, 3vw, 48px); width: 100%; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }

/* Карточки и таблицы */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.empty { color: var(--muted); padding: 18px 4px; }

/* Элементы */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); } .badge.bad { color: var(--bad); } .badge.warn { color: var(--warn); }
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
label { display: block; margin: 0 0 12px; color: var(--muted); font-size: 13px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.error { color: var(--bad); min-height: 1.4em; margin: 6px 0; font-size: 14px; }
.back { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; margin-bottom: 8px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
pre.secret { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 10px 0; }

/* Окно */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal-box h3 { font-size: 18px; margin-bottom: 12px; }
.notice { background: var(--panel-2); border-left: 3px solid var(--warn); padding: 10px 12px; border-radius: 6px; font-size: 14px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 10px 0 4px; }
  .who, .side .spacer { display: none; }
  .main { padding: 16px; }
}
.gap { margin-bottom: 20px; }
.wide { width: 100%; }
