:root {
  --bg: #0B0B12;
  --panel: #14141F;
  --panel2: #1B1B29;
  --line: #2A2A3D;
  --text: #ECECF4;
  --muted: #9A9AB0;
  --accent: #8B5CF6;
  --accent2: #06B6D4;
  --ok: #34D399;
  --bad: #F87171;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent2); }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; }
.logo { font-weight: 800; font-size: 19px; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo span { color: var(--muted); -webkit-text-fill-color: var(--muted); font-weight: 600; font-size: 13px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--text); text-decoration: none; padding: 9px 12px; border-radius: 10px; }
nav a:hover { background: var(--panel2); }
nav a.active { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent2); }
.logout { margin-top: auto; }
.logout button { width: 100%; }

main { padding: 28px clamp(16px, 3vw, 40px); max-width: 1200px; }
h1 { margin: 0 0 18px; font-size: 26px; }
h2 { margin: 22px 0 10px; font-size: 17px; }
h2:first-child { margin-top: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 18px; }
.card.narrow { max-width: 460px; }
.note { background: rgba(6, 182, 212, .08); border: 1px solid rgba(6, 182, 212, .3); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; color: #CFEFF6; }
.note ol { margin: 6px 0 0; padding-left: 20px; }
.muted { color: var(--muted); font-size: 13px; }
.flash { background: rgba(52, 211, 153, .12); border: 1px solid rgba(52, 211, 153, .4); padding: 10px 14px; border-radius: 12px; margin-bottom: 16px; }
.flash.error { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .45); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { font-size: 30px; }
.stat small { color: var(--muted); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.on { background: rgba(52, 211, 153, .15); color: var(--ok); }
.pill.off { background: rgba(248, 113, 113, .15); color: var(--bad); }

.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent2); }
.check span { display: flex; flex-direction: column; }
.check small, .field small { color: var(--muted); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; }
input, select, button { font: inherit; color: var(--text); }
input:not([type=checkbox]), select { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
input:invalid:not(:placeholder-shown) { border-color: var(--bad); }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 16px; cursor: pointer; }
button.primary { background: linear-gradient(90deg, var(--accent), var(--accent2)); border: 0; color: #0B0B10; font-weight: 800; margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); column-gap: 24px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; }
.table td input:not([type=checkbox]), .table td select { width: 100%; min-width: 80px; }
.table td.c { text-align: center; }
.table tr.new td { background: rgba(139, 92, 246, .06); }
.kv td { padding: 6px 12px 6px 0; }
.search { display: flex; gap: 8px; margin-bottom: 14px; max-width: 420px; }
.search input { flex: 1; }

body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo { margin-bottom: 12px; }
.login-card button { width: 100%; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); }
  nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin-top: 0; }
}

pre.log { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; }
