:root {
  --bg: #05060a;
  --panel: #0d1018;
  --panel2: #121722;
  --line: rgba(255,255,255,.08);
  --text: #eef2f7;
  --muted: #7d8799;
  --accent: #2fe0c5;
  --accent-dim: rgba(47,224,197,.14);
  --danger: #ff5d6c;
  --ok: #3dd68c;
  --warn: #f0b429;
  --radius: 14px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Syne", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --side: 236px;
  --ease: cubic-bezier(.22,1,.36,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body { overflow: hidden; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#bgCanvas {
  position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%;
  pointer-events: none;
}
.vignette {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,.55) 100%);
}

.toast {
  position: fixed; top: 20px; left: 50%; z-index: 50;
  transform: translateX(-50%) translateY(-8px);
  padding: 12px 18px; border-radius: 12px;
  background: rgba(13,16,24,.94); border: 1px solid rgba(47,224,197,.35);
  backdrop-filter: blur(12px); font-weight: 600; font-size: .9rem;
  opacity: 0; transition: .3s var(--ease); pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: rgba(255,93,108,.45); color: #ffb4bc; }

.screen {
  position: relative; z-index: 1;
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  padding: 36px 32px;
  background: rgba(13,16,24,.82);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(18px);
  animation: rise .5s var(--ease);
}
.brand-mark {
  display: flex; gap: 14px; align-items: center; margin-bottom: 28px;
}
.brand-mark h1 {
  margin: 0; font-family: var(--display); font-size: 1.45rem; letter-spacing: -.03em;
}
.brand-mark p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

.form, .stack { display: flex; flex-direction: column; gap: 12px; }
label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
input {
  background: #080a10; border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 14px; color: var(--text); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus {
  border-color: rgba(47,224,197,.5);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.btn {
  border: 0; border-radius: 11px; padding: 11px 18px;
  font-weight: 700; cursor: pointer;
  transition: transform .15s var(--ease), background .2s, border-color .2s, color .2s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn.wide { width: 100%; }
.btn.primary {
  background: var(--accent); color: #04120f;
  box-shadow: 0 10px 28px rgba(47,224,197,.2);
}
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.btn.ghost:hover { color: var(--text); border-color: rgba(255,255,255,.2); }
.btn.danger {
  background: transparent; color: var(--danger); border: 1px solid rgba(255,93,108,.35);
}
.btn.danger:hover { background: rgba(255,93,108,.1); }
.btn.sm { padding: 6px 10px; font-size: .75rem; border-radius: 8px; }
.err { margin: 12px 0 0; color: var(--danger); font-size: .88rem; }

.shell {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: var(--side) 1fr;
  height: 100dvh; animation: rise .4s var(--ease);
}
.side {
  display: flex; flex-direction: column; gap: 8px;
  padding: 20px 12px;
  background: rgba(8,10,16,.78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.side-brand {
  display: flex; gap: 10px; align-items: center; padding: 6px 10px 18px;
}
.side-brand strong {
  display: block; font-family: var(--display); font-size: .95rem; letter-spacing: -.02em;
}
.side-brand span { color: var(--muted); font-size: .72rem; }
.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow: auto; }
.nav-btn {
  appearance: none; border: 0; background: transparent; text-align: left;
  color: var(--muted); padding: 11px 12px; border-radius: 11px;
  font-weight: 600; cursor: pointer; transition: .2s;
}
.nav-btn:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-btn.on { color: var(--accent); background: var(--accent-dim); }
.side-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 8px 4px; border-top: 1px solid var(--line); margin-top: 8px;
}
.role {
  font-size: .65rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-dim); padding: 5px 9px; border-radius: 999px;
}

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.main-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px 10px; flex-shrink: 0;
}
.main-head h1 {
  margin: 0; font-family: var(--display); font-size: 1.55rem; letter-spacing: -.04em;
}
.live {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  font-family: var(--mono); font-size: .72rem; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 0 rgba(61,214,140,.5); animation: pulse 1.8s infinite; }
.dot.bad { background: var(--danger); }

.panels { flex: 1; min-height: 0; padding: 8px 28px 28px; }
.panel {
  display: none; flex-direction: column; gap: 12px; height: 100%; min-height: 0;
}
.panel.on { display: flex; animation: rise .35s var(--ease); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  background: rgba(13,16,24,.75); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 18px; min-height: 128px;
  display: flex; flex-direction: column; justify-content: flex-end;
  transition: transform .25s var(--ease), border-color .25s;
}
.stat:hover { transform: translateY(-3px); border-color: rgba(47,224,197,.28); }
.stat b { font-family: var(--display); font-size: 2rem; letter-spacing: -.04em; }
.stat span { margin-top: 6px; color: var(--muted); font-size: .82rem; }

.bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: rgba(13,16,24,.7); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; flex-shrink: 0;
}
.bar label { min-width: 96px; }
.bar label.grow, .stack label.grow { flex: 1; min-width: 160px; }
.stack {
  background: rgba(13,16,24,.7); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; flex-shrink: 0;
}

.flash {
  padding: 11px 14px; border-radius: 11px;
  background: rgba(61,214,140,.08); border: 1px solid rgba(61,214,140,.25);
  color: var(--ok); font-family: var(--mono); font-size: .78rem;
  white-space: pre-wrap; word-break: break-all;
}

.ver-row { color: var(--muted); font-size: .9rem; }
.ver-row strong { color: var(--accent); font-family: var(--mono); font-weight: 500; }

.drop {
  position: relative; min-height: 132px; border-radius: 16px;
  border: 1.5px dashed rgba(47,224,197,.35); background: rgba(47,224,197,.04);
  display: grid; place-content: center; text-align: center; gap: 4px; cursor: pointer;
  transition: .25s var(--ease);
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-dim); transform: scale(1.01); }
.drop strong { font-size: 1rem; }
.drop > span { color: var(--muted); font-size: .82rem; }
.drop-prog {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 8px;
  background: rgba(5,6,10,.9); border-radius: 16px;
}
.drop-prog div {
  width: 180px; height: 5px; border-radius: 99px; background: #1a2030; overflow: hidden; position: relative;
}
.drop-prog div::after {
  content: ""; position: absolute; inset: 0; width: 40%; background: var(--accent);
  animation: slide 1s linear infinite;
}
.drop-prog span { font-family: var(--mono); font-size: .75rem; color: var(--accent); }

.perms {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px;
}
.perms label {
  flex-direction: row; align-items: center; gap: 8px;
  text-transform: none; letter-spacing: 0; font-size: .88rem; color: var(--text); font-weight: 500;
}
.perms input { width: auto; accent-color: var(--accent); }

.table-wrap {
  flex: 1; min-height: 0; overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(13,16,24,.7);
}
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); }
th {
  position: sticky; top: 0; background: #10141e; color: var(--muted);
  font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; z-index: 1;
}
td { color: #c7ceda; }
.mono { font-family: var(--mono); font-size: .78rem; color: var(--accent); }
tr:hover td { background: rgba(255,255,255,.02); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.pill.ok { background: rgba(61,214,140,.12); color: var(--ok); }
.pill.warn { background: rgba(240,180,41,.12); color: var(--warn); }
.pill.bad { background: rgba(255,93,108,.12); color: var(--danger); }
.pill.muted { background: rgba(255,255,255,.06); color: var(--muted); }

.log-list {
  flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px;
}
.log-item {
  background: rgba(13,16,24,.75); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; transition: border-color .2s;
}
.log-item.open { border-color: rgba(47,224,197,.3); }
.log-sum {
  width: 100%; appearance: none; border: 0; background: transparent;
  display: grid; grid-template-columns: 150px 120px 1fr 20px;
  gap: 12px; align-items: center; text-align: left;
  padding: 14px 16px; cursor: pointer; color: var(--text); font-weight: 600;
}
.log-sum:hover { background: rgba(255,255,255,.03); }
.log-sum .chev {
  justify-self: end; color: var(--muted);
  transition: transform .25s var(--ease);
}
.log-item.open .chev { transform: rotate(90deg); color: var(--accent); }
.log-type { font-family: var(--mono); font-size: .78rem; color: var(--accent); font-weight: 500; }
.log-user { color: var(--text); }
.log-time { color: var(--muted); font-size: .8rem; font-weight: 500; }
.log-detail {
  display: none; padding: 0 16px 14px;
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: .78rem; color: var(--muted);
  line-height: 1.7;
}
.log-item.open .log-detail { display: block; animation: rise .25s var(--ease); }
.log-detail b { color: var(--text); font-weight: 600; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61,214,140,.45); }
  50% { box-shadow: 0 0 0 6px rgba(61,214,140,0); }
}
@keyframes slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(280%); }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .shell { grid-template-columns: 1fr; height: auto; min-height: 100dvh; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .panels { padding: 8px 16px 24px; }
  .log-sum { grid-template-columns: 1fr 1fr; }
  .log-sum .chev { grid-column: 2; }
}
