/* ServerMon — веб-панель */
:root {
  --bg: #080b14;
  --bg-2: #0c1120;
  --surface: rgba(20, 27, 45, 0.9);
  --surface-solid: #141b2d;
  --surface-2: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #e8edf7;
  --muted: #8794ac;
  --muted-2: #5c6883;
  --accent: #5b9dff;
  --accent-soft: rgba(91, 157, 255, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --crit: #f87171;
  --violet: #a78bfa;
  --cyan: #38bdf8;
  --orange: #fb923c;
  --pink: #f472b6;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.85);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(91, 157, 255, 0.16), transparent 60%),
    radial-gradient(700px 420px at 92% 4%, rgba(167, 139, 250, 0.13), transparent 62%),
    radial-gradient(800px 500px at 50% 105%, rgba(52, 211, 153, 0.07), transparent 60%);
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
::selection { background: rgba(91, 157, 255, 0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); background-clip: padding-box; }

/* ---------------- layout ---------------- */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: rgba(8, 11, 20, 0.6);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 20px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(140deg, var(--accent), var(--violet));
  display: grid; place-items: center; font-size: 19px;
  box-shadow: 0 8px 22px -8px rgba(91, 157, 255, .8);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.2px; }
.brand-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 500;
  border: 1px solid transparent; transition: .16s;
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #cfe1ff; border-color: rgba(91,157,255,.22); }
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; }
.nav-item .badge {
  margin-left: auto; background: var(--crit); color: #fff; font-size: 11px;
  padding: 1px 7px; border-radius: 20px; font-weight: 700;
}
.nav-sep { height: 1px; background: var(--line); margin: 12px 8px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; font-size: 11.5px; color: var(--muted-2); line-height: 1.7; }

.main { padding: 24px 30px 60px; min-width: 0; }

/* ---------------- header ---------------- */
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 23px; font-weight: 700; letter-spacing: -0.4px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 30px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(52,211,153,.16); }
.status-pill.warn .dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(251,191,36,.16); }
.status-pill.crit .dot { background: var(--crit); box-shadow: 0 0 0 4px rgba(248,113,113,.18); animation: pulse 1.6s infinite; }
.status-pill.info .dot { background: var(--muted); box-shadow: none; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
  padding: 8px 14px; border-radius: 11px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: .16s;
}
.btn:hover { border-color: rgba(91,157,255,.5); background: rgba(91,157,255,.1); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #7b7bff); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(248,113,113,.4); color: #ffb4b4; }
.btn.danger:hover { background: rgba(248,113,113,.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- cards ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 700; letter-spacing: .01em; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); align-items: start; }
.g-hero { grid-template-columns: 1.35fr 1fr 1fr; }
.mb { margin-bottom: 16px; }

/* ---------------- KPI ---------------- */
.kpi { display: flex; align-items: center; gap: 16px; }
.kpi-gauge { position: relative; width: 88px; height: 88px; flex: none; }
.kpi-gauge canvas { width: 88px; height: 88px; display: block; }
.kpi-gauge .val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 19px; font-weight: 700; letter-spacing: -.5px;
}
.kpi-body { min-width: 0; flex: 1; }
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.kpi-main { font-size: 17px; font-weight: 700; margin-top: 4px; letter-spacing: -.3px; }
.kpi-note { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.kpi-spark { height: 30px; margin-top: 8px; }
.kpi-spark canvas { width: 100%; height: 30px; display: block; }

/* ---------------- server card ---------------- */
.srv-row { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.srv-row:last-child { border-bottom: 0; }
.srv-row .k { color: var(--muted); min-width: 108px; }
.srv-row .v { font-weight: 600; margin-left: auto; text-align: right; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring canvas { width: 104px; height: 104px; }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.15; }
.ring .center b { font-size: 22px; letter-spacing: -.6px; }
.ring .center span { font-size: 11px; color: var(--muted); }

/* ---------------- bars ---------------- */
.bar { height: 7px; border-radius: 20px; background: rgba(255,255,255,.07); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 20px; background: var(--accent); transition: width .45s cubic-bezier(.4,0,.2,1); }
.bar.ok > i { background: linear-gradient(90deg, #34d399, #10b981); }
.bar.warn > i { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar.crit > i { background: linear-gradient(90deg, #fb7185, #ef4444); }

.core-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px 20px; }
.core { font-size: 12.5px; }
.core .top { display: flex; justify-content: space-between; margin-bottom: 5px; color: var(--muted); }
.core .top b { color: var(--text); }

/* ---------------- chart ---------------- */
.chart-box { position: relative; width: 100%; height: 300px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: rgba(10, 14, 25, .95); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 9px 11px; font-size: 12px; min-width: 130px;
  box-shadow: 0 12px 30px -10px #000; z-index: 5;
}
.chart-tip .t { color: var(--muted); margin-bottom: 5px; font-size: 11px; }
.chart-tip .r { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.chart-tip .r i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chart-tip .r b { margin-left: auto; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; background: rgba(255,255,255,.05); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  background: transparent; border: 0; color: var(--muted); font-size: 12.5px; font-weight: 600;
  padding: 6px 11px; border-radius: 8px; cursor: pointer; transition: .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: rgba(91,157,255,.2); color: #cfe1ff; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend button {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 11px; color: var(--muted); font-size: 12px; font-weight: 600; transition: .15s;
}
.legend button i { width: 9px; height: 9px; border-radius: 50%; }
.legend button.off { opacity: .38; }
.legend button:hover { border-color: var(--line-strong); color: var(--text); }

/* ---------------- tables ---------------- */
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th {
  text-align: left; color: var(--muted-2); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; font-weight: 700; padding: 0 10px 9px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.t td { padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: rgba(255,255,255,.025); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; border: 1px solid var(--line-strong); color: var(--muted);
  white-space: nowrap;
}
.tag.ok { color: #86efac; border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.1); }
.tag.warn { color: #fde68a; border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.1); }
.tag.crit { color: #fca5a5; border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.12); }
.tag.info { color: #bfdbfe; border-color: rgba(91,157,255,.35); background: rgba(91,157,255,.1); }
.tag.mute { color: var(--muted-2); }

/* ---------------- events ---------------- */
.event { display: flex; gap: 13px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; }
.event .dot.crit { background: var(--crit); }
.event .dot.warn { background: var(--warn); }
.event .dot.info { background: var(--accent); }
.event .dot.ok { background: var(--ok); }
.event .b { flex: 1; min-width: 0; }
.event .b .h { font-weight: 650; font-size: 13.5px; }
.event .b .m { color: var(--muted); font-size: 12.5px; margin-top: 3px; line-height: 1.5; }
.event .b .time { color: var(--muted-2); font-size: 11.5px; margin-top: 4px; }

.empty { text-align: center; color: var(--muted-2); padding: 36px 10px; font-size: 13.5px; }
.empty .ico { font-size: 30px; display: block; margin-bottom: 10px; opacity: .55; }

/* ---------------- forms ---------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; background: rgba(0,0,0,.28); border: 1px solid var(--line-strong);
  color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit;
  transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,157,255,.15);
}
.field .hint { font-size: 11.5px; color: var(--muted-2); margin-top: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.switch { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch .txt { flex: 1; }
.switch .txt b { display: block; font-size: 13.5px; font-weight: 650; }
.switch .txt span { font-size: 12px; color: var(--muted); }
.toggle { width: 44px; height: 25px; border-radius: 20px; background: rgba(255,255,255,.12); position: relative; cursor: pointer; transition: .2s; flex: none; border: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(19px); }

/* ---------------- toast ---------------- */
.toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 9px; z-index: 100; }
.toast {
  background: var(--surface-solid); border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 12px 16px; font-size: 13px; box-shadow: var(--shadow); max-width: 340px;
  animation: slidein .25s ease;
}
.toast.ok { border-color: rgba(52,211,153,.4); }
.toast.err { border-color: rgba(248,113,113,.45); }
@keyframes slidein { from { opacity: 0; transform: translateY(10px); } }

/* ---------------- login ---------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; z-index: 1; }
.login-card { width: 100%; max-width: 390px; }
.login-card .brand { justify-content: center; padding-bottom: 24px; }
.login-card h2 { margin: 0 0 6px; font-size: 20px; text-align: center; }
.login-card p.s { margin: 0 0 22px; text-align: center; color: var(--muted); font-size: 13px; }
.login-err { color: #fca5a5; font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }

.skeleton { background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.09), rgba(255,255,255,.04)); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; color: transparent; }
@keyframes sk { to { background-position: -200% 0; } }

.section { display: none; animation: fade .22s ease; }
.section.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; animation: pulse 2s infinite; }

.hbar { display: flex; align-items: center; gap: 10px; }
.hbar .bar { flex: 1; }
.hbar .v { font-size: 12.5px; color: var(--muted); min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }

.mount { padding: 13px 0; border-bottom: 1px solid var(--line); }
.mount:last-child { border-bottom: 0; }
.mount .top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.mount .top b { font-size: 13.5px; }
.mount .top .d { font-size: 11.5px; color: var(--muted-2); }
.mount .top .p { margin-left: auto; font-weight: 700; font-size: 13.5px; }
.mount .foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

@media (max-width: 1250px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-hero { grid-template-columns: 1fr 1fr; }
  .g-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto; flex-direction: row; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; gap: 4px; z-index: 20;
  }
  .brand, .nav-sep, .sidebar-foot { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 12px; }
  .nav-item .lbl { font-size: 13px; }
  .main { padding: 18px 14px 50px; }
  .g-4, .g-3, .g-2, .g-hero { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 19px; }
}
