:root {
  --bg: #05060b;
  --bg-2: #0a0c14;
  --surface: rgba(16, 19, 30, 0.72);
  --surface-solid: #10131e;
  --surface-2: #161a28;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #eceef6;
  --text-dim: #9aa3bd;
  --text-faint: #6b7390;
  --accent: #ff4655;
  --accent-2: #ff7a86;
  --accent-glow: rgba(255, 70, 85, 0.35);
  --green: #2dd4a7;
  --green-glow: rgba(45, 212, 167, 0.3);
  --gold: #f5c44c;
  --gold-glow: rgba(245, 196, 76, 0.3);
  --purple: #a78bfa;
  --danger: #ff5c74;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 70px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
}

::selection { background: var(--accent); color: #fff; }

.hidden { display: none !important; }

/* ---------- background scene ---------- */
.app-body, .auth-body {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 70, 85, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(167, 139, 250, 0.05), transparent 60%),
    var(--bg);
}
.app-body { padding-bottom: 110px; }

.app-bg, .auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.app-bg::before, .auth-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 0%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, black 30%, transparent 75%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
}
.blob-1 { width: 460px; height: 460px; top: -160px; left: -120px; background: rgba(255, 70, 85, 0.16); animation: drift1 22s ease-in-out infinite alternate; }
.blob-2 { width: 420px; height: 420px; bottom: -180px; right: -100px; background: rgba(167, 139, 250, 0.10); animation: drift2 26s ease-in-out infinite alternate; }
.blob-3 { width: 320px; height: 320px; top: 38%; left: 60%; background: rgba(45, 212, 167, 0.06); animation: drift3 30s ease-in-out infinite alternate; }

@keyframes drift1 { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(90px, 50px) scale(1.2); } }
@keyframes drift2 { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(-70px, -60px) scale(1.15); } }
@keyframes drift3 { 0% { transform: translate(0,0); } 100% { transform: translate(-90px, 60px); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.16s ease;
  user-select: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--accent-glow); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c7263a);
  border: none;
  color: #fff;
  box-shadow: 0 10px 28px -8px var(--accent-glow);
}
.btn-primary:hover { color: #fff; filter: brightness(1.12); box-shadow: 0 14px 34px -8px var(--accent-glow); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

.btn-danger { border-color: rgba(255, 92, 116, 0.4); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span, .label { font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.4px; text-transform: uppercase; }
.input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.ok-text { color: var(--green); font-size: 13px; }

/* ---------- auth ---------- */
.auth-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 24px;
}

.auth-logo { display: flex; align-items: center; gap: 16px; animation: fadeUp 0.5s ease; }
.logo-mark {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #c7263a);
  border-radius: 15px;
  font-weight: 900; font-size: 28px; color: #fff;
  box-shadow: 0 12px 30px -6px var(--accent-glow);
  letter-spacing: 0;
  position: relative;
  overflow: hidden;
}
.logo-mark::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.25), transparent 45%);
}
.logo-mark.small { width: 36px; height: 36px; font-size: 19px; border-radius: 11px; }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-name { font-weight: 800; letter-spacing: 5px; font-size: 21px; }
.logo-sub { color: var(--text-faint); font-size: 11px; letter-spacing: 3px; text-transform: uppercase; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.5s 0.08s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.auth-tabs { display: flex; gap: 4px; padding: 5px; background: rgba(0,0,0,0.3); border-radius: 12px; margin-bottom: 24px; }
.auth-tab {
  flex: 1; padding: 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-dim);
  font-weight: 600; font-family: var(--sans); font-size: 14px; cursor: pointer;
  transition: all 0.18s ease;
}
.auth-tab.active { background: linear-gradient(135deg, var(--accent), #c7263a); color: #fff; box-shadow: 0 6px 18px -4px var(--accent-glow); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-foot {
  display: flex; align-items: center; gap: 9px;
  justify-content: center;
  color: var(--text-faint); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
}
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--green-glow); opacity: 1; }
  50% { box-shadow: 0 0 0 7px transparent; opacity: 0.75; }
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(8, 10, 16, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.logo-chip {
  font-size: 10.5px; color: var(--text-dim);
  border: 1px solid var(--border-strong); padding: 3px 9px; border-radius: 20px;
  letter-spacing: 1.5px; text-transform: uppercase;
  background: rgba(255,255,255,0.03);
}

.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2c3350, #1b2034);
  border: 1px solid var(--border-strong);
  font-size: 14px; font-weight: 700;
}
.admin-link {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; color: var(--text);
  padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(245, 196, 76, 0.05);
  transition: all 0.15s;
  font-weight: 600; font-size: 13px;
}
.admin-link:hover { border-color: var(--gold); color: var(--gold); }
.admin-logo {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold), #c98a1e);
  color: #0a0b0d; font-weight: 900; font-size: 14px;
}

/* ---------- main layout ---------- */
.app-main {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  animation: fadeUp 0.4s ease;
}
.view-title { font-size: 26px; font-weight: 800; letter-spacing: 0.4px; margin-bottom: 24px; display: flex; align-items: center; gap: 12px; }
.view-title .tag { font-size: 12px; font-weight: 600; color: var(--text-dim); background: rgba(255,255,255,0.04); border: 1px solid var(--border); padding: 4px 10px; border-radius: 20px; letter-spacing: 1px; text-transform: uppercase; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.14), transparent);
}
.stat-icon { font-size: 20px; opacity: 0.85; margin-bottom: 14px; display: block; }
.stat-card b { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat-card b small { font-size: 15px; font-weight: 600; color: var(--text-faint); }
.stat-card > span:last-child { color: var(--text-faint); font-size: 11.5px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 600; }

/* ---------- cards ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 12px 40px -18px rgba(0,0,0,0.5);
}
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; letter-spacing: 0.2px; }
.card h4 { font-size: 13px; margin: 18px 0 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.muted { color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.empty { padding: 28px 4px; text-align: center; color: var(--text-faint); }

/* ---------- copy row ---------- */
.copy-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.copy-row code {
  flex: 1;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--green);
  word-break: break-all;
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); background: rgba(0,0,0,0.22); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.table th {
  text-align: left; padding: 12px 14px;
  color: var(--text-faint); font-weight: 600; font-size: 11px;
  letter-spacing: 1.2px; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  white-space: nowrap;
  position: sticky; top: 0;
}
.table td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: rgba(255, 70, 85, 0.045); }
.table .clickable { cursor: pointer; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-strong); color: var(--text-dim);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: rgba(45, 212, 167, 0.1); color: var(--green); border-color: rgba(45, 212, 167, 0.3); }
.badge-error { background: rgba(255, 92, 116, 0.1); color: var(--danger); border-color: rgba(255, 92, 116, 0.3); }
.badge-admin { background: rgba(245, 196, 76, 0.1); color: var(--gold); border-color: rgba(245, 196, 76, 0.3); }
.badge-dim { color: var(--text-faint); }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  gap: 4px;
  padding: 7px;
  background: rgba(14, 17, 27, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.nav-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 20px;
  background: transparent; border: 0; border-radius: 16px;
  color: var(--text-faint); cursor: pointer;
  font-family: var(--sans); font-size: 10.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  transition: all 0.16s ease;
  min-width: 74px;
}
.nav-icon { font-size: 19px; line-height: 1; transition: transform 0.16s; }
.nav-item:hover { color: var(--text); }
.nav-item:hover .nav-icon { transform: translateY(-1px); }
.nav-item.active { background: linear-gradient(135deg, var(--accent), #c7263a); color: #fff; box-shadow: 0 10px 26px -8px var(--accent-glow); }

/* ---------- pager / search ---------- */
.pager { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.search-row input { min-width: 240px; }
.search-row { flex: 1; max-width: 340px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 4, 8, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: 100%; max-width: 580px; max-height: 88vh; overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.2s ease;
}
.modal-card.wide { max-width: 900px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: transparent; border: 0; color: var(--text-faint);
  font-size: 17px; cursor: pointer; width: 32px; height: 32px;
  border-radius: 9px; transition: all 0.15s;
  display: grid; place-items: center;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.kv { display: grid; gap: 2px; margin: 16px 0; }
.kv div { display: flex; justify-content: space-between; gap: 18px; padding: 9px 2px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.kv span { color: var(--text-faint); font-size: 13px; white-space: nowrap; }
.kv b { font-size: 13.5px; text-align: right; word-break: break-all; font-weight: 600; }

.file-list { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.file-link {
  color: var(--green); text-decoration: none;
  font-family: var(--mono); font-size: 13px;
  padding: 9px 12px; background: rgba(0,0,0,0.3);
  border: 1px solid var(--border); border-radius: 9px;
  display: flex; justify-content: space-between; gap: 10px;
  transition: all 0.15s;
}
.file-link span { color: var(--text-faint); }
.file-link:hover { border-color: var(--green); background: rgba(45,212,167,0.06); }

/* ---------- build ---------- */
.build-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.build-status { margin-top: 18px; font-size: 14px; font-weight: 600; }
.build-live { color: var(--gold); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.build-log {
  margin-top: 14px; max-height: 280px; overflow-y: auto;
  background: #05060c; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; font-family: var(--mono); font-size: 12px; line-height: 1.65;
  color: #a5aec9; white-space: pre-wrap; word-break: break-word;
}

/* ---------- coming soon ---------- */
.coming-soon { text-align: center; padding: 70px 30px; position: relative; overflow: hidden; }
.coming-soon::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(400px 200px at 50% 0%, rgba(255,70,85,0.06), transparent 70%);
}
.cs-icon {
  font-size: 46px; color: var(--accent); margin-bottom: 16px;
  display: inline-block; animation: floaty 3s ease-in-out infinite;
}
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.coming-soon h3 { font-size: 22px; letter-spacing: 1px; }
.coming-soon .muted { max-width: 400px; margin: 12px auto 0; }

/* ---------- check ---------- */
.check { display: flex; align-items: flex-start; gap: 11px; margin-top: 16px; font-size: 13.5px; color: var(--text-dim); cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- admin ---------- */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 0 0 22px; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  padding: 12px 22px; border-radius: 12px;
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600;
  animation: toastIn 0.2s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.ok { border-color: rgba(45,212,167,0.4); color: var(--green); }
.toast.err { border-color: rgba(255,92,116,0.4); color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 120px; margin-top: 18px; padding-top: 10px; }
.chart .bar {
  flex: 1; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--accent), rgba(255,70,85,0.15));
  min-height: 2px;
  transition: height 0.5s ease;
  position: relative;
}
.chart .bar:hover { filter: brightness(1.3); }
.chart-axis { display: flex; justify-content: space-between; color: var(--text-faint); font-size: 10px; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262c42; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #333b58; background-clip: content-box; border: 3px solid transparent; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .topbar { padding: 10px 16px; }
  .logo-chip, .admin-link span { display: none; }
  .nav-item { padding: 8px 13px; min-width: 58px; }
  .nav-item span:last-child { font-size: 9px; }
  .app-main { padding: 22px 14px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 18px; }
  .view-title { font-size: 21px; }
}