:root{
  --sr-bg: #0b0d10;
  --sr-panel: rgba(17,21,28,.92);
  --sr-panel-2: rgba(15,19,26,.94);
  --sr-border: rgba(255,255,255,.10);
  --sr-border-2: rgba(255,255,255,.16);
  --sr-text: rgba(255,255,255,.92);
  --sr-muted: rgba(255,255,255,.62);
  --sr-brand: #dc3545;

  --sr-radius: 16px;
  --sr-topbar-h: 58px;
  --sr-sidebar-w: 292px;
  --sr-bottom-h: 66px;

  --sr-shadow: 0 16px 50px rgba(0,0,0,.45);

  /* safe-area (iOS notch/home-indicator) */
  --sr-safe-top: env(safe-area-inset-top, 0px);
  --sr-safe-bot: env(safe-area-inset-bottom, 0px);

  /* Medidas reais (JS atualiza) */
  --sr-topbar-real: calc(var(--sr-topbar-h) + var(--sr-safe-top));
  --sr-bottom-real: 0px; /* no desktop = 0, no mobile = bottomnav real */
}

/* reset / base */
*{ box-sizing: border-box; }
html, body { height: 100%; }
img, svg, video { max-width: 100%; height: auto; }

body.sr-body{
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;

  background:
    radial-gradient(1200px 600px at 18% 0%, rgba(220,53,69,.18), transparent 60%),
    radial-gradient(900px 500px at 88% 10%, rgba(13,110,253,.12), transparent 60%),
    var(--sr-bg);

  color: var(--sr-text);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* =========================================================
   TOPBAR
   ========================================================= */
.sr-topbar{
  position: sticky;
  top: 0;
  z-index: 1050;
  background: rgba(10,12,15,.65);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);

  padding-top: var(--sr-safe-top);
  min-height: var(--sr-topbar-real);
}

.sr-topbar .container-fluid{
  min-height: var(--sr-topbar-h);
  padding-left: 12px;
  padding-right: 12px;
  height: auto;
}

.sr-topbar-spacer{ flex: 1; }

.sr-brand{
  min-width: 0;
  max-width: 56vw;
}
.sr-brand .fw-bold{
  display: inline-block;
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 576px){
  .sr-brand{ max-width: none; }
  .sr-brand .fw-bold{ max-width: none; }
}

#meLabel{
  display: inline-block;
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-brand-dot{
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--sr-brand);
  box-shadow: 0 0 0 6px rgba(220,53,69,.16);
}

.sr-search{
  width: min(520px, 46vw);
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--sr-border);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  min-width: 0;
}
.sr-search i{ opacity: .75; }
.sr-search input{
  border: 0 !important;
  background: transparent !important;
  color: var(--sr-text) !important;
  padding: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  min-width: 0;
}

/* =========================================================
   APP SHELL (DESKTOP GRID)
   ========================================================= */
.sr-shell{
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: var(--sr-sidebar-w) minmax(0, 1fr);

  /* altura útil abaixo do topbar */
  min-height: calc(100dvh - var(--sr-topbar-real));
  min-height: calc(100svh - var(--sr-topbar-real));
  min-height: calc(100vh  - var(--sr-topbar-real));
}

/* Sidebar (desktop) */
.sr-sidenav{
  position: sticky;
  top: var(--sr-topbar-real);

  height: calc(100dvh - var(--sr-topbar-real));
  height: calc(100svh - var(--sr-topbar-real));
  height: calc(100vh  - var(--sr-topbar-real));

  border-right: 1px solid var(--sr-border);
  background: rgba(15,19,26,.72);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.sr-sidenav-inner{
  height: 100%;
  display:flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 10px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.sr-sidenav-title{
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .10em;
  color: var(--sr-muted);
  text-transform: uppercase;
  padding: 4px 10px;
}

.sr-sidenav-footer{
  margin-top: auto;
  padding: 10px;
  border: 1px dashed rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
}

/* Main */
.sr-main{
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding-bottom: calc(var(--sr-bottom-real) + 18px + var(--sr-safe-bot));
}

/* view precisa ser 100% SEMPRE */
#view{
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
}

/* =========================================================
   NAV LIST
   ========================================================= */
.sr-navlist{
  display:flex;
  flex-direction: column;
  gap: 6px;
}

.sr-navitem{
  width: 100%;
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sr-text);
  text-decoration: none;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
  min-width: 0;
}
.sr-navitem i{
  font-size: 1.1rem;
  opacity: .9;
  width: 22px;
  text-align:center;
}
.sr-navitem span{
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-navitem small{
  color: var(--sr-muted);
  font-weight: 600;
  margin-left:auto;
  white-space: nowrap;
}
.sr-navitem:hover{
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.08);
  transform: translateY(-1px);
}
.sr-navitem.active{
  background: rgba(220,53,69,.16);
  border-color: rgba(220,53,69,.40);
}

/* =========================================================
   COLLAPSED SIDEBAR — SÓ DESKTOP
   (isso resolve DEFINITIVAMENTE o “não 100%” no mobile)
   ========================================================= */
@media (min-width: 992px){
  :root{ --sr-bottom-real: 0px; }

  .sr-shell.sr-collapsed{
    grid-template-columns: 78px minmax(0, 1fr);
  }
  .sr-shell.sr-collapsed .sr-sidenav-title,
  .sr-shell.sr-collapsed .sr-sidenav-footer,
  .sr-shell.sr-collapsed .sr-navitem span,
  .sr-shell.sr-collapsed .sr-navitem small{
    display:none !important;
  }
  .sr-shell.sr-collapsed .sr-navitem{
    justify-content:center;
    padding: 12px;
  }
  .sr-shell.sr-collapsed .sr-navitem i{
    width: auto;
  }
}

/* =========================================================
   CARDS/ROWS
   ========================================================= */
.card{
  background: var(--sr-panel);
  color: var(--sr-text);
  border: 1px solid var(--sr-border);
  border-radius: calc(var(--sr-radius) + 2px);
  backdrop-filter: blur(6px);
  box-shadow: var(--sr-shadow);
}

.sr-row{
  background: rgba(17,21,28,.78);
  border: 1px solid var(--sr-border);
  border-radius: var(--sr-radius);
  padding: 14px;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
  min-width: 0;
  width: 100%;
}
.sr-row:hover{
  transform: translateY(-1px);
  border-color: var(--sr-border-2);
  background: rgba(17,21,28,.88);
}

.badge-soft{
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
  color: rgba(255,255,255,.86);
  font-weight: 700;
}

.sr-thumb{
  width: 54px;
  height: 54px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}

/* OFFCANVAS: não ficar por baixo do bottom nav */
.offcanvas .offcanvas-body{
  padding-bottom: calc(1rem + var(--sr-bottom-real) + var(--sr-safe-bot));
  -webkit-overflow-scrolling: touch;
}

/* =========================================================
   BOTTOM NAV (MOBILE)
   ========================================================= */
.sr-bottomnav{
  position: fixed;
  left: 0; right: 0; bottom: 0;

  background: rgba(15,19,26,.90);
  border-top: 1px solid var(--sr-border);
  backdrop-filter: blur(10px);

  z-index: 1044; /* abaixo do offcanvas/modal */

  display: none; /* default: desktop hidden */
}

/* =========================================================
   MOBILE LAYOUT — 100% SEM GUTTER FALSO
   ========================================================= */
@media (max-width: 991.98px){
  /* grid vira 1 coluna SEMPRE, mesmo se sr-collapsed existir */
  .sr-shell{
    grid-template-columns: 1fr !important;
  }

  /* bottom nav aparece e passa a empurrar o conteúdo */
  .sr-bottomnav{
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;

    padding: 10px 10px calc(10px + var(--sr-safe-bot));
    min-height: calc(var(--sr-bottom-h) + var(--sr-safe-bot));
  }

  /* garante que o main use a tela toda */
  .sr-main{
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Bootstrap col-md-* sem col-12: força 100% */
  #view .row > [class*="col-"]{
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Linhas d-flex com botões ao lado: quebra e ocupa 100% */
  #view .d-flex{
    min-width: 0;
  }
  #view .d-flex.gap-2,
  #view .d-flex.gap-3,
  #view .d-flex.gap-4{
    flex-wrap: wrap;
    width: 100%;
  }
  #view .d-flex > .card,
  #view .d-flex > .sr-row{
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
  #view .d-flex > .btn,
  #view .d-flex > .btn-group,
  #view .d-flex > .dropdown{
    margin-top: 6px;
  }
}

/* XS topbar wrap sem cortar */
@media (max-width: 575.98px){
  .sr-topbar .container-fluid{
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .sr-brand{ max-width: 66vw; }
  .sr-brand .fw-bold{ max-width: 46vw; }
  #meLabel{ max-width: 46vw; }
}

/* focus */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible{
  outline: 2px solid rgba(220,53,69,.55);
  outline-offset: 2px;
}

/* scrollbars */
*{ scrollbar-color: rgba(255,255,255,.18) transparent; }
*::-webkit-scrollbar{ height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.16); border-radius: 999px; }


/* =========================================================
   BOTTOM NAV (MOBILE) — estilo completo
   ========================================================= */
.sr-bottomnav{
  position: fixed;
  left: 0; right: 0; bottom: 0;

  background: rgba(15,19,26,.90);
  border-top: 1px solid var(--sr-border);
  backdrop-filter: blur(10px);

  z-index: 1044; /* abaixo do offcanvas/modal */

  display: none; /* desktop hidden; mobile liga no media query */
}

/* botão do bottom nav */
.sr-bottombtn{
  display:flex;
  flex-direction: column;
  align-items:center;
  justify-content:center;
  gap: 4px;

  border: 1px solid transparent;
  border-radius: 14px;

  background: rgba(255,255,255,.03);
  color: rgba(255,255,255,.80);

  padding: 10px 6px;
  min-height: 56px;

  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;

  transition: transform .12s ease, background .12s ease, border-color .12s ease, color .12s ease;
}

.sr-bottombtn i{
  font-size: 1.18rem;
  line-height: 1;
  opacity: .95;
}

.sr-bottombtn span{
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.1;

  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-bottombtn:hover{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.08);
  transform: translateY(-1px);
}

.sr-bottombtn:active{
  transform: translateY(0px) scale(.98);
}

/* estado ativo (route atual) */
.sr-bottombtn.active{
  background: rgba(220,53,69,.18);
  border-color: rgba(220,53,69,.40);
  color: rgba(255,255,255,.95);
}

/* =========================================================
   MOBILE: habilita a barra e define grid
   ========================================================= */
@media (max-width: 991.98px){
  .sr-bottomnav{
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;

    padding: 10px 10px calc(10px + var(--sr-safe-bot));
    min-height: calc(var(--sr-bottom-h) + var(--sr-safe-bot));
  }
}

/* quando estiver arrastando, bloqueia seleção de texto em tudo */
html.sr-dragging, html.sr-dragging * {
  -webkit-user-select: none !important;
  user-select: none !important;
}

/* UX: cursor de “pegar/arrastar” nos cards reordenáveis */
.sr-sortable .sr-row { cursor: grab; }
.sr-sortable .sr-row:active { cursor: grabbing; }

.sr-allow-select { user-select: text !important; -webkit-user-select: text !important; }

