/* HCC 360 | UX/UI 14.3
   Camada visual isolada: não altera autenticação, API, dados nem permissões.
   Prioridades: legibilidade, responsividade, zero sobreposição e acessibilidade.
*/
:root {
  --ink: #102f47;
  --muted: #627b8d;
  --line: #dbe7ef;
  --bg: #f5f8fb;
  --cyan: #078db5;
  --cyan-light: #e8f6fb;
  --navy: #08253a;
  --radius: 18px;
  --ux-focus: #14a9d1;
  --ux-shadow: 0 5px 22px rgba(12, 49, 73, .055);
}
html { min-width: 280px; scroll-behavior: smooth; }
body { font-size: 15px; line-height: 1.48; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-size: 14px; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--ux-focus); outline-offset: 3px; }

/* Contenção de elementos e texto: nenhum card pode expandir a página. */
.app-shell, .workarea, .content, .panel, .kpi, .hero, .grid, .grid > *,
.formgrid, .filtergrid, .formgrid > *, .filtergrid > *, .page-head,
.page-head > *, .panel-head, .panel-head > *, .actions, .question,
.question > *, .reasonrow, .reasonrow > *, .modal-card, .auth-card {
  min-width: 0;
}
.app-shell { grid-template-columns: 246px minmax(0, 1fr); }
.workarea { overflow: clip; }
.content { width: 100%; max-width: 1536px; padding: 32px clamp(22px, 2.5vw, 44px) 88px; }
.panel, .kpi, .hero { box-shadow: var(--ux-shadow); }
.panel { padding: 25px; }
.panel h2 { font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.panel-head { flex-wrap: wrap; }
.panel-head h2 { flex: 1 1 210px; }
.panel-head > :not(h2) { max-width: 100%; }
.page-head { align-items: flex-start; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(26px, 2.35vw, 34px); line-height: 1.18; letter-spacing: -.85px; overflow-wrap: anywhere; }
.page-head p { font-size: 14px; max-width: 860px; }
.eyebrow { font-size: 11px; letter-spacing: 1.35px; }
.grid { align-items: stretch; }
.grid.two, .grid.three, .grid.four { min-width: 0; }
.kpi { padding: 23px; min-height: 146px; }
.kpi .label { font-size: 12px; line-height: 1.4; letter-spacing: .12px; }
.kpi .value { font-size: clamp(30px, 3vw, 40px); line-height: 1.16; margin: 13px 0 9px; }
.kpi .detail { font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.hero { padding: 27px 30px; }
.hero h2 { font-size: clamp(21px, 2vw, 26px); }
.hero p { font-size: 13px; }
.hero > div { min-width: 0; }
.hero .btn { flex-shrink: 0; }

/* Formulários: controles grandes, rótulos legíveis e quebras previsíveis. */
.stack { gap: 18px; }
.stack label, .formgrid label, .filtergrid label { font-size: 13px; line-height: 1.4; gap: 8px; }
input, select, textarea { min-height: 46px; padding: 11px 13px; border-radius: 12px; font-size: 14px; line-height: 1.4; }
input[type="date"], input[type="datetime-local"], input[type="time"] { width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: #53b6d0; box-shadow: 0 0 0 3px rgba(16, 164, 203, .12); }
input:disabled, select:disabled { background: #f3f6f9; color: #6a8090; }
.formgrid, .filtergrid { gap: 17px; }
.formgrid .span2, .formgrid .span4 { min-width: 0; }
.formgrid .check { line-height: 1.4; }
.btn { min-height: 46px; border-radius: 12px; line-height: 1.3; white-space: normal; text-align: center; }
.btn.small { min-height: 38px; font-size: 12px; }
.btn.primary { background: #084562; }
.btn.primary:hover { background: #075f7d; }
.actions { gap: 10px; }
.actions > * { max-width: 100%; }
.form-actions { flex-wrap: wrap; }
.filter-actions { flex-wrap: wrap; }
.filter-actions > * { min-width: 0; }
.question { grid-template-columns: minmax(0, 1fr) auto; }
.question strong { font-size: 14px; line-height: 1.5; }
.choice { flex-wrap: wrap; justify-content: flex-end; }
.choice button { min-height: 45px; }
.reasonrow { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.note, .warning-inline { font-size: 12px; }

/* Tabelas e gráficos sempre contidos, com rolagem apenas dentro do componente. */
.tablewrap { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.tablewrap table { min-width: max-content; width: 100%; }
.tablewrap td, .tablewrap th { padding: 13px 15px; }
.tablewrap td { font-size: 13px; }
.chart-row { grid-template-columns: minmax(0, 1fr) minmax(75px, 2fr) minmax(40px, 50px); }
.chart-row > * { min-width: 0; }
.chart-row > :first-child { overflow-wrap: anywhere; }
.chart-svg { max-width: 100%; }
.subtabs { max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.subtabs button { font-size: 13px; }
.empty { font-size: 13px; overflow-wrap: anywhere; }
.pill { white-space: normal; line-height: 1.4; overflow-wrap: anywhere; }

/* Navegação, estados e hierarquia. */
.sidebar { background: var(--navy); }
.side-brand { padding: 24px 19px; }
.side-brand strong { font-size: 22px; }
.sidebar nav { padding: 21px 10px; }
.sidebar nav button { min-height: 48px; height: auto; padding: 11px 13px; font-size: 14px; line-height: 1.35; }
.sidebar nav button.active { background: #18536f; box-shadow: inset 3px 0 0 #56c9e9; }
.side-bottom { padding: 18px; }
.side-bottom div { font-size: 13px; line-height: 1.45; }
.topbar { min-height: 76px; height: auto; padding: 14px clamp(22px, 2.5vw, 44px); }
.topbar strong { font-size: 17px; }
.top-right { min-width: 0; flex-wrap: wrap; justify-content: flex-end; text-align: right; }
.top-right #top-user { max-width: 290px; line-height: 1.3; overflow-wrap: anywhere; }
.top-eyebrow { font-size: 10px; }

/* Modal: o conteúdo rola dentro dele, sem ultrapassar a janela. */
.modal { padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); z-index: 110; overflow: hidden; }
.modal-card { width: min(680px, 100%); max-height: min(780px, calc(100dvh - 32px)); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; border-radius: 22px; padding: 26px; }
.modal-head { gap: 14px; position: sticky; top: -26px; z-index: 2; background: #fff; padding: 10px 0 14px; }
.modal-head h2 { font-size: 21px; line-height: 1.25; overflow-wrap: anywhere; }
.modal-body, #modal-body { min-width: 0; overflow-wrap: anywhere; }
#modal-body .formgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#modal-body .formgrid .span4 { grid-column: 1/-1; }
#modal-body .formgrid .span2 { grid-column: span 2; }
.icon-btn { flex: 0 0 auto; }
/* Notificações acima da interface, sem bloquear a barra de navegação. */
.toast { z-index: 160; bottom: auto; top: max(20px, env(safe-area-inset-top)); right: 20px; width: max-content; max-width: min(410px, calc(100vw - 40px)); padding: 13px 17px; line-height: 1.45; overflow-wrap: anywhere; }

/* Tela de acesso: espaçamento confortável em resoluções menores. */
.auth-screen { min-height: 100dvh; }
.auth-split { grid-template-columns: minmax(0, 1fr) minmax(350px, 470px); gap: clamp(26px, 5vw, 76px); }
.auth-card { padding: clamp(28px, 3.1vw, 42px); }
.auth-card h2 { font-size: clamp(25px, 2.3vw, 30px); line-height: 1.2; }
.auth-card > p { font-size: 14px; }
.auth-card input { min-height: 49px; }
.auth-card .btn { min-height: 50px; }
.auth-note { font-size: 12px; }

/* Notebooks: não colocar dois formulários de duas colunas lado a lado. */
@media (max-width: 1280px) {
  .grid.two { grid-template-columns: 1fr; }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .formgrid, .filtergrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding-left: 26px; padding-right: 26px; }
}
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .side-brand { gap: 9px; padding: 20px 13px; }
  .side-brand img { width: 56px; }
  .side-brand strong { font-size: 19px; }
  .sidebar nav button { font-size: 13px; }
  .top-right #top-user { max-width: 170px; }
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { width: min(316px, 87vw); max-width: 100%; z-index: 91; box-shadow: 18px 0 55px rgba(4, 28, 47, .18); }
  .sidebar:not(.open) { box-shadow: none; }
  .sidebar.open { transform: translateX(0); }
  .app-shell:has(.sidebar.open)::before { content: ""; position: fixed; inset: 0; z-index: 90; background: rgba(2, 23, 40, .56); }
  .content { padding: 24px 18px calc(118px + env(safe-area-inset-bottom)); }
  .topbar { min-height: 68px; padding: 10px 18px; }
  .top-right #top-user { display: none; }
  .bottom-nav { min-height: 72px; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 7px 6px calc(7px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(12, 45, 70, .07); z-index: 80; }
  .bottom-nav button { min-width: 0; min-height: 53px; padding: 7px 2px; font-size: 12px; line-height: 1.25; border-radius: 12px; overflow-wrap: anywhere; }
  .bottom-nav button.active { background: #e6f6fb; }
  .bottom-nav #bottom-more { color: #315d74; }
  .auth-split { grid-template-columns: minmax(0, 1fr); gap: 23px; max-width: 510px; }
  .auth-card { padding: 29px; }
  .auth-tag { margin-top: 25px; }
  .auth-intro h1 { font-size: clamp(34px, 6vw, 42px); letter-spacing: -1.8px; }
}
@media (max-width: 620px) {
  .grid.two, .grid.three, .grid.four, .formgrid, .filtergrid { grid-template-columns: minmax(0, 1fr); }
  .formgrid .span2, .formgrid .span4 { grid-column: 1 / -1; }
  .content { padding: 22px 16px calc(116px + env(safe-area-inset-bottom)); }
  .page-head { gap: 12px; margin-bottom: 21px; }
  .page-head h1 { font-size: 27px; }
  .page-head p { font-size: 14px; }
  .hero { padding: 22px; gap: 19px; }
  .hero .btn { width: 100%; }
  .panel { padding: 19px; }
  .panel-head { align-items: flex-start; gap: 9px; }
  .panel-head h2 { flex-basis: 100%; }
  .kpi { min-height: 118px; padding: 20px; }
  .kpi .value { font-size: 32px; }
  .question { grid-template-columns: minmax(0, 1fr); }
  .choice { width: 100%; justify-content: stretch; }
  .choice button { flex: 1 1 60px; }
  .reasonrow { grid-template-columns: minmax(0, 1fr); }
  .chart-row { grid-template-columns: minmax(0, 1fr) minmax(65px, 1.2fr) 42px; gap: 7px; font-size: 11px; }
  .filter-actions { align-items: stretch; }
  .filter-actions > * { width: 100%; }
  .filter-actions .btn { width: 100%; }
  #modal-body .formgrid { grid-template-columns: minmax(0, 1fr); }
  #modal-body .formgrid .span2, #modal-body .formgrid .span4 { grid-column: 1 / -1; }
  .modal { padding: 10px; }
  .modal-card { max-height: calc(100dvh - 20px); padding: 19px; border-radius: 18px; }
  .modal-head { top: -19px; }
  .modal-head h2 { font-size: 19px; }
  .toast { left: 12px; right: 12px; width: auto; max-width: none; top: max(12px, env(safe-area-inset-top)); text-align: center; }
  .auth-screen { padding: 18px 13px 26px; }
  .auth-card { padding: 24px 22px; }
  .auth-intro h1 { font-size: 35px; }
  .top-right { font-size: 10px; }
}
@media (max-width: 360px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 15px; }
  .bottom-nav { padding-left: 3px; padding-right: 3px; }
  .bottom-nav button { font-size: 11px; }
  .topbar { gap: 10px; padding-left: 12px; padding-right: 12px; }
  .top-right { font-size: 9px; }
  .top-eyebrow { font-size: 9px; }
  .page-head h1 { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
