@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg: #050b09;
  --bg-2: #0a1612;
  --glass: rgba(18, 32, 27, 0.62);
  --glass-2: rgba(28, 46, 39, 0.7);
  --line: rgba(140, 255, 190, 0.10);
  --line-2: rgba(140, 255, 190, 0.20);
  --text: #eafff3;
  --muted: #8aa89a;
  --accent: #3ef08a;
  --accent-2: #19c46a;
  --accent-glow: rgba(62, 240, 138, 0.35);
  --blue: #6ea8ff;
  --amber: #ffc14d;
  --red: #ff6b6b;
  --radius: 18px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- stadium background ---------- */
.stadium { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 120%, #0f2e20 0%, transparent 70%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.012) 0 90px, transparent 90px 180px),
    linear-gradient(180deg, #06100c 0%, #071510 55%, #0a1d15 100%); }
.stadium::before { /* pitch markings */
  content: ''; position: absolute; inset: -5% -5%;
  background: center / min(1400px, 140vw) auto no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1050 680' fill='none' stroke='%2378ffb4' stroke-opacity='0.09' stroke-width='3'%3E%3Crect x='25' y='25' width='1000' height='630' rx='4'/%3E%3Cline x1='525' y1='25' x2='525' y2='655'/%3E%3Ccircle cx='525' cy='340' r='92'/%3E%3Ccircle cx='525' cy='340' r='4' fill='%2378ffb4' fill-opacity='0.12'/%3E%3Crect x='25' y='138' width='165' height='404'/%3E%3Crect x='25' y='248' width='55' height='184'/%3E%3Crect x='860' y='138' width='165' height='404'/%3E%3Crect x='970' y='248' width='55' height='184'/%3E%3Cpath d='M190 270a92 92 0 0 1 0 140M860 270a92 92 0 0 0 0 140'/%3E%3C/svg%3E");
  transform: perspective(1200px) rotateX(48deg) translateY(12%); transform-origin: 50% 100%;
  mask-image: linear-gradient(180deg, transparent 0%, #000 45%); }
.light { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(90px); opacity: .55; }
.light.l1 { top: -30vmax; left: -18vmax; background: radial-gradient(circle, rgba(62,240,138,.45), transparent 60%); animation: drift 22s ease-in-out infinite alternate; }
.light.l2 { top: -32vmax; right: -20vmax; background: radial-gradient(circle, rgba(110,168,255,.35), transparent 60%); animation: drift 26s ease-in-out infinite alternate-reverse; }
.light.l3 { bottom: -38vmax; left: 25%; background: radial-gradient(circle, rgba(62,240,138,.18), transparent 60%); animation: drift 30s ease-in-out infinite alternate; }
.grain { position: absolute; inset: 0; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"); }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(6vmax, 4vmax) scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .light { animation: none !important; } * { transition: none !important; } }

/* ---------- basics ---------- */
h1, h2, h3 { font-family: var(--display); margin: 0 0 .6rem; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: #002313; }

input, select {
  background: rgba(3, 10, 7, .55); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px;
  padding: .7rem .85rem; font: inherit; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #5f7a6d; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  background: var(--glass-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 11px;
  padding: .55rem 1rem; font: 600 .92rem var(--font); cursor: pointer; white-space: nowrap;
  transition: transform .12s, border-color .15s, background .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { border-color: rgba(140,255,190,.4); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #022614; box-shadow: 0 6px 22px var(--accent-glow); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 30px rgba(62,240,138,.5); border-color: transparent; }
.btn-danger { color: #ffb3b3; border-color: rgba(255,107,107,.35); background: rgba(80, 16, 20, .55); }
.btn-danger:hover:not(:disabled) { border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; padding: .9rem; font-size: 1rem; }
.form-error { color: #ffb3b3; min-height: 1.3em; margin: .5rem 0 0; font-size: .92rem; }

.card {
  position: relative; background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 18px; min-width: 0;
  backdrop-filter: blur(16px) saturate(130%); -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 20px 50px rgba(0,0,0,.35);

}
.card::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(140,255,190,.12), transparent 35%); mask: linear-gradient(#000, transparent 60%); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 2.2rem 1.6rem 1.6rem; border-radius: 26px; }
.crest { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto .9rem; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #0c8f4b); box-shadow: 0 10px 40px var(--accent-glow); }
.crest img { width: 40px; height: 40px; }
.login-card h1 { font-size: 1.7rem; }
.kicker { font: 600 .72rem var(--display); letter-spacing: .18em; text-transform: uppercase; color: var(--accent); margin-bottom: .35rem; }
#pin { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.scoreboard { display: flex; justify-content: center; gap: 8px; margin: 1.4rem 0 1.2rem; padding: .85rem; border-radius: 16px;
  background: rgba(0,0,0,.45); border: 1px solid var(--line); box-shadow: inset 0 2px 12px rgba(0,0,0,.6); }
.scoreboard span { width: 30px; height: 40px; border-radius: 8px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
  display: grid; place-items: center; transition: .18s; }
.scoreboard span.filled { background: rgba(62,240,138,.12); border-color: rgba(62,240,138,.45); }
.scoreboard span.filled::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 1rem; }
.keypad button { background: rgba(255,255,255,.035); border: 1px solid var(--line); color: var(--text);
  font: 600 1.4rem var(--display); padding: .85rem 0; border-radius: 14px; cursor: pointer; transition: .12s; }
.keypad button:hover { border-color: rgba(62,240,138,.5); background: rgba(62,240,138,.07); }
.keypad button:active { transform: scale(.95); background: rgba(62,240,138,.16); }
.keypad .key-alt { color: var(--muted); font-size: 1.1rem; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
.secure-note { display: flex; align-items: center; justify-content: center; gap: .4rem; margin-top: 1rem; }

/* ---------- dashboard layout ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .75rem max(16px, calc((100% - 1160px) / 2));
  background: rgba(5, 11, 9, .65); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; font: 700 1.05rem var(--display); }
.brand .crest { width: 34px; height: 34px; border-radius: 10px; margin: 0; box-shadow: 0 4px 18px var(--accent-glow); }
.brand .crest img { width: 22px; height: 22px; }
.live { font: 600 .68rem var(--font); letter-spacing: .1em; color: var(--accent); border: 1px solid rgba(62,240,138,.35);
  padding: .1rem .45rem; border-radius: 999px; display: inline-flex; align-items: center; gap: .3rem; }
.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.tabs { display: flex; gap: .2rem; flex: 1; justify-content: center; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; color: var(--muted); padding: .5rem .9rem; border-radius: 10px; font: 500 .93rem var(--font);
  cursor: pointer; white-space: nowrap; position: relative; transition: color .15s, background .15s; }
.tabs button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tabs button.active { color: var(--text); background: rgba(62,240,138,.1); }
.tabs button.active::after { content: ''; position: absolute; left: 22%; right: 22%; bottom: 2px; height: 2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.container { max-width: 1160px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: .5rem 0 1.2rem; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0; }
.grid { display: grid; gap: 18px; }
.grid > .card { margin-bottom: 0; }
.grid.stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
.grid.two { grid-template-columns: 1.3fr 1fr; margin-bottom: 18px; }
.grid.half { grid-template-columns: 1fr 1fr; margin-bottom: 18px; }

/* stat tiles */
.stat { display: flex; flex-direction: column; gap: .15rem; overflow: hidden; }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 1.1rem; margin-bottom: .55rem;
  background: rgba(62,240,138,.1); border: 1px solid rgba(62,240,138,.22); }
.stat.warn .stat-icon { background: rgba(255,193,77,.1); border-color: rgba(255,193,77,.3); }
.stat.blue .stat-icon { background: rgba(110,168,255,.1); border-color: rgba(110,168,255,.3); }
.stat-value { font: 700 2.1rem/1.1 var(--display); letter-spacing: -.02em; }
.stat.warn .stat-value { color: var(--amber); }
.stat-label { color: var(--muted); font-size: .86rem; }

/* week chart */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 150px; margin-top: .6rem; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: .35rem; height: 100%; justify-content: end; }
.bar { width: 100%; max-width: 38px; border-radius: 8px 8px 4px 4px; min-height: 4px;
  background: linear-gradient(180deg, var(--accent), rgba(25,196,106,.35)); box-shadow: 0 0 18px rgba(62,240,138,.25); transition: height .5s ease; }
.bar.zero { background: rgba(255,255,255,.07); box-shadow: none; }
.bar-n { font: 600 .78rem var(--display); }
.bar-day { font-size: .72rem; color: var(--muted); }

/* bot status */
.bot-row { display: flex; gap: .9rem; align-items: center; }
.avatar { border-radius: 50%; background: var(--glass-2); flex: none; border: 2px solid rgba(62,240,138,.25); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: .2rem; }
.dot.on { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dot.off { background: var(--red); box-shadow: 0 0 10px var(--red); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin-top: 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.top { margin: 0; padding: 0; list-style: none; display: grid; gap: .45rem; counter-reset: rank; }
.top li { display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border-radius: 11px; background: rgba(255,255,255,.025); counter-increment: rank; }
.top li::before { content: counter(rank); font: 700 .85rem var(--display); width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: rgba(62,240,138,.12); color: var(--accent); }
.top .n { margin-left: auto; font: 600 .85rem var(--display); color: var(--muted); }

/* users */
.checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.check { display: inline-flex; align-items: center; gap: .45rem; background: rgba(255,255,255,.03); border: 1px solid var(--line-2);
  padding: .45rem .75rem; border-radius: 10px; cursor: pointer; font: .88rem var(--mono); transition: .15s; user-select: none; }
.check:hover { border-color: rgba(62,240,138,.45); }
.check:has(input:checked) { background: rgba(62,240,138,.1); border-color: rgba(62,240,138,.5); }
.check.all { font-family: var(--font); font-weight: 600; }
.check input { accent-color: var(--accent); margin: 0; }
.add-row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: rgba(110,168,255,.1); color: #b9d3ff; border: 1px solid rgba(110,168,255,.25); border-radius: 999px; padding: .08rem .6rem; font: .78rem var(--mono); }
.chip.all { background: rgba(62,240,138,.1); color: #9cf7c4; border-color: rgba(62,240,138,.3); font-family: var(--font); font-weight: 600; }
.user-row { display: flex; gap: .9rem; align-items: flex-start; padding: 1rem .25rem; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-main { flex: 1; min-width: 0; display: grid; gap: .35rem; overflow-wrap: anywhere; }
.user-name { font-weight: 600; }
.user-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty .big { font-size: 2rem; display: block; margin-bottom: .3rem; }

/* commands */
.cmd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.cmd-card { display: flex; flex-direction: column; gap: .5rem; margin: 0; }
.cmd-name { font: 600 1.15rem var(--mono); color: var(--accent); }
.cmd-card .switch { margin-top: auto; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; border-radius: 14px; padding: .65rem .8rem;
  font: 600 .92rem var(--font); cursor: pointer; border: 1px solid; transition: .2s; color: var(--text); }
.switch .track { width: 44px; height: 24px; border-radius: 999px; position: relative; flex: none; transition: .2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch.locked { background: rgba(62,240,138,.08); border-color: rgba(62,240,138,.4); }
.switch.locked .track { background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.switch.locked .track::after { left: 23px; }
.switch.open { background: rgba(255,193,77,.08); border-color: rgba(255,193,77,.4); }
.switch.open .track { background: #5a4a22; }
.switch.open .track::after { left: 3px; }

/* tables */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input { width: 220px; }
.auto { display: inline-flex; gap: .4rem; align-items: center; color: var(--muted); margin-left: auto; font-size: .9rem; }
.auto input { accent-color: var(--accent); }
.table-wrap { overflow-x: auto; margin: 0 -.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font: 600 .74rem var(--font); letter-spacing: .08em; text-transform: uppercase; padding: .55rem .6rem; border-bottom: 1px solid var(--line-2); }
td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(62,240,138,.035); }
td.details { color: var(--muted); overflow-wrap: anywhere; min-width: 240px; }
tr.warn-row td { background: rgba(255,107,107,.05); }
.badge { padding: .14rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; border: 1px solid; }
.badge.success { background: rgba(62,240,138,.1); color: #9cf7c4; border-color: rgba(62,240,138,.3); }
.badge.denied { background: rgba(255,193,77,.1); color: #ffd98a; border-color: rgba(255,193,77,.3); }
.badge.error { background: rgba(255,107,107,.1); color: #ffb3b3; border-color: rgba(255,107,107,.3); }
.linkish { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font: inherit; font-weight: 500; text-align: left; overflow-wrap: anywhere; }
.linkish:hover { text-decoration: underline; }
.cmd-tag { font: .85rem var(--mono); color: var(--accent); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }

/* security */
.session { padding: .8rem .2rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; display: grid; gap: .15rem; }
.session:first-child { border-top: 0; }
#logout-all { margin-top: .9rem; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 24px); z-index: 50;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #022614; box-shadow: 0 10px 30px var(--accent-glow);
  padding: .75rem 1.2rem; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; font-weight: 700; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: linear-gradient(135deg, #ff7b7b, #d63c3c); color: #fff; box-shadow: 0 10px 30px rgba(255,107,107,.4); }

@media (max-width: 960px) {
  .cmd-grid { grid-template-columns: 1fr; }
  .grid.two, .grid.half { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { gap: .5rem; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .grid.stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-value { font-size: 1.7rem; }
  .user-row { flex-wrap: wrap; }
  .user-actions { width: 100%; justify-content: flex-start; }
  .filters input { width: 100%; }
  .auto { margin-left: 0; }
  .add-row { grid-template-columns: 1fr; }
}
.stack { display: grid; gap: .8rem; }
.flush { margin: 0; }
@media (max-height: 720px) {
  .login-body { place-items: start center; }
  .login-card { padding: 1.4rem 1.4rem 1.1rem; margin: 8px 0; }
  .crest { width: 52px; height: 52px; margin-bottom: .6rem; }
  .scoreboard { margin: 1rem 0 .9rem; padding: .6rem; }
  .keypad { gap: 8px; }
  .keypad button { padding: .6rem 0; font-size: 1.25rem; }
}
[data-panel] { animation: rise .4s ease both; }
.login-card { animation: rise .45s ease both; }
td .linkish { white-space: nowrap; overflow-wrap: normal; }
