:root {
  --navy: #0A2F5E; --navy-d: #071F40; --teal: #14A097; --teal-d: #0E7F78;
  --bg: #F4F8FA; --surface: #FFFFFF; --text: #12263F; --muted: #5B6B7F; --line: #DCE5EB;
  --ok: #0E7F78; --warn: #9A6A00; --off: #5B6B7F; --track: #E3ECF0;
  color-scheme: light;
  box-sizing: border-box; 
  padding-top: env(safe-area-inset-top, 0px); 
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1624; --surface: #122236; --text: #E6EEF6; --muted: #9FB0C3; --line: #233853;
    --ok: #3CC9BE; --warn: #E3B341; --off: #9FB0C3; --track: #1D3049; --navy: #0A2F5E; --navy-d: #061A36;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1624; --surface: #122236; --text: #E6EEF6; --muted: #9FB0C3; --line: #233853;
  --ok: #3CC9BE; --warn: #E3B341; --off: #9FB0C3; --track: #1D3049; --navy: #0A2F5E; --navy-d: #061A36;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
}
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 6px; font-weight: 600; }
h2 { font-size: 19px; margin: 0 0 14px; font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 28px; }

/* =========================================
   LAYOUT SHELL (Menu e Container Principal)
   ========================================= */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
aside {
  background: linear-gradient(180deg, var(--navy), var(--navy-d)); color: #fff;
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 24px; font-weight: 600; letter-spacing: .2px; }
.brand b { font-weight: 600; color: #5FE0D3; }
nav { display: flex; flex-direction: column; gap: 4px; }
nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #C9D8EA; text-decoration: none; font-weight: 500; }
nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
nav a[aria-current="page"] { background: #fff; color: var(--navy); }
nav a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
nav svg { width: 20px; height: 20px; flex: none; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .14);
}
.who { display: flex; gap: 10px; align-items: center; padding: 4px 8px; font-size: 14px; color: #C9D8EA; }
.who-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.who-info span { color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-info small { color: #9BB8D8; font-size: 12px; }
.av { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 600; }

.btn-sidebar-sair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
  color: #E6EEF6;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-sidebar-sair:hover {
  background: rgba(220, 53, 69, .22);
  border-color: rgba(255, 130, 140, .45);
  color: #fff;
}
.btn-sidebar-sair svg { width: 17px; height: 17px; flex: none; }

main { padding: 32px clamp(16px, 4vw, 48px) 48px; max-width: 1100px; width: 100%; }

/* Modo Tela de Login (sem sidebar, conteúdo centralizado) */
.app.auth-mode {
  grid-template-columns: 1fr;
}
.app.auth-mode aside {
  display: none;
}
.app.auth-mode main {
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

@media (max-width: 1024px) {
  .app { grid-template-columns: 204px 1fr; }
  main { padding: 26px 24px 40px; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  aside {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    gap: 10px;
  }
  .brand { font-size: 20px; padding: 0; }
  nav {
    order: 3;
    width: 100%;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a { flex: none; padding: 9px 11px; }
  nav a span { display: none; }
  .sidebar-footer {
    order: 2;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    flex-direction: row;
    align-items: center;
  }
  .who { display: none; }
  .btn-sidebar-sair { width: auto; padding: 8px 10px; }
  .btn-sidebar-sair span { display: none; }
  main { padding: 20px 16px 36px; }
  h1 { font-size: 24px; }
  .sub { margin-bottom: 20px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }