:root {
  --bg: #0d1020;
  --bg-2: #141830;
  --glass: rgba(255,255,255,.06);
  --glass-border: rgba(255,255,255,.10);
  --text: #eef0fb;
  --text-dim: #a4a8c3;
  --accent-1: #7c6cff;
  --accent-2: #38d6c6;
  --gradient: linear-gradient(135deg, var(--accent-1) 0%, #ac6cff 45%, var(--accent-2) 100%);
  --danger: #ff5d7a;
  --warn: #ffb454;
  --ok: #35d68b;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 10% -10%, rgba(124,108,255,.25), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(56,214,198,.18), transparent 55%),
    var(--bg);
  min-height: 100%;
  padding-bottom: 90px; /* room for the fixed bottom nav on mobile */
}

/* Shell layout: sidebar (desktop) + main column. On mobile the nav is a
   fixed bottom bar (position:fixed removes it from this flow entirely). */
.shell { display: flex; min-height: 100%; }
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  padding: 16px 20px;
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  backdrop-filter: blur(10px);
  background: rgba(13,16,32,.65);
  border-bottom: 1px solid var(--glass-border);
}
.brand-mini { font-weight: 800; letter-spacing: .3px; }
.brand-mini span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-border);
  padding: 7px 12px; border-radius: 20px;
}
.topbar-user i { font-size: 16px; color: var(--accent-2); }

/* App main */
.app-main {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .35s ease, transform .35s ease;
}
.app-main.view-in { opacity: 1; transform: translateY(0); }

/* Dashboard grids */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 14px;
  padding: 16px 18px; backdrop-filter: blur(14px); animation: rise .4s ease both;
}
.stat-card .stat-value { font-size: 26px; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.1; }
.stat-card .stat-label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-top: 6px; font-weight: 600; }

.columns-2 { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; }

/* Cards */
.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  animation: rise .4s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.card-title { margin: 0 0 14px; font-size: 15px; letter-spacing: .3px; color: var(--text); }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title-row .card-title { margin: 0; }
.sub { color: var(--text-dim); font-size: 13px; margin: -8px 0 14px; }

/* Auth */
.auth-wrap { display: flex; flex-direction: column; align-items: center; }
.auth-card { width: 100%; max-width: 420px; text-align: center; }
.brand { font-size: 28px; margin: 4px 0 4px; }
.brand span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hint { color: var(--text-dim); font-size: 13px; margin-top: 14px; }
.hint a { color: var(--accent-2); font-weight: 600; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; margin-bottom: 14px; }
.field span { font-size: 12px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
input, textarea, select {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(124,108,255,.2); }
input[readonly] { opacity: .65; }
.grid-form { display: flex; flex-direction: column; }
.pw-wrap { display: flex; gap: 8px; }
.pw-wrap input { flex: 1; }
.pw-toggle { background: rgba(255,255,255,.06); border: 1px solid var(--glass-border); color: var(--text); border-radius: 10px; width: 42px; cursor: pointer; }

/* Buttons */
.btn {
  border: none; cursor: pointer;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px; font-weight: 600;
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s ease, filter .2s ease, opacity .2s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gradient); }
.btn-warning { background: linear-gradient(135deg, var(--warn), #ff7d5c); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #c8385a); }
.btn-ghost { background: rgba(255,255,255,.08); border: 1px solid var(--glass-border); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn.is-loading { position: relative; pointer-events: none; opacity: .85; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Ads */
.ad-box { margin-bottom: 16px; min-height: 90px; border-radius: var(--radius); overflow: hidden; }
.ad-slot { display: block; width: 100%; min-height: 90px; }
.ad-box--rail { position: sticky; top: 84px; }

/* Accordion */
.accordion { color: var(--text); overflow: hidden; }
.tab { position: relative; margin-top: 10px; border-radius: 12px; overflow: hidden; border: 1px solid var(--glass-border); }
.tab input { position: absolute; opacity: 0; z-index: -1; }
.tab__label {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; cursor: pointer;
  background: rgba(255,255,255,.05);
  font-size: 14px;
}
.tab__label::after {
  content: "\276F"; margin-left: 10px; transform: rotate(90deg);
  transition: transform .3s ease; opacity: .6;
}
.tab input:checked + .tab__label::after { transform: rotate(270deg); }
.tab__content { max-height: 0; overflow: hidden; transition: max-height .35s ease; background: rgba(0,0,0,.15); }
.tab input:checked ~ .tab__content { max-height: 600px; }
.tab__content p, .tab__content .table-responsive { padding: 14px 16px; margin: 0; }
.badge { background: var(--gradient); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.row-actions { display: flex; gap: 8px; padding: 0 16px 14px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--glass-border); }
.table td { padding: 8px; border-bottom: 1px solid rgba(255,255,255,.05); }
.table-responsive { overflow-x: auto; }

/* Search */
.input-search { max-width: 180px; }

/* Empty state */
.empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 18px 0; }

/* Skeletons */
.skeleton-row {
  height: 46px; border-radius: 10px; margin-bottom: 10px;
  background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.10) 37%, rgba(255,255,255,.04) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* Bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-col label { margin-top: 8px; font-size: 11px; color: var(--text-dim); font-weight: 600; }
.bar {
  width: 100%; max-width: 44px;
  height: var(--h, 4%);
  min-height: 4px;
  border-radius: 8px 8px 4px 4px;
  background: var(--gradient);
  position: relative;
  animation: grow .6s ease both;
  display: flex; align-items: flex-start; justify-content: center;
}
.bar span { position: absolute; top: -20px; font-size: 11px; color: var(--text-dim); font-weight: 700; }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Code box */
.code-box {
  background: #05060f; border: 1px solid var(--glass-border); border-radius: 10px;
  padding: 14px; font-size: 12px; line-height: 1.6; color: #b9f6e0;
  overflow-x: auto; white-space: pre;
}

/* Dialog */
.dialog { border: none; border-radius: var(--radius); padding: 22px; width: min(460px, 92vw); background: var(--bg-2); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(5,6,15,.6); backdrop-filter: blur(3px); }

/* Nav — mobile-first: fixed bottom bar. .nav-links uses display:contents so
   its children (.nav-tab) sit as direct flex items of .nav, same as before. */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex;
  background: rgba(13,16,32,.85);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--glass-border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav-brand { display: none; }
.nav-links { display: contents; }
.nav-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: 10px; color: var(--text-dim);
  font-size: 10.5px; text-decoration: none; background: none; border: none; cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.nav-tab i { font-size: 18px; }
.nav-tab.active { color: #fff; background: rgba(124,108,255,.18); }
.nav-tab-logout { color: var(--danger); }

/* Toasts */
.toast-host { position: fixed; top: 16px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 10px; max-width: 320px; }
.toast {
  padding: 12px 16px; border-radius: 10px; color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow);
  transform: translateX(120%); opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
}
.toast.is-in { transform: translateX(0); opacity: 1; }
.toast--success { background: linear-gradient(135deg, var(--ok), #1fae74); }
.toast--error { background: linear-gradient(135deg, var(--danger), #c8385a); }
.toast--info { background: linear-gradient(135deg, var(--accent-1), #5847d6); }

@media (max-width: 480px) {
  .toast-host { left: 16px; right: 16px; max-width: none; }
}

/* ---- Desktop dashboard layout (>= 900px): sidebar nav, wider content ---- */
@media (min-width: 900px) {
  body { padding-bottom: 0; }

  .nav {
    position: fixed; top: 0; left: 0; bottom: 0; right: auto; z-index: 10;
    width: var(--sidebar-w);
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 4px;
    padding: 22px 14px;
    border-top: none; border-right: 1px solid var(--glass-border);
  }
  .nav-brand {
    display: block; font-weight: 800; font-size: 19px;
    padding: 2px 10px 22px;
  }
  .nav-brand span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .nav-links { display: flex; flex-direction: column; gap: 4px; }
  .nav-tab {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 12px; font-size: 14px; border-radius: 10px;
  }
  .nav-tab i { font-size: 16px; width: 18px; text-align: center; }
  .nav-tab small { font-size: 13.5px; font-weight: 600; }
  .nav-tab-logout { margin-top: auto; }

  .shell-main { margin-left: 0; }
  .nav:not([hidden]) + .shell-main { margin-left: var(--sidebar-w); }
  .nav:not([hidden]) + .shell-main .brand-mini { display: none; } /* sidebar already carries the brand */
  .nav:not([hidden]) + .shell-main .topbar { justify-content: flex-end; }
  .topbar { padding: 16px 32px; }
  .app-main { padding: 28px 32px 48px; }

  .columns-2 { grid-template-columns: 380px 1fr; }
  .columns-2--equal { grid-template-columns: 1fr 1fr; }
  .card-title-row .input-search { max-width: 220px; }
}
