/* LLOGARITES shell UI (index) */
:root{
  --sidebar-width:clamp(320px, 33.333vw, 520px);
  --header-height:68px;
  --safe-area-top:env(safe-area-inset-top, 0px);
  --safe-area-bottom:env(safe-area-inset-bottom, 0px);
  --header-safe-height:calc(var(--header-height) + var(--safe-area-top));
  --transition:.2s ease;
  --shell-header-padding:0 22px;
  --shell-header-pad-top:0px;
  --shell-header-pad-bottom:0px;
  --shell-header-gap:14px;
  --shell-header-align:center;
  --shell-logo-height:54px;
  --shell-logo-max-width:297px;
  --shell-logo-offset:0;
  --shell-header-right-gap:14px;
  --shell-menu-gap:10px;
  --shell-menu-btn-size:32px;
  --shell-menu-icon-size:18px;
  --shell-menu-label-size:1.18rem;
  --shell-nav-gap:8px;
  --shell-nav-size:1.4rem;
  --shell-nav-pad-y:12px;
  --shell-nav-pad-x:18px;
  --shell-gradient-start:#0b0838;
  --shell-gradient-mid:#32145d;
  --shell-gradient-end:#8d2357;
  --shell-header-base-gradient:linear-gradient(90deg, #0b0838 0%, #32145d 52%, #8d2357 100%);
  --shell-gradient-soft:linear-gradient(135deg, rgba(12,22,48,0.08) 0%, rgba(43,63,145,0.08) 48%, rgba(122,34,60,0.08) 100%);
  --shell-gradient-strong:linear-gradient(135deg, rgba(12,22,48,0.14) 0%, rgba(43,63,145,0.14) 48%, rgba(122,34,60,0.14) 100%);
  --shell-accent:#5b315c;
  --shell-sidebar-surface:linear-gradient(180deg, rgba(255,255,255,0.97) 0%, rgba(248,249,252,0.98) 100%);
  --shell-divider-soft:rgba(15,23,42,0.085);
  --shell-item-hover:linear-gradient(135deg, rgba(12,22,48,0.045) 0%, rgba(43,63,145,0.05) 52%, rgba(122,34,60,0.05) 100%);
  --shell-item-active:linear-gradient(135deg, rgba(12,22,48,0.075) 0%, rgba(43,63,145,0.08) 52%, rgba(122,34,60,0.08) 100%);
}

@keyframes shellHeaderGradientShift{
  0%{background-position:0% 50%, 0% 50%, 0% 50%, 100% 50%;}
  50%{background-position:58% 50%, 54% 50%, 52% 50%, 46% 50%;}
  100%{background-position:0% 50%, 0% 50%, 0% 50%, 100% 50%;}
}

@keyframes shellHeaderGlowDrift{
  0%{transform:translate3d(-3%, 0, 0) scale(1);}
  50%{transform:translate3d(3%, -0.5%, 0) scale(1.015);}
  100%{transform:translate3d(-3%, 0, 0) scale(1);}
}

@keyframes shellHeaderSheen{
  0%{transform:translate3d(-10%, 0, 0); opacity:.08;}
  50%{transform:translate3d(10%, 0, 0); opacity:.14;}
  100%{transform:translate3d(-10%, 0, 0); opacity:.08;}
}

/* App shell */
body{
  margin:0;
  background:var(--ui-bg);
  color:var(--ui-text);
  min-height:100vh;
  min-height:100dvh;
  height:100vh;
  height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.app-shell{
  width:min(1120px,100%);
  height:calc(100vh - 28px);
  margin:14px auto;
  background:var(--ui-surface);
  border:1px solid var(--ui-border);
  border-radius:var(--ui-radius-lg);
  box-shadow:var(--ui-shadow);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

header{
  background:
    radial-gradient(circle at 16% 24%, rgba(103,112,255,0.14) 0%, rgba(103,112,255,0.04) 24%, rgba(103,112,255,0) 48%),
    linear-gradient(118deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.012) 26%, rgba(255,255,255,0) 44%),
    linear-gradient(90deg, #0b0838 0%, #32145d 54%, #7c244f 100%),
    linear-gradient(145deg, rgba(11,8,56,0.985) 0%, rgba(45,20,86,0.955) 58%, rgba(124,36,79,0.965) 100%);
  background-size:140% 140%, 180% 180%, 150% 150%, 150% 150%;
  background-position:0% 50%, 0% 50%, 0% 50%, 100% 50%;
  animation:shellHeaderGradientShift 32s cubic-bezier(.4,0,.2,1) infinite;
  height:var(--header-safe-height);
  display:grid;
  grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
  align-items:center;
  gap:var(--shell-header-gap);
  padding:var(--shell-header-padding);
  padding-top:calc(var(--safe-area-top) + var(--shell-header-pad-top));
  padding-bottom:var(--shell-header-pad-bottom);
  border-bottom:1px solid rgba(15,23,42,0.08);
  position:sticky;
  top:0;
  z-index:100;
  box-shadow:0 8px 22px rgba(8,15,34,0.16);
  overflow:hidden;
  contain:paint;
}

header::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    radial-gradient(circle at 20% 34%, rgba(108,114,255,0.11) 0%, rgba(108,114,255,0.03) 18%, rgba(108,114,255,0) 38%),
    radial-gradient(circle at 74% 18%, rgba(214,92,164,0.08) 0%, rgba(214,92,164,0.025) 20%, rgba(214,92,164,0) 42%),
    radial-gradient(circle at 88% 76%, rgba(245,129,181,0.07) 0%, rgba(245,129,181,0.02) 20%, rgba(245,129,181,0) 42%);
  opacity:.54;
  pointer-events:none;
  animation:shellHeaderGlowDrift 38s cubic-bezier(.4,0,.2,1) infinite;
}

header::after{
  content:"";
  position:absolute;
  inset:0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0.012) 18%, rgba(255,255,255,0) 42%),
    linear-gradient(104deg, rgba(255,255,255,0) 18%, rgba(255,255,255,0.07) 42%, rgba(255,255,255,0.015) 50%, rgba(255,255,255,0) 66%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='0.22'/%3E%3C/svg%3E");
  background-size:100% 100%, 150% 100%, 220px 220px;
  background-position:center, center, center;
  mix-blend-mode:screen, screen, soft-light;
  pointer-events:none;
  animation:shellHeaderSheen 28s cubic-bezier(.4,0,.2,1) infinite;
  opacity:.72;
}

header > *{
  position:relative;
  z-index:1;
}

.header-side{
  display:flex;
  align-items:center;
  min-width:0;
}

.header-side-left{
  justify-content:flex-start;
}

.header-side-right{
  justify-content:flex-end;
}

.header-center{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:0;
}

.header-left{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:var(--shell-menu-gap);
  cursor:pointer;
  background:transparent;
  padding:6px 8px;
  min-height:42px;
  border:1px solid transparent;
  border-radius:0;
  transition:background-color .2s ease, border-color .2s ease, box-shadow .2s ease, padding .2s ease, gap .2s ease;
}

.header-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:var(--shell-header-right-gap);
  flex:0 0 auto;
  margin-left:auto;
  min-width:0;
}

.header-refresh-btn{
  color:rgba(255,255,255,0.92);
}

.menu-btn{
  background:none;
  border:none;
  color:rgba(255,255,255,0.92);
  cursor:pointer;
  padding:8px;
  display:flex;
  align-items:center;
  border-radius:10px;
  transition:var(--transition);
  width:var(--shell-menu-btn-size);
  height:var(--shell-menu-btn-size);
  justify-content:center;
}

.menu-btn:hover{
  background:rgba(255,255,255,0.08);
}

.menu-label{
  font-family:var(--font-ui);
  font-size:1.04rem;
  font-weight:700;
  letter-spacing:-0.02em;
  color:rgba(255,255,255,0.96);
  line-height:1;
}

.menu-btn svg{
  width:var(--shell-menu-icon-size);
  height:var(--shell-menu-icon-size);
  stroke-width:2;
}

.header-left.active .menu-label,
.header-left.active .menu-btn{
  color:#ffffff;
}

.header-left.active{
  background:transparent;
  border-color:transparent;
  box-shadow:none;
}

.header-brand{
  appearance:none;
  border:none;
  background:none;
  display:inline-flex;
  align-items:baseline;
  justify-content:center;
  gap:1px;
  padding:0;
  color:#ffffff;
  cursor:pointer;
}

.header-brand-main{
  font-family:var(--font-ui);
  font-size:clamp(1.3rem, 1.24rem + 0.34vw, 1.62rem);
  font-weight:800;
  letter-spacing:-0.045em;
  color:#ffffff;
  line-height:1;
}

.header-brand-dot{
  font-family:var(--font-ui);
  font-size:0.76rem;
  font-weight:600;
  color:rgba(255,255,255,0.72);
  line-height:1;
}

.header-brand:focus-visible,
.header-left:focus-visible,
.header-refresh-btn:focus-visible{
  outline:2px solid rgba(255,255,255,0.78);
  outline-offset:2px;
}

.menu-btn:focus-visible,
.nav-btn:focus-visible,
.menu-item:focus-visible{
  outline:2px solid var(--ui-primary);
  outline-offset:2px;
}

/* Top navigation */
.top-nav{
  display:flex;
  justify-content:flex-start;
  gap:var(--shell-nav-gap);
  background:transparent;
  height:auto;
  align-items:center;
  padding:0;
}

.nav-btn{
  background:none;
  border:none;
  font-family:var(--font-ui);
  font-size:var(--shell-nav-size);
  font-weight:900;
  color:#090979;
  cursor:pointer;
  position:relative;
  letter-spacing:.01em;
  padding:var(--shell-nav-pad-y) var(--shell-nav-pad-x);
  border-radius:8px;
  transition:var(--transition);
}

.nav-btn.active{
  color:#090979;
  font-weight:900;
}

.nav-btn:hover{
  background:rgba(9,9,121,0.06);
}

  .nav-btn.active::after{
    content:"";
    position:absolute;
    left:10px;
    right:10px;
    bottom:1px;
    height:2px;
    background:#090979;
    border-radius:2px;
  }


/* Sidebar */
.sidebar{
  position:fixed;
  top:var(--header-safe-height);
  left:0;
  width:var(--sidebar-width);
  height:calc(100vh - var(--header-safe-height));
  height:calc(100dvh - var(--header-safe-height));
  background:var(--shell-sidebar-surface);
  z-index:200;
  display:flex;
  flex-direction:column;
  border-right:1px solid rgba(255,255,255,0.68);
  box-shadow:none;
  transition:transform .28s cubic-bezier(.22,1,.36,1), opacity .2s ease, visibility .2s ease;
  transform:translateX(calc(-100% - 18px));
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  will-change:transform, opacity;
}

.sidebar-header{
  padding:24px 20px 14px;
  border-bottom:1px solid var(--ui-border);
  color:#090979;
  font-size:12px;
  letter-spacing:.18em;
  text-transform:uppercase;
}

.sidebar-menu{
  flex:1;
  padding:0 18px 14px;
  overflow-y:auto;
  transition:transform .2s ease, opacity .2s ease;
}

.sidebar:not(.active) .sidebar-menu{
  transform:translateY(-8px);
  opacity:0;
  pointer-events:none;
}

.sidebar.active .sidebar-menu{
  transform:translateY(0);
  opacity:1;
  pointer-events:auto;
}

.sidebar.active{
  transform:translateX(0);
  opacity:1;
  visibility:visible;
  pointer-events:auto;
}

.menu-group{
  background:transparent;
  border-radius:0;
  margin-bottom:0;
  overflow:hidden;
  border:none;
  box-shadow:none;
}

.menu-item{
  display:flex;
  align-items:center;
  width:100%;
  padding:14px 8px;
  border:none;
  background:none;
  font-size:0.98rem;
  font-weight:500;
  cursor:pointer;
  gap:14px;
  border-bottom:1px solid var(--shell-divider-soft);
  transition:var(--transition);
  color:#090979;
  border-radius:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  position:relative;
}

.menu-item i{
  color:#090979;
  width:20px;
  stroke-width:2;
  transition:color .2s ease;
}

.submenu{
  display:none;
  padding:4px 6px 8px 6px;
}

.submenu.open{
  display:block;
}

.submenu .menu-item{
  font-size:13px;
  padding:8px 10px;
  border-bottom:none;
  color:#090979;
  border-radius:8px;
}

.submenu .menu-item i{
  color:#090979;
}

.submenu-chevron{
  margin-left:auto;
  color:#090979;
}

.menu-item:hover{
  background:rgba(9,9,121,0.06);
  color:#090979;
}

.menu-item.active{
  background:rgba(9,9,121,0.08);
  color:#090979;
  font-weight:700;
}

.menu-item.active i{
  color:#090979;
}

.menu-item.active::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  bottom:0;
  width:3px;
  background:linear-gradient(180deg, var(--shell-gradient-mid) 0%, var(--shell-gradient-end) 100%);
}

.overlay{
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background:var(--ui-overlay);
  opacity:0;
  visibility:hidden;
  z-index:150;
  transition:.3s;
}

.overlay.active{
  opacity:1;
  visibility:visible;
}

/* Main area */
main{
  flex:1;
  background:var(--ui-surface);
  overflow:hidden;
  position:relative;
  border-top:1px solid var(--ui-border);
  margin:0;
}

.main-layout{
  display:flex;
  height:100%;
  gap:16px;
  contain:layout paint;
}

.content-area{
  flex:1;
  min-width:0;
  height:100%;
  contain:layout paint;
}

.page{
  display:none;
  width:100%;
  height:100%;
}

.page.active{
  display:block;
}

iframe{
  width:100%;
  height:100%;
  border:none;
  border-radius:0;
  display:block;
  background:transparent;
}

.sidebar-footer{
  padding:18px 18px 20px;
  font-size:11px;
  color:#090979;
  border-top:1px solid var(--shell-divider-soft);
  background:linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(245,247,251,0.96) 100%);
}

@media (prefers-reduced-motion: reduce){
  *{
    transition:none !important;
    animation:none !important;
  }
}

/* Compact mobile shell */
@media (max-width:899px){
  html,
  body{
    width:100%;
    height:100svh;
    max-height:100svh;
    overflow:hidden;
  }
  body{
    position:fixed;
    inset:0;
    overflow:hidden;
  }
  main{
    overflow:hidden;
  }
  .content-area,
  .page,
  iframe{
    height:100%;
  }
}

@media (max-width:720px){
  :root{
    --header-height:68px;
    --shell-header-padding:4px 12px 6px;
    --shell-header-pad-top:4px;
    --shell-header-pad-bottom:6px;
    --shell-header-gap:8px;
    --shell-header-align:flex-end;
    --shell-header-right-gap:8px;
    --shell-menu-gap:4px;
    --shell-menu-btn-size:34px;
    --shell-menu-icon-size:20px;
    --shell-nav-gap:6px;
    --shell-nav-size:1.3rem;
    --shell-nav-pad-y:10px;
    --shell-nav-pad-x:11px;
  }
  header{
    position:fixed;
    left:0;
    right:0;
    top:0;
    width:100%;
    background:
      radial-gradient(circle at 16% 24%, rgba(103,112,255,0.14) 0%, rgba(103,112,255,0.04) 24%, rgba(103,112,255,0) 48%),
      linear-gradient(118deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.012) 26%, rgba(255,255,255,0) 44%),
      linear-gradient(90deg, #0b0838 0%, #32145d 54%, #7c244f 100%),
      linear-gradient(145deg, rgba(11,8,56,0.985) 0%, rgba(45,20,86,0.955) 58%, rgba(124,36,79,0.965) 100%);
    background-size:140% 140%, 180% 180%, 150% 150%, 150% 150%;
    background-position:0% 50%, 0% 50%, 0% 50%, 100% 50%;
    animation:shellHeaderGradientShift 32s cubic-bezier(.4,0,.2,1) infinite;
    border-bottom:1px solid rgba(255,255,255,0.08);
    box-shadow:0 8px 22px rgba(8,15,34,0.16);
    backdrop-filter:none;
    grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
    transform:none;
    will-change:auto;
  }
  header::before{
    opacity:.54;
    animation:shellHeaderGlowDrift 38s cubic-bezier(.4,0,.2,1) infinite;
  }
  header::after{
    opacity:.72;
    animation:shellHeaderSheen 28s cubic-bezier(.4,0,.2,1) infinite;
  }
  .header-left{
    flex:0 0 auto;
    align-self:center;
    min-height:40px;
    padding:3px 5px;
    border-radius:999px;
    background:transparent;
    border:1px solid transparent;
    animation:none;
    backdrop-filter:none;
  }
  .header-refresh-btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:36px;
    height:36px;
    border-radius:999px;
    background:transparent;
    border:1px solid transparent;
    animation:none;
    backdrop-filter:none;
  }
  .header-brand{
    padding:3px 8px 5px;
    border-radius:999px;
    background:transparent;
    border:1px solid transparent;
    box-shadow:none;
    gap:3px;
  }
  .header-brand-main{
    font-size:1.48rem;
    color:#ffffff;
    background:none;
    -webkit-background-clip:border-box;
    background-clip:border-box;
    animation:none;
    text-shadow:none;
    line-height:1.08;
    letter-spacing:-0.02em;
  }
  .header-brand-dot{
    font-size:0.72rem;
    color:rgba(255,255,255,0.78);
    text-shadow:none;
    letter-spacing:0.01em;
  }
  .header-side{
    align-self:center;
  }
  .sidebar{
    top:var(--header-safe-height);
    height:calc(100svh - var(--header-safe-height));
  }
  .nav-btn{
    display:flex;
    align-items:center;
    line-height:1;
    min-height:42px;
  }
  .menu-label{
    display:none;
  }
  .header-left.active{
    width:min(42vw, 220px);
    max-width:220px;
    padding:4px 6px;
    gap:6px;
    justify-content:flex-start;
    background:linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.07) 100%);
  }
  .header-left.active .menu-label{
    display:inline;
    font-size:0.9rem;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  main{
    position:fixed;
    top:calc(var(--header-safe-height) + 8px);
    left:8px;
    right:8px;
    bottom:0;
    margin:0;
    height:auto;
    overflow:hidden;
    overscroll-behavior:none;
  }
  .content-area,
  .page{
    height:100%;
    overflow:hidden;
  }
  iframe{
    display:block;
    height:100%;
  }
}

/* Wide desktop shell */
@media (min-width:980px){
  main{margin:16px 16px 0 16px;}
}

/* Desktop shell */
@media (min-width:900px){
  .sidebar{
    left:12px;
    right:auto;
    top:calc(var(--header-safe-height) - 6px);
    height:calc(100vh - var(--header-safe-height) - 12px);
    height:calc(100dvh - var(--header-safe-height) - 12px);
    border-right:1px solid rgba(255,255,255,0.7);
    border-left:1px solid rgba(255,255,255,0.7);
    border-top:1px solid rgba(255,255,255,0.7);
    border-bottom:1px solid rgba(255,255,255,0.7);
    border-radius:0;
    box-shadow:inset 0 1px 0 rgba(255,255,255,0.42), 0 8px 24px rgba(15,23,42,0.05);
  }
  .sidebar.active{
    transform:translateX(0);
    opacity:1;
    visibility:visible;
    pointer-events:auto;
  }
  main{
    margin-left:calc(var(--sidebar-width) + 28px);
    margin-right:16px;
    width:calc(100% - var(--sidebar-width) - 44px);
  }
  .header-left.active{
    background:transparent;
    border-color:transparent;
  }
}

/* Tablet and mobile sidebar */
@media (max-width:899px){
  .sidebar{
    left:10px;
    right:auto;
    top:calc(var(--header-safe-height) - 2px);
    width:min(420px,72vw);
    max-width:calc(100vw - 22px);
    height:calc(100svh - var(--header-safe-height) + 2px);
    border-right:1px solid rgba(255,255,255,0.7);
    border-left:1px solid rgba(255,255,255,0.7);
    border-top:1px solid rgba(255,255,255,0.7);
    border-bottom:1px solid rgba(255,255,255,0.7);
    transform:translateX(calc(-100% - 18px));
    border-radius:0;
    background:var(--ui-surface);
  }
  .sidebar.active{
    transform:translateX(0);
  }
  .sidebar-menu{
    transform:none;
    opacity:1;
    pointer-events:auto;
    padding:0 14px 12px;
  }
  .sidebar:not(.active) .sidebar-menu{
    transform:none;
    opacity:1;
    pointer-events:auto;
  }
  .menu-btn{
    margin-left:0;
  }
  .menu-item{
    padding:13px 6px;
    border-radius:0;
    font-size:0.95rem;
  }
  .menu-item i{
    width:18px;
  }
  .overlay{
    background:var(--ui-overlay);
  }
  .main-layout{
    display:block;
  }
  .sidebar-footer{
    padding:14px 16px calc(14px + env(safe-area-inset-bottom));
  }
}
