:root {
  --bg: #030d0c;
  --side: rgba(4, 19, 18, .78);
  --surface: rgba(10, 34, 31, .62);
  --surface-2: rgba(18, 52, 47, .6);
  --line: rgba(127, 255, 219, .1);
  --line-strong: rgba(127, 255, 219, .26);
  --mint: #74f7d3;
  --mint-deep: #1f8f76;
  --text: #e2faf3;
  --muted: #83a9a0;
  --amber: #f4c46a;
  --rose: #ff7185;
  --sky: #8ab8ff;
  --display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --side-w: 264px;
  color-scheme: dark;
  box-sizing: border-box;
}
*, *::before, *::after { box-sizing: inherit; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; }
.muted { color: var(--muted); }
svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.aurora { position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 34% at 20% 10%, rgba(116, 247, 211, .13), transparent 70%),
    radial-gradient(34% 40% at 90% 88%, rgba(31, 143, 118, .17), transparent 70%);
  animation: drift 30s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate3d(-3%, 2%, 0) scale(1.05); } }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 11px; font: 600 17px var(--display); letter-spacing: .02em; }
.mark { position: relative; width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: conic-gradient(from 0deg, var(--mint), var(--mint-deep), rgba(116,247,211,.15), var(--mint));
  -webkit-mask: radial-gradient(circle, transparent 6px, #000 7px); mask: radial-gradient(circle, transparent 6px, #000 7px);
  filter: drop-shadow(0 0 8px rgba(116, 247, 211, .6)); animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- controls ---------- */
label { display: grid; align-content: start; gap: 6px; font-size: 13px; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); opacity: .85; }
input, select { font: inherit; color: var(--text); background: rgba(0, 0, 0, .35); width: 100%;
  border: 1px solid var(--line-strong); border-radius: 11px; padding: 10px 12px; min-width: 0;
  transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus { border-color: var(--mint); outline: none; box-shadow: 0 0 0 4px rgba(116, 247, 211, .1); }
input::placeholder { color: rgba(131, 169, 160, .55); }

.btn { font: 600 14px var(--body); border-radius: 11px; padding: 9px 16px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  transition: background .2s, border-color .2s, color .2s, transform .12s; }
.btn:hover { border-color: var(--mint); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--mint); color: #042019; border-color: var(--mint); }
.btn-primary:hover { background: #a3fce4; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: transparent; background: var(--surface-2); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn-danger:hover { border-color: var(--rose); color: var(--rose); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.loading::before { content: ""; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor;
  border-right-color: transparent; animation: spin .7s linear infinite; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--muted); transition: background .2s, color .2s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { font: 600 13px var(--body); border: 0; background: transparent; color: var(--muted); padding: 6px 12px;
  border-radius: 9px; cursor: pointer; transition: background .2s, color .2s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.seg button b { font-weight: 600; color: var(--mint); margin-left: 4px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(440px, 100%); padding: 34px 32px 30px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 24px; backdrop-filter: blur(16px); box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  animation: card-in .7s var(--ease) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.auth-card .brand { font-size: 22px; margin-bottom: 6px; }
.auth-card .mark { width: 30px; height: 30px; -webkit-mask: radial-gradient(circle, transparent 8px, #000 9px); mask: radial-gradient(circle, transparent 8px, #000 9px); }
.auth-card h2 { font-size: 18px; margin: 22px 0 4px; }
.auth-card > p { margin: 0 0 20px; color: var(--muted); }
.stack { display: grid; gap: 14px; }
.stack > .btn-sm { justify-self: start; }
.form-error { color: var(--rose); min-height: 1.3em; margin: 0; font-size: 13.5px; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }

.steps { display: flex; gap: 6px; margin: 22px 0 0; }
.steps span { flex: 1; height: 4px; border-radius: 999px; background: rgba(127, 255, 219, .1); overflow: hidden; position: relative; }
.steps span::after { content: ""; position: absolute; inset: 0; background: var(--mint); transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease); }
.steps span.done::after { transform: scaleX(1); }
.step-pane { animation: pane-in .45s var(--ease) both; }
.step-pane.back { animation-name: pane-back; }
@keyframes pane-in { from { opacity: 0; transform: translateX(26px); } }
@keyframes pane-back { from { opacity: 0; transform: translateX(-26px); } }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; min-height: 22px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: calc(22px + env(safe-area-inset-top, 0px)) 14px calc(16px + env(safe-area-inset-bottom, 0px));
  border-right: 1px solid var(--line); background: var(--side); backdrop-filter: blur(18px); overflow-y: auto; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.side-close { display: none; }
.nav { position: relative; display: grid; gap: 2px; }
.nav a { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px;
  text-decoration: none; color: var(--muted); font-weight: 500; transition: color .2s; }
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); }
.nav a svg { width: 19px; height: 19px; flex: none; transition: color .2s, transform .3s var(--ease); }
.nav a.active svg { color: var(--mint); }
.nav a:hover svg { transform: translateX(2px); }
.nav-pill { position: absolute; left: 0; right: 0; top: 0; height: 0; border-radius: 11px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line), inset 3px 0 0 var(--mint); pointer-events: none; opacity: 0;
  transition: transform .45s var(--ease), height .45s var(--ease), opacity .3s; }
.nav-group { margin: 16px 12px 4px; font-size: 12px; color: var(--muted); opacity: .6; }
.nav-group:first-of-type { margin-top: 0; }
.badge { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--mint); min-width: 20px; text-align: center; }
.badge:empty { display: none; }
.badge.bad { color: #1a0306; background: var(--rose); border-radius: 999px; padding: 0 7px; line-height: 19px; animation: pop .4s var(--ease); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.side-foot { margin-top: auto; display: grid; gap: 10px; }
.conn { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .2); }
.conn b { color: var(--text); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 4px 0 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 600 13px var(--display);
  color: #042019; background: linear-gradient(135deg, var(--mint), var(--mint-deep)); flex: none; }
.me-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.scrim { display: none; }

.main { padding: 28px 34px 64px; min-width: 0; }
.top { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.top-text { flex: 1; min-width: 200px; }
.top h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.top p { margin: 4px 0 0; font-size: 14px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.burger { display: none; }

/* ---------- blocks ---------- */
.view { display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.two { grid-template-columns: 1.3fr 1fr; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px;
  backdrop-filter: blur(12px); min-width: 0; }
.panel h2 { margin: 0 0 16px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel h2 small { font: 400 13px var(--body); color: var(--muted); }
.panel > p:last-child { margin-bottom: 0; }
.kpi { position: relative; overflow: hidden; }
.kpi p { margin: 0; color: var(--muted); font-size: 13.5px; }
.kpi .num { font: 500 34px/1.15 var(--display); margin: 10px 0 8px; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(116, 247, 211, .3); }
.kpi .num small { font-size: 20px; color: var(--muted); text-shadow: none; }
.kpi .num.accent { color: var(--mint); }
.kpi .sub { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.kpi::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(116, 247, 211, .09), transparent 70%); pointer-events: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; position: relative; }
.dot.ok { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.dot.bad { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
.dot.warn { background: var(--amber); }
.dot.live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 2s var(--ease) infinite; }
@keyframes ping { 70%, 100% { transform: scale(2.8); opacity: 0; } }

.banner { display: flex; gap: 10px; align-items: flex-start; border: 1px solid rgba(255, 113, 133, .4); background: rgba(255, 113, 133, .08);
  color: #ffc9d1; border-radius: 14px; padding: 12px 16px; }
.banner a { color: var(--text); font-weight: 600; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 6px 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .2s; }
tbody tr:hover { background: rgba(127, 255, 219, .03); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 13px; margin-top: 1px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.ok { background: rgba(116, 247, 211, .12); color: var(--mint); }
.tag.bad { background: rgba(255, 113, 133, .14); color: var(--rose); }
.tag.warn { background: rgba(244, 196, 106, .14); color: var(--amber); }
.tag.info { background: rgba(138, 184, 255, .14); color: var(--sky); }
.tag.off { background: rgba(131, 169, 160, .14); color: var(--muted); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 48px 86px 1fr; gap: 10px; align-items: baseline; padding: 9px 0; font-size: 14px;
  border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.feed .tag { justify-self: start; }
.day { font: 500 13px var(--display); color: var(--muted); margin: 18px 0 4px; }
.day:first-child { margin-top: 0; }

/* bars & chart */
.bars { display: grid; gap: 13px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 48px; gap: 12px; align-items: center; font-size: 14px; }
.bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 7px; border-radius: 999px; background: rgba(127, 255, 219, .08); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint-deep), var(--mint)); transform-origin: left; }
.chart svg { width: 100%; height: 150px; display: block; overflow: visible; }
.chart rect { transition: opacity .2s; }
.chart rect:hover { opacity: .75; }
.chart-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 10px; gap: 10px; flex-wrap: wrap; }
.chart-empty { height: 150px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px;
  border: 1px dashed var(--line-strong); border-radius: 14px; padding: 0 20px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 240px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 22px 0 6px; margin: 0; text-align: center; }

/* forms in settings */
.form { display: grid; gap: 16px; max-width: 640px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.env-note { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.env-note svg { width: 16px; height: 16px; flex: none; }
.env-note code, code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; color: var(--text);
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 7px; padding: 2px 7px; }

/* skeleton */
.skel { border-radius: 18px; background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 300% 100%; animation: shimmer 1.4s linear infinite; border: 1px solid var(--line); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- анимации появления: только при переходе, не при автообновлении ---------- */
.view.enter [data-a] { animation: rise-in .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 65ms); }
.view.enter tbody tr { animation: fade-in .45s var(--ease) both; animation-delay: calc(120ms + var(--r, 0) * 22ms); }
.view.enter .feed li { animation: slide-in .45s var(--ease) both; animation-delay: calc(150ms + var(--r, 0) * 45ms); }
.view.enter .bar i { animation: grow 1s var(--ease) both; animation-delay: .25s; }
.view.enter .chart rect { transform-box: fill-box; transform-origin: bottom; animation: rise-bar .7s var(--ease) both;
  animation-delay: calc(200ms + var(--r, 0) * 18ms); }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-10px); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes rise-bar { from { transform: scaleY(0); } }
.view.leave { opacity: 0; transform: translateY(6px); transition: opacity .15s, transform .15s; }

.toast { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 50; padding: 11px 16px;
  border-radius: 13px; background: #0f2e29; border: 1px solid var(--line-strong); display: flex; gap: 9px; align-items: center;
  opacity: 0; transform: translateY(14px) scale(.97); transition: opacity .25s var(--ease), transform .35s var(--ease);
  pointer-events: none; max-width: calc(100vw - 40px); box-shadow: 0 14px 40px rgba(0, 0, 0, .4); }
.toast.show { opacity: 1; transform: none; }
.toast.err { border-color: var(--rose); }

/* ---------- адаптив ---------- */
@media (max-width: 1150px) { .two { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100%;
    transform: translateX(-104%); transition: transform .4s var(--ease); background: rgba(4, 19, 18, .96); }
  .shell.menu-open .side { transform: none; box-shadow: 30px 0 80px rgba(0, 0, 0, .5); }
  .side-close { display: inline-grid; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .5); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .shell.menu-open .scrim { opacity: 1; pointer-events: auto; }
  .burger { display: inline-grid; margin-left: -6px; }
  .main { padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(50px + env(safe-area-inset-bottom, 0px)); }
  .top { align-items: center; gap: 10px; }
  .top h1 { font-size: 20px; }
  .top p { display: none; }
  .top-actions { width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .panel { padding: 16px; border-radius: 16px; }
  .kpi .num { font-size: 25px; }
  .form-grid { grid-template-columns: 1fr; }
  .feed li { grid-template-columns: 44px 1fr; }
  .feed .tag { grid-column: 2; grid-row: 1; }
  .feed li > span:last-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
