:root {
  --bg: #0a0a0d;
  --bg2: #0f0f14;
  --panel: #14141b;
  --panel2: #1a1a23;
  --line: #24242f;
  --line2: #30303d;
  --text: #ededf2;
  --muted: #8d8d9e;
  --dim: #5f5f70;
  --accent: #7c5cff;
  --accent2: #a48bff;
  --accent-bg: rgba(124, 92, 255, .12);
  --green: #33d69f;
  --green-bg: rgba(51, 214, 159, .12);
  --amber: #f5b546;
  --amber-bg: rgba(245, 181, 70, .12);
  --red: #ff5f72;
  --red-bg: rgba(255, 95, 114, .12);
  --blue: #53a8ff;
  --blue-bg: rgba(83, 168, 255, .12);
  --r: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; flex: none; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: rgba(124, 92, 255, .35); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg2), var(--bg));
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, #9c82ff, var(--accent) 60%, #4b2fd6);
  box-shadow: 0 6px 24px rgba(124, 92, 255, .35);
}
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: var(--muted); font-weight: 500; font-size: 14px; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.nav a.on svg { color: var(--accent2); }
.nav .cnt {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px; font-size: 12px; text-align: center;
  background: var(--accent-bg); color: var(--accent2); font-weight: 600;
}
.nav .cnt:empty { display: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }
.pulse-card {
  padding: 12px 13px; border-radius: 13px; background: var(--panel); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); line-height: 1.45;
}
.pulse-card b { color: var(--text); font-weight: 600; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); margin-right: 6px; vertical-align: 1px; }
.dot.live { background: var(--green); box-shadow: 0 0 0 0 rgba(51, 214, 159, .6); animation: ping 1.6s infinite; }
.dot.off { background: var(--red); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(51, 214, 159, .5); } 70% { box-shadow: 0 0 0 7px rgba(51, 214, 159, 0); } 100% { box-shadow: 0 0 0 0 rgba(51, 214, 159, 0); } }

.main { min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; padding: 18px 32px;
  background: rgba(10, 10, 13, .82); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.top p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.top .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 26px 32px 120px; max-width: 980px; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi { padding: 15px 16px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); }
.kpi small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.kpi b { font-size: 24px; letter-spacing: -.02em; font-weight: 650; }
.kpi em { font-style: normal; color: var(--dim); font-size: 13px; margin-left: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 11px; border: 1px solid var(--line2);
  background: var(--panel2); color: var(--text); font-size: 14px; font-weight: 550;
  cursor: pointer; white-space: nowrap; transition: transform .08s, background .15s, border-color .15s, opacity .15s;
  text-decoration: none;
}
.btn:hover { background: #22222d; border-color: #3a3a4a; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(124, 92, 255, .28); }
.btn.primary:hover { background: #8a6dff; }
.btn.green { background: var(--green); border-color: transparent; color: #04140e; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel); color: var(--text); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn.danger { color: var(--red); }
.btn .spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- filter chips ---------- */
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.chip {
  height: 32px; padding: 0 13px; border-radius: 99px; border: 1px solid var(--line2); background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 550; cursor: pointer;
}
.chip.on { background: var(--text); color: #0a0a0d; border-color: var(--text); }
.bar .sp { flex: 1; }

/* ---------- cards ---------- */
.list { display: flex; flex-direction: column; gap: 14px; }
.card {
  border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
  padding: 18px 20px; transition: border-color .2s, opacity .3s, transform .3s;
}
.card:hover { border-color: var(--line2); }
.card.leaving { opacity: 0; transform: translateX(24px); }
.card-h { display: flex; align-items: center; gap: 12px; }
.ava {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  color: #fff; flex: none; text-transform: uppercase;
}
.who { min-width: 0; flex: 1; }
.who a { color: var(--text); font-weight: 650; font-size: 15px; }
.who .meta { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none;
  font-weight: 750; font-size: 17px; letter-spacing: -.02em;
}
.score.hi { background: var(--green-bg); color: var(--green); }
.score.mid { background: var(--amber-bg); color: var(--amber); }
.score.lo { background: var(--panel2); color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 13px 0 0; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 7px;
  font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--muted);
}
.tag.t-auto { background: var(--accent-bg); color: var(--accent2); }
.tag.t-edu { background: var(--blue-bg); color: var(--blue); }
.tag.t-topic { background: var(--amber-bg); color: var(--amber); }
.tag.t-err { background: var(--red-bg); color: var(--red); }
.tag.t-ok { background: var(--green-bg); color: var(--green); }
.post-text {
  margin: 13px 0 0; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
}
.post-text.open { -webkit-line-clamp: unset; }
.more { background: none; border: 0; padding: 4px 0 0; color: var(--accent2); font-size: 13px; cursor: pointer; }
.why { margin: 10px 0 0; font-size: 13px; color: var(--muted); display: flex; gap: 7px; align-items: flex-start; }
.why svg { margin-top: 2px; color: var(--accent2); }
.err-line { margin: 10px 0 0; font-size: 13px; color: var(--red); }

.reply { margin-top: 16px; border-top: 1px dashed var(--line2); padding-top: 14px; }
.reply label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 7px; letter-spacing: .02em; text-transform: uppercase; }
textarea, input[type=text], input[type=password], input[type=number], select {
  width: 100%; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg2);
  padding: 11px 13px; font-size: 14.5px; line-height: 1.5; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 84px; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .18); }
.reply-f { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.reply-f .cnt { font-size: 12px; color: var(--dim); font-family: var(--mono); }
.reply-f .cnt.over { color: var(--red); }
.reply-f .sp { flex: 1; }
.sent-box { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--green-bg); color: #bff3e0; font-size: 14px; white-space: pre-wrap; }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); border: 1px dashed var(--line2); border-radius: 18px; }
.empty svg { margin: 0 auto 14px; color: var(--dim); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------- tables / rows ---------- */
.rows { border-radius: 18px; border: 1px solid var(--line); overflow: hidden; background: var(--panel); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .q { flex: 1; min-width: 0; font-weight: 550; }
.row .q small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.row.off .q { color: var(--dim); }
.grp-h { padding: 10px 16px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--bg2); border-top: 1px solid var(--line); }
.grp-h:first-child { border-top: 0; }
.add-row { display: flex; gap: 8px; margin-bottom: 16px; }
.add-row input { flex: 1; }
.add-row select { width: 170px; }

.toggle { position: relative; width: 40px; height: 24px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line2); cursor: pointer; transition: background .2s; }
.toggle span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(16px); }

.run { display: grid; grid-template-columns: 150px 1fr auto; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); align-items: start; }
.run:first-child { border-top: 0; }
.run .t { color: var(--muted); font-size: 13px; }
.run .t b { display: block; color: var(--text); font-size: 14px; }
.run .nums { display: flex; flex-wrap: wrap; gap: 6px; }
.run .log { grid-column: 2 / 4; font-size: 12.5px; color: var(--muted); white-space: pre-wrap; font-family: var(--mono); margin-top: -4px; }

/* ---------- settings ---------- */
.sec { border-radius: 18px; border: 1px solid var(--line); background: var(--panel); padding: 20px 22px; margin-bottom: 16px; }
.sec h3 { margin: 0 0 4px; font-size: 16px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.sec > p { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fld label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 550; }
.fld .hint { font-size: 12px; color: var(--dim); margin-top: 5px; }
.sw { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line); }
.sw:first-of-type { border-top: 0; }
.sw b { display: block; font-weight: 550; font-size: 14px; }
.sw small { color: var(--muted); font-size: 12.5px; }
.sec-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; }
.status-pill.ok { background: var(--green-bg); color: var(--green); }
.status-pill.no { background: var(--red-bg); color: var(--red); }
.status-pill.warn { background: var(--amber-bg); color: var(--amber); }
.note {
  border-radius: 14px; padding: 14px 16px; font-size: 13.5px; line-height: 1.55; margin-bottom: 16px;
  background: var(--amber-bg); color: #f7d9a3; border: 1px solid rgba(245, 181, 70, .25);
}
.note.info { background: var(--accent-bg); color: #d6ccff; border-color: rgba(124, 92, 255, .28); }
.note b { color: #fff; }
.steps { margin: 8px 0 0; padding-left: 18px; }
.steps li { margin: 4px 0; }
.copy-line {
  display: flex; align-items: center; gap: 8px; margin: 6px 0; padding: 8px 10px; border-radius: 10px;
  background: rgba(0,0,0,.25); font-family: var(--mono); font-size: 12.5px; word-break: break-all;
}
.copy-line span { flex: 1; }
.copy-line button { background: none; border: 0; color: var(--accent2); cursor: pointer; padding: 2px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(800px 500px at 50% -10%, rgba(124, 92, 255, .22), transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; padding: 30px 28px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.auth-card .brand { padding: 0 0 22px; }
.auth-card h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.auth-card p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }
.auth-card .fld { margin-bottom: 12px; }
.auth-card .btn { width: 100%; height: 44px; margin-top: 6px; }
.auth-card code { font-family: var(--mono); font-size: 12px; background: var(--bg2); padding: 2px 6px; border-radius: 6px; color: var(--accent2); }
.auth-err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast {
  max-width: 360px; padding: 12px 15px; border-radius: 13px; font-size: 14px; background: #1e1e28; border: 1px solid var(--line2);
  box-shadow: 0 16px 40px rgba(0,0,0,.45); animation: tin .25s ease-out;
}
.toast.ok { border-color: rgba(51, 214, 159, .4); }
.toast.err { border-color: rgba(255, 95, 114, .45); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- mobile ---------- */
.tabbar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .top { padding: 14px 16px; }
  .top p { display: none; }
  .content { padding: 16px 14px 110px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .run { grid-template-columns: 1fr; }
  .run .log { grid-column: 1; }
  .add-row { flex-direction: column; }
  .add-row select { width: 100%; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); background: rgba(12, 12, 16, .92);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); text-decoration: none; position: relative; padding: 4px 0; }
  .tabbar a.on { color: var(--text); }
  .tabbar a.on svg { color: var(--accent2); }
  .tabbar .cnt { position: absolute; top: -2px; left: 55%; background: var(--accent); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }
  .tabbar .cnt:empty { display: none; }
  #toasts { left: 14px; right: 14px; bottom: 84px; }
  .toast { max-width: none; }
}
