:root{
  --app-bg:#f6f7fb;
  --surface:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:rgba(15,23,42,.08);
  --shadow:0 14px 32px rgba(15,23,42,.07);
  --shadow-sm:0 8px 18px rgba(15,23,42,.06);
  --primary:#6d5dfc;
  --primary-weak:rgba(109,93,252,.14);
  --radius:18px;

  --sidebar-w:280px;
  --sidebar-w-collapsed:80px;
  --topbar-h:70px;
}

html,body{height:100%;}

body{
  background:var(--app-bg);
  color:var(--text);
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,'Helvetica Neue',Arial,sans-serif;
}

/* ----------------
   Shell
---------------- */
.app-shell{min-height:100vh;display:flex;}

.sidebar{
  width:var(--sidebar-w);
  background:var(--surface);
  border-right:1px solid var(--border);
  position:sticky;top:0;height:100vh;
  transition:width .18s ease;
}

.sidebar a{color:var(--text);text-decoration:none;}

.sidebar .brand{
  height:var(--topbar-h);
  display:flex;align-items:center;gap:.75rem;
  padding:0 1.1rem;
  border-bottom:1px solid var(--border);
}

.sidebar .brand .logo{
  width:38px;height:38px;border-radius:14px;
  background:var(--primary-weak);
  display:grid;place-items:center;
  color:var(--primary);
}

.sidebar .brand .brand-name{font-weight:800;letter-spacing:.2px;line-height:1.05;}
.sidebar .brand .brand-sub{font-size:.78rem;color:var(--muted);line-height:1.05;}

.sidebar .section-label{
  font-size:.72rem;letter-spacing:.08em;
  color:#94a3b8;
  padding:1rem 1.1rem .35rem;
  text-transform:uppercase;
}

.sidebar .nav-link{
  display:flex;align-items:center;gap:.8rem;
  padding:.62rem 1rem;
  border-radius:14px;
  margin:.15rem .7rem;
  color:var(--text);
}

.sidebar .nav-link:hover{background:rgba(15,23,42,.04);}

.sidebar .nav-link.active{
  background:var(--primary-weak);
  color:var(--primary);
  font-weight:700;
}

.sidebar .nav-link i{font-size:1.05rem;width:22px;text-align:center;color:#64748b;}
.sidebar .nav-link.active i{color:var(--primary);}

/* Collapsed */
.sidebar-collapsed .sidebar{width:var(--sidebar-w-collapsed);} 
.sidebar-collapsed .sidebar .nav-link span,
.sidebar-collapsed .sidebar .section-label,
.sidebar-collapsed .sidebar .brand .brand-text{display:none;}
.sidebar-collapsed .sidebar .nav-link{justify-content:center;}

/* Hidden */
.sidebar-hidden .sidebar{display:none;}

.main{flex:1;min-width:0;}

.topbar{
  height:var(--topbar-h);
  display:flex;align-items:center;justify-content:space-between;
  padding:.65rem 1rem;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  position:sticky;top:0;z-index:20;
}

.content{padding:1rem;}

/* ----------------
   Controls
---------------- */
.icon-btn{
  width:40px;height:40px;
  border-radius:14px;
  border:1px solid var(--border);
  background:#fff;
  display:grid;place-items:center;
  color:#334155;
}
.icon-btn:hover{background:rgba(15,23,42,.03);}

.searchbar{
  display:flex;align-items:center;gap:.55rem;
  background:#f1f5f9;
  border:1px solid rgba(15,23,42,.06);
  border-radius:999px;
  padding:.48rem .85rem;
  min-width:280px;
}
.searchbar i{color:#64748b;}
.searchbar input{
  border:0;background:transparent;outline:0;
  width:220px;font-size:.92rem;
}

/* ----------------
   Cards
---------------- */
.kpi-card{
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
}

.kpi-card .kpi-label{color:var(--muted);font-size:.82rem;}
.kpi-card .kpi-value{font-weight:900;font-size:1.45rem;letter-spacing:-.3px;}

.soft-badge{background:var(--primary-weak);color:var(--primary);border-radius:999px;padding:.35rem .55rem;font-weight:700;font-size:.75rem;}

/* ----------------
   Loader
---------------- */
.page-loader{
  position:fixed;inset:0;
  background:rgba(246,247,251,.85);
  backdrop-filter:blur(7px);
  z-index:3000;
  display:none;
}
.page-loader.active{display:flex;align-items:center;justify-content:center;}

.loader-box{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:22px;
  padding:18px 20px;
  box-shadow:var(--shadow);
  display:flex;align-items:center;gap:12px;
}

.spinner-ring{
  width:22px;height:22px;
  border-radius:50%;
  border:3px solid rgba(109,93,252,.22);
  border-top-color:var(--primary);
  animation:spin .9s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg);}}

/* ----------------
   Mobile
---------------- */
@media (max-width: 992px){
  .sidebar{
    position:fixed;left:0;top:0;z-index:40;
    box-shadow:0 18px 48px rgba(0,0,0,.25);
    display:none;
  }
  .sidebar-open .sidebar{display:block;}
  .sidebar-overlay{display:none;}
  .sidebar-open .sidebar-overlay{
    display:block;position:fixed;inset:0;
    background:rgba(15,23,42,.38);
    z-index:35;
  }
  .searchbar{display:none;}
}
