@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/inter-400.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/inter-500.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/inter-600.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/inter-700.ttf") format("truetype"); }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/manrope-600.ttf") format("truetype"); }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/manrope-700.ttf") format("truetype"); }

/* Biware 2026: tokens canônicos do tema escuro. Referência: DESIGN.md. */
:root {
  color-scheme: dark;
  --color-bg: #10243A;
  --color-surface: #142C45;
  --color-surface-alt: #1B3550;
  --color-primary: #2864DC;
  --color-primary-dark: #2155BC;
  --color-accent: #43C7D5;
  --color-link: #86B7FF;
  --color-text: #F3F6F9;
  --color-text-muted: #A7BACD;
  --color-border: #30485F;
  --color-danger: #FF8B93;
  --color-positive: #61D7AE;
  --color-positive-dark: #2CB387;
  --color-target-met: #86B7FF;
  --color-negative: #FF948C;
  --color-negative-dark: #D95D55;
  --color-sidebar-bg: #0C1D30;
  --color-sidebar-text: #B7C9DB;
  --color-on-primary: #FFFFFF;
  --font-sans: "Inter", "IBM Plex Sans", system-ui, sans-serif;
  --font-display: "Manrope", "Inter", system-ui, sans-serif;
  --color-scrollbar: #4A647E;
  --color-scrollbar-hover: #7294B4;
  --z-tooltip: 30;
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-bg: #F3F6F9;
  --color-surface: #FFFFFF;
  --color-surface-alt: #EAF0F6;
  --color-primary: #2864DC;
  --color-primary-dark: #2155BC;
  --color-accent: #087D8A;
  --color-link: #2155BC;
  --color-text: #10243A;
  --color-text-muted: #52677C;
  --color-border: #D6E0EA;
  --color-danger: #B83E48;
  --color-positive: #117A56;
  --color-positive-dark: #086644;
  --color-target-met: #2155BC;
  --color-negative: #B83E3E;
  --color-negative-dark: #9E2929;
  --color-sidebar-bg: #FFFFFF;
  --color-sidebar-text: #40566F;
  --color-scrollbar: #91A5B8;
  --color-scrollbar-hover: #607C98;
}

/* IBM Plex Sans, a fonte do demonstrativo da Biware — servida daqui mesmo
   (a CSP só aceita fontes do próprio site). Um arquivo variável cobre os
   pesos 400-700. */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-sans-latin.woff2") format("woff2");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
}

/* Admin UX refresh — a calmer shell, clearer navigation and denser overview. */
.admin-icon {
  width: 1.2rem;
  height: 1.2rem;
  flex: 0 0 auto;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: var(--color-primary);
  color: #111827;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.admin-shell {
  background:
    radial-gradient(circle at 78% 0%, rgba(251, 177, 47, 0.055), transparent 24rem),
    var(--color-bg);
}

.admin-sidebar {
  border-right: 1px solid var(--color-border);
  padding: 1.15rem 0.8rem 0.9rem;
  gap: 0;
  transition: width 0.22s ease, padding 0.22s ease, transform 0.22s ease;
}

.admin-sidebar .brand {
  min-height: 3rem;
  margin: 0 0 1.25rem;
  padding: 0.15rem 0.55rem;
  color: var(--color-text);
  text-decoration: none;
  overflow: visible;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(251, 177, 47, 0.1);
  border: 1px solid rgba(251, 177, 47, 0.18);
}

.brand-mark .logo-biware { width: 1.75rem; height: auto; }
.brand-copy, .sidebar-footer-copy, .account-copy { display: flex; flex-direction: column; min-width: 0; }
.admin-sidebar .brand .brand-copy { color: var(--color-text); letter-spacing: 0; }
.brand-copy strong { font-size: 0.9rem; line-height: 1.2; }
.brand-copy small { margin-top: 0.15rem; color: var(--color-text-muted); font-size: 0.68rem; font-weight: 500; }
.admin-nav { flex: 1; }
.nav-group { margin-bottom: 0.85rem; }
.nav-group-label { padding: 0.55rem 0.7rem 0.4rem; font-size: 0.64rem; font-weight: 700; }

.nav-link {
  position: relative;
  gap: 0.72rem;
  min-height: 2.65rem;
  margin: 0.08rem 0;
  padding: 0.65rem 0.72rem;
  border-radius: 10px;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-link:hover { transform: translateX(2px); background: rgba(255, 255, 255, 0.055); }
:root[data-theme="light"] .nav-link:hover { background: var(--color-surface-alt); }
.nav-link.active { background: rgba(251, 177, 47, 0.13); color: var(--color-link); }
.nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.8rem;
  width: 3px;
  height: 1.45rem;
  border-radius: 0 3px 3px 0;
  background: var(--color-primary);
}

.nav-icon { width: 1.1rem; height: 1.1rem; }
.nav-link-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3.5rem;
  padding: 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 11px;
  background: rgba(255,255,255,0.025);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-status-dot { width: 0.5rem; height: 0.5rem; flex: 0 0 auto; border-radius: 50%; background: var(--color-positive); box-shadow: 0 0 0 4px rgba(47, 220, 154, 0.1); }
.sidebar-footer-copy strong { font-size: 0.72rem; }
.sidebar-footer-copy small { color: var(--color-text-muted); font-size: 0.65rem; margin-top: 0.1rem; }

.admin-shell.sidebar-collapsed .admin-sidebar { width: 4.6rem; padding-left: 0.65rem; padding-right: 0.65rem; overflow: visible; }
.admin-shell.sidebar-collapsed .brand-copy,
.admin-shell.sidebar-collapsed .nav-group-label,
.admin-shell.sidebar-collapsed .nav-link-label,
.admin-shell.sidebar-collapsed .sidebar-footer-copy { display: none; }
.admin-shell.sidebar-collapsed .admin-sidebar .brand { justify-content: center; padding: 0; }
.admin-shell.sidebar-collapsed .nav-link { justify-content: center; padding-inline: 0; }
.admin-shell.sidebar-collapsed .nav-link.active::before { left: -0.65rem; }
.admin-shell.sidebar-collapsed .sidebar-footer { justify-content: center; padding-inline: 0; }

.admin-header {
  height: 4.5rem;
  padding: 0 2rem;
  background: color-mix(in srgb, var(--color-surface) 91%, transparent);
  backdrop-filter: blur(14px);
}
.admin-header .header-left, .header-actions { display: flex; align-items: center; gap: 0.8rem; }
.icon-btn { width: 2.4rem; height: 2.4rem; display: inline-grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 9px; }
.icon-btn:hover { border-color: var(--color-border); }
.header-context { display: flex; flex-direction: column; }
.header-context span { color: var(--color-text-muted); font-size: 0.65rem; line-height: 1; }
.header-context strong { margin-top: 0.22rem; font-size: 0.92rem; line-height: 1.1; }
.theme-toggle .theme-icon-dark { display: none; }
:root[data-theme="light"] .theme-toggle .theme-icon-light { display: none; }
:root[data-theme="light"] .theme-toggle .theme-icon-dark { display: block; }

.account-menu-trigger { gap: 0.65rem; padding: 0.3rem 0.45rem 0.3rem 0.3rem; }
.account-avatar { width: 2rem; height: 2rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: linear-gradient(145deg, var(--color-primary), var(--color-primary-dark)); color: #172033; font-size: 0.68rem; font-weight: 800; }
.account-copy { text-align: left; max-width: 10rem; }
.account-copy strong { overflow: hidden; text-overflow: ellipsis; font-size: 0.78rem; white-space: nowrap; }
.account-copy small { color: var(--color-text-muted); font-size: 0.65rem; margin-top: 0.1rem; }
.account-chevron { width: 0.85rem; transition: transform 0.16s ease; }
.account-menu.open .account-chevron { transform: rotate(90deg); }
.account-menu-dropdown { top: calc(100% + 0.55rem); min-width: 13rem; padding: 0.45rem; border-radius: 11px; background: var(--color-surface); }
.account-dropdown-label { padding: 0.45rem 0.6rem 0.55rem; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.account-menu-dropdown button { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.35rem; }
.account-menu-dropdown .admin-icon { width: 1rem; }

.admin-main { width: 100%; max-width: 92rem; margin: 0 auto; padding: 2.35rem 2.5rem 3.5rem; }
.admin-main h1 { font-size: clamp(1.65rem, 2vw, 2.05rem); letter-spacing: -0.025em; }
.admin-main .subtitle { line-height: 1.55; }
.page-header { margin-bottom: 1.75rem; }
.page-header h1 + .subtitle { margin-top: 0.3rem; }

.admin-main button.primary, .admin-main a.primary { border-radius: 9px; box-shadow: 0 4px 14px rgba(251, 177, 47, 0.13); transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease; }
.admin-main button.primary:hover, .admin-main a.primary:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(251, 177, 47, 0.18); }
.admin-main input, .admin-main select, .admin-main textarea { min-height: 2.65rem; border-radius: 9px; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.admin-main input:focus, .admin-main select:focus, .admin-main textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(251, 177, 47, 0.12); }
.toolbar { padding: 0.75rem; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); }
.data-table-wrap, .detail-card, .modal { box-shadow: 0 10px 30px rgba(0,0,0,0.08); }
.data-table tbody tr { transition: background 0.15s ease; }
:root[data-theme="light"] .data-table tbody tr:hover { background: #f8fafc; }

.overview-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; margin-bottom: 1.8rem; }
.overview-hero h1 { margin: 0.2rem 0 0.3rem; font-size: clamp(1.8rem, 2.6vw, 2.5rem); }
.overview-hero .subtitle { margin: 0; }
.eyebrow { color: var(--color-link); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.overview-date { color: var(--color-text-muted); font-size: 0.78rem; text-transform: capitalize; white-space: nowrap; }
.overview-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; margin-bottom: 1.35rem; }
.overview-card { position: relative; display: flex; align-items: center; gap: 1rem; min-height: 7.4rem; padding: 1.2rem; color: var(--color-text); text-decoration: none; overflow: hidden; box-shadow: 0 8px 28px rgba(0,0,0,0.07); transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease; }
.overview-card:not(.is-loading):hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--card-accent, var(--color-primary)) 55%, var(--color-border)); box-shadow: 0 13px 32px rgba(0,0,0,0.13); }
.overview-card-icon { width: 2.75rem; height: 2.75rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; color: var(--card-accent); background: color-mix(in srgb, var(--card-accent) 13%, transparent); }
.overview-card-icon .admin-icon { width: 1.3rem; height: 1.3rem; }
.overview-card .value { font-size: 1.85rem; line-height: 1; }
.overview-card .label { margin-top: 0.4rem; }
.overview-card-arrow { position: absolute; right: 1rem; top: 1rem; color: var(--color-text-muted); opacity: 0; transform: translateX(-4px); transition: opacity 0.18s, transform 0.18s; }
.overview-card:hover .overview-card-arrow { opacity: 1; transform: none; }
.tone-blue { --card-accent: #60a5fa; }.tone-green { --card-accent: #34d399; }.tone-amber { --card-accent: #fbb12f; }.tone-purple { --card-accent: #a78bfa; }

.overview-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(18rem, 0.75fr); gap: 1rem; align-items: start; }
.overview-panel { padding: 1.15rem; border: 1px solid var(--color-border); border-radius: 14px; background: var(--color-surface); box-shadow: 0 8px 28px rgba(0,0,0,0.06); }
.overview-panel-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; min-height: 2.75rem; margin-bottom: 0.8rem; }
.overview-panel-header h2 { margin: 0.15rem 0 0; font-size: 1.03rem; }
.text-link { color: var(--color-link); font-size: 0.76rem; text-decoration: none; white-space: nowrap; }
.text-link:hover { text-decoration: underline; }
.activity-list { gap: 0; }
.activity-item { align-items: center; padding: 0.8rem 0.25rem; border: 0; border-top: 1px solid var(--color-border); border-radius: 0; background: transparent; }
.activity-icon { width: 2rem; height: 2rem; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: var(--color-text-muted); background: var(--color-surface-alt); }
.activity-icon .admin-icon { width: 0.95rem; }
.activity-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.activity-copy strong { overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; white-space: nowrap; }
.activity-copy small { margin-top: 0.15rem; color: var(--color-text-muted); font-size: 0.7rem; }
.activity-item .activity-meta { font-size: 0.7rem; }
.quick-actions > a { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem; padding: 0.75rem 0.2rem; border-top: 1px solid var(--color-border); color: var(--color-text); text-decoration: none; }
.quick-actions > a:hover b { color: var(--color-link); transform: translateX(2px); }
.quick-action-icon { width: 2.25rem; height: 2.25rem; display: grid; place-items: center; border-radius: 9px; color: var(--color-link); background: rgba(251,177,47,0.1); }
.quick-action-icon .admin-icon { width: 1rem; }
.quick-actions a > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.quick-actions strong { font-size: 0.78rem; }
.quick-actions small { margin-top: 0.15rem; color: var(--color-text-muted); font-size: 0.68rem; }
.quick-actions b { color: var(--color-text-muted); font-size: 0.9rem; transition: transform 0.16s, color 0.16s; }

@media (max-width: 1100px) {
  .overview-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .admin-shell.sidebar-collapsed .admin-sidebar { width: var(--sidebar-width); padding: 1.15rem 0.8rem 0.9rem; overflow-y: auto; }
  .admin-shell.sidebar-collapsed .brand-copy,
  .admin-shell.sidebar-collapsed .nav-group-label,
  .admin-shell.sidebar-collapsed .nav-link-label,
  .admin-shell.sidebar-collapsed .sidebar-footer-copy { display: flex; }
  .admin-shell.sidebar-collapsed .nav-group-label { display: block; }
  .admin-shell.sidebar-collapsed .admin-sidebar .brand,
  .admin-shell.sidebar-collapsed .nav-link,
  .admin-shell.sidebar-collapsed .sidebar-footer { justify-content: flex-start; padding-left: 0.7rem; padding-right: 0.7rem; }
  .admin-header { padding: 0 1rem; }
  .header-context span { display: none; }
  .account-copy, .account-chevron { display: none; }
}

@media (max-width: 600px) {
  .admin-main { padding: 1.45rem 1rem 2.5rem; }
  .overview-hero { align-items: flex-start; flex-direction: column; gap: 0.6rem; }
  .overview-cards { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .overview-card { min-height: 6.5rem; padding: 0.95rem; gap: 0.7rem; }
  .overview-card-icon { width: 2.25rem; height: 2.25rem; }
  .overview-card .value { font-size: 1.5rem; }
  .overview-card .label { font-size: 0.72rem; }
  .overview-panel { padding: 1rem; }
  .overview-panel-header { align-items: flex-start; }
  .activity-item { flex-direction: row; }
  .activity-meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-shell *, .admin-shell *::before, .admin-shell *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

a {
  color: inherit;
}

input {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
}

textarea,
select {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  font-family: inherit;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

button {
  font-family: inherit;
}

button.primary,
a.primary,
button.secondary,
button.danger {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

button.primary,
a.primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

a.primary {
  display: block;
  text-align: center;
  text-decoration: none;
}

button.primary:hover,
a.primary:hover {
  background: var(--color-primary-dark);
}

button.secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

button.secondary:hover {
  background: var(--color-border);
}

button.danger {
  background: var(--color-danger);
  color: #fff;
}

button.danger:hover {
  filter: brightness(1.1);
}

button.primary:disabled,
button.secondary:disabled,
button.danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.link-btn,
a.link-btn {
  background: none;
  border: none;
  color: var(--color-link);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
  text-decoration: none;
  display: inline-block;
}

button.link-btn:hover,
a.link-btn:hover {
  text-decoration: underline;
}

button.link-btn.danger-link {
  color: var(--color-danger);
}

.logo-biware {
  height: 2rem;
  width: auto;
  object-fit: contain;
}

.error-text {
  color: var(--color-danger);
  font-size: 0.9rem;
  min-height: 1.2rem;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login-card .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.login-card .brand span {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
}

.field {
  margin-bottom: 0;
}

/* Admin shell */
:root {
  --sidebar-width: 16rem;
  --header-height: 3.75rem;
}

.admin-shell {
  min-height: 100vh;
  display: flex;
}

.admin-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  transition: width 0.18s ease;
}

.admin-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.5rem;
  margin-bottom: 1.5rem;
  white-space: nowrap;
  overflow: hidden;
}

.admin-sidebar .brand span {
  font-size: 0.75rem;
  color: var(--color-sidebar-text);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.nav-group {
  margin-bottom: 0.75rem;
}

.nav-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 0.5rem 0.75rem 0.35rem;
  white-space: nowrap;
  overflow: hidden;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text);
}

.nav-link.active {
  background: var(--color-primary);
  color: var(--color-bg);
}

/* No icon set in this phase, so a narrow icon-rail would just clip nav
   labels into unreadable fragments — collapse hides the sidebar outright
   instead; the toggle stays reachable in the header to bring it back. */
.admin-shell.sidebar-collapsed .admin-sidebar {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
}

.admin-content-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.admin-header .header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

.icon-btn:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.hamburger-btn {
  display: none;
}

.header-title {
  font-weight: 600;
  font-size: 1rem;
}

.account-menu {
  position: relative;
}

.account-menu-trigger {
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}

.account-menu-trigger:hover {
  background: var(--color-surface-alt);
}

.account-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  min-width: 10rem;
  padding: 0.35rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.account-menu.open .account-menu-dropdown {
  display: block;
}

.account-menu-dropdown button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--color-text);
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.account-menu-dropdown button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-main {
  flex: 1;
  padding: 2rem 2.5rem 3rem;
}

.admin-main h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.admin-main .subtitle {
  color: var(--color-text-muted);
  margin: 0 0 1.75rem;
}

.admin-backdrop {
  display: none;
}

/* Overview cards + activity */
.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.overview-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}

.overview-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
}

.overview-card .label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.section-heading {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.88rem;
}

.activity-item .activity-meta {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Empty state (pages without CRUD yet) */
.empty-state {
  border: 1px dashed var(--color-border);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state p {
  margin: 0.25rem 0;
}

.empty-state-hint {
  font-size: 0.85rem;
}

/* Tablet */
@media (max-width: 1024px) {
  .admin-main {
    padding: 1.5rem 1.5rem 2.5rem;
  }
}

/* Mobile: sidebar becomes a drawer */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    transform: translateX(-100%);
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);
  }

  .admin-shell.sidebar-collapsed .admin-sidebar {
    width: var(--sidebar-width);
  }

  .admin-shell.sidebar-collapsed .nav-group-label,
  .admin-shell.sidebar-collapsed .admin-sidebar .brand span {
    display: block;
  }

  .admin-shell.mobile-open .admin-sidebar {
    transform: translateX(0);
  }

  .admin-shell.mobile-open .admin-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 15;
  }

  .hamburger-btn {
    display: inline-flex;
  }

  .collapse-btn {
    display: none;
  }

  .admin-main {
    padding: 1.25rem 1rem 2rem;
  }

  .overview-cards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .overview-cards {
    grid-template-columns: 1fr;
  }

  .activity-item {
    flex-direction: column;
    gap: 0.25rem;
  }
}

/* Page header with primary action (e.g. Empresas + "Nova empresa") */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
}

.page-header .subtitle {
  margin: 0;
}

/* Toolbar: search + status filter */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.toolbar input[type="search"] {
  min-width: 16rem;
  flex: 1;
}

.toolbar select {
  min-width: 10rem;
}

/* Data table */
.data-table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
}

/* Only the table itself scrolls horizontally on narrow screens — the
   pagination footer below it stays put (data-table-wrap's overflow:hidden
   only rounds the corners of the whole card). */
.table-scroll {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Click-to-sort headers (B25) */
.data-table th.dashboard-table-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th.dashboard-table-sortable:hover,
.data-table th.dashboard-table-sortable:focus-visible {
  color: var(--color-text);
}

.data-table th.dashboard-table-sorted {
  color: var(--color-link);
}

.dashboard-table-sort-arrow {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.7em;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table .actions-cell {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(52, 199, 89, 0.15);
  color: #34c759;
}

.status-badge.inactive {
  background: rgba(242, 84, 91, 0.15);
  color: var(--color-danger);
}

.status-badge.pending {
  background: rgba(251, 177, 47, 0.15);
  color: var(--color-link);
}

.status-badge.expired,
.status-badge.cancelled {
  background: rgba(139, 150, 172, 0.15);
  color: var(--color-text-muted);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.pagination .pagination-controls {
  display: flex;
  gap: 0.5rem;
}

/* Loading / error states inline in a data area */
.state-message {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
}

.state-message.is-error {
  color: var(--color-danger);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  width: 100%;
  max-width: 32rem;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Several modals wrap .modal-body/.modal-footer in a bare <form> (a block
   element by default) as a direct child of .modal. Without this, the form
   never participates in .modal's flex column, so .modal-body's flex/
   min-height never gets a constrained space to shrink into. */
.modal > form {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.modal-header {
  flex: 0 0 auto;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.25rem;
}

.modal-close-btn:hover {
  color: var(--color-text);
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-body p {
  margin: 0;
  color: var(--color-text-muted);
}

.modal-footer {
  flex: 0 0 auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.3rem;
}

.field-error {
  font-size: 0.8rem;
  color: var(--color-danger);
  margin-top: 0.3rem;
  min-height: 1rem;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 60;
}

.toast {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  font-size: 0.88rem;
  min-width: 16rem;
  max-width: 22rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.toast.success {
  border-left-color: #34c759;
}

.toast.error {
  border-left-color: var(--color-danger);
}

@media (max-width: 480px) {
  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }

  .data-table th:nth-child(3),
  .data-table td:nth-child(3) {
    display: none;
  }
}

/* Company chips (list columns) */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.chip-muted {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* Detail page layout (user-detail.html) */
.detail-back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.detail-back-link:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

.detail-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.5rem;
}

.detail-card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.detail-card .field {
  margin-bottom: 1rem;
}

.detail-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.detail-meta {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* Organization tree (companies -> departments) */
.org-tree {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 26rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.org-company-block {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-alt);
}

.org-company-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
}

.org-company-header input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.org-department-list {
  padding: 0 1rem 0.85rem 2.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.org-department-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.org-department-list input[type="checkbox"] {
  accent-color: var(--color-primary);
  cursor: pointer;
}

.org-department-empty {
  padding: 0 1rem 0.85rem 2.6rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.org-inactive-tag {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

@media (max-width: 1024px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

/* Section tree (A9) */
.section-tree {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.section-row:last-child {
  border-bottom: none;
}

.section-row-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.section-name {
  font-weight: 500;
}

.section-row-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
}

@media (max-width: 600px) {
  .section-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .section-row-meta {
    width: 100%;
    justify-content: space-between;
  }
}

/* Permissions editor (A11) */
.permission-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 18rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.permission-list-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.permission-list-item:hover {
  background: var(--color-surface-alt);
}

.permission-list-item input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.permission-list-item input[type="checkbox"]:disabled {
  cursor: not-allowed;
}

/* Audit log detail modal (A12) */
.audit-detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
}

.audit-detail-list dt {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.audit-detail-list dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-word;
}

/* Row actions dropdown (post-A14 user admin actions) */
button.actions-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0;
  font-size: 0.85rem;
  cursor: pointer;
}
button.actions-menu-trigger svg { width: 1.2rem; height: 1.2rem; }
button.actions-menu-trigger:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; }
button.actions-menu-trigger[aria-expanded="true"] { background: var(--color-surface-alt); }

button.actions-menu-trigger:hover {
  background: var(--color-border);
}

/* Rendered as a direct child of <body> (not inside .table-scroll) and
   positioned via getBoundingClientRect, so the table's overflow-x never
   clips it — see showActionsMenu() in ui.js. */
.actions-menu {
  position: fixed;
  min-width: 12rem;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 0.35rem;
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.actions-menu .actions-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  text-decoration: none;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 0.88rem;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}

.actions-menu-item:hover,
.actions-menu-item:focus-visible {
  background: var(--color-surface-alt);
}
.actions-menu-item:focus-visible { outline: 2px solid var(--color-text); outline-offset: -2px; }

.actions-menu-item.danger {
  color: var(--color-danger);
}

.actions-menu-separator {
  height: 1px;
  background: var(--color-border);
  margin: 0.3rem 0.2rem;
}

.status-badge.deleted {
  background: rgba(139, 150, 172, 0.15);
  color: var(--color-text-muted);
  text-decoration: line-through;
}

/* Portal Cliente (B2) — same navy/orange identity and reuses generic
   building blocks (.icon-btn, .account-menu*, .empty-state) from the
   Admin, but its own shell: a top header (logo + empresa ativa + usuário)
   instead of the Admin's persistent nav-group sidebar. The sidebar here is
   dynamic content (the catalog), not a fixed product menu — a different
   product, not a reskinned Admin. */
.portal-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.portal-header .header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  flex: 1 1 auto;
}

/* B22: wraps the new action icons (tema/imprimir/e-mail/foto) and the
   account menu together as the header's right-hand flex child — the icons
   work on every /portal/ page (not just report.html), since none of them
   need report-specific data (print/photo capture whatever's on screen,
   the theme applies globally, email links to the current page). */
.portal-header .header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.portal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin-right: 0.5rem;
  padding-right: 0.65rem;
  border-right: 1px solid var(--color-border);
}

.portal-header-actions .icon-btn {
  font-size: 1rem;
}

/* The e-mail action is a dropdown (Gmail/Outlook/padrão) reusing the same
   switcher mechanics as the company/report switcher, but right-aligned
   under an icon-only trigger near the header's right edge instead of a
   labeled pill trigger on the left. */
.portal-header-actions .portal-header-switcher-dropdown {
  left: auto;
  right: 0;
  min-width: 11rem;
}

.portal-header .logo-biware {
  height: 1.75rem;
  flex-shrink: 0;
}

.portal-hamburger-btn {
  flex-shrink: 0;
}

.portal-sidebar-toggle-btn {
  flex-shrink: 0;
  display: none;
}

/* Shared company switcher on home, account and report pages. */
.portal-header-switcher {
  position: relative;
  min-width: 0;
}

#portal-company-switcher {
  flex: 0 1 32rem;
  margin-right: 1rem;
}

#portal-company-switcher-trigger {
  width: 100%;
  min-width: 0;
}

.portal-header-switcher-trigger {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  max-width: 100%;
}

#portal-company-switcher-label {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
  text-align: left;
}

#portal-company-switcher-dropdown {
  width: 100%;
  min-width: min(24rem, calc(100vw - 5rem));
}

#portal-company-switcher-dropdown button {
  overflow-wrap: anywhere;
}

.portal-header-switcher-trigger:hover {
  background: var(--color-surface-alt);
}

.portal-header-switcher-trigger:disabled {
  cursor: default;
  opacity: 0.7;
}

.portal-header-switcher-dropdown {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 0.35rem);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  min-width: 14rem;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.35rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.portal-header-switcher.open .portal-header-switcher-dropdown {
  display: block;
}

.portal-header-switcher-dropdown button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--color-text);
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.portal-header-switcher-dropdown button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.portal-header-switcher-dropdown button.active {
  color: var(--color-link);
  font-weight: 600;
}

.portal-header-switcher-empty {
  padding: 0.5rem 0.6rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* "Voltar ao menu principal" (B9) — replaces the sidebar collapse toggle
   in the report view, where the sidebar nav doesn't exist at all, so a
   clear way back to the report grid takes its place. Deliberately more
   prominent than the plain icon-only .icon-btn buttons around it. */
.portal-back-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
}

.portal-back-btn:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
}

.portal-back-btn span {
  color: var(--color-link);
  font-size: 1rem;
}

/* Report view (B9): no sidebar nav at all — a "Voltar ao menu principal"
   button in the header replaces it. */
.portal-shell.no-sidebar .portal-sidebar {
  display: none;
}

.portal-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.portal-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
}

@media (min-width: 901px) {
  .portal-sidebar-toggle-btn {
    display: inline-flex;
  }

  .portal-sidebar {
    transition: width 0.15s ease, padding 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
  }

  /* Recolhido = trilho de ícones; o nome aparece em um balão flutuante. */
  .portal-shell.sidebar-collapsed .portal-sidebar {
    width: 4.75rem;
    overflow-x: hidden;
  }

  .portal-shell.sidebar-collapsed .portal-nav-texto,
  .portal-shell.sidebar-collapsed .portal-nav-group-label {
    display: none;
  }

  .portal-shell.sidebar-collapsed .portal-nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .portal-shell.sidebar-collapsed .portal-nav-subgroup {
    margin-left: 0;
  }
}

.portal-nav-group {
  margin-bottom: 0.75rem;
}

.portal-nav-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 0.5rem 0.75rem 0.35rem;
}

.portal-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.portal-nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text);
}

.portal-nav-link.active {
  background: var(--color-primary);
  color: var(--color-bg);
}

.portal-nav-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }

/* Fora do sidebar para não ser cortado pela rolagem do trilho. */
.portal-nav-tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  width: max-content;
  padding: .65rem .9rem;
  border: 1px solid var(--color-primary-dark);
  border-radius: 10px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--color-bg) 25%, transparent);
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-6px);
  transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .18s;
}
.portal-nav-tooltip::before {
  content: "";
  position: absolute;
  left: -5px;
  top: var(--tooltip-arrow-top, 50%);
  width: 8px;
  height: 8px;
  background: inherit;
  border-left: inherit;
  border-bottom: inherit;
  transform: translateY(-50%) rotate(45deg);
}
.portal-nav-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition-delay: 0s;
}
@media (max-width: 900px) { .portal-nav-tooltip { display: none; } }
@media (prefers-reduced-motion: reduce) { .portal-nav-tooltip { transition: none; transform: none; } }

.portal-nav-subgroup {
  margin-left: 0.75rem;
}

.portal-backdrop {
  display: none;
}

.portal-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 3rem;
  overflow-y: auto;
}

.portal-hero h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

.portal-hero p {
  color: var(--color-text-muted);
  margin: 0 0 2rem;
}

.portal-hero .portal-hero-stats {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-link);
}

.portal-search {
  margin-bottom: 1.25rem;
}

.portal-search input[type="search"] {
  width: 100%;
  max-width: 24rem;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
}

.portal-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.portal-report-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: var(--color-text);
  display: block;
}

.portal-report-card:hover {
  border-color: var(--color-primary);
}

.portal-report-card .name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.portal-report-card .section {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.portal-report-description {
  color: var(--color-text-muted);
  margin: 0 0 1.5rem;
  max-width: 48rem;
}

.portal-breadcrumb {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.portal-report-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  min-height: 20rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 1024px) {
  .portal-content {
    padding: 1.5rem 1.5rem 2.5rem;
  }
}

@media (max-width: 900px) {
  .portal-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);
  }

  .portal-shell.mobile-open .portal-sidebar {
    transform: translateX(0);
  }

  .portal-shell.mobile-open .portal-backdrop {
    display: block;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 15;
  }

  .portal-hamburger-btn {
    display: inline-flex;
  }

  .portal-content {
    padding: 1.25rem 1rem 2rem;
  }

  .portal-report-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 901px) {
  .portal-hamburger-btn {
    display: none;
  }
}

/* Generic dashboard renderer (B4) — consumes a ReportDefinition; knows
   only the five component types, never a specific report/module. */
/* "Atualizado em" (B9/B10) — standalone card by default (used only when
   a report has no filters to share a row with); when nested inside the
   filters row it becomes an inline group instead — the left-most item on
   the same line as the filters, not a block stacked above them. */
.dashboard-updated-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1.1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

/* B13: filters cluster at the far left, "Atualizado em" at the far right
   of the same row. `margin-left: auto` has to live on #dashboard-updated-bar-slot
   (the actual flex item inside .dashboard-filters-row) rather than on
   .dashboard-updated-bar itself, since the bar is rendered *into* that
   slot one level deeper — an auto margin on a non-flex-item has no effect. */
.dashboard-filters-row #dashboard-updated-bar-slot {
  margin-left: auto;
}

.dashboard-filters-row .dashboard-updated-bar {
  align-self: center;
  margin-bottom: 0;
  padding: 0 0 0 1.1rem;
  background: none;
  border: none;
  border-left: 1px solid var(--color-border);
  border-radius: 0;
  font-size: 0.95rem;
  white-space: nowrap;
}

.dashboard-filters-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.dashboard-updated-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--color-success, #5ac8a8);
  flex-shrink: 0;
}

.dashboard-refresh-btn {
  flex-shrink: 0;
  background: var(--color-primary);
  color: var(--color-bg);
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
}

.dashboard-refresh-btn:hover {
  filter: brightness(1.08);
}

/* B22: CSV/"Excel" export — both download the same .csv (approved by the
   client as equivalent to a real .xlsx: Excel opens a .csv natively, and
   a fake .xlsx extension on csv content would trigger a format-mismatch
   warning). Secondary styling vs. the primary refresh button. */
.dashboard-export-btn {
  flex-shrink: 0;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
}

.dashboard-export-btn:hover {
  background: var(--color-border);
}

.dashboard-filters {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.dashboard-filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.dashboard-filter {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.dashboard-filter-input {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

/* Consecutive blocks (B25) — each KPI group renders as its own grid, so
   they need the same spacing between them that the gap gives inside one. */
.dashboard-grid + .dashboard-grid {
  margin-top: 1rem;
}

/* Aligned KPI row (B24) — the renderer sets --dashboard-columns to the
   number of KPI cards so they divide the row evenly instead of leaving an
   orphan on a second row, stepping down on narrower viewports. */
.dashboard-grid-fixed {
  grid-template-columns: repeat(var(--dashboard-columns, 4), minmax(0, 1fr));
}

/* Fixed counts, not min(var(...), N): browsers reject a math function in
   repeat()'s track count, which would silently drop these rules. */
@media (max-width: 1500px) {
  .dashboard-grid-fixed {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Até 4 cards cabem lado a lado nessa faixa: forçar 3 deixaria um órfão
   (4 cards) ou uma coluna vazia (2 cards). */
@media (max-width: 1500px) and (min-width: 901px) {
  .dashboard-grid-fixed.dashboard-grid-ate4 {
    grid-template-columns: repeat(var(--dashboard-columns), minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .dashboard-grid-fixed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .dashboard-grid-fixed {
    grid-template-columns: minmax(0, 1fr);
  }
}

.dashboard-component {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}

.dashboard-component:has(canvas):not(.dashboard-component-compact),
.dashboard-component:has(.data-table-wrap),
.dashboard-component:has(.dashboard-matrix-wrap),
.dashboard-component:has(.dashboard-composition-bar),
.dashboard-component:has(.dashboard-stages) {
  grid-column: 1 / -1;
}

.dashboard-component-title {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.dashboard-component-body {
  transition: opacity 0.15s ease;
}

/* Automatic filter re-apply (B11) — the previous content stays visible,
   just dimmed, instead of flashing to "Carregando..." on every keystroke
   or selection change. */
.dashboard-component-body-loading {
  opacity: 0.45;
  pointer-events: none;
}

.dashboard-loading,
.dashboard-error {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.dashboard-error {
  color: var(--color-danger);
}

.dashboard-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dashboard-kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.dashboard-kpi-comparison {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.dashboard-chart-wrap {
  position: relative;
  height: 18rem;
}

/* A chart sharing its row with others gets less height too — three
   full-height cards side by side would push everything else off screen. */
.dashboard-component-compact .dashboard-chart-wrap {
  height: 13rem;
}



.dashboard-truncated-notice {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0.5rem 0 0;
}

/* B21: replaces the "R$" repeated in every currency cell of the matrix. */
.dashboard-matrix-note {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0.5rem 0 0;
}

/* MATRIX component (B8) — comparison matrix (indicator × period). First
   column stays readable via `position: sticky` rather than color alone,
   so the report remains usable when the table scrolls horizontally on
   narrow screens; only the table itself scrolls, never the whole page. */
.dashboard-matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

table.dashboard-matrix {
  width: 100%;
  /* B21: lowered from 56rem — wrapped column labels (B20) and the R$
     prefix moved out of currency cells (below) both shrink each column's
     natural width, so a lower floor is enough to fit at 100% zoom on a
     normal desktop width without the wrap's horizontal scrollbar. */
  min-width: 42rem;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.dashboard-matrix th,
.dashboard-matrix td {
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.dashboard-matrix thead th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: right;
  background: var(--color-surface);
}

.dashboard-matrix thead th:first-child {
  text-align: left;
}

/* B20: column labels wrap onto multiple lines ("Orçado Proporcional" →
   two lines) instead of forcing every column wide enough for one line —
   narrower columns read as cleaner/tighter. Scoped to the label row only
   (last row of thead); data cells and the "Dia"/"Mês"/"Ano" group row
   stay nowrap. */
.dashboard-matrix thead tr:last-child th {
  white-space: normal;
  max-width: 6rem;
  line-height: 1.25;
}

/* Column grouping (B10) — "Dia" / "Mês" / "Ano" spanning headers plus a
   stronger divider at each group boundary, so a wide matrix reads as
   clusters instead of one undifferentiated row of numbers. Generic:
   only appears when a component's columns actually declare a `group`. */
.dashboard-matrix-group-header {
  text-align: center;
  font-size: 0.68rem;
  color: var(--color-text);
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
}

.dashboard-matrix-group-start {
  border-left: 2px solid var(--color-border);
}

/* Row groups (B13) — a blank separator between clusters ("Atendimentos"
   vs. "Vendas" vs. cancellations vs. líquido), a fold/unfold toggle on a
   group's total row when it has collapsible detail rows, and a subtle
   background tint on highlighted rows (never the sole signal). */
.dashboard-matrix-break td,
.dashboard-matrix-break th {
  border-bottom: none;
  border-top: none;
  /* B19: `border-top` here never actually rendered, at any width — with
     `border-collapse: collapse` a table only ever paints ONE border per
     shared edge, resolved by the browser's own conflict rules, and no
     width/color on this side beat that resolution in testing. `box-shadow`
     isn't part of the border model at all, so it paints unconditionally
     regardless of what the row above declares. */
  box-shadow: inset 0 2px 0 var(--color-text-muted);
  padding: 0.4rem 0;
}

/* Corner logo (B14) — the top-left header cell only goes unused when
   columns are grouped (otherwise it holds "Indicador"); a module may put
   a small logo there via MatrixComponent.corner_logo_url. */
/* Identidade compartilhada por relatórios e guias dos apps. */
.dashboard-contexto { display: flex; align-items: center; gap: 16px; padding: 4px 0; margin-bottom: 16px; }
.jc-aba > .dashboard-contexto { margin-bottom: 0; }
.dashboard-contexto img { object-fit: contain; flex: none; }
.dashboard-contexto-monograma { flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 12px; font-size: 1.15rem; font-weight: 700; color: var(--color-link); background: color-mix(in srgb, var(--color-primary) 14%, transparent); }
.dashboard-contexto > div { min-width: 0; }
.dashboard-contexto h2 { margin: 2px 0 5px; font-size: 1.4rem; color: var(--color-text); overflow-wrap: anywhere; }
.dashboard-contexto p { margin: 0; color: var(--color-text-muted); font-size: .85rem; }
.dashboard-contexto .dashboard-contexto-marca { color: var(--color-link); font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
:root[data-theme="light"] .dashboard-contexto-logo-monocromatica { filter: brightness(.2); }
@media (max-width: 480px) {
  .dashboard-contexto { gap: 10px; }
  .dashboard-contexto img { width: 48px; height: 48px; }
  .dashboard-contexto-monograma { width: 48px; height: 48px; font-size: .95rem; }
  .dashboard-contexto h2 { font-size: 1.2rem; }
}

.dashboard-matrix-corner {
  background: var(--color-surface);
  text-align: center;
  vertical-align: middle;
}

.dashboard-matrix-corner-logo {
  max-height: 2.1rem;
  max-width: 7rem;
  object-fit: contain;
}

/* Variation arrow (B14) — sized up independently from the percentage text
   next to it, so it reads at a glance even against a tinted row. */
.dashboard-matrix-arrow {
  font-size: 1.3em;
  vertical-align: middle;
  display: inline-block;
}

.dashboard-matrix-toggle {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0;
  margin-right: 0.35rem;
}

/* Column group fold/unfold (B20) — Excel-grouping-style toggle next to
   "Mês"/"Ano" in the spanning group header, only rendered when that group
   actually has a collapsible column. */
.dashboard-matrix-col-toggle {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0;
  vertical-align: middle;
}

.dashboard-matrix-row-red .dashboard-matrix-row-label,
.dashboard-matrix-row-red .dashboard-matrix-value {
  background: rgba(226, 100, 95, 0.14);
}

.dashboard-matrix-row-green .dashboard-matrix-row-label,
.dashboard-matrix-row-green .dashboard-matrix-value {
  background: rgba(90, 200, 168, 0.14);
}

.dashboard-matrix-row-label {
  text-align: left;
  font-weight: 600;
  color: var(--color-text);
  position: sticky;
  left: 0;
  background: var(--color-surface);
}

.dashboard-matrix-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.dashboard-matrix tbody tr:last-child th,
.dashboard-matrix tbody tr:last-child td {
  border-bottom: none;
}

/* Text weight/arrow still carries the meaning first (rule 13 of the B8
   brief: never rely on color alone), but the color itself (B14) is a more
   saturated, higher-contrast tone than the muted --color-success/--color-danger
   — needed to stay legible against a highlighted row's own red/green tint. */
.dashboard-matrix-up {
  color: #2fdc9a;
  font-weight: 700;
}

.dashboard-matrix-down {
  color: #ff5f52;
  font-weight: 700;
}

@media (max-width: 900px) {
  .dashboard-filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-updated-bar {
    flex-wrap: wrap;
  }

  .dashboard-filters-row #dashboard-updated-bar-slot {
    margin-left: 0;
  }

  .dashboard-filters-row .dashboard-updated-bar {
    white-space: normal;
    padding: 0 0 0.85rem;
    margin-bottom: 0.85rem;
    border-left: none;
    border-bottom: 1px solid var(--color-border);
  }
}

/* Minha conta (B6) */
.account-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  max-width: 32rem;
}

.account-section h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

.account-section .field {
  margin-bottom: 1rem;
}

.account-company-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--color-text);
}

.account-form-actions {
  margin-top: 1.5rem;
}

/* Print (B22) — the "imprimir" header button just calls window.print();
   this is what makes that actually useful instead of printing the whole
   chrome (sidebar, header buttons, dropdowns) around the report. */
@media print {
  .portal-header,
  .portal-sidebar,
  .portal-backdrop,
  .dashboard-refresh-btn,
  .dashboard-export-btn {
    display: none !important;
  }

  .portal-shell,
  .portal-body,
  .portal-content {
    display: block !important;
    height: auto !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .dashboard-matrix-wrap {
    overflow: visible;
  }
}

/* Tabs (B23) — only rendered when a report's ReportDefinition sets
   `tabs`; every existing (non-tabbed) report is unaffected. */
.dashboard-tab-bar {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.dashboard-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
}

.dashboard-tab-btn:hover {
  color: var(--color-text);
}

.dashboard-tab-btn.active {
  color: var(--color-link);
  border-bottom-color: var(--color-primary);
}

/* KPI_COMPARISON (B23, restyled B24) — Realizado, progress track vs. the
   Orçado, then Orçado + Diferença | Variação, then optional breakdown. */
.dashboard-kpi-compare-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.dashboard-kpi-compare-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.dashboard-kpi-compare-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 10px;
  color: var(--color-link);
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
}

.dashboard-kpi-compare-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

.dashboard-kpi-compare-track {
  height: 5px;
  margin-top: 0.85rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-text-muted) 20%, transparent);
  overflow: hidden;
}

.dashboard-kpi-compare-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.dashboard-kpi-compare-fill-good {
  background: linear-gradient(90deg, var(--color-positive-dark), var(--color-positive));
}

.dashboard-kpi-compare-fill-warn {
  background: linear-gradient(90deg, #d79420, #fbb12f);
}

.dashboard-kpi-compare-fill-bad {
  background: linear-gradient(90deg, var(--color-negative-dark), var(--color-negative));
}

/* Stacked, never side-by-side: a long currency Orçado wrapped on some
   cards and not others, so the six cards' inner lines stopped matching. */
.dashboard-kpi-compare-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.dashboard-kpi-compare-budget b {
  color: var(--color-text);
  font-weight: 600;
}

.dashboard-kpi-compare-diff {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.dashboard-kpi-compare-break {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--color-border);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.dashboard-kpi-compare-break b {
  color: var(--color-text);
  font-weight: 600;
}

.dashboard-kpi-compare-arrow {
  font-size: 1.1em;
  vertical-align: middle;
}

.dashboard-kpi-compare-up {
  color: var(--color-positive);
}

.dashboard-kpi-compare-down {
  color: var(--color-negative);
}

/* COMPOSITION (B25) — stacked proportion bars, one per whole. */
.dashboard-composition-bar + .dashboard-composition-bar {
  margin-top: 1.4rem;
}

.dashboard-composition-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.dashboard-composition-track {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--color-text-muted) 20%, transparent);
}

.dashboard-composition-slice {
  display: block;
  height: 100%;
  transition: width 0.4s ease;
}

.dashboard-composition-slice.dashboard-composition-positive {
  background: linear-gradient(90deg, var(--color-positive-dark), var(--color-positive));
}

.dashboard-composition-slice.dashboard-composition-negative {
  background: linear-gradient(90deg, var(--color-negative-dark), var(--color-negative));
}

.dashboard-composition-slice.dashboard-composition-neutral {
  background: linear-gradient(90deg, var(--color-primary-dark), var(--color-primary));
}

/* Palette for bars whose parts carry no good/bad meaning (B26) — the same
   hues the charts use, so a segment reads the same across components. */
.dashboard-composition-p1 {
  background: #fbb12f;
}

.dashboard-composition-p2 {
  background: #4f8ef7;
}

.dashboard-composition-p3 {
  background: #5ac8a8;
}

.dashboard-composition-p4 {
  background: #b48ade;
}

.dashboard-composition-p5 {
  background: #e2645f;
}

.dashboard-composition-p6 {
  background: #e0a15c;
}

.dashboard-composition-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.75rem;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.dashboard-composition-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}

.dashboard-composition-item b {
  color: var(--color-text);
  font-weight: 600;
}

.dashboard-composition-share {
  font-variant-numeric: tabular-nums;
}

.dashboard-composition-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  align-self: center;
}

.dashboard-composition-dot.dashboard-composition-positive {
  background: var(--color-positive);
}

.dashboard-composition-dot.dashboard-composition-negative {
  background: var(--color-negative);
}

.dashboard-composition-dot.dashboard-composition-neutral {
  background: var(--color-primary);
}

.dashboard-composition-empty {
  color: var(--color-text-muted);
}

/* STAGES (B25) — sequential panels joined by arrows. */
.dashboard-stages {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.dashboard-stage {
  flex: 1 1 0;
  min-width: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface-alt);
}

.dashboard-stage-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.dashboard-stage-value {
  margin-top: 0.4rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.dashboard-stage-detail {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.dashboard-stage-detail b {
  color: var(--color-text);
  font-weight: 600;
  white-space: nowrap;
}

.dashboard-stage-arrow {
  align-self: center;
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

@media (max-width: 900px) {
  .dashboard-stages {
    flex-direction: column;
  }

  .dashboard-stage-arrow {
    transform: rotate(90deg);
  }
}

/* TARGET_CHART summary (B34) — the period's figures beside the chart. */
.dashboard-target {
  display: flex;
  align-items: stretch;
  gap: 1.25rem;
}

.dashboard-target-summary {
  flex: 0 0 9.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
}

.dashboard-target .dashboard-chart-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.dashboard-target-metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dashboard-target-metric span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.dashboard-target-metric b {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.dashboard-target-metric.is-up b {
  color: var(--color-target-met);
}

.dashboard-target-metric.is-down b {
  color: var(--color-negative);
}

@media (max-width: 900px) {
  .dashboard-target {
    flex-direction: column;
  }

  .dashboard-target-summary {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* TABLE bar column (B23) — a thin proportional bar behind the value,
   scaled to that column's own max among the returned rows. */
.dashboard-table-bar-cell {
  position: relative;
  min-width: 8rem;
}

.dashboard-table-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--color-primary) 25%, transparent);
  border-radius: 4px;
  z-index: 0;
}

.dashboard-table-bar-label {
  position: relative;
  z-index: 1;
  padding: 0 0.4rem;
}

/* Relatórios públicos mantêm o título na barra. No portal autenticado,
   a barra identifica a empresa e oferece o painel de filtros. */
.portal-header-titulo {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.portal-filtro-btn[hidden] { display: none; }
.portal-filtro-btn svg { display: block; }
.portal-filtros-aberto .portal-filtro-btn { color: var(--color-link); }

.portal-filtros {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: min(360px, 100vw);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.3);
  transform: translateX(-105%);
  transition: transform 0.18s ease;
  overflow-y: auto;
}
.portal-filtros-aberto .portal-filtros { transform: translateX(0); }
.portal-filtros-fundo { display: none; }
.portal-filtros-aberto .portal-filtros-fundo {
  display: block;
  position: fixed;
  inset: var(--header-height) 0 0 0;
  z-index: 39;
  background: rgba(0, 0, 0, 0.35);
}
.portal-filtros-cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.portal-filtros-topo { padding: 0.9rem 1rem 0; }
.portal-filtros-topo:empty { display: none; }
.portal-filtros-corpo { padding: 0.9rem 1rem 1.5rem; display: flex; flex-direction: column; gap: 0.9rem; }

/* Dentro do painel tudo empilha em uma coluna, ocupando a largura. */
.portal-filtros .dashboard-updated-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  width: 100%;
}
.portal-filtros .dashboard-updated-bar[hidden] { display: none; }
.portal-filtros .dashboard-filters {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  box-shadow: none;
}
.portal-filtros .dashboard-filters-row { flex-direction: column; align-items: stretch; gap: 0.75rem; }
.portal-filtros .dashboard-filters-fields { display: flex; flex-direction: column; align-items: stretch; gap: 0.75rem; }
.portal-filtros .dashboard-filter { width: 100%; }
.portal-filtros .dashboard-filter-input { width: 100%; }
.portal-filtros [hidden] { display: none !important; }

/* Ícones Lucide (portal-shell.js _icone) e avatar com as iniciais, no
   padrão do demonstrativo da Biware. */
.portal-icone {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  display: block;
}

.portal-header .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 8px;
}

#portal-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  width: auto;
  padding: 0 .6rem;
  white-space: nowrap;
}

.portal-nav-texto {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.account-menu-trigger {
  gap: 0.6rem;
}

/* Celular: empresa em uma linha própria, abaixo dos controles. */
@media (max-width: 640px) {
  #portal-shell,
  .portal-filtros,
  .portal-filtros-fundo {
    --header-height: 6.5rem;
  }

  .portal-header {
    padding-inline: 0.75rem;
  }

  #portal-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.35rem;
    padding-block: 0.5rem;
  }

  #portal-header .header-left {
    display: contents;
  }

  #portal-header .portal-hamburger-btn {
    grid-column: 1;
    grid-row: 1;
  }

  #portal-header .header-right {
    grid-column: 2;
    grid-row: 1;
  }

  #portal-company-switcher {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-right: 0;
  }

  #portal-company-switcher-dropdown {
    min-width: 0;
  }

  #account-menu-name {
    display: none;
  }

  .portal-header .logo-biware {
    display: none;
  }
}

/* Um botão de menu por tamanho de tela: gaveta no celular, recolher no
   desktop (o .portal-header .icon-btn acima não pode mostrar os dois). */
.portal-header .portal-sidebar-toggle-btn {
  display: none;
}

@media (min-width: 901px) {
  .portal-header .portal-hamburger-btn {
    display: none;
  }

  .portal-header .portal-sidebar-toggle-btn {
    display: inline-flex;
  }
}

/* Ícone do relatório no cartão da página inicial (o mesmo do menu). */
.portal-report-card-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  background: rgba(247, 168, 36, 0.12);
  color: var(--color-link);
}

/* Relatórios genéricos no padrão do dashboard do Frigorífico Santos: KPI
   com título + ícone cheio num quadrado colorido em cima e o valor embaixo;
   título dos demais cards (gráficos, tabelas) em negrito com uma linha. */
.dashboard-kpi-cab {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.dashboard-kpi-cab .dashboard-component-title {
  margin: 0;
}

.dashboard-kpi-icone {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 8px;
  color: var(--kpi-cor, var(--color-primary));
  background: color-mix(in srgb, var(--kpi-cor, var(--color-primary)) 14%, transparent);
}

.dashboard-kpi-icone svg {
  width: 0.95rem;
  height: 0.95rem;
}

.dashboard-component:not(.dashboard-kpi-card) > .dashboard-component-title {
  font-weight: 700;
  color: var(--color-text);
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

/* Filtro de uma aba só (FilterDefinition.tabs), escondido nas outras. */
.dashboard-filter[hidden] {
  display: none;
}

/* Tabela com muitas colunas (mais de 10, ex.: o ranking da Equipe): menos
   respiro em cada célula para caber inteira na tela, sem rolar de lado. */
table.data-table-compacta {
  font-size: 0.82rem;
}

.data-table-compacta th,
.data-table-compacta td {
  padding: 0.55rem 0.45rem;
}

.data-table-compacta th {
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.data-table-compacta .dashboard-table-bar-cell {
  white-space: nowrap;
  min-width: 6rem;
}

/* Tabelas longas do dashboard (ex.: Demografia, centenas de cidades)
   rolam dentro do card, com o cabeçalho fixo, em vez de esticar a página. */
.dashboard-table-scroll {
  max-height: 70vh;
  overflow-y: auto;
}

.dashboard-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-surface);
}

/* No tema claro o texto branco do logo some: troca pela variante com o
   texto em azul-marinho (mesmo PNG, só o branco recolorido). */
:root[data-theme="light"] img.logo-biware {
  content: url("/assets/img/biware-wordmark-light.png");
}

/* These shell rules intentionally live last: the stylesheet also contains
   legacy admin declarations kept for older screens. */
.admin-sidebar { padding: 1.15rem 0.8rem 0.9rem; gap: 0; overflow-y: auto; transition: width 0.22s ease, padding 0.22s ease, transform 0.22s ease; }
.admin-sidebar .brand { min-height: 3rem; margin: 0 0 1.25rem; padding: 0.15rem 0.55rem; overflow: visible; }
.nav-group { margin-bottom: 0.85rem; }
.nav-group-label { padding: 0.55rem 0.7rem 0.4rem; font-size: 0.64rem; font-weight: 700; }
.nav-link { gap: 0.72rem; min-height: 2.65rem; margin: 0.08rem 0; padding: 0.65rem 0.72rem; border-radius: 10px; }
.nav-link:hover { background: rgba(255,255,255,0.055); }
.nav-link.active { background: rgba(251,177,47,0.13); color: var(--color-link); }
.admin-shell.sidebar-collapsed .admin-sidebar { width: 4.6rem; padding-left: 0.65rem; padding-right: 0.65rem; overflow: visible; }
.admin-header { height: 4.5rem; padding: 0 2rem; background: color-mix(in srgb, var(--color-surface) 91%, transparent); }
.icon-btn { padding: 0; border: 1px solid transparent; border-radius: 9px; }
.account-menu-trigger { gap: 0.65rem; padding: 0.3rem 0.45rem 0.3rem 0.3rem; }
.account-menu-dropdown { top: calc(100% + 0.55rem); min-width: 13rem; padding: 0.45rem; border-radius: 11px; background: var(--color-surface); }
.admin-main { width: 100%; max-width: 92rem; margin: 0 auto; padding: 2.35rem 2.5rem 3.5rem; }
.admin-main h1 { font-size: clamp(1.65rem, 2vw, 2.05rem); }
.admin-main .subtitle { line-height: 1.55; }
.overview-cards { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0.9rem; margin-bottom: 1.35rem; }
.overview-card { display: flex; min-height: 7.4rem; padding: 1.2rem; border-radius: 12px; }
.overview-card .value { font-size: 1.85rem; }
.activity-list { gap: 0; }
.activity-item { align-items: center; padding: 0.8rem 0.25rem; border: 0; border-top: 1px solid var(--color-border); border-radius: 0; background: transparent; }
.activity-item .activity-meta { font-size: 0.7rem; }

@media (max-width: 1100px) {
  .overview-cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 1024px) {
  .admin-main { padding: 2rem 1.5rem 3rem; }
}

@media (max-width: 900px) {
  .admin-shell.sidebar-collapsed .admin-sidebar { width: var(--sidebar-width); padding: 1.15rem 0.8rem 0.9rem; overflow-y: auto; }
  .admin-header { padding: 0 1rem; }
  .admin-main { padding: 1.5rem 1rem 2.5rem; }
}

@media (max-width: 600px) {
  .overview-cards { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .overview-card { min-height: 6.5rem; padding: 0.95rem; }
  .overview-card .value { font-size: 1.5rem; }
  .activity-item { flex-direction: row; }
}

/* Admin filter panels: shared by audit and report access selection. */
.admin-filter-panel {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
}
.admin-filter-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.admin-filter-heading h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.admin-readonly-label { color: var(--color-text-muted); font-size: 0.75rem; white-space: nowrap; }
.admin-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; align-items: end; }
.admin-filter-search { grid-column: span 2; }
.admin-context-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.admin-filter-field { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.admin-filter-field label { color: var(--color-text-muted); font-size: 0.8rem; font-weight: 500; }
.admin-filter-field :is(input, select) { width: 100%; min-width: 0; min-height: 2.75rem; }
.admin-filter-field input[type="date"] { color-scheme: dark; }
:root[data-theme="light"] .admin-filter-field input[type="date"] { color-scheme: light; }
.admin-filter-actions { display: flex; justify-content: flex-end; }
.admin-filter-actions button { min-height: 2.75rem; }
.admin-filter-hint { margin: 0.85rem 0 0; color: var(--color-text-muted); font-size: 0.8rem; line-height: 1.5; }
.admin-filter-panel :is(input, select, button):focus-visible { outline: 2px solid var(--color-text); outline-offset: 3px; }
#permissions-area { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
#permissions-area > * { grid-column: 1 / -1; min-width: 0; }
#permissions-area > .permission-selection-card { grid-column: auto; }
#permissions-area .detail-card { margin: 0; }
#permissions-area .permission-list-item { flex-wrap: wrap; overflow-wrap: anywhere; }
#permissions-area .permission-list-item:has(input:checked) { background: var(--color-surface-alt); }
#permissions-area .permission-list-item:focus-within { outline: 2px solid var(--color-text); outline-offset: -2px; }
#permissions-area .detail-meta { overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .admin-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-filter-actions { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .admin-filter-panel { padding: 1rem; }
  .admin-filter-grid, .admin-context-grid, #permissions-area { grid-template-columns: minmax(0, 1fr); }
  .admin-filter-search { grid-column: auto; }
  .admin-filter-actions button { width: 100%; }
}
.department-permission-page [hidden] { display: none !important; }
.department-report-search { display: flex; gap: 0.5rem; }
.department-report-search input { min-width: 0; flex: 1; }
.department-permissions-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 1rem 0; }
.department-permissions-controls p { flex: 1 1 16rem; }
.department-report-group { margin: 1.25rem 0; }
.department-report-group h2 { font-size: 1rem; margin-bottom: 0.5rem; }
.department-report-group .permission-list { max-height: none; }
.department-report-option { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; border-radius: 8px; cursor: pointer; }
.department-report-option:hover { background: var(--color-surface-alt); }
.department-report-option:focus-within { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.department-report-option input { flex: 0 0 auto; }
.department-report-option span { min-width: 0; overflow-wrap: anywhere; }
.department-report-option small { display: block; color: var(--color-text-muted); margin-top: 0.2rem; }
.department-report-option:has(input:disabled) { opacity: 0.7; cursor: default; }
.shared-departments { margin-top: 1rem; padding: 1rem; }
@media (max-width: 600px) {
  .department-permission-page .page-header { flex-direction: column; align-items: stretch; }
  .department-permissions-controls button { flex: 1 1 12rem; }
}

/* Account and access surfaces extend the canonical Biware tokens. */
.auth-layout { min-height: 100svh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brand-panel { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(2rem,5vw,5rem); background: var(--color-sidebar-bg); border-right: 1px solid var(--color-border); }
.auth-brand { display: inline-flex; align-items: center; gap: 0.85rem; font-size: 1.15rem; font-weight: 600; color: var(--color-text); text-decoration: none; }
.auth-brand img { width: 2.75rem; height: 2.75rem; object-fit: contain; }
.auth-brand-copy { padding: 4rem 0; max-width: 35rem; }
.auth-eyebrow { display: block; color: var(--color-link); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; margin-bottom: 1rem; }
.auth-brand-copy h1 { font-size: clamp(2.4rem,4.5vw,4.2rem); line-height: 1.12; font-weight: 500; letter-spacing: -0.05em; margin: 0 0 1.6rem; }
.auth-brand-copy p { font-size: 1.1rem; line-height: 1.7; max-width: 28rem; color: var(--color-text-muted); }
.auth-brand-footer { color: var(--color-text-muted); font-size: 0.85rem; }
.auth-brand-lines { display: flex; align-items: end; gap: 0.75rem; height: 5rem; margin-top: 3rem; }
.auth-brand-lines span { background: var(--color-surface-alt); border: 1px solid var(--color-border); width: 2rem; border-radius: 4px; height: 30%; }
.auth-brand-lines span:nth-child(2) { height: 50%; }
.auth-brand-lines span:nth-child(3) { height: 65%; }
.auth-brand-lines span:last-child { height: 100%; background: var(--color-primary); border-color: var(--color-primary); }
.auth-form-panel { display: flex; align-items: center; justify-content: center; padding: clamp(1.5rem,4vw,4rem); }
.auth-form-wrap { width: 100%; max-width: 27rem; }
.auth-form-wrap h1,.auth-form-wrap h2 { font-size: 2rem; letter-spacing: -0.03em; line-height: 1.2; margin: 0 0 1rem; }
.auth-intro { color: var(--color-text-muted); line-height: 1.6; margin: 0 0 2rem; }
.auth-entry-switch { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--color-border); border-radius: 12px; padding: 0.3rem; gap: 0.3rem; margin-bottom: 2.75rem; }
.auth-entry-switch a { padding: 0.8rem 0.4rem; text-align: center; font-size: 0.85rem; color: var(--color-text-muted); border-radius: 8px; text-decoration: none; }
.auth-entry-switch a[aria-current] { color: var(--color-text); background: var(--color-surface-alt); }
.auth-form-wrap .field { margin-bottom: 1.2rem; }
.auth-form-wrap input { min-height: 3.2rem; width: 100%; }
.password-input { display: flex; position: relative; align-items: center; }
.password-input input { width: 100%; padding-right: 5.6rem; }
.password-toggle { position: absolute; right: 0.4rem; background: transparent; color: var(--color-text-muted); border: 0; padding: 0.55rem; font-size: 0.8rem; min-height: 2.6rem; cursor: pointer; }
.password-toggle:hover { color: var(--color-link); }
.auth-recovery { display: flex; justify-content: flex-end; margin-top: -0.3rem; }
.auth-recovery a,.recovery-card a:not(.support-link):not(.auth-brand) { color: var(--color-link); font-size: 0.85rem; }
.auth-message { min-height: 1.7rem; margin: 0.7rem 0; line-height: 1.5; }
.auth-submit { width: 100%; min-height: 3.2rem; font-weight: 600; }
.auth-support { border-top: 1px solid var(--color-border); padding-top: 1.5rem; margin-top: 2rem; display: flex; justify-content: center; }
.auth-footnote { text-align: center; color: var(--color-text-muted); font-size: 0.78rem; line-height: 1.5; margin-top: 1rem; }
.support-link { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--color-text-muted); text-decoration: none; font-size: 0.85rem; padding: 0.6rem; border-radius: 8px; white-space: nowrap; }
.support-link svg { width: 1.3rem; height: 1.3rem; flex-shrink: 0; }
.support-link:hover { color: var(--color-text); background: var(--color-surface-alt); }
.recovery-layout { min-height: 100svh; display: grid; place-items: center; padding: 1.5rem; }
.recovery-card { padding: 2.4rem; border: 1px solid var(--color-border); background: var(--color-surface); border-radius: 20px; max-width: 30rem; }
.recovery-card .auth-brand { margin-bottom: 2.5rem; }
.company-brand-mark { width: 2.7rem; height: 2.7rem; flex: 0 0 auto; display: grid; place-items: center; color: var(--color-link); background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 10px; font-size: 0.8rem; font-weight: 600; }
.company-brand-image { width: 100%; height: 100%; padding: 0.3rem; object-fit: contain; border-radius: inherit; }
.profile-avatar-image { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 50%; }
.portal-avatar,.account-avatar { overflow: hidden; flex: 0 0 auto; }
.account-menu-dropdown a { display: block; padding: 0.8rem 1rem; color: var(--color-text); text-decoration: none; }
.account-menu-dropdown a:hover { background: var(--color-surface-alt); }
.profile-page-title p { color: var(--color-text-muted); margin-bottom: 0; }
.profile-layout { display: grid; grid-template-columns: 18rem minmax(0,1fr); gap: 1.5rem; align-items: start; }
.profile-main { display: grid; gap: 1.5rem; }
.profile-main .detail-card h2,.profile-summary h2 { margin: 0 0 1.2rem; font-size: 1.15rem; }
.profile-summary { text-align: center; }
.profile-summary > p { overflow-wrap: anywhere; color: var(--color-text-muted); font-size: 0.85rem; }
.profile-photo { width: 7rem; height: 7rem; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 50%; display: grid; place-items: center; margin: 1.3rem auto; font-size: 2rem; color: var(--color-link); overflow: hidden; }
.photo-picker { display: inline-flex; cursor: pointer; justify-content: center; }
.local-company-heading { display: flex; align-items: center; gap: 0.8rem; margin: 0.6rem 0; }
.local-company-heading h1 { margin: 0; }
#avatar-file { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.photo-picker:has(+ #avatar-file:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 3px; }
#avatar-preview-img { width: 6rem; height: 6rem; object-fit: cover; border-radius: 50%; margin-top: 1rem; }
.profile-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0.5rem 1.2rem; }
.profile-fields input { width: 100%; }
.profile-access-list { list-style: none; padding: 0; margin: 0; }
.profile-access-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--color-border); }
.profile-access-row span { color: var(--color-text-muted); font-size: 0.85rem; }
.profile-access-row:last-child { border-bottom: 0; }
.company-access-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--color-border); }
.company-access-row > strong { flex: 1 1 12rem; }
.company-access-row .field { margin: 0; }
.company-access-row .error-text { width: 100%; }
.check-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0; cursor: pointer; font-size: 0.9rem; }
.check-row input { width: auto; min-height: auto; }
.local-record-list { list-style: none; margin: 0; padding: 0; }
.local-record-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 0.8rem; padding: 1rem 0; border-bottom: 1px solid var(--color-border); }
.local-record-list strong { flex: 1 1 14rem; }
.local-record-list span { color: var(--color-text-muted); }
.local-permissions-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1.5rem; margin: 1.5rem 0; }
#local-editor { margin-top: 1.5rem; }
.portal-catalog-block { margin-top: 2rem; padding: 1.5rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; }
.portal-catalog-block h2 { font-size: 1.25rem; margin: 0 0 1.2rem; }
.portal-catalog-block h3 { font-size: 0.9rem; color: var(--color-text-muted); margin: 1.5rem 0 0.8rem; }
.portal-catalog-block .portal-report-grid { margin-top: 0; }
.portal-search { display: flex; align-items: center; gap: 0.7rem; }
.portal-search input { min-width: 0; flex: 1; }
[data-report-readonly="true"] :is(.cd-novo,.cd-row-actions,.fs-cp-enviar,.nf-emitir-lote,.nf-novo-tomador,.nf-editar-tomador,.nf-novo-contrato,.nf-editar-contrato,.nf-consultar,.nf-descartar,.nf-cancelar-nota,[data-tab="emitir"]) { display: none !important; }
[hidden] { display: none !important; }
:where(a,button,input,select):focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
textarea { resize: none; }
@media (max-width: 1000px) {
  .profile-layout { grid-template-columns: 15rem minmax(0,1fr); }
  .auth-brand-panel { padding: 2rem; }
  .auth-brand-copy h1 { font-size: 3rem; }
}
@media (max-width: 760px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-brand-panel { padding: 1.3rem 1.5rem; border-right: 0; border-bottom: 1px solid var(--color-border); }
  .auth-brand-copy,.auth-brand-footer { display: none; }
  .auth-form-panel { align-items: start; padding: 2rem 1.5rem; }
  .auth-entry-switch { margin-bottom: 2rem; }
  .profile-layout,.profile-fields,.local-permissions-grid { grid-template-columns: 1fr; }
  .profile-summary { text-align: left; }
  .profile-photo { margin-left: 0; }
  .profile-access-row { flex-direction: column; gap: 0.35rem; }
  .portal-catalog-block { padding: 1rem; }
  .company-brand-mark { width: 2rem; height: 2rem; }
  .portal-header .header-right .support-link span,.admin-header .support-link span { display: none; }
  .recovery-card { padding: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { .auth-layout *, .profile-layout * { transition: none !important; } }

/* Biware 2026 — composição compartilhada. Tokens pertencem ao :root acima. */
html { background: var(--color-bg); scrollbar-color: var(--color-scrollbar) var(--color-sidebar-bg); scrollbar-width: thin; }
* { scrollbar-color: var(--color-scrollbar) var(--color-sidebar-bg); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--color-sidebar-bg); }
::-webkit-scrollbar-thumb { background: var(--color-scrollbar); border: 2px solid var(--color-sidebar-bg); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-scrollbar-hover); }
::-webkit-scrollbar-thumb:active { background: var(--color-accent); }
h1,h2,h3 { font-family: var(--font-display); font-weight: 600; }
button,input,select,textarea { font-family: inherit; }
button:not(:disabled),a,summary { cursor: pointer; }
:where(a,button,input,select,textarea,summary):focus-visible { outline: 2px solid var(--color-accent); outline-offset: 4px; }
input,select,textarea { transition: border-color .16s ease, background .16s ease; }
input:hover,select:hover,textarea:hover { border-color: var(--color-scrollbar); }
input:focus,select:focus,textarea:focus { border-color: var(--color-accent); }
input::placeholder,textarea::placeholder { color: var(--color-text-muted); opacity: .8; }
.link-btn,.auth-recovery a,.recovery-card a:not(.support-link):not(.auth-brand),.auth-eyebrow { color: var(--color-link); }
.auth-eyebrow { letter-spacing: .14em; font-size: .65rem; font-weight: 600; }
button.primary,a.primary { border: 1px solid color-mix(in srgb,var(--color-primary),white 15%); }
button.primary:active,a.primary:active { background: var(--color-primary-dark); }
button.secondary:active { background: var(--color-border); }
.auth-layout { grid-template-columns: minmax(0,1.12fr) minmax(0,1fr); background: var(--color-bg); }
.auth-brand-panel { position: relative; isolation: isolate; overflow: hidden; min-width: 0; padding: 3.2rem clamp(2.5rem,5vw,6rem); background: radial-gradient(ellipse at 0 0,color-mix(in srgb,var(--color-primary),transparent 78%),transparent 65%),var(--color-sidebar-bg); border-right-color: var(--color-border); }
.auth-brand { position: relative; z-index: 1; }
.auth-brand img { width: 210px; height: auto; object-fit: contain; }
.auth-brand-panel .auth-brand { max-width: 100%; }
.auth-brand-panel .auth-brand img { width: 420px; max-width: 100%; height: auto; }
.auth-brand-copy { position: relative; z-index: 1; padding: 4.5rem 0; max-width: 35rem; }
.auth-brand-copy .auth-eyebrow { color: var(--color-accent); margin-bottom: 1.8rem; }
.auth-brand-copy h1 { font-family: var(--font-display); font-size: clamp(2.8rem,4.5vw,4.8rem); font-weight: 600; line-height: 1.09; letter-spacing: -.055em; margin-bottom: 1.8rem; }
.auth-brand-copy h1 em { font-style: normal; color: var(--color-accent); }
.auth-brand-copy p { font-size: .95rem; line-height: 1.85; max-width: 26rem; }
.auth-brand-footer { display: flex; align-items: center; gap: 1.2rem; position: relative; z-index: 1; font-size: .56rem; letter-spacing: .18em; }
.auth-footer-line { height: 1px; width: 3.5rem; background: var(--color-accent); }
.auth-ribbon { position: absolute; z-index: -1; inset: 0; pointer-events: none; opacity: .65; }
.auth-ribbon span { position: absolute; width: 28rem; height: 22rem; right: -16rem; border: 1px solid color-mix(in srgb,var(--color-accent),transparent 65%); border-radius: 4rem; transform: rotate(-42deg); background: linear-gradient(135deg,transparent 30%,color-mix(in srgb,var(--color-primary),transparent 88%)); }
.auth-ribbon span:nth-child(1) { top: -5rem; }
.auth-ribbon span:nth-child(2) { top: 17rem; right: -19rem; }
.auth-ribbon span:nth-child(3) { bottom: -11rem; right: -7rem; width: 36rem; }
.auth-form-panel { min-width: 0; padding: 3rem clamp(1.5rem,5vw,5rem); }
.auth-form-wrap { max-width: 25rem; }
.auth-entry-switch { display: flex; width: fit-content; gap: 1.1rem; padding: 0; margin-bottom: 3.5rem; border: 0; border-bottom: 1px solid var(--color-border); border-radius: 0; }
.auth-entry-switch a { padding: .9rem .1rem; border-radius: 0; font-size: .75rem; position: relative; }
.auth-entry-switch a:hover { color: var(--color-text); }
.auth-entry-switch a[aria-current] { background: transparent; color: var(--color-text); }
.auth-entry-switch a[aria-current]::after { content: ''; position: absolute; left: 0; right: 0; height: 2px; bottom: -1px; background: var(--color-accent); }
.auth-form-wrap h1,.auth-form-wrap h2 { font-size: clamp(1.8rem,2.6vw,2.6rem); font-weight: 600; letter-spacing: -.045em; line-height: 1.18; margin-bottom: 1rem; }
.auth-intro { font-size: .85rem; line-height: 1.8; margin-bottom: 2rem; }
.auth-form-wrap label { font-size: .76rem; font-weight: 500; }
.auth-form-wrap input { min-height: 3.3rem; font-size: .86rem; border-radius: 8px; background: var(--color-surface); }
.auth-form-wrap .field { margin-bottom: 1.1rem; }
.auth-recovery a { font-size: .75rem; text-decoration: none; }
.auth-recovery a:hover { text-decoration: underline; }
.auth-submit { min-height: 3.25rem; font-size: .83rem; letter-spacing: .01em; }
.auth-message { font-size: .8rem; }
.auth-support { padding-top: 1.15rem; margin-top: 1.7rem; }
.auth-footnote { font-size: .68rem; }
.password-toggle { color: var(--color-text-muted); font-size: .72rem; }
.password-toggle:hover { color: var(--color-accent); }
.recovery-layout,.login-screen { background: radial-gradient(ellipse at 50% 0,color-mix(in srgb,var(--color-primary),transparent 85%),transparent 65%),var(--color-bg); }
.recovery-card,.login-card { border-radius: 16px; box-shadow: 0 24px 80px #06132340; }
.recovery-card .auth-brand img { width: 190px; height: auto; }
.login-card .brand .logo-biware { width: 190px; height: auto; }
.admin-sidebar,.portal-sidebar { background: var(--color-sidebar-bg); border-right: 1px solid var(--color-border); }
.admin-sidebar .brand { flex-wrap: wrap; gap: .25rem; padding: .8rem .7rem 1.4rem; margin-bottom: .8rem; border-bottom: 1px solid var(--color-border); }
.brand-wordmark { width: 158px; height: auto; display: block; }
.brand-symbol { display: none; width: 34px; height: 34px; object-fit: contain; }
.admin-sidebar .brand-copy { width: 100%; padding: .2rem .3rem 0; }
.admin-sidebar .brand-copy small { font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; }
.admin-shell.sidebar-collapsed .brand-wordmark { display: none; }
.admin-shell.sidebar-collapsed .brand-symbol { display: block; }
.nav-group-label,.portal-nav-group-label { color: var(--color-text-muted); font-size: .61rem; font-weight: 500; letter-spacing: .12em; }
.nav-link,.portal-nav-link { color: var(--color-sidebar-text); font-size: .79rem; border-radius: 7px; }
.nav-link.active,.portal-nav-link.active { background: color-mix(in srgb,var(--color-primary),transparent 80%); color: var(--color-link); }
.nav-link.active::before { background: var(--color-accent); }
.nav-link:hover,.portal-nav-link:hover { transform: none; background: var(--color-surface-alt); color: var(--color-text); }
.admin-header,.portal-header { background: var(--color-bg); border-bottom: 1px solid var(--color-border); }
.portal-header .logo-biware { width: 125px; height: auto; }
.portal-header-switcher-trigger { background: transparent; border-color: var(--color-border); border-radius: 7px; }
.portal-header .company-brand-mark { border-radius: 8px; }
.account-avatar,.portal-avatar { color: var(--color-accent); background: var(--color-surface-alt); border: 1px solid var(--color-border); }
.admin-main,.portal-content { background: var(--color-bg); }
.portal-content:has(.portal-hero) { padding: 2.75rem clamp(1.5rem,3vw,3.5rem) 4rem; }
.portal-hero { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .8rem 2rem; align-items: end; padding-bottom: 2rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--color-border); }
.portal-hero .auth-eyebrow,.portal-hero h1,.portal-hero > p:not(.portal-hero-stats) { grid-column: 1; }
.portal-hero .auth-eyebrow { margin: 0 0 .35rem; font-size: .63rem; color: var(--color-accent); }
.portal-hero h1 { font-size: clamp(1.9rem,2.8vw,2.7rem); letter-spacing: -.045em; }
.portal-hero > p { font-size: .84rem; margin: 0; }
.portal-hero .portal-hero-stats { grid-column: 2; grid-row: 1 / span 3; align-self: end; margin: 0; border: 1px solid var(--color-border); border-radius: 6px; padding: .65rem .8rem; font-size: .7rem; font-weight: 400; color: var(--color-text-muted); }
.portal-search { display: block; margin: 1.5rem 0 2rem; }
.portal-search-label { display: block; margin-bottom: .7rem; font-size: .72rem; color: var(--color-text-muted); }
.portal-search-controls { display: flex; align-items: center; gap: .7rem; }
.portal-catalog-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,260px),1fr)); gap: 2rem 1.2rem; }
.portal-catalog-grid > .portal-catalog-block { margin-top: 0; min-width: 0; }
.portal-catalog-grid .portal-report-grid { grid-template-columns: 1fr; }
.portal-tv-access { padding-top: 1.5rem; border-top: 1px solid var(--color-border); }
.portal-tv-access .portal-report-card { min-height: auto; }
.portal-search input[type="search"] { max-width: 34rem; min-height: 3rem; padding: .75rem 1rem; background: var(--color-surface); font-size: .8rem; }
.portal-catalog-block { padding: 0; margin-top: 2rem; background: transparent; border: 0; border-radius: 0; }
.portal-catalog-block h2 { font-size: 1rem; letter-spacing: -.02em; margin-bottom: 1rem; }
.portal-report-grid { grid-template-columns: repeat(auto-fill,minmax(min(100%,260px),1fr)); gap: .85rem; }
.portal-report-card { position: relative; display: flex; flex-direction: column; min-height: 10.5rem; padding: 1.35rem; border-radius: 10px; background: var(--color-surface); transition: background .15s ease,border-color .15s ease; }
.portal-report-card:hover { background: var(--color-surface-alt); border-color: var(--color-scrollbar-hover); }
.portal-report-card::after { content: '↗'; position: absolute; right: 1.3rem; top: 1.25rem; color: var(--color-text-muted); font-size: 1rem; }
.portal-report-card-icone { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; margin-bottom: 1.3rem; border-radius: 8px; background: color-mix(in srgb,var(--color-primary),transparent 85%); color: var(--color-link); }
.portal-report-card-icone svg { width: 1.2rem; height: 1.2rem; }
.portal-report-card .name { font-family: var(--font-display); font-size: .9rem; font-weight: 600; margin-bottom: .45rem; }
.portal-report-card .section { font-size: .7rem; line-height: 1.6; }
.dashboard-component,.detail-card,.overview-panel,.overview-card,.data-table-wrap { border-radius: 10px; }
.dashboard-component { background: var(--color-surface); border-color: var(--color-border); }
.dashboard-kpi-value { font-family: var(--font-display); letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.dashboard-contexto h2 { letter-spacing: -.035em; }
.dashboard-tab-btn.active { color: var(--color-link); border-bottom-color: var(--color-accent); }
.data-table thead th { color: var(--color-text-muted); font-size: .69rem; font-weight: 500; background: var(--color-surface-alt); }
.data-table tbody td { font-size: .78rem; }
.empty-state { border: 1px dashed var(--color-border); background: var(--color-surface); border-radius: 10px; }
.ux-preview-bar { position: relative; z-index: 200; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .5rem 1.2rem; padding: .55rem 1rem; background: #061323; color: var(--color-text-muted); font-size: .62rem; border-bottom: 1px solid var(--color-border); }
.ux-preview-bar strong { color: var(--color-accent); font-weight: 500; }
.ux-preview-bar nav { display: flex; gap: 1rem; }
.ux-preview-bar a { color: var(--color-text); text-decoration: none; }
.ux-preview-bar a:hover { color: var(--color-accent); }
body[data-ux-preview] .auth-layout { min-height: calc(100svh - 38px); }
@media (min-width: 761px) {
  .auth-layout { height: 100dvh; min-height: 0; }
  body[data-ux-preview] .auth-layout { height: calc(100dvh - 38px); min-height: 0; }
  .auth-brand-panel { padding-block: clamp(1rem,3dvh,3.2rem); }
  .auth-brand-copy { padding-block: clamp(.75rem,3dvh,4.5rem); }
  .auth-form-panel { padding-block: clamp(1rem,2.5dvh,3rem); align-items: safe center; }
  .auth-entry-switch { margin-bottom: clamp(1rem,3dvh,3.5rem); }
  .auth-intro { margin-bottom: clamp(.75rem,2dvh,2rem); }
  .auth-support { margin-top: clamp(.75rem,2dvh,1.7rem); }
}
@media (max-width: 1100px) {
  .auth-brand-panel { padding: 2.5rem; }
  .auth-brand-copy h1 { font-size: 3.3rem; }
  .auth-brand-copy .auth-eyebrow { font-size: .57rem; }
  .auth-brand-footer { font-size: .5rem; gap: .6rem; }
  .auth-footer-line { width: 1.5rem; }
}
@media (max-width: 760px) {
  .auth-layout { display: block; }
  .auth-brand-panel { padding: 1.3rem 1.5rem; min-height: 6rem; border-right: 0; border-bottom: 1px solid var(--color-border); }
  .auth-brand-panel .auth-brand img { width: 310px; }
  .auth-brand-copy,.auth-brand-footer { display: none; }
  .auth-ribbon span { width: 20rem; height: 12rem; right: -11rem; }
  .auth-form-panel { padding: 1.5rem 1.5rem 2.5rem; }
  .auth-entry-switch { margin-bottom: 2rem; }
  .auth-form-wrap { max-width: 28rem; }
  .auth-form-wrap h2 { font-size: 2rem; }
  .portal-header .logo-biware { width: 90px; }
  .portal-hero { display: block; padding-bottom: 1.5rem; }
  .portal-hero h1 { margin: .6rem 0; }
  .portal-hero .portal-hero-stats { margin-top: 1rem; display: inline-block; }
  .portal-content:has(.portal-hero) { padding: 1.6rem 1.2rem 3rem; }
  .portal-report-card { min-height: 9rem; }
  .ux-preview-bar { font-size: .6rem; padding: .45rem .7rem; }
  .ux-preview-bar > span { display: none; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
@media (forced-colors: active) { * { scrollbar-color: auto; } :focus-visible { outline-color: Highlight; } }

/* A marca pertence à navegação: símbolo recolhido, controle no hover/foco. */
.sidebar-brand-header { position: sticky; top: 0; z-index: 2; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--color-border); background: var(--color-sidebar-bg); }
.sidebar-wordmark-link { display: block; min-width: 0; flex: 1; }
.sidebar-wordmark { display: block; width: 190px; max-width: 100%; height: auto; }
.sidebar-toggle-btn { position: relative; flex: 0 0 36px; display: grid; place-items: center; width: 36px; height: 40px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--color-sidebar-text); }
.sidebar-toggle-btn:hover { background: var(--color-surface-alt); color: var(--color-text); }
.sidebar-toggle-symbol { display: none; width: 34px; height: 34px; object-fit: contain; }
.sidebar-toggle-glyph { display: grid; place-items: center; }
.sidebar-toggle-glyph svg { width: 21px; height: 21px; }
@media (min-width: 901px) {
  .portal-shell.sidebar-collapsed .sidebar-wordmark-link { display: none; }
  .portal-shell.sidebar-collapsed .sidebar-brand-header { justify-content: center; }
  .portal-shell.sidebar-collapsed .sidebar-toggle-symbol { display: block; opacity: 1; }
  .portal-shell.sidebar-collapsed .sidebar-toggle-glyph { position: absolute; inset: 0; opacity: 0; }
  .portal-shell.sidebar-collapsed .sidebar-toggle-btn:is(:hover,:focus-visible) .sidebar-toggle-symbol { opacity: 0; }
  .portal-shell.sidebar-collapsed .sidebar-toggle-btn:is(:hover,:focus-visible) .sidebar-toggle-glyph { opacity: 1; }
}
@media (min-width: 1025px) {
  .admin-shell.sidebar-collapsed .sidebar-wordmark-link { display: none; }
  .admin-shell.sidebar-collapsed .sidebar-brand-header { justify-content: center; }
  .admin-shell.sidebar-collapsed .sidebar-toggle-symbol { display: block; opacity: 1; }
  .admin-shell.sidebar-collapsed .sidebar-toggle-glyph { position: absolute; inset: 0; opacity: 0; }
  .admin-shell.sidebar-collapsed .sidebar-toggle-btn:is(:hover,:focus-visible) .sidebar-toggle-symbol { opacity: 0; }
  .admin-shell.sidebar-collapsed .sidebar-toggle-btn:is(:hover,:focus-visible) .sidebar-toggle-glyph { opacity: 1; }
}
@media (hover: none) {
  .sidebar-collapsed .sidebar-toggle-btn .sidebar-toggle-symbol { opacity: 0; }
  .sidebar-collapsed .sidebar-toggle-btn .sidebar-toggle-glyph { opacity: 1; }
}

/* Shell cliente: navegação de ponta a ponta; cabeçalho e conteúdo à direita. */
#portal-shell { --portal-top-offset: 0px; }
body[data-ux-preview] #portal-shell { --portal-top-offset: 38px; }
.ux-preview-bar { position: sticky; top: 0; min-height: 38px; }
#portal-header { top: var(--portal-top-offset); }
#portal-header .portal-active-company-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; color: var(--color-text-muted); min-width: 0; }
#portal-company-switcher { position: relative; flex: 0 0 auto; width: auto; max-width: none; margin: 0 .35rem; }
#portal-company-switcher-trigger { width: 2.5rem; height: 2.5rem; min-width: 2.5rem; padding: 0; justify-content: center; }
#portal-company-switcher-trigger svg { width: 1.2rem; height: 1.2rem; }
#portal-company-switcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#portal-company-switcher-dropdown { left: auto; right: 0; width: 22rem; min-width: 0; max-width: calc(100vw - 2rem); padding: .5rem; border-radius: 12px; background: var(--color-surface); }
.portal-company-popup-heading { padding: .65rem .7rem .85rem; font-family: var(--font-display); font-size: .95rem; border-bottom: 1px solid var(--color-border); margin-bottom: .35rem; }
#portal-company-switcher-dropdown button { display: flex; align-items: center; justify-content: space-between; gap: .8rem; min-height: 44px; padding: .7rem; font-size: .8rem; }
#portal-company-switcher-dropdown button > span:first-child { min-width: 0; overflow-wrap: anywhere; }
#portal-company-switcher-dropdown button:hover,#portal-company-switcher-dropdown button:focus-visible { background: var(--color-surface-alt); }
.portal-company-current { flex: 0 0 auto; font-size: .62rem; color: var(--color-link); border: 1px solid var(--color-border); border-radius: 4px; padding: .2rem .35rem; }
@media screen and (min-width: 901px) {
  #portal-shell { --portal-nav-width: var(--sidebar-width); }
  #portal-shell.sidebar-collapsed { --portal-nav-width: 4.75rem; }
  #portal-shell:not(.no-sidebar) > .portal-header,
  #portal-shell:not(.no-sidebar) > .portal-body { margin-left: var(--portal-nav-width); }
  #portal-shell:not(.no-sidebar) .portal-sidebar { position: fixed; inset: var(--portal-top-offset) auto 0 0; width: var(--portal-nav-width); height: auto; z-index: 20; transition: none; }
}
@media screen and (max-width: 900px) {
  #portal-shell .portal-sidebar { top: var(--portal-top-offset); height: calc(100dvh - var(--portal-top-offset)); }
  #portal-shell.mobile-open .portal-backdrop { inset: var(--portal-top-offset) 0 0; }
  #portal-company-switcher-dropdown { position: fixed; top: calc(var(--portal-top-offset) + var(--header-height) + .5rem); left: .75rem; right: .75rem; width: auto; max-width: none; }
}
@media screen and (max-width: 640px) {
  #portal-shell { --header-height: 3.75rem; }
  #portal-header { display: flex; gap: .5rem; padding-block: 0; }
  #portal-header .header-left { display: flex; flex: 0 0 auto; }
  #portal-header .header-right { gap: .2rem; }
  #portal-header .company-brand-mark,#portal-header .portal-active-company-name { display: none; }
  #portal-header .portal-header-actions { margin-right: 0; padding-right: .35rem; }
  #portal-header .support-link { padding: .35rem; }
  #portal-company-switcher { margin-inline: 0; }
  #portal-company-switcher-trigger { width: 2rem; height: 2rem; min-width: 2rem; }
  #portal-header .account-menu-trigger { width: 2.25rem; min-width: 2.25rem; padding: .125rem; gap: 0; font-size: 0; }
  #portal-header .portal-avatar { font-size: .7rem; }
}

/* Only the navigation list scrolls; content can never pass under the wordmark. */
#portal-shell .portal-sidebar { display: flex; flex-direction: column; overflow: hidden; padding-top: 0; padding-bottom: 0; }
#portal-shell .sidebar-brand-header { position: relative; flex: 0 0 6rem; margin: 0; background: var(--color-sidebar-bg); opacity: 1; }
#portal-sidebar-nav { flex: 1 1 auto; min-height: 0; overflow: auto; padding-block: .8rem 1.25rem; overscroll-behavior: contain; }
.admin-sidebar:has(> .sidebar-brand-header) { overflow: hidden; }
.admin-sidebar > .sidebar-brand-header { position: relative; flex: 0 0 5rem; margin-bottom: .5rem; }
.admin-sidebar > .admin-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.portal-nav-home { margin-bottom: .75rem; }
.portal-nav-section { margin-bottom: .35rem; }
.portal-nav-section > summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 44px; padding: .6rem .75rem; color: var(--color-text-muted); font-size: .75rem; font-weight: 600; cursor: pointer; list-style: none; white-space: normal; }
.portal-nav-section > summary::-webkit-details-marker { display: none; }
.portal-nav-section > summary::after { content: '›'; font-size: 1rem; transform: rotate(90deg); }
.portal-nav-section:not([open]) > summary::after { transform: none; }
.portal-nav-section > summary:is(:hover,:focus-visible) { color: var(--color-text); background: var(--color-surface-alt); border-radius: 7px; }
.portal-nav-section > summary:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.portal-nav-section-content { margin-left: .65rem; padding-left: .3rem; border-left: 1px solid var(--color-border); }
.portal-nav-section-content .portal-nav-link { white-space: normal; }
.portal-nav-rail { display: none; }
.portal-card-description { margin: 0; color: var(--color-text-muted); font-size: .76rem; line-height: 1.65; }
@media screen and (min-width: 901px) {
  .portal-shell.sidebar-collapsed .portal-nav-tree { display: none; }
  .portal-shell.sidebar-collapsed .portal-nav-rail { display: block; }
  .portal-shell.sidebar-collapsed #portal-sidebar-nav { scrollbar-width: thin; }
}
