
*{box-sizing:border-box;
font-family:Calibri,"Segoe UI",Arial,sans-serif}

:root{--bg:#f7f4fb;
    --panel:#fff;
    --panel-soft:#fbf8ff;
    --text:#1d1830;
    --muted:#635c77;
    --lilac:#efe6ff;
    --lilac-strong:#9b78cf;
    --lilac-deep:#6d4c9b;
    --brand-plum:#5f428f;
    --brand-soft:#d9c6f0;
    --border:#e6dcef;
    --shadow:0 24px 60px rgba(57,33,94,.12);
    --shadow-soft:0 12px 30px rgba(57,33,94,.08);
    --shadow-hover:0 22px 44px rgba(109,76,155,.16);
    --radius:22px;--sidebar-width:284px}
    
html,body{
    margin:0;
    padding:0;
    background:var(--bg);
    color:var(--text)}
    a{color:inherit;text-decoration:none}
    svg{width:20px;height:20px;display:block;fill:currentColor}
    img{max-width:100%;display:block}

.sidebar{
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    width:var(--sidebar-width);
    display:flex;
    flex-direction:column;
    gap:24px;
    padding:24px 20px;
    background:linear-gradient(180deg,rgba(233,222,248,.96) 0%,rgba(214,194,241,.94) 52%,rgba(195,172,231,.96) 100%);
    color:#1d1830;
    border-right:1px solid rgba(95,66,143,.12);
    box-shadow:12px 0 40px rgba(95,66,143,.16);
    backdrop-filter:blur(18px) saturate(140%);
    -webkit-backdrop-filter:blur(18px) saturate(140%);
    z-index:50}

.sidebar__brand{
    display:flex;
    align-items:center;
    gap:14px;
    padding:16px;
    border-radius:22px;
    background:linear-gradient(180deg,rgba(255,255,255,.36),rgba(255,255,255,.18));
    border:1px solid rgba(255,255,255,.42);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.35), 0 10px 24px rgba(95,66,143,.10)}

.sidebar__brand img{
    width:72px}

.sidebar__eyebrow{
    font-size:11px;
    text-transform:uppercase;
    letter-spacing:.22em;
    color:var(--brand-plum);
    margin-bottom:4px}
    
.sidebar__title{
    font-size:20px;
    font-weight:700;
    line-height:1.15;
    color:#1f1730}

.sidebar__nav{
    display:flex;
    flex-direction:column;
    gap:10px}

    
.nav-group-label{
    margin:8px 12px 2px;
    color:#5f428f;
    font-size:12px;
    font-weight:800;
    letter-spacing:.18em;
    text-transform:uppercase}

.nav-link{
    display:flex;
    align-items:center;
    gap:14px;
    min-height:52px;
    padding:0 16px;
    border-radius:16px;
    color:#17131f;
    font-size:16px;
    font-weight:800;
    transition:.18s ease}
    
.nav-link__icon{
    width:22px;
    height:22px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    color:#2a1f40;
    flex:0 0 22px}

.nav-link:hover{
    background:linear-gradient(180deg,rgba(255,255,255,.42),rgba(255,255,255,.24));
    color:#000;
    transform:translateX(2px);
    box-shadow:0 8px 22px rgba(95,66,143,.10)}
    
.nav-link:hover 
.nav-link__icon,
.nav-link.is-active 
.nav-link__icon{
    color:#000}
    
.nav-link.is-active{
    background:linear-gradient(180deg,rgba(186,160,225,.95),rgba(170,142,214,.92));
    color:#000;
    border:1px solid rgba(255,255,255,.38);
    box-shadow:0 12px 28px rgba(95,66,143,.20)}

.sidebar__footer{
    margin-top:auto;
    display:grid;
    gap:14px}
    
.user-card{
    padding:14px 16px;
    border-radius:18px;
    background:linear-gradient(180deg,rgba(118,90,168,.22),rgba(255,255,255,.18));
    border:1px solid rgba(255,255,255,.34);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.24)}
    
.user-card__name{
    font-size:16px;
    font-weight:800;
    color:#1d1830}
    
.user-card__meta{
    margin-top:4px;
    color:#44335d;
    font-size:14px}

.latest-manuals h2 {
    margin-bottom: 5px;
}

.latest-manuals p {
    margin-bottom: 15px;
}

.main{
    min-height:100vh;
    margin-left:var(--sidebar-width)}
        
.topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:20px;
    padding:22px 28px 12px}
    
.topbar__left{
    display:flex;
    align-items:center;
    gap:14px}
    
.topbar__heading{
    font-size:30px;
    font-weight:700;
    line-height:1.05}
    
.topbar__sub{
    margin-top:4px;
    color:var(--muted);
    font-size:17px}

.topbar__search{
    position:relative;
    display:flex;
    align-items:center;
    gap:10px;
    width:min(100%,460px)}
    
.topbar__search input{
    padding-left:42px}
    
.search-icon{
    position:absolute;
    left:14px;
    top:50%;
    transform:translateY(-50%);
    color:#8f8cb2;
    pointer-events:none}

.content{
    padding:0 28px 28px}
    
.tabs{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    margin-bottom:18px}
    
.tab{
    min-height:42px;
    padding:0 16px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border-radius:999px;
    background:rgba(255,255,255,.92);
    border:1px solid var(--border);
    color:#000;
    font-size:16px;
    font-weight:800}
    
.tab.is-active,.tab:hover{
    background:linear-gradient(180deg,#efe4ff,#dfcff7);
    border-color:#ccb8e8;
    color:#000}

.hero{
    display:grid;
    grid-template-columns:minmax(0,1.7fr) minmax(320px,.95fr);
    gap:18px;
    margin-bottom:18px}
    
.hero__content,
.hero__aside,
.card{
    background:var(--panel);
    border:1px solid var(--border);
    border-radius:var(--radius);
    box-shadow:var(--shadow-soft);
    padding:28px;
    transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.hero__content:hover,
.hero__aside:hover,
.card:hover{
    transform:translateY(-2px);
    box-shadow:var(--shadow-hover);
    border-color:#ddd6ff;
}

.eyebrow{
    display:inline-flex;
    align-items:center;
    min-height:30px;
    padding:0 12px;
    border-radius:999px;
    background:var(--lilac);
    color:#5f4bda;
    font-size:12px;
    font-weight:700;
    letter-spacing:.08em;
    text-transform:uppercase}

.hero h1{
    margin:16px 0 10px;
    font-size:clamp(34px,4vw,52px);
    line-height:1.02}
    
.hero__text{
    max-width:62ch;
    color:var(--muted);
    font-size:19px;
    line-height:1.5}
    
.hero__actions{
    display:flex;
    gap:12px;
    flex-wrap:wrap;
    margin-top:22px}
    
.hero-aside__label{
    color:var(--muted);
    font-size:15px;
    font-weight:700;
    margin-bottom:14px}

.metric-grid{
    display:grid;
    gap:18px;
    margin-bottom:18px}
    
.metric-grid--2{
    grid-template-columns:repeat(2,minmax(0,1fr));
    margin-bottom:0}
    
.metric-grid--3{
    grid-template-columns:repeat(3,minmax(0,1fr))}

.metric-tile{
    border-radius:18px;
    background:var(--panel-soft);
    border:1px solid #ebe6ff;
    padding:18px}
    
.metric-tile__icon{
    width:44px;
    height:44px;
    border-radius:14px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    background:#e4ddff;
    color:#644fe0;
    margin-bottom:14px}
    
.metric-tile__icon--soft{
    margin-bottom:0}

.metric-tile__value,
.metric-card__value{
    font-size:42px;
    font-weight:700;
    line-height:1;
    margin-bottom:8px}
    
.metric-tile__label,
.metric-card__title{
    font-size:18px;
    font-weight:700;
    color:var(--text)}
    
.muted{
    color:var(--muted);
    font-size:16px;
    line-height:1.45}

.status-pill{
    min-height:30px;
    padding:0 12px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border-radius:999px;
    background:#e9f8ef;
    color:#1f9254;
    font-size:13px;
    font-weight:700}
    
.status-pill--soft{
    background:#f0ecff;
    color:#654fea}
    
.status-pill--outline{
    background:#fff;
    border:1px solid #dcd7ff;
    color:#654fea}

.dashboard-grid{
    display:grid;
    grid-template-columns:minmax(0,1.75fr) minmax(320px,1fr);
    gap:24px;
    align-items:start}

.dashboard-grid > .card,
.side-stack > .card{
    height:100%;
}

.side-stack{
    position:sticky;
    top:24px;
    align-self:start;
}

.dashboard-grid--actions-only{
    grid-template-columns:minmax(320px,560px);
    justify-content:end;
}

.dashboard-grid--actions-only .side-stack{
    position:static;
    top:auto;
}
    
.section-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:14px;
    margin-bottom:18px}
    
.section-head h3{
    margin:0 0 6px;
    font-size:24px;
    font-weight:700}

.list-stack,
.side-stack,
.action-grid{
    display:grid;
    gap:16px}

.list-stack{
    align-content:start;
}
    
.list-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px}
    
.list-row--card{
    padding:20px 22px;
    border-radius:20px;
    background:linear-gradient(180deg,#fdfcff 0%,#f7f4ff 100%);
    border:1px solid #ece8fa;
    box-shadow:0 10px 24px rgba(28,30,58,.04);
    transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.list-row--card:hover{
    transform:translateY(-3px);
    box-shadow:var(--shadow-hover);
    border-color:#d8cffd;
}
    
.list-row__main{
    flex:1 1 auto;
    min-width:0;
}

.list-row__title{
    font-size:24px;
    font-weight:700;
    color:var(--text)}
    
.list-row__meta{
    margin-top:6px;
    font-size:15px;
    font-weight:400;
    color:var(--muted)}
    
.list-row__actions{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    align-items:center;
    justify-content:flex-end;
    flex:0 0 auto;
}

.action-card{
    display:flex;
    align-items:center;
    gap:14px;
    padding:18px 20px;
    border-radius:20px;
    background:linear-gradient(180deg,#fdfcff 0%,#f7f4ff 100%);
    border:1px solid #ece8fa;
    box-shadow:0 10px 24px rgba(28,30,58,.04);
    transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease}
    
.action-card:hover{
    transform:translateY(-3px);
    border-color:#d6cdfa;
    box-shadow:var(--shadow-hover)}
    
.action-card__icon{
    width:42px;
    height:42px;
    border-radius:14px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    background:#e7e1ff;
    color:#624de0;
    flex:0 0 42px}
    
.action-card strong{
    display:block;
    font-size:18px;
    margin-bottom:2px}
    
.action-card small{
    color:var(--muted);
    font-size:14px}

.empty-state{
    padding:24px;
    border-radius:18px;
    border:1px dashed #d8d2f7;
    background:#fbfaff}
    
.empty-state__title{
    font-size:20px;
    font-weight:700;
    margin-bottom:8px}

.btn{
    min-height:44px;
    padding:0 16px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    border-radius:14px;
    border:1px solid var(--border);
    background:#fff;
    color:var(--text);
    font-size:16px;
    font-weight:700;
    cursor:pointer;
    transition:.16s ease}
    
.btn:hover{
    transform:translateY(-1px);
    box-shadow:var(--shadow-soft)}
    
.btn-primary{
    background:linear-gradient(180deg,#b792eb,#9d78d2);
    border-color:rgba(95,66,143,.10);
    color:#000;
    box-shadow:0 10px 24px rgba(95,66,143,.16)}
    
.btn-block{
    width:100%}
    
.btn__icon{
    width:18px;
    height:18px}

input,
select,
textarea{
    width:100%;
    min-height:46px;
    padding:0 14px;
    border:1px solid var(--border);
    border-radius:14px;
    background:#fff;
    color:var(--text);
    font-size:16px;
    outline:none}

input:focus,
select:focus,
textarea:focus{
    border-color:#c9bfff;
    box-shadow:0 0 0 4px rgba(123,104,238,.12)}

.flashwrap{
    display:grid;
    gap:10px;
    margin-bottom:16px}
    
.flash{
    padding:12px 14px;
    border-radius:14px;
    font-size:15px;
    font-weight:700;
    border:1px solid var(--border);
    background:#fff}

#toastWrap{
    position:fixed;
    right:18px;
    bottom:18px;
    display:grid;
    gap:10px;
    z-index:120}
    
.toast{
    min-width:260px;
    max-width:360px;
    padding:12px 14px;
    border-radius:14px;
    border:1px solid var(--border);
    background:#fff;
    box-shadow:var(--shadow);
    font-size:15px;
    font-weight:700}

.icon-btn{
    width:44px;
    height:44px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border-radius:14px;
    border:1px solid var(--border);
    background:#fff;
    color:var(--text);
    cursor:pointer}
    
.mobile-only,
.app-overlay{
    display:none}


@media (max-width:1200px){.hero,.dashboard-grid,.metric-grid--3{grid-template-columns:1fr}.side-stack{position:static;top:auto}}

@media (max-width:980px){

  .app-layout{
    display:block;
  }

  .sidebar{
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    height:100vh;
    width:var(--sidebar-width);

    transform:translateX(-100%);
    transition:transform .25s ease;

    z-index:9999 !important;

    background:#f3eefc !important;

    backdrop-filter:none !important;
    -webkit-backdrop-filter:none !important;

    filter:none !important;
    opacity:1 !important;

    box-shadow:18px 0 42px rgba(24,24,39,.22);
  }

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

  .app-overlay{
    position:fixed;
    inset:0;

    background:rgba(0,0,0,.25);

    z-index:9998;

    opacity:0;
    pointer-events:none;

    transition:opacity .2s ease;

    backdrop-filter:none !important;
    -webkit-backdrop-filter:none !important;
  }

  .app-overlay.is-open{
    opacity:1;
    pointer-events:auto;
  }

  .main{
    margin-left:0 !important;
  }
}

@media (max-width:720px){.tabs{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;overflow:visible;padding-bottom:4px}.tab{min-width:0;padding:0 10px;font-size:14px}.metric-grid--2{grid-template-columns:1fr}.list-row,.list-row__actions,.section-head{flex-direction:column;align-items:stretch}.list-row--card{padding:18px}.btn,.list-row__actions .btn{width:100%}.hero__content,.hero__aside,.card{padding:20px}.hero h1{font-size:36px}.topbar{align-items:flex-start}.topbar__left{width:100%}.topbar__title{min-width:0}.topbar__heading{font-size:24px}.topbar__sub{font-size:15px}.topbar__search{display:grid;grid-template-columns:minmax(0,1fr) 128px;align-items:center}.topbar__search .btn{width:100%}}
@media (max-width:480px){.topbar__heading{font-size:22px}.topbar__sub{font-size:14px}.topbar__search{grid-template-columns:minmax(0,1fr) 112px}.tab{font-size:13px;padding:0 6px}}


.form-grid{display:grid;gap:18px}
.field{display:grid;gap:8px}
.field__label{font-size:15px;font-weight:700;color:var(--text)}
.field__help{color:var(--muted);font-size:13px}
.form-actions{display:flex;gap:12px;flex-wrap:wrap}

/* Flat premium layout refresh */
:root{
    --bg:#f6f6fb;
    --panel:#ffffff;
    --panel-soft:#fbfaff;
    --border:#ebe7f6;
    --shadow:0 10px 28px rgba(24,24,39,.06);
    --shadow-soft:0 6px 18px rgba(24,24,39,.05);
    --shadow-hover:0 14px 30px rgba(80,66,182,.10);
}

body.app-shell{
    background:linear-gradient(180deg,#fbf8ff 0%, #f3eef8 100%);
}

.main{
    background:transparent;
}

.topbar{
    padding:24px 28px 14px;
}

.content{
    padding:0 28px 28px;
}

.hero__content,
.hero__aside,
.card,
.list-row--card,
.action-card,
.metric-tile,
.empty-state,
.item{
    background:#fff;
}

.hero__content,
.hero__aside,
.card{
    border:1px solid var(--border);
    box-shadow:var(--shadow-soft);
    border-radius:24px;
}

.hero__content:hover,
.hero__aside:hover,
.card:hover{
    transform:none;
    box-shadow:var(--shadow-soft);
    border-color:var(--border);
}

.hero{
    grid-template-columns:minmax(0,2fr) minmax(320px,1fr);
    gap:24px;
    margin-bottom:24px;
}

.metric-grid{
    gap:16px;
    margin-bottom:24px;
}

.metric-grid--3{
    grid-template-columns:repeat(3,minmax(0,1fr));
}

.metric-tile,
.card--metric{
    border:1px solid var(--border);
    box-shadow:none;
}

.card--metric{
    padding:24px;
}

.dashboard-grid{
    grid-template-columns:minmax(0,2fr) minmax(300px,1fr);
    gap:24px;
}

.side-stack{
    gap:20px;
}

.section-head{
    margin-bottom:20px;
}

.list-row--card,
.action-card,
.item{
    border:1px solid var(--border);
    box-shadow:0 4px 14px rgba(24,24,39,.04);
    border-radius:20px;
}

.list-row--card,
.item{
    padding:18px 20px;
}

.list-row--card:hover,
.action-card:hover,
.item:hover{
    transform:translateY(-2px);
    box-shadow:var(--shadow-hover);
    border-color:#ddd6f8;
}

.action-card{
    padding:16px 18px;
    background:#fff;
}

.metric-tile__icon,
.action-card__icon{
    background:#f0ebff;
}

.card--note{
    display:none;
}

.page-title{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:16px;
    margin-bottom:18px;
}

.page-title h2{
    margin:0 0 6px;
    font-size:30px;
}

.page-title .sub{
    color:var(--muted);
    font-size:16px;
    line-height:1.5;
}

.list{
    list-style:none;
    margin:0;
    padding:0;
    display:grid;
    gap:14px;
}

.item{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
}

.meta{
    color:var(--muted);
    font-size:15px;
    line-height:1.45;
}

.sidebar__footer-actions{
    display:grid;
    gap:10px;
}

@media (max-width:1200px){
    .hero,
    .dashboard-grid,
    .metric-grid--3{
        grid-template-columns:1fr;
    }
    .side-stack{
        position:static;
        top:auto;
    }
}

@media (max-width:980px){
    body.app-shell{
        background:#faf6ff;
    }
    .topbar{
        padding:18px 18px 12px;
    }
    .content{
        padding:0 18px 20px;
    }
    .hero{
        gap:16px;
        margin-bottom:16px;
    }
    .metric-grid{
        margin-bottom:16px;
        gap:14px;
    }
    .dashboard-grid{
        gap:16px;
    }
}

@media (max-width:720px){
    .topbar{
        gap:14px;
    }
    .tabs{
        display:grid;
        grid-template-columns:repeat(4,minmax(0,1fr));
        gap:8px;
        margin-bottom:14px;
    }
    .tab{
        min-height:40px;
        padding:0 8px;
        font-size:13px;
        border-radius:14px;
        white-space:nowrap;
    }
    .hero__content,
    .hero__aside,
    .card{
        padding:18px;
        border-radius:20px;
    }
    .hero h1{
        font-size:32px;
    }
    .list-row--card,
    .item,
    .action-card{
        padding:16px;
        border-radius:18px;
    }
    .list-row,
    .list-row__actions,
    .section-head,
    .item,
    .page-title{
        flex-direction:column;
        align-items:stretch;
    }
    .list-row__actions,
    .item > div:last-child{
        width:100%;
    }
    .btn,
    .list-row__actions .btn,
    .item .btn{
        width:100%;
    }
    .page-title h2{
        font-size:26px;
    }
    .mobile-files-rail .item{
        min-height:100%;
    }
    .mobile-files-rail .item .btn{
        width:100%;
    }
    .topbar__search{
        display:grid;
        grid-template-columns:minmax(0,1fr) 116px;
        gap:10px;
    }
    .topbar__search input{
        min-width:0;
    }
}

@media (max-width:480px){
    .content{
        padding:0 14px 16px;
    }
    .topbar{
        padding:14px 14px 10px;
    }
    .topbar__heading{
        font-size:22px;
    }
    .topbar__sub{
        font-size:14px;
        line-height:1.35;
    }
    .topbar__search{
        grid-template-columns:minmax(0,1fr) 104px;
        gap:8px;
    }
    .hero__actions{
        gap:10px;
    }
    .hero__actions .btn{
        width:100%;
    }
    .metric-card__value,
    .metric-tile__value{
        font-size:34px;
    }
}


.card--metric-users .metric-card__title{
  margin-bottom:14px;
}
.user-status-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
  margin-top:2px;
}
.user-status{
  text-decoration:none;
  border-radius:18px;
  padding:16px 14px;
  display:flex;
  flex-direction:column;
  gap:4px;
  border:1px solid transparent;
  transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.user-status:hover{
  transform:translateY(-2px);
  box-shadow:0 12px 28px rgba(24,24,39,.10);
}
.user-status__count{
  font-size:28px;
  line-height:1;
  font-weight:800;
}
.user-status__label{
  font-size:14px;
  font-weight:700;
}
.user-status--active{
  background:rgba(34,197,94,.10);
  border-color:rgba(34,197,94,.18);
  color:#15803d;
}
.user-status--inactive{
  background:rgba(239,68,68,.10);
  border-color:rgba(239,68,68,.18);
  color:#dc2626;
}
@media (max-width: 768px){
  .user-status-grid{
    grid-template-columns:1fr;
  }
}


.sidebar .btn-soft,
.sidebar .btn-primary,
.sidebar .nav-link,
.sidebar__brand,
.user-card{
    backdrop-filter:blur(14px) saturate(135%);
    -webkit-backdrop-filter:blur(14px) saturate(135%);
}

.sidebar .btn-soft{
    background:rgba(255,255,255,.72);
    border-color:rgba(95,66,143,.12);
    color:#000;
}

.sidebar .btn-soft:hover,
.sidebar .btn-primary:hover{
    color:#000;
}

@media (max-width:980px){
    .sidebar{
        background:linear-gradient(180deg,rgba(237,228,250,.97) 0%,rgba(219,201,245,.96) 50%,rgba(201,181,233,.97) 100%);
    }
    .sidebar__brand{
        background:linear-gradient(180deg,rgba(255,255,255,.44),rgba(255,255,255,.20));
    }
    .nav-link,
    .sidebar .btn-soft,
    .sidebar .btn-primary{
        text-shadow:none;
    }
}

@media (max-width:720px){
    .nav-link{
        min-height:56px;
    }
    .nav-link span:last-child,
    .tab,
    .sidebar .btn-soft,
    .sidebar .btn-primary{
        color:#000 !important;
    }
}

.install-app-btn[hidden]{display:none !important}



/* Premium light gray + lilac theme upgrade */
:root{
    --bg:#f1f2f6;
    --panel:#fcfbff;
    --panel-soft:#f7f4ff;
    --text:#1e1a2b;
    --muted:#6f6884;
    --lilac:#ece4ff;
    --lilac-strong:#b89af4;
    --lilac-deep:#7a5ac8;
    --brand-plum:#6950a8;
    --brand-soft:#d9c8f6;
    --border:#e5dff2;
    --shadow:0 18px 44px rgba(60,48,94,.10);
    --shadow-soft:0 10px 26px rgba(60,48,94,.07);
    --shadow-hover:0 22px 48px rgba(88,71,136,.14);
}

body.app-shell{
    position:relative;
    background:
      radial-gradient(circle at top left, rgba(197,177,241,.28), transparent 34%),
      radial-gradient(circle at 85% 10%, rgba(232,224,255,.85), transparent 26%),
      linear-gradient(180deg, #f6f7fa 0%, #eff1f6 100%);
}

body.app-shell::before,
body.app-shell::after{
    content:"";
    position:fixed;
    pointer-events:none;
    inset:auto;
    z-index:0;
    filter:blur(16px);
    opacity:.7;
}

body.app-shell::before{
    top:84px;
    right:80px;
    width:260px;
    height:260px;
    border-radius:50%;
    background:radial-gradient(circle, rgba(212,196,249,.42), transparent 68%);
}

body.app-shell::after{
    bottom:40px;
    left:340px;
    width:320px;
    height:320px;
    border-radius:50%;
    background:radial-gradient(circle, rgba(255,255,255,.72), transparent 65%);
}

.main,
.sidebar,
.topbar,
.content{
    position:relative;
    z-index:1;
}

.sidebar{
    background:linear-gradient(180deg, rgba(239,233,250,.94) 0%, rgba(227,218,246,.96) 46%, rgba(214,202,240,.98) 100%);
    border-right:1px solid rgba(126,102,176,.14);
    box-shadow:18px 0 48px rgba(84,67,128,.12);
}

.sidebar__brand{
    background:linear-gradient(180deg, rgba(255,255,255,.68), rgba(247,242,255,.44));
    border:1px solid rgba(255,255,255,.62);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.7), 0 16px 34px rgba(92,72,145,.12);
}

.nav-link{
    color:#241d35;
    font-weight:700;
    border:1px solid transparent;
}

.nav-link:hover{
    background:linear-gradient(180deg, rgba(255,255,255,.76), rgba(246,241,255,.56));
    border-color:rgba(123,99,188,.12);
    box-shadow:0 12px 26px rgba(104,83,162,.10);
}

.nav-link.is-active{
    background:linear-gradient(180deg, #c7b0f4, #b89bea);
    border-color:rgba(255,255,255,.55);
    box-shadow:0 16px 30px rgba(104,83,162,.18);
}

.user-card{
    background:linear-gradient(180deg, rgba(255,255,255,.44), rgba(233,224,252,.36));
    border:1px solid rgba(255,255,255,.46);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.52), 0 10px 24px rgba(84,67,128,.08);
}

.topbar{
    padding:28px 32px 16px;
}

.topbar__heading{
    letter-spacing:-.03em;
}

.topbar__sub{
    color:#736d86;
}

.topbar__search input,
input,
select,
textarea{
    background:rgba(255,255,255,.88);
    border-color:#e3ddef;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.8);
}

.topbar__search input:focus,
input:focus,
select:focus,
textarea:focus{
    border-color:#c4b3ef;
    box-shadow:0 0 0 5px rgba(164,140,231,.14);
}

.tabs{
    gap:12px;
    margin-bottom:22px;
}

.tab{
    background:rgba(255,255,255,.7);
    box-shadow:0 8px 18px rgba(60,48,94,.05);
    border-color:#e2dbf0;
}

.tab.is-active,
.tab:hover{
    background:linear-gradient(180deg, #f1eaff, #e0d3fb);
    border-color:#d1c1f1;
    box-shadow:0 12px 22px rgba(95,79,146,.10);
}

.hero__content,
.hero__aside,
.card{
    background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(252,250,255,.94));
    border:1px solid rgba(228,221,240,.95);
    border-radius:28px;
    box-shadow:0 16px 36px rgba(60,48,94,.08);
}

.hero{
    gap:22px;
}

.hero__content{
    overflow:hidden;
}

.hero__content::after{
    content:"";
    position:absolute;
    right:-48px;
    top:-48px;
    width:220px;
    height:220px;
    border-radius:50%;
    background:radial-gradient(circle, rgba(224,210,255,.55), rgba(224,210,255,0) 68%);
    pointer-events:none;
}

.hero h1,
.page-title h2,
.section-head h3,
.list-row__title{
    letter-spacing:-.035em;
}

.eyebrow,
.status-pill--soft,
.status-pill--outline{
    background:linear-gradient(180deg, #f3edff, #e7ddff);
    color:#6847c3;
    border:1px solid #e0d4fb;
}

.metric-tile,
.card--metric,
.list-row--card,
.action-card,
.item,
.empty-state{
    background:linear-gradient(180deg, rgba(255,255,255,.98), rgba(249,246,255,.96));
    border:1px solid #e8e2f3;
    box-shadow:0 10px 24px rgba(60,48,94,.05);
}

.metric-tile__icon,
.action-card__icon,
.metric-tile__icon--soft{
    background:linear-gradient(180deg, #efe7ff, #e3d7ff);
    color:#694cc6;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.6);
}

.metric-card__value,
.metric-tile__value{
    letter-spacing:-.04em;
}

.btn{
    border-radius:16px;
    box-shadow:0 8px 18px rgba(60,48,94,.05);
}

.btn-primary{
    background:linear-gradient(180deg, #c6aff4 0%, #b08ce7 100%);
    border-color:#b89be7;
    color:#241b34;
    box-shadow:0 12px 28px rgba(107,79,162,.18);
}

.btn-primary:hover{
    box-shadow:0 16px 32px rgba(107,79,162,.22);
}

.btn-soft{
    background:linear-gradient(180deg, rgba(255,255,255,.88), rgba(243,238,252,.92));
    border-color:#e2daf1;
}

.flash,
.toast{
    background:linear-gradient(180deg, rgba(255,255,255,.98), rgba(249,246,255,.96));
}

.status-pill{
    background:linear-gradient(180deg, #edf9f1, #dff4e6);
    color:#1d8f55;
}

.user-status--active{
    background:linear-gradient(180deg, rgba(68,194,128,.13), rgba(68,194,128,.08));
}

.user-status--inactive{
    background:linear-gradient(180deg, rgba(245,126,126,.14), rgba(245,126,126,.08));
}

.action-card strong,
.metric-card__title,
.metric-tile__label{
    color:#231d33;
}

@media (max-width:980px){
    body.app-shell::after{left:40px; width:220px; height:220px;}
    .topbar{padding:20px 18px 12px;}
}

@media (max-width:720px){
    body.app-shell::before,
    body.app-shell::after{display:none;}
    .hero__content,
    .hero__aside,
    .card{border-radius:22px;}
    .tab{box-shadow:none;}
}

/* === Premium redesign overrides === */
:root{
  --bg:#f3f2f7;
  --bg-accent:#ece8f8;
  --panel:#ffffff;
  --panel-soft:#faf8ff;
  --text:#181428;
  --muted:#6d6780;
  --lilac:#eee8ff;
  --lilac-strong:#9d84df;
  --lilac-deep:#6f56c8;
  --brand-plum:#5f46ad;
  --brand-soft:#dcd1ff;
  --border:#e8e3f2;
  --shadow:0 24px 60px rgba(28, 20, 53, .08);
  --shadow-soft:0 12px 30px rgba(28, 20, 53, .05);
  --shadow-hover:0 20px 46px rgba(76, 54, 140, .11);
  --radius:24px;
  --sidebar-width:296px;
}

html,body{
  background:
    radial-gradient(circle at top right, rgba(183,160,247,.20), transparent 24%),
    linear-gradient(180deg, #f6f5f9 0%, #f1f0f5 100%);
  color:var(--text);
}

body{
  font-family:Calibri,"Segoe UI",Arial,sans-serif;
}

body::before,
body::after{
  content:"";
  position:fixed;
  inset:auto;
  pointer-events:none;
  z-index:0;
  border-radius:999px;
  filter:blur(50px);
}

body::before{
  top:28px;
  right:52px;
  width:260px;
  height:260px;
  background:rgba(194,174,255,.18);
}

body::after{
  bottom:42px;
  left:320px;
  width:220px;
  height:220px;
  background:rgba(255,255,255,.55);
}

.sidebar,
.main,
.topbar,
.content{position:relative;z-index:1}

.sidebar{
  width:var(--sidebar-width);
  padding:20px 18px;
  background:rgba(255,255,255,.84);
  border-right:1px solid rgba(120,99,179,.08);
  box-shadow:18px 0 44px rgba(54,37,99,.07);
  backdrop-filter:blur(24px) saturate(135%);
  -webkit-backdrop-filter:blur(24px) saturate(135%);
}

.sidebar__brand{
  gap:12px;
  padding:16px;
  border-radius:24px;
  background:linear-gradient(180deg, rgba(246,243,255,.94), rgba(255,255,255,.78));
  border:1px solid rgba(223,215,246,.9);
  box-shadow:0 8px 24px rgba(78,58,126,.06);
}

.sidebar__brand img{width:68px}

.sidebar__title{
  font-size:19px;
  letter-spacing:-.02em;
}

.sidebar__eyebrow,
.nav-group-label{
  color:#725ac6;
}

.sidebar__nav{gap:8px}

.nav-link{
  min-height:50px;
  padding:0 14px;
  border-radius:16px;
  color:#4a445d;
  font-size:15px;
  font-weight:700;
}

.nav-link__icon{color:#7c72a3}

.nav-link:hover{
  background:rgba(240,236,251,.9);
  color:#231d34;
  transform:none;
  box-shadow:none;
}

.nav-link:hover .nav-link__icon,
.nav-link.is-active .nav-link__icon{
  color:var(--lilac-deep);
}

.nav-link.is-active{
  background:linear-gradient(180deg, #f1ecff 0%, #e9e2ff 100%);
  color:#241d39;
  border:1px solid #dfd6fb;
  box-shadow:0 10px 24px rgba(111,86,200,.10);
}

.user-card{
  padding:16px 18px;
  border-radius:20px;
  background:linear-gradient(180deg, rgba(245,242,255,.95), rgba(255,255,255,.92));
  border:1px solid #e3dbf8;
  box-shadow:0 8px 24px rgba(67,49,119,.06);
}

.user-card__name{font-size:15px}
.user-card__meta{font-size:13px;color:#6e6292}

.main{margin-left:var(--sidebar-width)}

.topbar{
  gap:24px;
  padding:22px 28px 10px;
  align-items:flex-end;
}

.topbar__heading{
  font-size:34px;
  font-weight:800;
  letter-spacing:-.04em;
}

.topbar__sub{
  margin-top:6px;
  color:var(--muted);
  font-size:15px;
}

.topbar__search{
  width:min(100%, 430px);
  gap:10px;
  padding:8px;
  border-radius:18px;
  background:rgba(255,255,255,.72);
  border:1px solid rgba(227,221,243,.95);
  box-shadow:0 8px 24px rgba(29,20,48,.05);
}

.topbar__search input,
input,
select,
textarea{
  border:1px solid var(--border);
  border-radius:16px;
  background:#fff;
  color:var(--text);
  min-height:48px;
  padding:12px 14px;
  font-size:15px;
  transition:border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.topbar__search input{
  border:none;
  background:transparent;
  min-height:42px;
}

.topbar__search input:focus,
input:focus,
select:focus,
textarea:focus{
  outline:none;
  border-color:#c9bbf7;
  box-shadow:0 0 0 4px rgba(157,132,223,.14);
}

.content{padding:0 28px 34px}

.tabs{
  gap:10px;
  margin-bottom:22px;
}

.tab{
  min-height:44px;
  padding:0 16px;
  background:rgba(255,255,255,.8);
  border:1px solid rgba(228,223,241,.95);
  color:#625a77;
  font-size:14px;
  font-weight:800;
  box-shadow:0 4px 12px rgba(29,20,48,.03);
}

.tab.is-active,
.tab:hover{
  background:linear-gradient(180deg, #f0ebff, #e8e0ff);
  border-color:#d8cdfb;
  color:#322953;
}

.hero,
.premium-hero{
  display:grid;
  grid-template-columns:minmax(0, 1.55fr) minmax(320px, .95fr);
  gap:20px;
  margin-bottom:20px;
}

.hero__content,
.hero__aside,
.card,
.premium-hero__main,
.premium-hero__aside{
  background:rgba(255,255,255,.86);
  border:1px solid rgba(233,227,245,.95);
  border-radius:24px;
  box-shadow:var(--shadow-soft);
  padding:24px;
  transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.premium-hero__main{
  padding:28px;
  background:
    radial-gradient(circle at top right, rgba(206,189,255,.28), transparent 28%),
    linear-gradient(180deg, rgba(255,255,255,.95) 0%, rgba(249,247,255,.97) 100%);
}

.hero__content:hover,
.hero__aside:hover,
.card:hover,
.premium-hero__main:hover,
.premium-hero__aside:hover{
  transform:translateY(-2px);
  box-shadow:var(--shadow-hover);
  border-color:#ddd3f8;
}

.eyebrow{
  min-height:32px;
  padding:0 13px;
  background:var(--lilac);
  color:#6b55c4;
  font-size:11px;
  letter-spacing:.16em;
}

.hero h1,
.premium-hero h1{
  margin:16px 0 10px;
  font-size:clamp(32px,3.8vw,52px);
  line-height:1.02;
  letter-spacing:-.04em;
}

.hero__text{
  max-width:60ch;
  color:var(--muted);
  font-size:17px;
  line-height:1.55;
}

.hero-chip-row{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  margin-top:22px;
}

.hero-chip{
  min-width:132px;
  padding:14px 16px;
  border-radius:18px;
  background:rgba(244,240,255,.9);
  border:1px solid #e2daf8;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.7);
}

.hero-chip__label{
  display:block;
  color:#766d90;
  font-size:12px;
  font-weight:700;
  margin-bottom:6px;
}

.hero-chip strong{
  font-size:22px;
  letter-spacing:-.03em;
}

.premium-stack,
.dashboard-showcase__main,
.dashboard-showcase__side{display:grid;gap:20px}

.signal-card{
  padding:22px;
  border-radius:22px;
  background:linear-gradient(180deg, #f8f5ff 0%, #f1edff 100%);
  border:1px solid #e3dbfb;
}

.signal-card--soft{
  background:linear-gradient(180deg, #ffffff 0%, #faf8ff 100%);
}

.signal-card__label{
  font-size:12px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.14em;
  color:#7c69b9;
}

.signal-card__value{
  margin-top:14px;
  font-size:44px;
  font-weight:800;
  line-height:1;
  letter-spacing:-.05em;
}

.signal-card__value--small{font-size:28px}

.signal-card__text{
  margin-top:10px;
  color:var(--muted);
  line-height:1.55;
  font-size:14px;
}

.signal-card__footer{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
  margin-top:16px;
}

.mini-note{
  color:#7b718f;
  font-size:13px;
  font-weight:700;
}

.metric-grid{gap:20px;margin-bottom:20px}
.metric-grid--3{grid-template-columns:repeat(3,minmax(0,1fr))}

.stat-card{
  padding:22px;
  background:linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(250,248,255,.96) 100%);
}

.stat-card__top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:18px;
}

.stat-card--spotlight{
  background:linear-gradient(180deg, #ffffff 0%, #f7f3ff 100%);
}

.metric-tile__icon{
  width:48px;
  height:48px;
  border-radius:16px;
  background:#ebe4ff;
  color:#6b54c8;
}

.metric-card__value,
.metric-tile__value{
  font-size:40px;
  font-weight:800;
  letter-spacing:-.05em;
}

.metric-card__title,
.metric-tile__label{
  font-size:18px;
  font-weight:800;
  letter-spacing:-.02em;
}

.muted{
  color:var(--muted);
  font-size:15px;
  line-height:1.55;
}

.status-pill{
  min-height:30px;
  padding:0 12px;
  background:#e8f7ef;
  color:#197a48;
  font-size:12px;
  font-weight:800;
}

.status-pill--soft{
  background:#efeaff;
  color:#6c56c7;
}

.status-pill--outline{
  background:#fff;
  border:1px solid #ddd4fb;
  color:#6854be;
}

.user-status-grid{gap:12px;margin-top:16px}

.user-status{
  border-radius:18px;
  padding:18px;
  box-shadow:none;
}

.user-status--active{
  background:linear-gradient(180deg, #effaf4 0%, #e8f5ee 100%);
  border:1px solid #cfe8d9;
}

.user-status--inactive{
  background:linear-gradient(180deg, #fff4f4 0%, #fdeeed 100%);
  border:1px solid #f4d6d4;
}

.dashboard-showcase{
  display:grid;
  grid-template-columns:minmax(0,1.45fr) minmax(300px,.8fr);
  gap:20px;
  align-items:start;
}

.section-head{margin-bottom:18px}
.section-head--tight{margin-bottom:16px}
.section-head h3{
  margin:0 0 6px;
  font-size:24px;
  font-weight:800;
  letter-spacing:-.03em;
}

.action-grid{gap:14px}
.action-grid--premium{grid-template-columns:repeat(2,minmax(0,1fr))}

.action-card{
  align-items:center;
  gap:14px;
  padding:18px;
  border-radius:20px;
  background:linear-gradient(180deg, #ffffff 0%, #f7f4ff 100%);
  border:1px solid #ebe4f8;
  box-shadow:0 10px 24px rgba(28,30,58,.04);
}

.action-card:hover{
  transform:translateY(-2px);
  border-color:#d7cdf8;
}

.action-card__icon{
  width:44px;
  height:44px;
  border-radius:14px;
  background:#ece5ff;
  color:#654ed0;
}

.action-card strong{
  display:block;
  font-size:17px;
  margin-bottom:4px;
}

.action-card small{
  display:block;
  color:var(--muted);
  font-size:13px;
  line-height:1.4;
}

.action-card__arrow{
  margin-left:auto;
  color:#8b80aa;
}

.card--accent{
  background:linear-gradient(180deg, #fcfbff 0%, #f4efff 100%);
}

.bullet-list{
  margin:0;
  padding-left:18px;
  display:grid;
  gap:10px;
}

.list,
.list-stack,
.side-stack,
.action-grid{display:grid;gap:14px}

.list-row--card,
.item,
.card .item{
  padding:18px 20px;
  border-radius:20px;
  background:linear-gradient(180deg, #ffffff 0%, #f8f5ff 100%);
  border:1px solid #ece5f7;
  box-shadow:0 10px 24px rgba(28,30,58,.04);
}

.list-row--card:hover,
.item:hover,
.card .item:hover{
  transform:translateY(-2px);
  box-shadow:0 16px 32px rgba(76,54,140,.09);
  border-color:#ddd2f7;
}

.list-row__title,
.page-title h2,
.card-title h3{letter-spacing:-.03em}
.page-title .sub{color:var(--muted)}

.btn{
  min-height:46px;
  padding:0 16px;
  border-radius:14px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  font-size:15px;
  font-weight:800;
}

.btn:hover{
  transform:translateY(-1px);
  box-shadow:0 10px 20px rgba(29,20,48,.06);
}

.btn-primary,
.btn.primary{
  color:#fff;
  border-color:transparent;
  background:linear-gradient(135deg, #a88cf0 0%, #7f64dd 100%);
  box-shadow:0 12px 24px rgba(111,86,200,.24);
}

.btn-primary:hover,
.btn.primary:hover{
  box-shadow:0 16px 28px rgba(111,86,200,.28);
}

.btn-soft{
  background:linear-gradient(180deg, #ffffff 0%, #f8f5ff 100%);
  color:#4f4472;
}

.empty-state{
  padding:26px;
  border-radius:20px;
  border:1px dashed #daccf7;
  background:rgba(251,249,255,.95);
}

.flash{
  border-radius:16px;
  padding:14px 16px;
  border:1px solid #e8e3f2;
  background:#fff;
  box-shadow:0 10px 20px rgba(29,20,48,.04);
}

@media (max-width: 1100px){
  .hero,
  .premium-hero,
  .dashboard-showcase,
  .metric-grid--3,
  .action-grid--premium{
    grid-template-columns:1fr;
  }

  .topbar{
    align-items:stretch;
    flex-direction:column;
  }

  .topbar__search{width:100%}
}

@media (max-width: 980px){
  :root{--sidebar-width:286px}
  .main{margin-left:0}
  body::after{left:24px}
}

@media (max-width: 720px){
  .content,
  .topbar{padding-left:18px;padding-right:18px}
  .premium-hero__main,
  .hero__content,
  .hero__aside,
  .card,
  .premium-hero__aside{padding:20px}
  .hero h1,
  .premium-hero h1{font-size:30px}
  .hero-chip{flex:1 1 calc(50% - 12px)}
  .signal-card__footer{flex-direction:column;align-items:flex-start}
}


/* Auth pages */
body.app-shell--auth{
    background: radial-gradient(circle at top, rgba(220,208,243,.55) 0%, rgba(246,243,251,.96) 42%, #f7f4fb 100%);
}

body.app-shell--auth .main{
    margin-left:0;
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:32px 18px;
}

body.app-shell--auth .content{
    width:100%;
    max-width:1120px;
    padding:0;
}

.auth-shell{
    min-height:calc(100vh - 64px);
    display:flex;
    align-items:center;
    justify-content:center;
}

.auth-card{
    width:min(100%, 540px);
    margin:0 auto;
    background:rgba(255,255,255,.9);
    border:1px solid rgba(233,227,246,.95);
    border-radius:28px;
    box-shadow:0 20px 60px rgba(60,44,98,.10);
    padding:28px;
    backdrop-filter:blur(10px);
}

.auth-card--wide{
    width:min(100%, 760px);
}

.auth-branding{
    display:grid;
    gap:18px;
    justify-items:center;
    text-align:center;
    margin-bottom:24px;
}

.auth-branding__logo{
    width:min(100%, 420px);
    height:auto;
    object-fit:contain;
    filter:drop-shadow(0 14px 30px rgba(69,45,116,.12));
}

.auth-branding--compact{
    gap:14px;
}

.auth-branding__logo--small{
    width:min(100%, 200px);
}

.auth-branding__copy h1{
    margin:0 0 8px;
    font-size:clamp(30px, 4vw, 42px);
    line-height:1.05;
    color:#1f1730;
}

.auth-branding__copy p{
    margin:0;
    color:var(--muted);
    font-size:17px;
    line-height:1.55;
    max-width:32rem;
}

.auth-panel{
    background:linear-gradient(180deg, rgba(255,255,255,.92), rgba(250,247,255,.96));
    border:1px solid var(--border);
    border-radius:22px;
    padding:22px;
}

.auth-panel .form-grid{
    gap:16px;
}

.auth-panel input{
    min-height:52px;
    background:#fff;
}

.auth-actions{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:12px;
    margin-top:4px;
}

.auth-note{
    margin:2px 0 0;
    color:var(--muted);
    font-size:14px;
    line-height:1.5;
}

@media (max-width: 720px){
    body.app-shell--auth .main{
        padding:20px 14px;
    }

    .auth-shell{
        min-height:auto;
    }

    .auth-card,
    .auth-card--wide{
        width:100%;
        padding:18px;
        border-radius:22px;
    }

    .auth-branding{
        margin-bottom:18px;
    }

    .auth-branding__logo{
        width:min(100%, 280px);
    }

    .auth-branding__copy h1{
        font-size:30px;
    }

    .auth-branding__copy p{
        font-size:15px;
    }

    .auth-panel{
        padding:16px;
        border-radius:18px;
    }

    .auth-actions{
        grid-template-columns:1fr;
    }
}


/* ===== Layout stabilization overrides ===== */
html, body {
  min-height: 100%;
  overflow-x: hidden;
}

body.app-shell {
  min-height: 100vh;
}

.main {
  min-height: 100vh;
  display: block;
}

.topbar {
  padding-top: 18px !important;
  padding-bottom: 8px !important;
  margin: 0 !important;
}

.content {
  padding-top: 0 !important;
}

.tabs {
  margin-top: 0 !important;
  margin-bottom: 18px !important;
}

.content > *:first-child,
.content .flashwrap + * {
  margin-top: 0 !important;
}

.hero,
.premium-hero,
.metric-grid,
.dashboard-showcase {
  align-items: start;
}

.premium-hero,
.hero {
  margin-bottom: 18px !important;
}

.sidebar {
  justify-content: flex-start;
}

.sidebar__nav {
  flex: 1 1 auto;
  min-height: 0;
}

.sidebar__footer {
  margin-top: auto !important;
  padding-top: 8px;
}

body.app-shell--auth .main {
  margin-left: 0 !important;
  padding: 24px 16px !important;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.app-shell--auth .content {
  max-width: 760px !important;
  width: 100%;
  padding: 0 !important;
}

body.app-shell--auth .flashwrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 760px);
  margin: 0;
  z-index: 100;
}

body.app-shell--auth .flash {
  margin: 0;
}

.auth-shell {
  min-height: auto !important;
  width: 100%;
}

.auth-card,
.auth-card--wide {
  width: min(100%, 720px) !important;
  margin: 0 auto !important;
}

.auth-branding {
  margin-bottom: 20px !important;
}

.auth-branding__logo,
.auth-branding__logo--small {
  width: min(100%, 240px) !important;
  max-width: 240px !important;
  height: auto !important;
}

.auth-branding__copy h1 {
  font-size: clamp(28px, 3.4vw, 40px) !important;
}

.auth-branding__copy p {
  max-width: 34rem;
  margin-inline: auto;
}

.auth-panel {
  width: 100%;
}

@media (max-width: 980px) {
  .main {
    margin-left: 0 !important;
  }
}

@media (max-width: 720px) {
  body.app-shell--auth .flashwrap {
    top: 12px;
    width: calc(100vw - 24px);
  }

  .auth-branding__logo,
  .auth-branding__logo--small {
    width: min(100%, 180px) !important;
    max-width: 180px !important;
  }
}


/* final scroll and layout guard */
html { scroll-behavior: auto; }
.main { overflow-anchor: none; }
.content { display: block; }
.content > * { scroll-margin-top: 0; }
body.app-shell--auth .content { max-width: 720px !important; }


/* stable sidebar layout refresh */
body.app-shell{transition:background .25s ease,color .25s ease}
.app-layout{display:grid;grid-template-columns:var(--sidebar-width) minmax(0,1fr);min-height:100vh;align-items:stretch}
.sidebar,.main,.nav-link,.btn,.card,.action-card,.tab,.app-overlay{transition:transform .24s ease, width .24s ease, margin .24s ease, opacity .24s ease, box-shadow .24s ease, background-color .24s ease, border-color .24s ease, grid-template-columns .24s ease}
.sidebar{overflow-x:hidden}
.main{min-width:0;margin-left:0}
.nav-link__text,.sidebar__brand div,.nav-group-label,.user-card,.sidebar__footer-actions{transition:opacity .18s ease}
#sidebarToggle{flex:0 0 auto}

@media (min-width:981px){
  .sidebar{position:sticky;top:0;left:auto;bottom:auto;height:100vh;width:auto}
  .app-overlay{display:none !important}
  body.sidebar-collapsed .app-layout{grid-template-columns:88px minmax(0,1fr)}
  body.sidebar-collapsed .sidebar{padding-left:14px;padding-right:14px}
  body.sidebar-collapsed .sidebar__brand{justify-content:center;padding:12px}
  body.sidebar-collapsed .sidebar__brand img{width:46px}
  body.sidebar-collapsed .sidebar__brand div,
  body.sidebar-collapsed .nav-link__text,
  body.sidebar-collapsed .nav-group-label,
  body.sidebar-collapsed .user-card,
  body.sidebar-collapsed .sidebar__footer-actions .btn:not(.install-app-btn){opacity:0;pointer-events:none;height:0;min-height:0;padding:0;border:0;margin:0;overflow:hidden}
  body.sidebar-collapsed .nav-link{justify-content:center;padding:0}
  body.sidebar-collapsed .nav-link__icon{margin:0}
  body.sidebar-collapsed .sidebar__footer{gap:10px}
  body.sidebar-collapsed .install-app-btn{display:none !important}
}

@media (max-width:980px){
  .app-layout{display:block}
  .sidebar{position:fixed;top:0;left:0;bottom:0;height:100vh;width:var(--sidebar-width);transform:translateX(-100%);box-shadow:18px 0 42px rgba(24,24,39,.18)}
  .sidebar.is-open{transform:translateX(0)}
  .app-overlay{position:fixed;inset:0;background:rgba(28,24,48,.28);backdrop-filter:blur(4px);z-index:40;opacity:0;pointer-events:none;display:block}
  .app-overlay.is-open{opacity:1;pointer-events:auto}
  .main{margin-left:0}
}

.welcome-banner{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:18px}
.welcome-banner h2{margin:14px 0 8px;font-size:32px}
.welcome-banner__chips{display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:flex-end}
.dashboard-showcase--franchise{grid-template-columns:minmax(0,1.45fr) minmax(280px,.8fr)}
.dashboard-showcase--franchise .dashboard-showcase__main{order:1}
.dashboard-showcase--franchise .dashboard-showcase__side{order:2}

@media (max-width:1200px){
  .welcome-banner{flex-direction:column;align-items:flex-start}
  .dashboard-showcase--franchise{grid-template-columns:1fr}
}

/* Mobile polish: iPhone/Android alignment and tap targets */
*, *::before, *::after {
  box-sizing: border-box;
}

img, svg, video, canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar__heading,
.topbar__sub,
.sidebar__title,
.nav-link__text,
.card,
.item,
.action-card,
.tab,
.btn {
  min-width: 0;
}

.topbar__heading,
.topbar__sub,
.title,
.doc-title,
.metric-card__title,
.action-card strong,
.action-card small {
  overflow-wrap: anywhere;
}

@supports (height: 100dvh) {
  body.app-shell,
  .app-layout,
  .main {
    min-height: 100dvh;
  }

  @media (max-width: 980px) {
    .sidebar {
      height: 100dvh;
    }
  }
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: min(86vw, 320px);
  }

  body.sidebar-drawer-open {
    overflow: hidden;
    touch-action: none;
  }

  .sidebar {
    z-index: 60;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .app-overlay {
    z-index: 50;
  }

  .topbar,
  .content {
    width: 100%;
  }

  .topbar {
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
  }

  .content {
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
    padding-bottom: max(28px, env(safe-area-inset-bottom)) !important;
  }

  .premium-hero,
  .hero,
  .dashboard-showcase,
  .metric-grid,
  .grid,
  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }

  .premium-hero__main,
  .premium-hero__aside,
  .dashboard-showcase__main,
  .dashboard-showcase__side {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch !important;
  }

  .topbar__left {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .topbar__heading {
    font-size: 22px !important;
    line-height: 1.12;
  }

  .topbar__sub {
    font-size: 14px !important;
    line-height: 1.35;
  }

  .topbar__search {
    width: 100%;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px;
    padding: 6px !important;
    align-items: center;
  }

  .topbar__search input {
    width: 100%;
    min-height: 44px;
    padding-left: 38px !important;
  }

  .topbar__search .btn {
    width: auto !important;
    min-width: 86px;
    min-height: 44px;
    padding-inline: 14px;
  }

  .tabs {
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 0 0 8px !important;
    margin-left: -2px !important;
    margin-right: -2px !important;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    min-width: 92px;
    min-height: 42px;
    padding: 0 14px !important;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .page-title,
  .section-head,
  .card-title,
  .welcome-banner,
  .list-row,
  .item {
    align-items: stretch !important;
  }

  .page-title,
  .section-head,
  .card-title {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .page-title h2,
  .welcome-banner h2,
  .premium-hero h1 {
    font-size: 28px !important;
    line-height: 1.12;
  }

  .premium-hero,
  .hero__content,
  .hero__aside,
  .card,
  .auth-card,
  .auth-card--wide {
    border-radius: 18px !important;
    padding: 18px !important;
  }

  .hero-chip-row,
  .hero__actions,
  .form-actions,
  .deletebar,
  .welcome-banner__chips {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px;
    justify-content: stretch !important;
  }

  .hero-chip,
  .status-pill,
  .select-pill {
    justify-content: center;
    width: 100%;
  }

  .btn,
  .item .btn,
  .list-row__actions .btn,
  .form-actions .btn,
  .page-title > .btn {
    width: 100% !important;
    min-height: 44px;
  }

  .action-grid,
  .action-grid--premium,
  .metric-grid,
  .user-status-grid {
    grid-template-columns: 1fr !important;
  }

  .action-card {
    grid-template-columns: 42px minmax(0, 1fr) 24px;
    align-items: center;
    min-height: 72px;
  }

  .action-card__icon {
    width: 42px;
    height: 42px;
  }

  .mobile-files-rail {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 12px !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    scroll-snap-type: none !important;
  }

  .mobile-files-rail > .item {
    width: 100% !important;
    flex-basis: auto !important;
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .mobile-files-rail .row-left,
  .item > div,
  .item > div:last-child,
  .mobile-files-rail .deletebar {
    width: 100%;
  }

  .mobile-files-rail .row-left {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }

  .mobile-files-rail .item > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr;
  }

  .doc-meta {
    display: grid !important;
    grid-template-columns: 1fr;
  }

  .auth-panel .form-grid,
  .form-grid,
  .row {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 390px) {
  .topbar,
  .content {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .topbar__search {
    grid-template-columns: 1fr !important;
  }

  .topbar__search .btn {
    width: 100% !important;
  }

  .tab {
    min-width: 84px;
    font-size: 13px !important;
  }

  .premium-hero,
  .hero__content,
  .hero__aside,
  .card,
  .auth-card,
  .auth-card--wide {
    padding: 16px !important;
  }
}
