/* =========================================================
   1) ROOT TOKENS
   ========================================================= */
:root{
  --blue:#1F5FBF;
  --orange:#F05A28;
  --green:#3CBF6B;
  --red:#D64545;
  --amber:#F4A62A;
  --bg:#F4F6F9;
  --text:#1F2937;
  --muted:#6B7280;
  --border:#D9E0E7;
  --white:#FFFFFF;
  --dark:#3F4A5A;
  --shadow:0 10px 30px rgba(15,23,42,.08);
}

/* =========================================================
   2) BASE / RESET
   ========================================================= */
*{box-sizing:border-box}

body{
  margin:0;
  font-family:Arial,Helvetica,sans-serif;
  background:var(--bg);
  color:var(--text);
}

a{
  text-decoration:none;
  color:inherit;
}

code{
  background:#f2f4f7;
  padding:2px 6px;
  border-radius:6px;
}

h1,h2,h3{margin:0 0 8px}
p{margin:0 0 12px}

.sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

.muted{color:var(--muted)}

/* =========================================================
   3) APP SHELL LAYOUT
   ========================================================= */
.app-shell{
  display:flex;
  min-height:100vh;
}

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

.content{
  padding:24px 26px;
}

/* =========================================================
   4) SIDEBAR
   ========================================================= */
.sidebar{
  width:270px;
  background:var(--dark);
  color:#fff;
  padding:26px 18px;
  transition:width .2s ease,padding .2s ease;
}

.brand{
  font-size:30px;
  font-weight:800;
  letter-spacing:-0.02em;
}

.brand-link{
  display:inline-block;
  color:#fff;
}

.sidebar-brand-block{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:6px;
  margin-bottom:20px;
}

.sidebar-logo-wrap{
  display:block;
  max-width:148px;
}

.sidebar-logo{
  display:block;
  max-width:148px;
  max-height:44px;
  width:auto;
  height:auto;
  border-radius:8px;
  background:#fff;
  padding:4px;
}

.brand-company{
  font-size:14px;
  font-weight:800;
  color:#fff;
  opacity:.96;
  line-height:1.25;
  margin:0;
}

.brand-tagline{
  font-size:12px;
  color:rgba(255,255,255,.8);
  line-height:1.35;
  margin:0;
}

.brand-sub{
  font-size:12px;
  opacity:.8;
  margin-top:6px;
  margin-bottom:22px;
  line-height:1.4;
}

.sidebar-head-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}

.sidebar-toggle{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:38px;
  height:38px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.07);
  color:#fff;
  cursor:pointer;
  flex:0 0 auto;
  margin-top:2px;
}

.sidebar-overlay{display:none}
.sidebar-overlay[hidden]{display:none !important}

/* =========================================================
   5) NAVIGATION
   ========================================================= */
.nav{
  display:grid;
  gap:8px;
}

.nav a{
  padding:12px 14px;
  border-radius:12px;
  color:#eef3f8;
  font-weight:600;
}

.nav a.active,
.nav a:hover{
  background:rgba(255,255,255,.09);
}

.nav-static-link{
  display:block;
  padding:12px 14px;
  border-radius:12px;
  color:#eef3f8;
  font-weight:600;
}

.nav-static-link.active,
.nav-static-link:hover{
  background:rgba(255,255,255,.09);
}

.nav-groups{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.nav-group{
  border-radius:12px;
  overflow:hidden;
  background:rgba(255,255,255,0.03);
}

.nav-group summary{
  list-style:none;
  cursor:pointer;
  padding:12px 14px;
  font-weight:600;
  color:inherit;
  user-select:none;
  display:flex;
  align-items:center;
}

.nav-group summary::-webkit-details-marker{
  display:none;
}

.nav-group summary::after{
  content:"▸";
  float:right;
  transition:transform .2s ease;
}

.nav-group[open] summary::after{
  transform:rotate(90deg);
}

.nav-group.active-group summary{
  background:rgba(255,255,255,.09);
  color:#fff;
}

.nav-sub{
  display:flex;
  flex-direction:column;
  padding:0 8px 8px;
}

.nav-sub a{
  display:block;
  padding:10px 12px;
  border-radius:10px;
  text-decoration:none;
}

.nav-sub a.active{
  font-weight:600;
  background:rgba(255,255,255,.11);
  color:#fff;
}

.nav-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  margin-right:10px;
  opacity:.92;
}

.nav-label{
  display:inline-block;
  vertical-align:middle;
}

.nav-group summary .nav-label,
.nav-static-link .nav-label{
  vertical-align:middle;
}

.nav-static-link{
  display:flex;
  align-items:center;
}

/* =========================================================
   6) SIDEBAR COLLAPSED STATE
   ========================================================= */
body.sidebar-collapsed .sidebar{
  width:92px;
  padding:26px 12px;
}

body.sidebar-collapsed .sidebar-brand-block{
  align-items:center;
  text-align:center;
}

body.sidebar-collapsed .sidebar-head-row{
  flex-direction:column;
  align-items:center;
}

body.sidebar-collapsed .sidebar-logo-wrap,
body.sidebar-collapsed .brand-company,
body.sidebar-collapsed .brand-tagline,
body.sidebar-collapsed .nav-groups{
  display:none;
}

body.sidebar-collapsed .brand-link{
  font-size:18px;
  text-align:center;
}

body.sidebar-collapsed .sidebar-toggle{
  width:44px;
}

body.sidebar-collapsed .nav-icon{
  margin-right:0;
}

body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-group summary::after{
  display:none;
}

body.sidebar-collapsed .nav-group summary,
body.sidebar-collapsed .nav-static-link{
  justify-content:center;
  padding-left:10px;
  padding-right:10px;
}

body.sidebar-collapsed .nav-group{
  overflow:visible;
}

body.sidebar-collapsed .nav-sub{
  display:none;
}

/* =========================================================
   7) TOPBAR
   ========================================================= */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  background:#fff;
  padding:20px 26px;
  border-bottom:1px solid var(--border);
}

.topbar-left{
  display:flex;
  align-items:flex-start;
  gap:14px;
  min-width:0;
}

.topbar-copy{
  min-width:0;
}

.topbar h1{
  font-size:30px;
  letter-spacing:-0.02em;
}

.subtitle{
  color:var(--muted);
  font-size:14px;
}

.top-user-actions{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.top-actions{
  display:flex;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.top-logout-link{
  color:var(--blue);
  font-weight:700;
}

.topbar-search{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:min(460px,42vw);
}

.topbar-search-input{
  min-width:260px;
}

.topbar-search-btn{
  white-space:nowrap;
}

.topbar-menu-btn{
  display:none;
  align-items:center;
  justify-content:center;
  width:42px;
  height:42px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  cursor:pointer;
  box-shadow:var(--shadow);
}

/* =========================================================
   8) USER MENU
   ========================================================= */
.user-chip{
  background:#eef4ff;
  color:var(--blue);
  padding:10px 12px;
  border-radius:999px;
  font-weight:700;
}

.user-menu{
  position:relative;
}

.user-menu summary{
  list-style:none;
  cursor:pointer;
}

.user-menu summary::-webkit-details-marker{
  display:none;
}

.user-menu-summary{
  display:block;
}

.user-menu-panel{
  position:absolute;
  right:0;
  top:calc(100% + 10px);
  min-width:180px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:var(--shadow);
  padding:8px;
  display:grid;
  gap:4px;
  z-index:40;
}

.user-menu-panel a{
  padding:10px 12px;
  border-radius:10px;
  color:var(--text);
  font-weight:600;
}

.user-menu-panel a:hover{
  background:#f5f8fc;
}

/* =========================================================
   9) SHARED UI: CARDS / GRIDS / LISTS / TABLES
   ========================================================= */
.card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:18px;
  padding:20px;
  box-shadow:var(--shadow);
}

.grid{
  display:grid;
  gap:18px;
}

.grid.two{grid-template-columns:1fr 1fr}
.grid.three{grid-template-columns:repeat(3,1fr)}
.grid.four{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:16px;
}

.card-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:12px;
  gap:12px;
}

.card-head a{
  color:var(--blue);
  font-weight:700;
  font-size:14px;
}

.simple-bars{
  display:grid;
  gap:12px;
}

.bar-row{
  display:grid;
  grid-template-columns:48px 1fr auto;
  gap:12px;
  align-items:center;
}

.bar-track{
  height:12px;
  border-radius:999px;
  background:#eef2f7;
  overflow:hidden;
  min-width:0;
}

.bar-fill{
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg,var(--blue),var(--orange));
}

.list-stack{
  display:grid;
  gap:12px;
}

.list-item{
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:center;
  padding:14px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fcfdff;
  min-width:0;
}

.list-item > div{
  min-width:0;
}

.list-item.align-top{
  align-items:flex-start;
}

.item-title{
  font-weight:700;
  overflow-wrap:anywhere;
}

.item-meta,
.item-copy{
  font-size:13px;
  color:var(--muted);
  overflow-wrap:anywhere;
}

.score-pill,
.tag{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:46px;
  padding:8px 10px;
  border-radius:999px;
  background:#eef4fb;
  color:var(--blue);
  font-weight:800;
  font-size:12px;
}

.table-wrap{
  overflow:auto;
}

.table{
  width:100%;
  border-collapse:collapse;
}

.table th,
.table td{
  padding:14px 12px;
  border-bottom:1px solid var(--border);
  text-align:left;
  vertical-align:top;
}

.table th{
  font-size:13px;
  color:var(--muted);
  background:#fafcfe;
}

.inline-link{
  color:var(--blue);
  font-weight:700;
}

.empty-cell{
  text-align:center;
  color:var(--muted);
  padding:24px;
}

.badge{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  background:#eef4fb;
  color:var(--blue);
  font-size:12px;
  font-weight:700;
  text-transform:capitalize;
}

.empty{
  min-height:180px;
  border:1px dashed var(--border);
  border-radius:12px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--muted);
  background:#fafcfe;
}

.helper-note{
  font-size:13px;
  color:var(--muted);
  margin-top:14px;
  line-height:1.5;
}

.divider{
  height:1px;
  background:var(--border);
  margin:20px 0;
}

.plain-list{
  margin:0;
  padding-left:18px;
  color:var(--muted);
  display:grid;
  gap:8px;
}

/* =========================================================
   10) KPI / DASHBOARD BLOCKS
   ========================================================= */
.kpi-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:16px;
  margin-bottom:20px;
}

.kpi-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:18px;
  padding:18px;
  box-shadow:var(--shadow);
}

.kpi-card span{
  display:block;
  color:var(--muted);
  font-size:13px;
  margin-bottom:10px;
}

.kpi-card strong{
  font-size:28px;
  line-height:1.1;
}

.kpi-card.success{border-top:4px solid var(--green)}
.kpi-card.warning{border-top:4px solid var(--amber)}
.kpi-card.danger{border-top:4px solid var(--red)}

.mini-kpis{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

.mini-kpi{
  background:#fff;
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px 14px;
  box-shadow:var(--shadow);
}

.mini-kpi span{
  display:block;
  color:var(--muted);
  font-size:12px;
}

.mini-kpi strong{
  font-size:18px;
  line-height:1.2;
}

/* =========================================================
   11) PAGE TOOLS / PROFILE / STATS
   ========================================================= */
.page-tools{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:18px;
  margin-bottom:18px;
}

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

.profile-title{
  font-size:30px;
  font-weight:800;
}

.profile-meta{
  color:var(--muted);
}

.stat-lg{
  font-size:34px;
  font-weight:800;
  line-height:1.1;
}

.oem-stat-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:16px;
}

/* =========================================================
   12) FORMS / BUTTONS / INPUTS
   ========================================================= */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:12px 16px;
  border-radius:12px;
  border:1px solid transparent;
  font-weight:700;
  cursor:pointer;
}

.btn-primary{
  background:var(--blue);
  color:#fff;
}

.btn-secondary{
  background:#fff;
  border-color:var(--border);
  color:var(--text);
}

.btn-small{
  padding:8px 10px;
  font-size:12px;
}

.label{
  display:block;
  font-size:13px;
  color:var(--muted);
  margin-bottom:8px;
}

.input{
  width:100%;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
}

.textarea{resize:vertical}

.form-stack{
  display:grid;
  gap:16px;
}

.form-card{
  max-width:860px;
}

.compact-form .input{
  padding:11px 13px;
}

.inline-form{
  display:flex;
  align-items:center;
  gap:8px;
}

.input-sm{
  min-width:110px;
  padding:8px 10px;
}

.inline-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

.actions-row{
  display:flex;
  gap:12px;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.remember-row{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:14px;
  color:#6B7280;
}

/* =========================================================
   13) ALERTS / STATUS
   ========================================================= */
.alert{
  padding:14px 16px;
  border-radius:12px;
  margin-bottom:16px;
}

.alert.success{
  background:#e9f8ef;
  color:#166534;
}

.alert.danger{
  background:#fdecec;
  color:#991b1b;
}

.alert-item.critical{border-left:4px solid #D64545}
.alert-item.warning{border-left:4px solid #F4A62A}
.alert-item.info{border-left:4px solid #1F5FBF}

/* =========================================================
   14) AUTH
   ========================================================= */
.auth-shell{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:linear-gradient(135deg,#eef4fb 0%,#f7f9fc 100%);
}

.auth-card{
  width:100%;
  max-width:430px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:20px;
  padding:32px;
  box-shadow:var(--shadow);
}

.auth-brand{
  color:var(--blue);
  margin-bottom:10px;
}

/* =========================================================
   15) LARGE / MID BREAKPOINTS
   ========================================================= */
@media (max-width: 1320px){
  .kpi-grid{grid-template-columns:repeat(3,1fr)}
}

@media (max-width: 1100px){
  .grid.two,
  .grid.three{
    grid-template-columns:1fr;
  }

  .kpi-grid{
    grid-template-columns:repeat(2,1fr);
  }
}

@media (max-width: 1080px){
  .topbar{
    gap:14px;
    align-items:stretch;
    flex-wrap:wrap;
  }

  .top-actions{
    width:100%;
    justify-content:space-between;
  }

  .topbar-search{
    min-width:0;
    flex:1;
  }

  .topbar-search-input{
    min-width:0;
  }
}

@media (max-width: 900px){
  .grid.four{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

/* =========================================================
   16) BASE MOBILE LAYOUT
   ========================================================= */
@media (max-width: 820px){
  body{overflow-x:hidden}
  body.mobile-sidebar-open{overflow:hidden}

  .app-shell{
    display:block;
    min-height:100dvh;
  }

  .sidebar{
    position:fixed;
    left:0;
    top:0;
    bottom:0;
    z-index:35;
    max-width:320px;
    width:min(88vw,320px);
    transform:translateX(-102%);
    transition:transform .22s ease,padding .2s ease;
    overflow:auto;
    overscroll-behavior:contain;
    box-shadow:var(--shadow);
    padding:18px 14px calc(24px + env(safe-area-inset-bottom));
  }

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

  .sidebar-overlay{
    position:fixed;
    inset:0;
    background:rgba(15,23,42,.35);
    z-index:30;
    display:none;
  }

  body.mobile-sidebar-open .sidebar-overlay:not([hidden]){
    display:block;
  }

  .sidebar-head-row{
    position:sticky;
    top:0;
    z-index:2;
    padding-bottom:12px;
    background:var(--dark);
    align-items:flex-start;
  }

  .sidebar-brand-block{
    gap:4px;
    margin-bottom:14px;
    max-width:100%;
  }

  .sidebar-logo-wrap{max-width:132px}
  .sidebar-logo{
    max-width:132px;
    max-height:40px;
  }

  .brand{
    font-size:28px;
    line-height:1.05;
  }

  .brand-company{font-size:13px}

  .brand-tagline{
    font-size:11px;
    line-height:1.3;
  }

  .nav{gap:10px}

  .nav-group,
  .nav-static-link{
    background:rgba(255,255,255,.03);
  }

  .nav-group summary,
  .nav-static-link,
  .nav-sub a{
    min-height:46px;
    padding-top:12px;
    padding-bottom:12px;
  }

  .nav-sub{
    padding:0 6px 6px;
  }

  .topbar,
  .content{
    padding:16px;
  }

  .topbar-menu-btn{
    display:inline-flex;
    touch-action:manipulation;
  }

  .kpi-grid,
  .grid.two,
  .grid.three{
    grid-template-columns:1fr;
  }

  .page-tools,
  .profile-head{
    display:block;
  }

  .mini-kpis{
    margin-bottom:12px;
  }

  .page-tools,
  .profile-head,
  .card-head,
  .actions-row{
    gap:12px;
  }

  .bar-row{
    grid-template-columns:42px minmax(0,1fr) auto;
    gap:10px;
  }

  .table-wrap{
    overflow:auto;
    -webkit-overflow-scrolling:touch;
  }

  .table{
    min-width:680px;
  }

  .grid.four{
    grid-template-columns:1fr;
  }

  .oem-stat-grid{
    grid-template-columns:repeat(2,1fr);
    gap:12px;
  }
}

/* =========================================================
   17) MOBILE HEADER + KPI POLISH
   ========================================================= */
.mobile-quickbar{display:none}

@media (max-width: 820px){
  .topbar{
    position:sticky;
    top:0;
    z-index:20;
    display:grid;
    grid-template-columns:44px minmax(0,1fr);
    grid-template-areas:
      "menu user"
      "search search";
    align-items:center;
    column-gap:10px;
    row-gap:10px;
    padding:12px 14px 10px;
    background:rgba(255,255,255,.96);
    backdrop-filter:saturate(140%) blur(8px);
  }

  .topbar-left{
    display:contents;
  }

  .topbar-menu-btn{
    grid-area:menu;
    display:inline-flex;
    width:44px;
    height:44px;
    min-width:44px;
    min-height:44px;
    border-radius:14px;
    font-size:18px;
    flex:0 0 44px;
  }

  .topbar-copy{
    display:none;
  }

  .top-actions{
    display:flex;
    align-items:center;
    gap:14px;
    flex-wrap:wrap;
    justify-content:flex-end;
  }

  .topbar > .user-menu,
  .topbar > .topbar-user-menu{
    grid-area:user;
    justify-self:end;
    min-width:0;
    width:auto;
    max-width:44vw;
  }

  .user-chip{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-height:40px;
    max-width:44vw;
    padding:8px 12px;
    font-size:13px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .user-menu-panel{
    right:0;
    left:auto;
    min-width:180px;
    max-width:min(90vw,240px);
  }

  .topbar > .topbar-search{
    grid-area:search;
    position:relative;
    display:block;
    width:100%;
    min-width:0;
    margin-top:0;
  }

  .topbar-search-input{
    width:100%;
    min-width:0;
    min-height:46px;
    padding-right:54px;
    border-radius:14px;
    font-size:16px;
  }

  .topbar-search .btn{
    min-height:42px;
    width:auto;
  }

  .topbar-search-btn{
    position:absolute;
    right:6px;
    top:50%;
    transform:translateY(-50%);
    width:38px;
    min-width:38px;
    max-width:38px;
    height:38px;
    min-height:38px;
    padding:0;
    border-radius:10px;
    font-size:0;
    box-shadow:none;
    white-space:nowrap;
  }

  .topbar-search-btn::before{
    content:"⌕";
    font-size:18px;
    line-height:1;
    color:var(--text);
  }

  .topbar-search-btn-text{
    display:none;
  }

  .card,
  .kpi-card,
  .mini-kpi{
    border-radius:16px;
  }

  .card{
    padding:18px;
  }

  .card-head{
    align-items:flex-start;
    flex-wrap:wrap;
  }

  .list-item{
    padding:14px;
  }

  .content{
    padding:14px 14px calc(88px + env(safe-area-inset-bottom));
  }

  /* Swipeable KPI rows */
  .mini-kpis,
  .kpi-grid{
    display:grid;
    grid-auto-flow:column;
    grid-auto-columns:minmax(82vw,82vw);
    gap:12px;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    scroll-snap-type:x proximity;
    scrollbar-width:none;
    padding-bottom:4px;
  }

  .mini-kpis::-webkit-scrollbar,
  .kpi-grid::-webkit-scrollbar{
    display:none;
  }

  .mini-kpi,
  .kpi-card{
    width:100%;
    scroll-snap-align:start;
  }

  .mini-kpi{
    min-height:112px;
    padding:16px 16px 18px;
  }

  .mini-kpi strong{
    font-size:18px;
    line-height:1.2;
    word-break:break-word;
  }

  .kpi-card{
    min-height:112px;
    padding:18px;
  }

  .kpi-card strong{
    font-size:24px;
    line-height:1.1;
    word-break:break-word;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .oem-stat-grid{
    grid-template-columns:1fr !important;
  }

  /* Bottom quick actions bar */
  .mobile-quickbar{
    position:fixed;
    left:0;
    right:0;
    bottom:0;
    z-index:24;
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:8px;
    padding:10px 12px calc(10px + env(safe-area-inset-bottom));
    background:rgba(255,255,255,.96);
    border-top:1px solid var(--border);
    backdrop-filter:saturate(140%) blur(10px);
  }

  .mobile-quickbar-link{
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:4px;
    min-height:54px;
    padding:6px 4px;
    border-radius:14px;
    color:var(--muted);
    font-weight:700;
    font-size:11px;
  }

  .mobile-quickbar-link.active{
    background:#eef4ff;
    color:var(--blue);
  }

  .mobile-quickbar-icon{
    font-size:18px;
    line-height:1;
  }

  .mobile-quickbar-label{
    line-height:1.1;
    text-align:center;
  }

  /* Dashboard mobile-only targeted fix */
  .dashboard-page{
    overflow-x:hidden;
  }

  .dashboard-page .dashboard-forecast-row{
    grid-template-columns:1fr !important;
    overflow-x:hidden;
  }

  .dashboard-page .dashboard-forecast-row > .card{
    min-width:0;
    max-width:100%;
    overflow:hidden;
  }

  .dashboard-page .dashboard-forecast-card .card-head,
  .dashboard-page .dashboard-qbr-card .card-head{
    min-width:0;
    flex-wrap:wrap;
    align-items:flex-start;
    gap:8px;
  }

  .dashboard-page .dashboard-forecast-card .card-head h3,
  .dashboard-page .dashboard-forecast-card .card-head a,
  .dashboard-page .dashboard-qbr-card .card-head h3,
  .dashboard-page .dashboard-qbr-card .card-head a{
    min-width:0;
    max-width:100%;
    overflow-wrap:anywhere;
  }

  .dashboard-page .dashboard-forecast-row .mini-kpis{
    display:grid !important;
    grid-template-columns:1fr !important;
    grid-auto-flow:row !important;
    grid-auto-columns:auto !important;
    gap:10px;
    overflow:visible !important;
    padding-bottom:0;
    margin-bottom:14px;
  }

  .dashboard-page .dashboard-forecast-row .mini-kpi{
    min-height:0;
    width:100%;
  }

  .dashboard-page .dashboard-forecast-row .list-item{
    min-width:0;
    max-width:100%;
    align-items:flex-start;
  }

  .dashboard-page .dashboard-forecast-row .list-item > div{
    min-width:0;
    flex:1 1 auto;
  }

  .dashboard-page .dashboard-forecast-row .item-title,
  .dashboard-page .dashboard-forecast-row .item-meta,
  .dashboard-page .dashboard-forecast-row .tag{
    overflow-wrap:anywhere;
    word-break:break-word;
  }
}

/* =========================================================
   18) SMALL MOBILE
   ========================================================= */
@media (max-width: 560px){
  .topbar{
    padding:10px 12px 8px;
  }

  .topbar > .user-menu,
  .topbar > .topbar-user-menu{
    max-width:40vw;
  }

  .user-chip{
    max-width:40vw;
    padding:8px 11px;
    font-size:12px;
  }

  .topbar-search{
    display:block;
    position:relative;
    width:100%;
    min-width:0;
  }

  .topbar-search .btn{
    width:auto;
  }

  .topbar-search-input{
    min-height:44px;
    padding-right:52px;
  }

  .topbar-search-btn,
  .topbar-search .topbar-search-btn{
    position:absolute;
    right:6px;
    top:50%;
    transform:translateY(-50%);
    width:38px;
    min-width:38px;
    max-width:38px;
    height:38px;
    min-height:38px;
    padding:0;
  }

  .kpi-grid{
    grid-template-columns:1fr;
  }

  .mini-kpis,
  .kpi-grid{
    grid-auto-columns:minmax(86vw,86vw);
  }

  .mini-kpi,
  .kpi-card{
    min-height:108px;
  }

  .oem-stat-grid{
    grid-template-columns:1fr;
  }

  .inline-form{
    display:grid;
    grid-template-columns:1fr;
    align-items:stretch;
  }

  .input-sm{
    min-width:0;
  }

  .card{
    padding:16px;
  }

  .dashboard-page .dashboard-forecast-row .mini-kpis{
    grid-auto-columns:auto !important;
  }

  .dashboard-page .dashboard-forecast-row .mini-kpi{
    min-height:0;
  }
}

/* =========================================================
   19) COLLAPSED SIDEBAR SAFETY ON MOBILE
   ========================================================= */
@media (max-width: 820px){
  body.sidebar-collapsed .sidebar{
    width:100%;
    padding:18px;
  }

  body.sidebar-collapsed .sidebar-logo-wrap,
  body.sidebar-collapsed .brand-company,
  body.sidebar-collapsed .brand-tagline,
  body.sidebar-collapsed .nav-groups{
    display:block;
  }

  body.sidebar-collapsed .sidebar-head-row{
    flex-direction:row;
    align-items:flex-start;
  }

  body.sidebar-collapsed .brand-link{
    font-size:30px;
    text-align:left;
  }
}

/* =========================================================
   20) PARTNERS PAGE ACTION LINKS
   ========================================================= */
.partners-mobile-links{
  display:flex;
  flex-wrap:wrap;
  gap:10px 12px;
  margin:14px 0 18px;
}

.partners-mobile-links a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border:1px solid var(--border);
  border-radius:999px;
  background:#fff;
  color:var(--blue);
  font-weight:700;
  font-size:14px;
  line-height:1.2;
  box-shadow:var(--shadow);
  white-space:nowrap;
}

.partners-mobile-links a:hover{
  background:#eef4ff;
}

@media (max-width: 820px){
  .partners-mobile-links{
    justify-content:flex-start;
  }

  .partners-mobile-links a{
    font-size:13px;
    padding:9px 12px;
    box-shadow:none;
  }
}
/* Desktop topbar alignment fix */
@media (min-width: 821px){
  .topbar{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:18px;
  }

  .topbar-left{
    flex:1 1 auto;
    min-width:0;
  }

  .topbar > .topbar-search{
    margin-left:auto;
  }

  .topbar > .user-menu,
  .topbar > .topbar-user-menu{
    order:3;
    margin-left:12px;
    flex:0 0 auto;
  }

  .topbar > .topbar-search{
    order:2;
    flex:0 1 460px;
    min-width:320px;
  }
}
.dashboard-layout-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:0 0 14px;
}
.dashboard-layout-note{
  font-size:13px;
  color:#64748b;
}
.dashboard-layout-actions{
  display:flex;
  align-items:center;
  gap:8px;
}
.dashboard-layout-board{
  display:block;
}
.dashboard-draggable-card{
  position:relative;
  cursor:grab;
}
.dashboard-draggable-card.is-dragging{
  opacity:.55;
  cursor:grabbing;
}
.dashboard-draggable-card.drag-over-before{
  box-shadow: inset 0 3px 0 rgba(37, 99, 235, .45);
}
.dashboard-draggable-card.drag-over-after{
  box-shadow: inset 0 -3px 0 rgba(37, 99, 235, .45);
}
@media (max-width: 820px){
  .dashboard-layout-toolbar{
    flex-direction:column;
    align-items:flex-start;
  }
  .dashboard-layout-note{
    font-size:12px;
  }
  .dashboard-draggable-card{
    cursor:default;
  }
}

.search-hero-card{
  overflow:hidden;
}

.search-hero-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:16px;
}

.search-hero-badge{
  margin-bottom:10px;
}

.search-hero-title{
  margin:0 0 8px;
  font-size:28px;
  line-height:1.1;
}

.search-hero-subtitle{
  max-width:820px;
}

.search-page-form{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:12px;
  margin-bottom:18px;
}

.search-page-input{
  min-width:0;
}

.search-summary-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
}

.search-summary-card{
  border:1px solid var(--border);
  border-radius:16px;
  background:#fcfdff;
  padding:16px;
  box-shadow:var(--shadow);
}

.search-summary-card span,
.search-summary-card small{
  display:block;
}

.search-summary-card span{
  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.04em;
  margin-bottom:8px;
}

.search-summary-card strong{
  display:block;
  font-size:28px;
  line-height:1;
  margin-bottom:8px;
}

.search-summary-card small{
  color:var(--muted);
  line-height:1.4;
}

.search-empty-state,
.search-best-match-wrap,
.search-group-card,
.search-results-toolbar{
  margin-top:20px;
}

.search-empty-state{
  border:1px dashed var(--border);
  border-radius:18px;
  background:#fafcfe;
  padding:20px;
}

.search-empty-copy h3{
  margin:0 0 6px;
}

.search-empty-copy p{
  margin:0;
  color:var(--muted);
}

.search-suggestion-chips,
.search-section-pills,
.search-result-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.search-suggestion-chips,
.search-shortcuts-grid{
  margin-top:16px;
}

.search-chip,
.search-section-pill,
.search-action-link{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border:1px solid var(--border);
  border-radius:999px;
  background:#fff;
  color:var(--text);
  font-size:13px;
  font-weight:700;
  text-decoration:none;
}

.search-section-pill span{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:22px;
  height:22px;
  padding:0 6px;
  border-radius:999px;
  background:#eef4fb;
  color:var(--blue);
  font-size:12px;
}

.search-shortcuts-grid,
.search-best-match-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
}

.search-shortcut-card,
.search-best-match-card{
  display:block;
  border:1px solid var(--border);
  border-radius:16px;
  background:#fff;
  padding:16px;
  text-decoration:none;
  color:inherit;
  box-shadow:var(--shadow);
}

.search-shortcut-card strong,
.search-best-match-card strong{
  display:block;
  margin-bottom:6px;
}

.search-shortcut-card span,
.search-best-match-card small,
.search-best-match-label{
  display:block;
  color:var(--muted);
}

.search-best-match-label{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.04em;
  margin-bottom:10px;
}

.search-results-toolbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
}

.search-results-copy h3{
  margin:0 0 4px;
}

.search-groups-improved{
  display:grid;
  gap:18px;
}

.search-group-card{
  border:1px solid var(--border);
  border-radius:18px;
  background:#fff;
  box-shadow:var(--shadow);
  padding:18px;
}

.search-group-head{
  align-items:center;
  margin-bottom:14px;
}

.search-group-count{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  height:34px;
  padding:0 10px;
  border-radius:999px;
  background:#eef4fb;
  color:var(--blue);
  font-weight:800;
}

.search-group-list-improved{
  display:grid;
  gap:12px;
}

.search-result-row-card{
  border:1px solid var(--border);
  border-radius:16px;
  background:#fcfdff;
  padding:14px;
}

.search-result-main{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  text-decoration:none;
  color:inherit;
}

.search-result-main-copy{
  min-width:0;
}

.search-result-title{
  font-weight:800;
  margin-bottom:6px;
  overflow-wrap:anywhere;
}

.search-result-meta{
  color:var(--muted);
  font-size:13px;
  line-height:1.45;
  overflow-wrap:anywhere;
}

.search-result-type{
  white-space:nowrap;
}

.search-result-actions{
  margin-top:12px;
}

.search-result-row-card mark,
.search-best-match-card mark{
  background:#fff3bf;
  padding:0 2px;
  border-radius:3px;
}

@media (max-width: 1100px){
  .search-shortcuts-grid,
  .search-best-match-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media (max-width: 820px){
  .search-hero-top,
  .search-results-toolbar{
    flex-direction:column;
    align-items:flex-start;
  }

  .search-hero-title{
    font-size:24px;
  }

  .search-page-form,
  .search-summary-grid,
  .search-shortcuts-grid,
  .search-best-match-grid{
    grid-template-columns:1fr;
  }

  .search-result-main{
    flex-direction:column;
  }

  .search-result-type{
    white-space:normal;
  }
}
