:root{
  --sidebar-bg:#0b2340;
  --sidebar-bg2:#081a2f;
  --sidebar-text:#e8eef7;
  --primary:#0d5bd7;
}

body.role-oficina{
  --sidebar-bg:#c4ccd5;
  --sidebar-bg2:#9eaab7;
  --sidebar-text:#1f2b38;
  --primary:#6f7d8c;
}

html,body{height:100%;}
body{background:#f4f7fb;}
body.sidebar-mobile-open{overflow:hidden;}

.sidebar{
  position:fixed; top:0; left:0; bottom:0;
  width:260px;
  background:linear-gradient(180deg,var(--sidebar-bg),var(--sidebar-bg2));
  color:var(--sidebar-text);
  padding:18px 0;
  overflow-y:auto;
  overflow-x:hidden;
  z-index:1040;
}
.sidebar-backdrop{display:none}
.mobile-sidebar-toggle{
  display:none;
  position:fixed;
  top:12px;
  left:12px;
  z-index:1055;
  width:44px;
  height:44px;
  border:0;
  border-radius:10px;
  background:rgba(255,255,255,.96);
  box-shadow:0 8px 18px rgba(15,39,64,.16);
  padding:10px 9px;
  backdrop-filter:blur(8px);
}
.mobile-sidebar-toggle span{
  display:block;
  width:100%;
  height:3px;
  margin:4px 0;
  border-radius:999px;
  background:#0f2740;
}

.sidebar .brand{
  padding:0 14px 12px;
  display:flex; align-items:center; gap:10px;
  border-bottom:1px solid rgba(255,255,255,.08);
  margin-bottom:14px;
  overflow:hidden;
  min-height:72px;
}
.brand .logo{
  width:34px; height:34px;
  border-radius:10px;
  background:#1f6feb;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; color:white;
  overflow:hidden;
  flex:0 0 34px;
}
.brand .title{line-height:1.05;min-width:0;overflow:hidden;flex:1 1 auto;}
.brand .title .name{font-weight:700;font-size:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.brand .title .sub{font-size:11px; opacity:.82;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

.sidebar .userbox{
  padding:12px 18px;
  border-bottom:1px solid rgba(255,255,255,.08);
  margin-bottom:10px;
}
.userbox .role{font-weight:700;}
.userbox .meta{font-size:12px; opacity:.85;}
.userbox .badge{
  display:inline-block;
  padding:2px 8px;
  border-radius:12px;
  background:rgba(255,255,255,.12);
  font-size:11px;
  margin-top:6px;
}

.sidebar .nav-title{
  padding:10px 18px 4px;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.05em;
  opacity:.6;
}

.sidebar .nav a{
  color:var(--sidebar-text);
  padding:9px 18px;
  display:block;
  text-decoration:none;
  opacity:.92;
  word-break:break-word;
  line-height:1.2;
}

/* garante itens do menu um embaixo do outro */
.sidebar .nav{display:flex; flex-direction:column;}
.sidebar .nav a:hover, .sidebar .nav a.active{
  background:rgba(255,255,255,.08);
  opacity:1;
}

.sidebar .logout{
  position:fixed;
  left:18px;
  bottom:14px;
  width:224px;
}

.main{
  margin-left:260px;
  min-height:100%;
}

.topbar{
  height:48px;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  padding:0 18px;
  font-size:13px;
  color:#5b6b80;
}

.content{
  padding:12px 6px 28px;
}

/* Em monitores grandes (ex.: 21"), evita esticar demais e mantem o layout alinhado */
@media (min-width: 1401px){
  .content{max-width:none; margin:0;}
}

.card-metric{
  border:1px solid rgba(0,0,0,.08);
  border-left:4px solid var(--primary);
  border-radius:3px;
}
.card-metric .label{font-size:13px; color:#6b7b8f;}
.card-metric .value{font-size:30px; font-weight:700; line-height:1;}

.table thead th{background:#eef2f6;}

/* Ajuste fino para telas 14"/15" (ex.: 1366px): layout mais compacto */
@media (max-width: 1400px){
  .sidebar{width:220px;}
  .sidebar .logout{width:188px; position:static; margin:12px 18px 0;}
  .main{margin-left:220px;}
  .content{padding:10px 6px 24px;}
  body{font-size:14px;}
  .table td, .table th{padding:.45rem;}
  .card-metric .value{font-size:26px;}
}

/* Melhorias gerais de responsividade em tabelas e botoes */
.table td.text-nowrap, .table th.text-nowrap{white-space:nowrap;}
.btn-group .btn{white-space:nowrap;}
.form-help{font-size:12px; color:#6b7b8f;}
.login-shell{
  display:flex;
  min-height:100vh;
}
.login-side{
  width:320px;
  background:linear-gradient(180deg,var(--sidebar-bg),var(--sidebar-bg2));
  color:var(--sidebar-text);
  padding:26px 18px;
}
.login-side h4{font-weight:700;}
.login-side p{opacity:.9;}
.login-main{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.login-card{
  width:480px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:6px;
  box-shadow:0 12px 24px rgba(0,0,0,.06);
}


/* Responsividade */
@media (max-width: 991.98px){
  .mobile-sidebar-toggle{display:block}
  .sidebar{
    position:fixed;
    width:232px;
    max-width:74vw;
    height:100vh;
    padding:12px 0 18px;
    transform:translateX(-104%);
    transition:transform .24s ease;
    box-shadow:0 14px 32px rgba(36,49,66,.18);
  }
  body.sidebar-mobile-open .sidebar{transform:translateX(0)}
  .sidebar-backdrop{
    position:fixed;
    inset:0;
    background:rgba(36,49,66,.24);
    z-index:1035;
  }
  body.sidebar-mobile-open .sidebar-backdrop{display:block}
  .sidebar .brand{
    margin-bottom:8px;
    padding:0 12px 10px;
    min-height:64px;
  }
  .brand .title .name{font-size:17px;}
  .brand .title .sub{font-size:10px;}
  .sidebar .logout{position:static;width:auto;margin:14px 18px 0}
  .main{margin-left:0;}
  .content{padding:12px;}
  .topbar{
    justify-content:space-between;
    padding:12px 12px 12px 64px;
    min-height:64px;
  }
  .topbar-right{gap:10px}
  .topbar-user .name{font-size:15px}
  .topbar-user .meta{font-size:11px}
  .topbar-time{font-size:11px}
  .table-responsive{overflow-x:auto; -webkit-overflow-scrolling:touch;}
  .card{border-radius:12px;}
}

@media (max-width: 575.98px){
  .content{padding:10px;}
  .btn{white-space:nowrap;}
  table{font-size:12px;}
  .topbar{
    align-items:flex-start;
    flex-direction:column;
    gap:8px;
    padding:12px 10px 10px 62px;
  }
  .topbar-left,.topbar-right{width:100%}
  .topbar-right{justify-content:space-between}
  .topbar-user{text-align:left}
}

.brand .logo img{width:100%;height:100%;max-width:100%;max-height:100%;display:block;object-fit:contain;}
.topbar{min-height:58px;display:flex;align-items:center;justify-content:space-between;padding:10px 18px;font-size:13px;color:#5b6b80;background:#fff;border-bottom:1px solid rgba(0,0,0,.06);}
.topbar-left{display:flex;align-items:center;gap:10px;font-weight:700;color:#20324a;}
.topbar-left img{width:28px;height:28px;object-fit:contain;}
.topbar-title{font-size:16px;}
.topbar-right{display:flex;align-items:center;gap:18px;}
.topbar-user .name{font-weight:700;color:#1d2c3f;}
.topbar-user .meta{font-size:12px;color:#6a7b8f;}
.topbar-time{white-space:nowrap;}
.row-saved{background:#eceff3 !important;}

body.role-oficina .sidebar .brand,
body.role-oficina .sidebar .userbox{
  border-bottom-color:rgba(31,43,56,.12);
}
body.role-oficina .brand .logo{
  background:#8d99a8;
  color:#1f2b38;
}
body.role-oficina .brand .title .sub,
body.role-oficina .userbox .meta,
body.role-oficina .sidebar .nav-title{
  opacity:.72;
}
body.role-oficina .userbox .badge{
  background:rgba(31,43,56,.10);
}
body.role-oficina .sidebar .nav a:hover,
body.role-oficina .sidebar .nav a.active{
  background:rgba(31,43,56,.10);
}
.row-warning-soft{background:#fff8d8 !important;}
#totais_gerais{text-align:right;}

.sidebar .userbox{display:none !important;}
.brand .logo{
  width:48px;
  height:48px;
  flex:0 0 48px;
  background:#fff;
  border-radius:12px;
  box-shadow:0 2px 8px rgba(0,0,0,.12);
  padding:4px;
  align-self:flex-start;
}
.brand .logo img{
  width:100%;
  height:100%;
  max-width:100%;
  max-height:100%;
  display:block;
  object-fit:contain;
  object-position:center;
  border-radius:8px;
}
.brand .title .name,.brand .title .sub{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.topbar{min-height:74px;display:flex;align-items:center;justify-content:space-between;padding:14px 22px;font-size:13px;color:#5b6b80;background:#fff;border-bottom:1px solid rgba(0,0,0,.08);position:sticky;top:0;z-index:10}
.topbar-left{display:flex;align-items:center;gap:12px;font-weight:700;color:#20324a;}
.topbar-left img{width:42px;height:42px;object-fit:contain;border-radius:12px;background:#fff;box-shadow:0 2px 8px rgba(0,0,0,.08);padding:4px;}
.topbar-title-wrap{display:flex;flex-direction:column;line-height:1.05;}
.topbar-title{font-size:18px;font-weight:800;color:#0d5bd7}
.topbar-sub{font-size:12px;color:#6a7b8f;font-weight:600;}
.topbar-right{display:flex;align-items:center;gap:18px;}
.topbar-user{text-align:right;}
.topbar-user .name{font-weight:700;color:#1d2c3f;font-size:18px;line-height:1.1;}
.topbar-user .meta{font-size:13px;color:#6a7b8f;}
.topbar-time{white-space:nowrap;font-size:13px;color:#44556a;}
#pecas_table .table-responsive,#serv_table .table-responsive,.table-fit-full .table-responsive{overflow-x:visible !important;}
.os-line-locked{background:#eceff3 !important;}
.os-line-over{background:#fff7cf !important;}
.os-line-ok{background:#eceff3 !important;}

.os-view-row{margin-top:6px!important}.os-view-card{padding-top:0!important}.content>.card:first-child,.content>.row:first-child{margin-top:6px!important}
.page-shell-wide{width:100%;max-width:none;padding-left:0;padding-right:0}
.page-shell-wide .card{margin-left:0;margin-right:0}

@media (max-width: 991.98px){
  .dashboard-header-grid{grid-template-columns:1fr !important}
  .dashboard-metrics{row-gap:1rem}
  .sidebar .nav a{padding:8px 16px;font-size:15px}
  .sidebar .nav-title{padding:10px 16px 4px}
}

@media (max-width: 991.98px){
  html,body{overflow-x:hidden;}
  .mobile-sidebar-toggle{
    display:flex !important;
    align-items:center;
    justify-content:center;
  }
  .sidebar{
    left:0 !important;
    top:0 !important;
    bottom:0 !important;
    width:min(284px,82vw) !important;
    max-width:min(284px,82vw) !important;
    padding-bottom:24px !important;
    transform:translateX(-108%) !important;
    transition:transform .22s ease !important;
    box-shadow:0 14px 36px rgba(7,20,38,.28) !important;
    z-index:1050 !important;
  }
  body.sidebar-mobile-open .sidebar{
    transform:translateX(0) !important;
  }
  .sidebar-backdrop{
    display:block;
    position:fixed;
    inset:0;
    background:rgba(7,20,38,.52);
    opacity:0;
    visibility:hidden;
    transition:opacity .2s ease, visibility .2s ease;
    z-index:1045;
  }
  body.sidebar-mobile-open .sidebar-backdrop{
    opacity:1;
    visibility:visible;
  }
  .main{
    margin-left:0 !important;
    width:100%;
    min-width:0;
  }
  .topbar{
    position:sticky;
    top:0;
    z-index:1030;
    min-height:68px !important;
    padding:12px 12px 12px 66px !important;
  }
  .topbar-right{
    min-width:0;
    gap:10px !important;
  }
  .topbar-user{
    min-width:0;
  }
  .topbar-user .name,
  .topbar-user .meta{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .content{
    padding:12px !important;
  }
}

@media (max-width: 575.98px){
  .sidebar{
    width:min(300px,86vw) !important;
    max-width:min(300px,86vw) !important;
  }
  .topbar{
    padding:10px 10px 10px 62px !important;
    align-items:flex-start !important;
    flex-direction:column !important;
    gap:8px !important;
  }
  .topbar-left,
  .topbar-right{
    width:100%;
  }
  .topbar-right{
    justify-content:space-between;
  }
  .topbar-user{
    text-align:left !important;
  }
  .content{
    padding:10px !important;
  }
}








/* Layout superior inspirado no ComexPro */
:root{
  --fm-primary:#12355b;
  --fm-primary-2:#1f6feb;
  --fm-accent:#19a7ce;
  --fm-bg:#f3f7fb;
  --fm-ink:#152238;
  --fm-muted:#6b7a90;
  --fm-border:#dde7f0;
}

body.app-layout-topnav{
  background:
    radial-gradient(circle at top left, rgba(31,111,235,.10), transparent 34rem),
    linear-gradient(180deg, #f8fbff 0%, var(--fm-bg) 100%);
  color:var(--fm-ink);
  min-height:100vh;
}

body.app-layout-topnav .app-nav{
  background:rgba(255,255,255,.94)!important;
  backdrop-filter:blur(12px);
  z-index:1040;
}

body.app-layout-topnav .navbar-brand{
  color:var(--fm-primary)!important;
  letter-spacing:-.03em;
  min-width:210px;
}

body.app-layout-topnav .app-brand-logo{
  width:42px;
  height:42px;
  border-radius:14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#fff;
  box-shadow:0 .45rem 1rem rgba(18,53,91,.14);
  padding:4px;
  overflow:hidden;
}

body.app-layout-topnav .app-brand-logo img{
  width:100%;
  height:100%;
  object-fit:contain;
}

body.app-layout-topnav .app-brand-text{
  display:flex;
  flex-direction:column;
  line-height:1.05;
}

body.app-layout-topnav .app-brand-name{
  font-weight:800;
  font-size:1.05rem;
}

body.app-layout-topnav .app-brand-sub{
  color:var(--fm-muted);
  font-size:.72rem;
  font-weight:700;
}

body.app-layout-topnav .navbar-nav .nav-link{
  color:var(--fm-muted)!important;
  border-radius:999px;
  padding:.45rem .75rem!important;
  margin:.1rem .05rem;
  font-weight:600;
}

body.app-layout-topnav .navbar-nav .nav-link:hover,
body.app-layout-topnav .navbar-nav .nav-link.active,
body.app-layout-topnav .navbar-nav .show>.nav-link{
  background:#eaf2ff;
  color:var(--fm-primary-2)!important;
}

body.app-layout-topnav .dropdown-menu{
  border:1px solid var(--fm-border);
  border-radius:1rem;
  box-shadow:0 .85rem 1.75rem rgba(18,53,91,.12);
}

body.app-layout-topnav .dropdown-item{
  border-radius:.65rem;
  margin:.1rem .35rem;
  width:auto;
}

body.app-layout-topnav .app-unit-label{
  color:var(--fm-primary);
  font-weight:700;
  font-size:.85rem;
}

body.app-layout-topnav .app-user-name{
  color:var(--fm-ink);
  font-weight:800;
  font-size:.88rem;
  line-height:1.05;
}

body.app-layout-topnav .app-user-email{
  color:var(--fm-muted);
  font-size:.74rem;
  max-width:260px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

body.app-layout-topnav .main{
  margin-left:0!important;
  min-height:calc(100vh - 72px);
}

body.app-layout-topnav .content{
  padding:18px 18px 32px!important;
}

body.app-layout-topnav .sidebar,
body.app-layout-topnav .sidebar-backdrop,
body.app-layout-topnav .mobile-sidebar-toggle,
body.app-layout-topnav .topbar{
  display:none!important;
}

body.app-layout-topnav .card{
  border-color:var(--fm-border)!important;
  border-radius:1rem;
}

body.app-layout-topnav .shadow-sm{
  box-shadow:0 .65rem 1.65rem rgba(18,53,91,.08)!important;
}

body.app-layout-topnav .card-metric{
  border:1px solid var(--fm-border);
  border-left:4px solid var(--fm-primary-2);
  border-radius:1rem;
  box-shadow:0 .65rem 1.65rem rgba(18,53,91,.08);
}

body.app-layout-topnav .table thead th{
  background:#eef4fb;
  color:var(--fm-muted);
  font-size:.78rem;
  text-transform:uppercase;
  letter-spacing:.04em;
}

body.app-layout-topnav .btn-primary{
  background:var(--fm-primary-2);
  border-color:var(--fm-primary-2);
}

@media (max-width:991.98px){
  body.app-layout-topnav .navbar-brand{min-width:auto;}
  body.app-layout-topnav .app-user-box{align-items:flex-start!important;margin-top:.75rem;}
  body.app-layout-topnav .app-user-meta{text-align:left!important;}
  body.app-layout-topnav .content{padding:12px!important;}
}

/* Tarja superior reutilizável no padrão visual do dashboard */
.app-page-hero,
body.app-layout-topnav .app-page-hero{
  background:linear-gradient(135deg,#12355b 0%,#174a7c 52%,#19a7ce 100%)!important;
  color:#fff!important;
  border-radius:1.25rem!important;
  padding:1.15rem 1.25rem!important;
  box-shadow:0 1rem 2.25rem rgba(18,53,91,.18)!important;
}

/* Segurança visual: evita exibir uma segunda tarja igual quando páginas antigas ainda injetam hero local. */
.app-page-hero + .app-page-hero,
body.app-layout-topnav .app-page-hero + .app-page-hero{
  display:none!important;
}

.app-page-hero .app-page-actions,
body.app-layout-topnav .app-page-hero .app-page-actions{
  display:flex;
  flex-wrap:wrap;
  gap:.5rem;
  justify-content:flex-end;
}
.app-page-hero .app-page-hero-title,
.app-page-hero .h5,
.app-page-hero h1,
.app-page-hero h2,
.app-page-hero h3,
.app-page-hero h4,
.app-page-hero h5,
.app-page-hero h6{
  color:#fff!important;
}
.app-page-hero .text-muted,
body.app-layout-topnav .app-page-hero .text-muted{
  color:rgba(255,255,255,.78)!important;
}
.app-page-hero .btn-outline-primary,
body.app-layout-topnav .app-page-hero .btn-outline-primary{
  background:transparent!important;
  color:#fff!important;
  border-color:rgba(255,255,255,.72)!important;
  font-weight:700!important;
}
.app-page-hero .btn-outline-primary:hover,
body.app-layout-topnav .app-page-hero .btn-outline-primary:hover{
  background:#fff!important;
  color:#12355b!important;
  border-color:#fff!important;
}
.app-page-hero .btn-outline-secondary,
.app-page-hero .btn-light,
body.app-layout-topnav .app-page-hero .btn-outline-secondary,
body.app-layout-topnav .app-page-hero .btn-light{
  background:transparent!important;
  color:#fff!important;
  border-color:rgba(255,255,255,.48)!important;
  font-weight:700!important;
}
.app-page-hero .btn-outline-secondary:hover,
.app-page-hero .btn-light:hover,
body.app-layout-topnav .app-page-hero .btn-outline-secondary:hover,
body.app-layout-topnav .app-page-hero .btn-light:hover{
  background:rgba(255,255,255,.14)!important;
  color:#fff!important;
  border-color:#fff!important;
}
@media (max-width:575.98px){
  .app-page-hero,
  body.app-layout-topnav .app-page-hero{
    border-radius:1rem!important;
    padding:1rem!important;
  }
  .app-page-hero .app-page-actions,
  body.app-layout-topnav .app-page-hero .app-page-actions{
    justify-content:flex-start;
    width:100%;
  }
}

