/* Casca da aplicacao: layout, navegacao, estado de carga e login.
   Nao contem estilo de nenhum modulo — cada um traz o seu. */

.app-shell {
  display: grid;
  grid-template-columns: 112px 1fr;
  min-height: 100vh;
  background: radial-gradient(circle at 82% -10%, #edf2ff 0, transparent 32%), #f6f8fc;
}

.shell-sidebar {
  background: linear-gradient(180deg, #141b2d, #182540 58%, #111827);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 20px 0;
  position: sticky;
  top: 0;
  min-height: 100vh;
}

.shell-logo {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  border: 1px solid rgba(141, 169, 255, 0.5);
  background: linear-gradient(180deg, #ffffff, #e8efff);
  overflow: hidden;
  flex: 0 0 auto;
}
.shell-logo img { width: 100%; height: 100%; object-fit: contain; }

#navModulos {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

/* Itens de navegacao sao <button>: focaveis e operaveis pelo teclado. */
.nav-modulo {
  appearance: none;
  font-family: inherit;
  cursor: pointer;
  width: 82px;
  padding: 11px 4px;
  border-radius: 14px;
  color: #bfcae2;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid transparent;
  font-size: 10px;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.nav-modulo-icone { font-size: 20px; line-height: 1; }
.nav-modulo.ativo {
  color: #fff;
  background: linear-gradient(180deg, rgba(69, 113, 239, 0.78), rgba(44, 83, 197, 0.58));
  border-color: rgba(163, 187, 255, 0.52);
  box-shadow: 0 8px 18px rgba(4, 11, 29, .22);
}
.nav-modulo:focus-visible,
.update:focus-visible,
#sairLink:focus-visible {
  outline: 3px solid #0b7cff;
  outline-offset: 2px;
}

.shell-main { padding: 24px 28px 38px; min-width: 0; }

.shell-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 17px 22px;
  margin-bottom: 18px;
  box-shadow: 0 8px 22px rgba(30, 45, 79, .05);
}
.shell-topbar h1 { font-size: 26px; margin: 4px 0 0; color: #0f172a; }
.brand-kicker { font-size: 11px; letter-spacing: 0.6px; color: #64748b; text-transform: uppercase; }
.shell-actions { display: flex; align-items: center; gap: 14px; color: #475569; flex-wrap: wrap; }
.mobile-menu-toggle{display:none}

/* Estado da ultima carga. */
.status-dados {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status-dados[data-estado="ok"] { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.status-dados[data-estado="carregando"] { color: #1e40af; background: #dbeafe; border-color: #bfdbfe; }
.status-dados[data-estado="parcial"] { color: #92400e; background: #fef3c7; border-color: #fde68a; }
.status-dados[data-estado="erro"] { color: #991b1b; background: #fee2e2; border-color: #fecaca; }

/* Falha isolada de um modulo. */
.modulo-erro {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
  font-size: 13px;
  font-weight: 600;
}

.modulo-host[hidden] { display: none; }

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fafc;
  color: #475569;
  z-index: 50;
}
.loading-overlay button {
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid #0b7cff;
  background: #0b7cff;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* Rotulos so para leitores de tela. */
.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;
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .shell-sidebar {
    position:fixed;z-index:50;left:0;top:0;bottom:0;width:min(300px,86vw);min-height:100vh;
    align-items:stretch;overflow-y:auto;padding:16px;gap:16px;
    transform:translateX(-105%);transition:transform .22s ease;box-shadow:16px 0 36px rgba(15,23,42,.22);
  }
  .menu-mobile-aberto .shell-sidebar{transform:translateX(0)}
  .menu-mobile-aberto::after{content:"";position:fixed;z-index:40;inset:0;background:rgba(15,23,42,.38);backdrop-filter:blur(2px)}
  .shell-logo{display:block;width:54px;height:54px;border-radius:14px;margin:0 auto}
  #navModulos { align-items:stretch;gap:7px; }
  .nav-modulo { width:100%;min-height:50px;padding:9px 11px;flex:0 0 auto;font-size:12px;border-radius:10px;flex-direction:row;justify-content:flex-start;text-align:left; }
  .nav-modulo-icone{font-size:18px;width:24px;text-align:center}
  .shell-main { padding: 16px 12px 28px; }
  .shell-topbar{padding:14px;margin-bottom:14px}.shell-topbar h1{font-size:20px}.shell-actions{gap:8px;width:100%;justify-content:space-between}.status-dados{font-size:10px}.mobile-menu-toggle{display:inline-flex;align-items:center;gap:6px;order:-1;border:1px solid #cbd5e1;border-radius:9px;padding:8px 10px;background:#fff;color:#1e3a5f;font:inherit;font-size:12px;font-weight:800}.shell-actions #relogio{display:none}
}
body.sessao-bloqueada .app-shell{visibility:hidden}
