:root {
  --color-primary: #174e86;
  --color-primary-dark: #10365f;
  --color-primary-soft: #e8f2ff;
  --color-success: #238a61;
  --color-warning: #b77908;
  --color-danger: #b83b3b;
  --color-info: #2878a8;
  --color-background: #f4f7fb;
  --color-surface: #ffffff;
  --color-surface-subtle: #f8fafc;
  --color-border: #d9e3ef;
  --color-text: #132337;
  --color-text-secondary: #5b6b7e;
  --color-text-muted: #7b8797;
  --shadow-sm: 0 3px 12px rgba(16, 54, 95, 0.06);
  --shadow-md: 0 12px 32px rgba(16, 54, 95, 0.10);
  --radius-sm: 0.65rem;
  --radius-md: 0.9rem;
  --radius-lg: 1.25rem;
  --space-unit: 0.25rem;
  --transition-fast: 150ms ease;
  --transition-base: 220ms ease;
  --control-height: 2.75rem;
  --control-height-lg: 3.15rem;
  --app-bg: var(--color-background);
  --card-bg: var(--color-surface);
  --brand: var(--color-primary);
  --brand-soft: var(--color-primary-soft);
  --brand-strong: var(--color-primary-dark);
  --text-main: var(--color-text);
  --text-muted: var(--color-text-secondary);
  --border-soft: var(--color-border);
}

html {
  font-size: 16px;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--color-background);
  color: var(--text-main);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.tab-session-guard { position: fixed; z-index: 2200; inset: 0; display: grid; place-items: center; padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); background: var(--color-background); text-align: center; }
.tab-session-guard[hidden] { display: none; }
.tab-session-guard > div { width: min(100%, 28rem); padding: 1.5rem; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-md); }
.tab-session-guard h1 { margin: 1rem 0 0.35rem; font-size: 1.25rem; }
.tab-session-guard p { margin: 0 0 1rem; color: var(--color-text-secondary); }
.tab-session-guard .login-spinner { display: inline-block; width: 2rem; height: 2rem; border: 3px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: tab-session-spin 0.8s linear infinite; }
@keyframes tab-session-spin { to { transform: rotate(360deg); } }

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--color-border);
}

@supports (padding: env(safe-area-inset-top)) {
  .app-shell {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .app-header {
    padding-top: env(safe-area-inset-top);
  }

  .app-shell > .container-fluid {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)) !important;
  }
}

.navbar-brand {
  color: var(--brand);
  letter-spacing: 0.02em;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  font-size: 1.02rem;
  font-weight: 750;
  text-decoration: none;
}

.app-brand img,
.auth-brand img,
.login-complete img {
  flex: 0 0 auto;
  border-radius: 22%;
  box-shadow: var(--shadow-sm);
}

.app-user-name {
  max-width: 15rem;
  overflow: hidden;
  color: var(--color-text);
  font-size: 0.84rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-user-status {
  color: var(--color-text-muted);
  font-size: 0.72rem;
}

.app-mobile-title {
  display: none;
}

.app-content {
  max-width: 1680px;
  margin-inline: auto;
}

.hero-card,
.content-card,
.sidebar-card {
  background: linear-gradient(135deg, var(--card-bg) 0%, #f7fbff 100%);
  border: 1px solid var(--border-soft);
}

.eyebrow {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-panel {
  background: #fdfefe;
  border: 1px solid var(--border-soft);
}

.placeholder-panel {
  background: linear-gradient(180deg, rgba(23, 72, 133, 0.05), rgba(255, 255, 255, 0.95));
  border: 1px solid var(--border-soft);
}

.lead,
.text-secondary {
  color: var(--text-muted) !important;
}

.sidebar-title {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-soft);
}

.sidebar-nav {
  font-size: 0.97rem;
}

.sidebar-link,
.sidebar-sublink,
.sidebar-group-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.8rem 0.95rem;
  border-radius: 0.9rem;
  border: 0;
  background: transparent;
  color: var(--text-main);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar-link:hover,
.sidebar-sublink:hover,
.sidebar-group-toggle:hover {
  background: #edf4fd;
  color: var(--brand-strong);
  transform: translateX(2px);
}

.sidebar-link.active,
.sidebar-sublink.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(23, 72, 133, 0.18);
}

.sidebar-group-toggle {
  flex: 0 0 auto;
  width: 2.75rem;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar-group-header {
  display: flex;
  gap: 0.35rem;
}

.sidebar-group-header .sidebar-link {
  flex: 1 1 auto;
}

.sidebar-group-toggle:hover {
  transform: none;
}

.sidebar-group-toggle::after {
  content: "+";
  font-size: 1rem;
  color: var(--text-muted);
}

.sidebar-group-toggle:not(.collapsed)::after {
  content: "-";
}

.sidebar-group-toggle,
.sidebar-group-toggle:hover {
  justify-content: space-between;
  background: #f6f9fc;
}

.sidebar-submenu {
  margin: 0.55rem 0 0;
  padding-left: 0.85rem;
  border-left: 1px solid var(--border-soft);
  display: grid;
  gap: 0.35rem;
}

.sidebar-sublink {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  font-size: 0.94rem;
}

.module-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 8.5rem;
  padding: 0.85rem 1rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}

.auth-card {
  width: 100%;
  max-width: 30rem;
}

.auth-body {
  min-height: 100dvh;
  background: var(--color-background);
}

.auth-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
}

.auth-panel {
  width: min(100%, 28rem);
  padding: clamp(1.4rem, 5vw, 2.6rem);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.auth-brand-name {
  margin-top: 0.2rem;
  color: var(--color-primary-dark);
  font-size: 1.1rem;
  font-weight: 800;
}

.auth-feedback {
  border-color: color-mix(in srgb, var(--color-danger) 25%, transparent);
  background: color-mix(in srgb, var(--color-danger) 8%, white);
  color: var(--color-danger);
}

.auth-note {
  margin: 1.25rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.77rem;
  text-align: center;
}

.auth-form { width: 100%; }
.auth-field { display: grid; width: 100%; gap: 0.4rem; }
.auth-field > label { display: block; width: 100%; }
.auth-field > .form-control { display: block; width: 100%; box-sizing: border-box; }
.auth-actions { display: flex; width: 100%; }
.auth-actions > .btn { min-width: 7rem; }

.login-complete {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  justify-items: center;
  padding: 1.5rem;
  text-align: center;
}

.login-complete h1 {
  margin: 1rem 0 0.25rem;
  font-size: 1.1rem;
}

.login-complete p {
  color: var(--color-text-secondary);
}

.login-complete-spinner {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 1.25rem;
  border: 2px solid var(--color-primary-soft);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: app-spin 700ms linear infinite;
}

@keyframes app-spin { to { transform: rotate(360deg); } }

.status-panel li {
  position: relative;
  padding-left: 1.5rem;
  color: var(--text-muted);
}

.status-panel li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--brand);
}

@media (max-width: 991.98px) {
  #appSidebar {
    margin-top: 0.25rem;
  }

  .sidebar-link,
  .sidebar-sublink,
  .sidebar-group-toggle {
    min-height: 44px;
  }
}

@media (max-width: 575.98px) {
  .app-header .container-fluid {
    flex-wrap: nowrap;
  }

  .app-brand span,
  .app-user-area {
    display: none;
  }

  .app-brand img { width: 32px; height: 32px; }

  .app-mobile-title {
    display: block;
    min-width: 0;
    margin-left: 0.25rem;
    overflow: hidden;
    color: var(--color-text);
    font-size: 0.95rem;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-menu-toggle,
  .app-logout {
    min-width: 44px;
    min-height: 44px;
  }

  .auth-shell {
    align-items: start;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .auth-panel {
    margin-block: auto;
  }
}

@supports (padding: env(safe-area-inset-bottom)) {
  .auth-shell,
  .login-complete {
    padding-right: calc(1rem + env(safe-area-inset-right));
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    padding-left: calc(1rem + env(safe-area-inset-left));
  }

  .modal-content {
    margin-bottom: env(safe-area-inset-bottom);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Os componentes reutilizaveis do Design System (cards, tabelas, toolbar,
   chips, badges, drawer, etc.) vivem em wwwroot/css/design-system.css. */
