:root{
  color-scheme:light;
  --app-bg:#f5f7fb;
  --surface:#ffffff;
  --surface-soft:#f8fafc;
  --surface-muted:#eff4fb;
  --line:#dbe4f0;
  --line-strong:#cbd5e1;
  --text:#0f172a;
  --text-muted:#64748b;
  --brand:#2563eb;
  --brand-strong:#1d4ed8;
  --brand-soft:#dbeafe;
  --danger:#ef4444;
  --shadow:0 14px 34px rgba(15,23,42,.08);
  --shadow-soft:0 10px 26px rgba(15,23,42,.06);
  --input-bg:#ffffff;
  --input-text:#0f172a;
  --topbar-bg:rgba(255,255,255,.86);
  --topbar-border:rgba(219,228,240,.9);
  --mobile-overlay:rgba(2,6,23,.55);
}

html.theme-dark{
  color-scheme:dark;
  --app-bg:#081120;
  --surface:#0f1b2d;
  --surface-soft:#122038;
  --surface-muted:#16253f;
  --line:#223554;
  --line-strong:#2f4568;
  --text:#e6edf8;
  --text-muted:#96a7c2;
  --brand:#60a5fa;
  --brand-strong:#3b82f6;
  --brand-soft:rgba(59,130,246,.16);
  --danger:#f87171;
  --shadow:0 18px 44px rgba(0,0,0,.28);
  --shadow-soft:0 14px 34px rgba(0,0,0,.22);
  --input-bg:#091427;
  --input-text:#f8fbff;
  --topbar-bg:rgba(6,16,32,.86);
  --topbar-border:rgba(34,53,84,.9);
  --mobile-overlay:rgba(2,6,23,.72);
}

html,
body{
  background:var(--app-bg);
  color:var(--text);
}

body{
  transition:background-color .2s ease,color .2s ease;
}

.container--wide{
  max-width:1480px;
  width:min(1480px, calc(100% - 40px));
  margin:0 auto;
}

@media (max-width:900px){
  .container--wide{
    width:calc(100% - 24px);
  }
}

.topbar{
  position:sticky;
  top:0;
  z-index:2000;
  background:var(--topbar-bg);
  border-bottom:1px solid var(--topbar-border);
  backdrop-filter:blur(14px);
  box-shadow:0 1px 0 rgba(255,255,255,.35);
}

.topbar__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:12px 0;
}

.topbar__left{
  display:flex;
  align-items:center;
  gap:14px;
  min-width:280px;
  flex:0 0 auto;
}

.topbar__center{
  flex:1 1 auto;
  display:flex;
  justify-content:center;
  min-width:0;
}

.topbar__center .nav{
  display:flex;
  align-items:center;
  gap:14px;
}

.topbar__right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  min-width:280px;
  flex:0 0 auto;
}

.topbar__actions{
  display:flex;
  align-items:center;
  gap:10px;
}

.topbar__burger{
  display:none;
  width:44px;
  height:44px;
  border-radius:14px;
  border:1px solid var(--line);
  background:var(--surface);
  color:var(--text);
  cursor:pointer;
  align-items:center;
  justify-content:center;
  position:relative;
  z-index:3001;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
  padding:0;
  box-shadow:var(--shadow-soft);
}

.topbar__burger:hover{
  background:var(--surface-soft);
  border-color:var(--line-strong);
}

.burgerLines{
  width:20px;
  height:14px;
  position:relative;
  display:block;
}

.burgerLines i{
  position:absolute;
  left:0;
  right:0;
  height:2px;
  background:currentColor;
  border-radius:2px;
  transition:transform .18s ease,opacity .18s ease,top .18s ease;
}

.burgerLines i:nth-child(1){ top:0; }
.burgerLines i:nth-child(2){ top:6px; }
.burgerLines i:nth-child(3){ top:12px; }

.topbar__burger[aria-expanded="true"] .burgerLines i:nth-child(1){
  top:6px;
  transform:rotate(45deg);
}

.topbar__burger[aria-expanded="true"] .burgerLines i:nth-child(2){
  opacity:0;
}

.topbar__burger[aria-expanded="true"] .burgerLines i:nth-child(3){
  top:6px;
  transform:rotate(-45deg);
}

.userbar{
  display:flex;
  align-items:center;
  gap:10px;
}

.userbar__who{
  display:flex;
  align-items:center;
  gap:10px;
}

.userbar__name{
  font-weight:800;
  color:var(--text);
}

.themeToggle{
  appearance:none;
  border:0;
  background:transparent;
  padding:0;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.themeToggle:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:3px;
  border-radius:999px;
}

.themeToggle__track{
  position:relative;
  width:62px;
  height:36px;
  border-radius:999px;
  background:linear-gradient(180deg, #eef4ff 0%, #dde8fb 100%);
  border:1px solid #d5e2f6;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.75), 0 10px 24px rgba(37,99,235,.14);
  display:inline-flex;
  align-items:center;
  justify-content:space-between;
  padding:0 10px;
  box-sizing:border-box;
  transition:background .22s ease,border-color .22s ease,box-shadow .22s ease;
}

.themeToggle__thumb{
  position:absolute;
  top:3px;
  left:3px;
  width:28px;
  height:28px;
  border-radius:50%;
  background:linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow:0 4px 12px rgba(15,23,42,.16);
  transition:transform .22s ease,background .22s ease,box-shadow .22s ease;
}

.themeToggle__icon{
  position:relative;
  z-index:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:14px;
  height:14px;
}

.themeToggle__icon svg{
  width:14px;
  height:14px;
  display:block;
}

.themeToggle__icon--sun{
  color:#f59e0b;
}

.themeToggle__icon--moon{
  color:#7c8ba3;
}

html.theme-dark .themeToggle__track{
  background:linear-gradient(180deg, #162845 0%, #0f1d33 100%);
  border-color:#28415f;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.04), 0 10px 24px rgba(0,0,0,.22);
}

html.theme-dark .themeToggle__thumb{
  transform:translateX(26px);
  background:linear-gradient(180deg, #dbe6ff 0%, #c6d4f5 100%);
  box-shadow:0 4px 14px rgba(59,130,246,.18);
}

html.theme-dark .themeToggle__icon--sun{
  color:#6f88ac;
}

html.theme-dark .themeToggle__icon--moon{
  color:#f8fbff;
}

.mnavOverlay{
  position:fixed;
  inset:0;
  background:var(--mobile-overlay);
  backdrop-filter:blur(2px);
  display:none;
  z-index:3000;
}

.mnavOverlay.is-open{
  display:block;
}

.mnavPanel{
  position:fixed;
  top:0;
  right:0;
  height:100vh;
  width:min(360px, 92vw);
  background:var(--surface);
  border-left:1px solid var(--line);
  box-shadow:-18px 0 40px rgba(0,0,0,.18);
  transform:translateX(105%);
  transition:transform .22s ease;
  z-index:3002;
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.mnavPanel.is-open{
  transform:translateX(0);
}

.mnavHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding-bottom:10px;
  border-bottom:1px solid var(--line);
}

.mnavTitle{
  font-weight:950;
  letter-spacing:-.2px;
  color:var(--text);
}

.mnavClose{
  width:40px;
  height:40px;
  border-radius:14px;
  border:1px solid var(--line);
  background:var(--surface);
  color:var(--text);
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.mnavLinks{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding-top:6px;
}

.mnavLinks a{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 12px;
  border:1px solid var(--line);
  border-radius:14px;
  text-decoration:none;
  color:var(--text);
  font-weight:900;
  background:var(--surface);
}

.mnavLinks a:hover{
  background:var(--surface-soft);
  border-color:var(--line-strong);
}

.mnavLinks a.is-active{
  background:var(--brand-soft);
  border-color:rgba(37,99,235,.22);
  color:var(--brand-strong);
}

html.theme-dark .mnavLinks a.is-active{
  border-color:rgba(96,165,250,.24);
  color:#cfe2ff;
}

html.theme-dark .topbar .nav__link,
html.theme-dark .topbar .userbar__name,
html.theme-dark .topbar .brand,
html.theme-dark .topbar .iconbtn{
  color:var(--text);
}

html.theme-dark .topbar .nav__link.is-active{
  background:var(--brand-soft);
  color:#dceaff;
}

html.theme-dark .card,
html.theme-dark .panel,
html.theme-dark .widget,
html.theme-dark .statsCard,
html.theme-dark .tableWrap,
html.theme-dark .modal__content,
html.theme-dark .auth-card,
html.theme-dark .auth-card.card,
html.theme-dark .chartCard,
html.theme-dark .kpiCard,
html.theme-dark .filters{
  background:var(--surface) !important;
  color:var(--text) !important;
  border-color:var(--line) !important;
  box-shadow:var(--shadow-soft);
}

html.theme-dark h1,
html.theme-dark h2,
html.theme-dark h3,
html.theme-dark h4,
html.theme-dark h5,
html.theme-dark h6,
html.theme-dark label,
html.theme-dark th,
html.theme-dark td,
html.theme-dark .pageTitle,
html.theme-dark .btn{
  color:var(--text);
}

html.theme-dark .muted,
html.theme-dark .small,
html.theme-dark .subtext,
html.theme-dark .note,
html.theme-dark .hint,
html.theme-dark .p,
html.theme-dark p{
  color:var(--text-muted);
}

html.theme-dark input,
html.theme-dark select,
html.theme-dark textarea{
  background:var(--input-bg) !important;
  color:var(--input-text) !important;
  border-color:var(--line-strong) !important;
}

html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder{
  color:#70829d !important;
}

html.theme-dark input[type="date"]::-webkit-calendar-picker-indicator{
  filter:invert(1) brightness(1.15);
}

html.theme-dark table,
html.theme-dark th,
html.theme-dark td{
  border-color:var(--line) !important;
}

@media (max-width:900px){
  .topbar__left{
    min-width:0;
  }

  .topbar__right{
    min-width:0;
    gap:8px;
  }

  .topbar__center{
    justify-content:flex-end;
  }

  .topbar__center .nav{
    display:none;
  }

  .topbar__burger{
    display:inline-flex;
  }

  .seasonpill{
    max-width:46vw;
  }

  .seasonpill__name{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  .userbar__name{
    display:none;
  }
}


/* === Dark mode refinement (soft slate) === */
:root{
  --bg: var(--app-bg);
  --card: var(--surface);
  --txt: var(--text);
  --muted: var(--text-muted);
  --border: var(--line);
}

html.theme-dark{
  --app-bg:#0b1220;
  --surface:#141d2d;
  --surface-soft:#1a2638;
  --surface-muted:#1d2b40;
  --line:#26364d;
  --line-strong:#314562;
  --text:#edf3ff;
  --text-muted:#9fb0c8;
  --brand:#6ea8ff;
  --brand-strong:#4f8dff;
  --brand-soft:rgba(79,141,255,.16);
  --shadow:0 18px 44px rgba(0,0,0,.22);
  --shadow-soft:0 12px 28px rgba(0,0,0,.18);
  --input-bg:#0f1727;
  --input-text:#edf3ff;
  --topbar-bg:rgba(10,18,31,.88);
  --topbar-border:rgba(38,54,77,.92);
  --mobile-overlay:rgba(2,6,23,.64);
  --bg: var(--app-bg);
  --card: var(--surface);
  --txt: var(--text);
  --muted: var(--text-muted);
  --border: var(--line);
}

html.theme-dark body{
  background:
    radial-gradient(circle at top, rgba(59,130,246,.10), transparent 34%),
    linear-gradient(180deg, #0b1220 0%, #0e1627 100%);
}

html.theme-dark .topbar{
  box-shadow:0 1px 0 rgba(255,255,255,.02);
}

html.theme-dark .topbar .nav__link{
  color:#c7d4e8;
}

html.theme-dark .topbar .nav__link:hover{
  background:rgba(255,255,255,.04);
  color:#f8fbff;
}

html.theme-dark .topbar .nav__link.is-active{
  background:rgba(110,168,255,.16);
  color:#f8fbff;
  border:1px solid rgba(110,168,255,.16);
}

html.theme-dark .themeToggle__track{
  width:56px;
  height:32px;
  padding:0 8px;
  background:linear-gradient(180deg, #182437 0%, #111b2d 100%);
  border-color:#2a3c57;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03), 0 8px 20px rgba(0,0,0,.18);
}

html.theme-dark .themeToggle__thumb,
.themeToggle__thumb{
  width:24px;
  height:24px;
  top:3px;
  left:3px;
}

html.theme-dark .themeToggle__thumb{
  transform:translateX(24px);
  background:linear-gradient(180deg, #d8e6ff 0%, #bfd2f4 100%);
}

.themeToggle__track{
  width:56px;
  height:32px;
  padding:0 8px;
}

.themeToggle__icon,
.themeToggle__icon svg{
  width:13px;
  height:13px;
}

html.theme-dark .hero,
html.theme-dark .panel,
html.theme-dark .kpi,
html.theme-dark .banner,
html.theme-dark .tablewrap,
html.theme-dark .tablewrap thead th,
html.theme-dark .chartCard,
html.theme-dark .statsCard,
html.theme-dark .filters,
html.theme-dark .card{
  background:var(--surface) !important;
  color:var(--text) !important;
  border-color:var(--line) !important;
  box-shadow:var(--shadow-soft);
}

html.theme-dark .hero,
html.theme-dark .kpi{
  background:linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0)) , var(--surface) !important;
}

html.theme-dark .panel__sub,
html.theme-dark .hero .sub,
html.theme-dark .kpi__label,
html.theme-dark .kpi__hint,
html.theme-dark .rowMag .line2,
html.theme-dark .pager .meta,
html.theme-dark .banner,
html.theme-dark .small,
html.theme-dark .p,
html.theme-dark .subtext,
html.theme-dark .note,
html.theme-dark p{
  color:var(--text-muted) !important;
}

html.theme-dark input,
html.theme-dark select,
html.theme-dark textarea,
html.theme-dark input[type="date"]{
  background:var(--input-bg) !important;
  color:var(--input-text) !important;
  border-color:var(--line-strong) !important;
}

html.theme-dark .btn:not(.primary){
  background:var(--surface-soft) !important;
  color:var(--text) !important;
  border-color:var(--line-strong) !important;
}

html.theme-dark .btn:not(.primary):hover{
  background:#22324a !important;
}

html.theme-dark .badge,
html.theme-dark .pill{
  background:var(--surface-soft);
  border-color:var(--line-strong);
  color:var(--text);
}

html.theme-dark .badge.blue{ background:rgba(37,99,235,.22); color:#cfe1ff; }
html.theme-dark .badge.green{ background:rgba(22,163,74,.22); color:#d7ffe8; }
html.theme-dark .badge.amber{ background:rgba(245,158,11,.22); color:#ffe7b8; }
html.theme-dark .badge.red{ background:rgba(239,68,68,.22); color:#ffd0d0; }
html.theme-dark .badge.gray{ background:rgba(148,163,184,.12); color:#d8e2f0; }

html.theme-dark .tablewrap tbody tr:hover td{
  background:rgba(255,255,255,.02);
}

html.theme-dark .tablewrap thead th{
  box-shadow:0 1px 0 rgba(255,255,255,.03);
}

html.theme-dark canvas{
  filter:saturate(.95) brightness(.98);
}

/* mobile hardening layout */
@media (max-width:640px){
  .topbar__inner{
    gap:10px;
    padding:10px 0;
  }

  .topbar__left{
    gap:10px;
  }

  .seasonpill{
    max-width:58vw;
  }
}


/* whole-site mobile pass */
.brand{
  display:inline-flex;
  align-items:center;
}
.brand__logo{
  display:block;
  width:auto;
  max-width:180px;
  max-height:44px;
  height:auto;
  object-fit:contain;
}

.logoutForm{
  display:inline-flex;
  margin:0;
}

.logoutForm button{
  appearance:none;
}

.mnavLogoutForm{
  display:block;
  margin:0;
}

.mnavLogoutForm .mnavLogout{
  width:100%;
  appearance:none;
  cursor:pointer;
}
.mnavLogout{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  margin-top:10px;
  border-radius:14px;
  text-decoration:none;
  font-weight:900;
  background:rgba(239,68,68,.08);
  border:1px solid rgba(239,68,68,.18);
  color:var(--danger);
}

@media (max-width:640px){
  .topbar{
    position:sticky;
    top:0;
  }

  .topbar__inner{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:10px;
    padding:8px 0;
  }

  .topbar__left,
  .topbar__right{
    min-width:0;
  }

  .topbar__left{
    gap:8px;
  }

  .brand__logo{
    max-width:120px;
    max-height:36px;
  }

  .seasonpill{
    max-width:none;
    min-width:0;
    padding:8px 10px;
    gap:8px;
  }

  .seasonpill__label{
    display:none;
  }

  .seasonpill__name{
    max-width:34vw;
    font-size:.95rem;
  }

  .topbar__actions{
    width:100%;
    justify-content:flex-end;
    gap:8px;
  }

  .themeToggle__track{
    width:52px;
    height:30px;
  }

  .themeToggle__thumb,
  html.theme-dark .themeToggle__thumb{
    width:22px;
    height:22px;
    top:3px;
    left:3px;
  }

  html.theme-dark .themeToggle__thumb{
    transform:translateX(22px);
  }

  .topbar__burger,
  .iconbtn,
  .avatar{
    width:42px;
    height:42px;
  }

  .userbar{
    gap:8px;
  }

  .userbar__name{
    display:none;
  }

  .userbar .iconbtn.danger{
    display:none;
  }

  .mnavPanel{
    width:min(92vw, 360px);
  }

  main.container.container--wide{
    padding-top:12px;
  }
}

@media (max-width:420px){
  .topbar__inner{
    grid-template-columns:minmax(0,1fr) auto;
  }

  .brand__logo{
    max-width:72px;
  }

  .seasonpill{
    padding:7px 9px;
  }

  .seasonpill__name{
    max-width:30vw;
    font-size:.88rem;
  }

  .topbar__actions{
    gap:6px;
  }
}


/* mobile topbar global fix */
html.theme-dark .brand__logo{
  filter:brightness(0) invert(1);
}

@media (max-width:640px){
  .topbar__inner{
    display:grid !important;
    grid-template-columns:minmax(0,1fr) auto !important;
    grid-template-areas:
      "left right"
      "season right";
    align-items:center;
    column-gap:10px;
    row-gap:8px;
    padding:10px 0 !important;
  }

  .topbar__left{
    display:grid;
    grid-template-columns:minmax(0,1fr);
    grid-template-areas:
      "brand"
      "season";
    align-items:start;
    justify-items:start;
    gap:8px;
    min-width:0;
  }

  .topbar__left .brand{
    grid-area:brand;
    display:inline-flex;
    align-items:center;
    min-width:0;
    max-width:100%;
  }

  .topbar__left .seasonpill{
    grid-area:season;
    max-width:min(72vw, 260px);
    width:max-content;
  }

  .topbar__right{
    align-self:start;
    justify-self:end;
    min-width:0;
  }

  .brand__logo{
    max-width:110px !important;
    height:auto !important;
  }

  .seasonpill__name{
    max-width:46vw !important;
  }
}

@media (max-width:420px){
  .brand__logo{
    max-width:96px !important;
  }

  .topbar__left .seasonpill{
    max-width:min(70vw, 220px);
  }

  .seasonpill__name{
    max-width:44vw !important;
    font-size:.9rem !important;
  }
}
