/* ==========================================================================
   Telas de listagem (Chamados, Equipamentos, Usuários, Relatório) e modais.
   Camada final — carregada depois de refresh.css.
   ========================================================================== */

/* --- Cartões-resumo (KPI) clicáveis -------------------------------------- */
.kpi-link { position: relative; overflow: hidden; }
.kpi-link.is-active {
  border-color: var(--primary-border-soft);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary-border-soft);
}
.kpi-link.is-active::after {
  content: "";
  position: absolute;
  inset: auto 14px 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
}
.kpi-card .kpi-copy strong { font-variant-numeric: tabular-nums; }
.role-icon--admin { color: var(--violet); background: color-mix(in srgb, var(--violet) 12%, transparent); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }
.role-icon--tecnico { color: var(--primary); }
.role-icon--solicitante { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 24%, transparent); }

/* --- Barra de filtros: busca ocupa o espaço livre ------------------------ */
.registry-toolbar,
.equip-filter-toolbar {
  grid-template-columns: minmax(14rem, 1fr) minmax(9rem, 12rem) minmax(9rem, 12rem) auto;
  justify-content: stretch;
  align-items: end;
  gap: .6rem;
}
.equip-filter-form {
  padding-bottom: .7rem;
  margin-bottom: .7rem;
  border-bottom: 1px solid var(--border-soft);
}
.registry-toolbar .btn,
.equip-filter-actions .btn { min-height: 36px; }
.equip-filter-toolbar select,
.equip-filter-search .input-with-icon input { min-height: 36px; }
@media (max-width: 960px) {
  .registry-toolbar,
  .equip-filter-toolbar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .registry-toolbar,
  .equip-filter-toolbar { grid-template-columns: 1fr; }
}

/* --- Tabelas de cadastro ------------------------------------------------- */
.entity-table tbody td { padding-top: .62rem; padding-bottom: .62rem; vertical-align: middle; }
.entity-table tbody tr { transition: background 100ms ease; }
.entity-table tbody tr:hover td { background: var(--surface-hover); }
.entity-table th.actions-col,
.entity-table td.actions-col { text-align: right; width: 1%; white-space: nowrap; }

.entity-cell { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.entity-cell__copy { display: flex; flex-direction: column; min-width: 0; }
.entity-cell__copy .cell-subtext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.entity-avatar {
  --tone: var(--primary);
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent);
  background: color-mix(in srgb, var(--tone) 11%, transparent);
  color: var(--tone);
  font-size: .8rem;
  font-weight: 800;
}
.entity-avatar--admin { --tone: var(--violet); }
.entity-avatar--tecnico { --tone: var(--primary); }
.entity-avatar--solicitante { --tone: var(--success); }
.entity-avatar--equip { --tone: var(--primary); }

.entity-link { color: var(--heading); font-weight: 750; font-size: .78rem; text-decoration: none; }
.entity-link:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

.mono-chip {
  display: inline-block;
  padding: .12rem .45rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .7rem;
}

.role-chip {
  --tone: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--tone) 24%, transparent);
  background: color-mix(in srgb, var(--tone) 8%, transparent);
  color: var(--text-soft);
  font-size: .7rem;
  font-weight: 650;
  white-space: nowrap;
}
.role-chip svg { color: var(--tone); }
.role-chip--admin { --tone: var(--violet); }
.role-chip--tecnico { --tone: var(--primary); }
.role-chip--solicitante { --tone: var(--success); }

.status-dot {
  --tone: var(--success);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--text-soft);
  font-size: .72rem;
  font-weight: 650;
  white-space: nowrap;
}
.status-dot::before {
  content: "";
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent);
}
.status-dot.is-off { --tone: var(--muted-2); color: var(--muted); }

.row-action {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 30px;
  padding: .25rem .6rem;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-soft);
  font: inherit;
  font-size: .72rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.row-action:hover,
.row-action:focus-visible {
  border-color: var(--primary-border-soft);
  background: var(--primary-soft);
  color: var(--primary);
}

.cell-muted { color: var(--muted-2); font-style: italic; font-size: .74rem; }

.empty-state svg { color: var(--muted-2); margin-bottom: .2rem; }

/* --- Fila de chamados ---------------------------------------------------- */
.owner-cell { display: inline-flex; align-items: center; gap: .45rem; color: var(--text-soft); }
.owner-avatar {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft-strong);
  color: var(--primary);
  font-size: .64rem;
  font-weight: 800;
}
.compact-ticket-table .protocol-link {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-weight: 700;
  letter-spacing: .01em;
}
.compact-ticket-table tbody td { vertical-align: middle; }

/* --- Relatório ----------------------------------------------------------- */
.report-type-line strong small { margin-left: .35rem; color: var(--muted); font-weight: 600; font-size: .66rem; }
.report-progress span { transition: width 300ms ease; }
.report-dist-group { transition: border-color 120ms ease; }
.report-dist-group:hover { border-color: var(--primary-border-soft); }

/* ==========================================================================
   Modais
   ========================================================================== */
.modal {
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(2, 8, 23, .45), 0 0 0 1px var(--border-soft);
}
html[data-theme="light"] .modal { box-shadow: 0 30px 80px rgba(15, 23, 42, .2), 0 0 0 1px rgba(15, 23, 42, .04); }
.modal.modal-lg { width: min(100%, 720px); }

/* Corpo rolável ocupa o que sobra abaixo do cabeçalho, seja qual for a altura dele. */
.modal { display: flex; flex-direction: column; }
.modal-header { flex: 0 0 auto; }
.modal-body,
.modal .modal-body { flex: 1 1 auto; min-height: 0; max-height: none; overflow: hidden; }

.modal-form:has(> .modal-actions:last-child) > .modal-actions,
.ticket-form.modal-form:has(> .modal-actions:last-child) > .modal-actions {
  margin-inline: -1.1rem;
  margin-bottom: 0;
  padding-bottom: calc(.82rem + env(safe-area-inset-bottom));
}
.modal-form--stacked .modal-form-scroll { gap: .85rem; }

.modal-header--rich {
  align-items: center;
  padding: 1rem 1.1rem;
  background:
    radial-gradient(120% 140% at 0% 0%, var(--primary-soft-strong), transparent 60%),
    var(--modal-header-bg);
}
.modal-header--rich .modal-heading { align-items: center; gap: .8rem; }
.modal-header--rich .modal-heading-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 0;
  background: var(--primary-button);
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 30%, transparent);
}
.modal-header--rich .eyebrow {
  display: inline-block;
  margin-bottom: .12rem;
  color: var(--primary);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.modal-header--rich h2 { font-size: 1.06rem; letter-spacing: -.01em; }
.modal-header--rich p { font-size: .72rem; line-height: 1.45; margin-top: .2rem; }
.modal-close { border-radius: 10px; }
.modal-close:hover { background: var(--surface-2); }

.modal-form, .ticket-form.modal-form { padding: 1rem 1.1rem 1.05rem; gap: .85rem; counter-reset: modal-step; }
.modal-form--stacked { gap: .85rem; }

/* Seções numeradas: guiam o preenchimento passo a passo. */
.modal-form .modal-section,
.modal-form .form-section {
  padding: .85rem .9rem .9rem;
  margin: 0;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface-subtle);
}
.modal-form .modal-section-title,
.modal-form .form-section-title {
  counter-increment: modal-step;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem .55rem;
  margin-bottom: .7rem;
  color: var(--heading);
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
}
.modal-form .modal-section-title::before,
.modal-form .form-section-title::before {
  content: counter(modal-step);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft-strong);
  color: var(--primary);
  font-size: .68rem;
  font-weight: 800;
}
.modal-form .modal-section-title small,
.modal-form .form-section-title small {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 500;
}
.modal-form .modal-section-title small::before,
.modal-form .form-section-title small::before { content: "— "; color: var(--muted-2); }

.modal-form .form-field label { font-weight: 650; }
.modal-form input:not([type="checkbox"]):not([type="radio"]),
.modal-form select,
.modal-form textarea { min-height: 38px; border-radius: 9px; }
.modal-form textarea { min-height: 110px; line-height: 1.5; }

.modal-form .switch-field { border-radius: 12px; padding: .75rem .85rem; }
.modal-form .form-grid.two-cols > .user-conta-ativa-switch {
  align-self: end;
  margin-bottom: 1.38rem;
}
@media (max-width: 640px) {
  .modal-form .form-grid.two-cols > .user-conta-ativa-switch {
    align-self: stretch;
    margin-bottom: 0;
  }
}
.modal-form .switch-field:has(input:checked) {
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
  background: var(--success-soft);
}

/* Cartões de escolha (perfil de acesso) */
.choice-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.choice-card {
  --tone: var(--primary);
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: .55rem;
  padding: .7rem .75rem;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.choice-card--admin { --tone: var(--violet); }
.choice-card--solicitante { --tone: var(--success); }
.choice-card:hover { border-color: color-mix(in srgb, var(--tone) 40%, transparent); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card__icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  color: var(--tone);
}
.choice-card__copy { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.choice-card__copy strong { color: var(--heading); font-size: .76rem; }
.choice-card__copy small { color: var(--muted); font-size: .66rem; line-height: 1.4; }
.choice-card__check {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--tone);
  color: #fff;
  opacity: 0;
  transform: scale(.6);
  transition: opacity 120ms ease, transform 120ms ease;
}
.choice-card:has(input:checked) {
  border-color: var(--tone);
  background: color-mix(in srgb, var(--tone) 7%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 14%, transparent);
}
.choice-card:has(input:checked) .choice-card__check { opacity: 1; transform: none; }
.choice-card:has(input:focus-visible) { outline: 2px solid var(--tone); outline-offset: 2px; }
@media (max-width: 640px) {
  .choice-cards { grid-template-columns: 1fr; }
}

/* Rodapé de ações (fora da área rolável; margens negativas só no eixo horizontal / base do form) */
.modal-actions--outside { margin: 0; padding-inline: 1.1rem; }
.modal-actions .btn { min-height: 38px; padding-inline: 1rem; border-radius: 9px; }
.modal-actions .btn.primary { box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 25%, transparent); }

@media (max-width: 640px) {
  .modal-header--rich { padding: .85rem .9rem; }
  .modal-header--rich .modal-heading-icon { width: 36px; height: 36px; }
  .modal-form, .ticket-form.modal-form { padding: .85rem .9rem; }
  .modal-form:has(> .modal-actions:last-child) > .modal-actions,
  .ticket-form.modal-form:has(> .modal-actions:last-child) > .modal-actions {
    margin-inline: -.9rem;
    padding-inline: .9rem;
  }
}

/* ==========================================================================
   Fila de chamados — mobile (≤ 760px)
   ========================================================================== */
.ticket-mobile-list { display: none; }

@media (max-width: 760px) {
  /* Cabeçalho e filtros enxutos: o conteúdo é a lista. */
  .ticket-list-card { padding: .8rem; }
  .ticket-list-header { flex-direction: row; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
  .ticket-list-header .lista-count-chip { flex-direction: row; white-space: nowrap; }
  .ticket-list-card .advanced-filters { margin-top: .2rem; }
  .ticket-list-header__copy p,
  .ticket-list-card .filter-hint { display: none; }
  .ticket-list-card .ticket-filter-primary--staff {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .5rem;
  }
  .ticket-list-card .ticket-filter-primary--staff .filter-search { grid-column: 1 / -1; }
  .ticket-list-card .ticket-filter-primary > .form-field > label { font-size: .66rem; }
  .ticket-list-card .filter-search label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ticket-list-card .filter-search input { min-height: 42px; font-size: 16px; border-radius: 11px; }
  .ticket-list-card .ticket-filter-primary select { min-height: 40px; font-size: 15px; }
  .ticket-list-card .clear-filter {
    grid-column: 1 / -1;
    justify-self: end;
    min-height: 0 !important;
    padding: .1rem 0;
    border: 0;
    background: none;
    color: var(--primary);
    font-size: .74rem;
    box-shadow: none;
  }
  .ticket-list-card .advanced-filters > summary { padding-block: .55rem; }
  .ticket-list-card .advanced-filter-grid { grid-template-columns: 1fr; }
  .ticket-list-card .advanced-filter-grid .period-field { grid-column: 1 / -1; }

  /* Lista em cartões */
  .ticket-table-wrap { display: none; }
  .ticket-mobile-list { display: grid; gap: .6rem; }

  .tcard {
    --prio: var(--primary);
    position: relative;
    border-bottom: 1px solid var(--border-soft);
    background: color-mix(in srgb, var(--prio) 11%, var(--surface));
  }
  .ticket-mobile-list { gap: 0; margin-inline: -.8rem; border-top: 1px solid var(--border-soft); }
  .tcard.prio-edge-baixa {
    --prio: var(--muted-2);
    background: color-mix(in srgb, var(--prio) 6%, var(--surface));
  }
  .tcard.prio-edge-media { --prio: var(--primary); }
  .tcard.prio-edge-alta { --prio: var(--warning); }
  .tcard.prio-edge-urgente {
    --prio: var(--danger);
    background: color-mix(in srgb, var(--prio) 13%, var(--surface));
  }
  html[data-theme="light"] .tcard {
    background: color-mix(in srgb, var(--prio) 9%, var(--surface));
  }
  html[data-theme="light"] .tcard.prio-edge-baixa {
    background: color-mix(in srgb, var(--prio) 5%, var(--surface));
  }
  html[data-theme="light"] .tcard.prio-edge-urgente {
    background: color-mix(in srgb, var(--prio) 11%, var(--surface));
  }
  .tcard.is-pinned {
    --prio: var(--primary);
    background: color-mix(in srgb, var(--primary) 16%, var(--surface));
  }
  .tcard.ticket-row--status-resolvido,
  .tcard.ticket-row--status-fechado { opacity: .65; }
  .tcard:active {
    background: color-mix(in srgb, var(--prio) 16%, var(--surface-hover));
  }

  .tcard__link {
    display: grid;
    gap: .22rem;
    padding: .62rem .8rem;
    color: inherit;
    text-decoration: none;
  }
  .tcard__row { display: flex; align-items: center; gap: .5rem; min-width: 0; }
  .tcard:has(.tcard__pin) .tcard__row:first-child { padding-right: 2rem; }
  .tcard__row .badge { margin-left: auto; flex: 0 0 auto; font-size: .64rem; padding: .1rem .45rem; min-height: 0; }
  .tcard__protocol {
    color: var(--protocol);
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: .74rem;
    font-weight: 700;
  }
  .tcard__time { color: var(--muted-2); font-size: .68rem; font-variant-numeric: tabular-nums; }
  .tcard__desc {
    margin: 0;
    overflow: hidden;
    color: var(--heading);
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .tcard__meta { color: var(--muted); font-size: .7rem; }
  .tcard__person { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .tcard__prio { --tone: var(--muted-2); flex: 0 0 auto; display: inline-flex; align-items: center; gap: .3rem; color: var(--text-soft); font-weight: 650; }
  .tcard__prio::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); }
  .tcard__prio--media { --tone: var(--primary); }
  .tcard__prio--alta { --tone: var(--warning); }
  .tcard__prio--urgente { --tone: var(--danger); color: var(--danger); }
  .tcard__meta .owner-avatar { width: 20px; height: 20px; font-size: .6rem; flex: 0 0 auto; }
  .owner-avatar--empty { background: var(--surface-2); color: var(--muted-2); }

  .tcard__pin { position: absolute; top: .35rem; right: .45rem; margin: 0; }
  .tcard__pin .pin-toggle { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; }

  /* Paginação: botões grandes, fáceis de tocar */
  .ticket-list-card .lista-pagination { flex-direction: column; align-items: stretch; gap: .5rem; }
  .ticket-list-card .lista-pagination__summary { text-align: center; }
  .ticket-list-card .lista-pagination__controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem; }
  .ticket-list-card .lista-page-btn { min-height: 42px; display: grid; place-items: center; border-radius: 10px; }
  .ticket-list-card .lista-page-status { font-size: .72rem; white-space: nowrap; }
}

/* Filtros da fila: no celular, só a busca + botão que abre o painel. */
.filter-search-row { display: flex; align-items: stretch; gap: .45rem; }
.filter-search-row .input-with-icon { flex: 1 1 auto; min-width: 0; }
.filter-toggle-btn { display: none; }

@media (max-width: 760px) {
  .ticket-list-card .ticket-filter-form { padding-bottom: .7rem; margin-bottom: 0; }
  .ticket-list-card .ticket-filter-primary { gap: .5rem; }

  .filter-toggle-btn {
    position: relative;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
  }
  .filter-toggle-btn.has-active,
  .is-filters-open .filter-toggle-btn {
    border-color: var(--primary-border-soft);
    background: var(--primary-soft);
    color: var(--primary);
  }
  .filter-toggle-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: .62rem;
    font-weight: 800;
  }

  /* Painel recolhido por padrão */
  .ticket-filter-form:not(.is-filters-open) .ticket-filter-primary > .form-field:not(.filter-search),
  .ticket-filter-form:not(.is-filters-open) .filter-quick-heading,
  .ticket-filter-form:not(.is-filters-open) .clear-filter,
  .ticket-filter-form:not(.is-filters-open) .advanced-filters { display: none !important; }

  .ticket-filter-form.is-filters-open .ticket-filter-primary > .form-field:not(.filter-search),
  .ticket-filter-form.is-filters-open .advanced-filters { animation: filtros-in 140ms ease-out; }
  .ticket-list-card .advanced-filters {
    margin-top: .5rem;
    border: 1px solid var(--border-soft);
    border-radius: 11px;
    padding: 0 .65rem;
  }
  .ticket-list-card .advanced-filters[open] { padding-bottom: .65rem; }
  .ticket-list-card .advanced-filters[open] {
    position: fixed;
    top: 5.2rem;
    right: .65rem;
    bottom: calc(5.15rem + env(safe-area-inset-bottom));
    left: .65rem;
    z-index: 40;
    overflow-y: auto;
    margin: 0;
    box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .18), 0 18px 42px rgba(15, 23, 42, .18);
    overscroll-behavior: contain;
  }
  .ticket-list-card:has(.advanced-filters[open]) { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .ticket-list-card .advanced-filters > summary { padding-block: .6rem; }
}
@keyframes filtros-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Botão com aparência de link (ex.: "Sair" no primeiro acesso) */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; text-underline-offset: 2px; }

/* --- LGPD: aviso de privacidade, ciência e links --- */
.legal-page { min-height: 100dvh; padding: 2rem 1rem 3rem; display: flex; justify-content: center; background: var(--bg); }
.legal-card { width: min(100%, 760px); height: fit-content; padding: 1.6rem 1.8rem; display: grid; gap: 1.1rem; line-height: 1.6; }
.legal-head { display: grid; gap: .5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-soft); }
.legal-brand { width: fit-content; }
.legal-brand .login-logo { height: 34px; width: auto; }
.legal-head h1 { margin: .3rem 0 0; color: var(--heading); font-size: 1.5rem; }
.legal-head p { margin: 0; color: var(--muted); font-size: .85rem; }
.legal-card h2 { margin: 0 0 .35rem; color: var(--heading); font-size: 1rem; }
.legal-card p, .legal-card li { color: var(--text-soft); font-size: .86rem; }
.legal-card p { margin: 0 0 .4rem; }
.legal-card ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .25rem; }
.legal-contact { padding: .9rem 1rem; border: 1px solid var(--primary-border-soft); border-radius: 12px; background: var(--primary-soft); }
.legal-foot { padding-top: .6rem; border-top: 1px solid var(--border-soft); }
@media (max-width: 640px) { .legal-card { padding: 1.1rem; } }

.consent-check { display: flex; align-items: flex-start; gap: .55rem; padding: .65rem .7rem; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface-subtle); color: var(--text-soft); font-size: .74rem; line-height: 1.45; cursor: pointer; }
.consent-check input { width: 17px; height: 17px; margin-top: .1rem; flex: 0 0 auto; accent-color: var(--primary); }
.consent-check.has-error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }

/* Perfil: coluna lateral com Segurança + Privacidade empilhados */
.profile-side { display: grid; gap: .75rem; min-width: 0; align-content: start; }

.profile-privacy-foot {
  margin: .85rem 0 0;
  padding-top: .65rem;
  border-top: 1px solid var(--border-soft);
  color: var(--muted-2);
  font-size: .68rem;
  text-align: center;
}
.profile-privacy-foot a {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.profile-privacy-foot a:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ==========================================================================
   Celular e tablet estreito
   ========================================================================== */
.sidebar-close, .mobile-actions-jump { display: none; }

@media (min-width: 901px) {
  .dash-bar-value:not(.is-peak) { display: none; }
}

@media (max-width: 900px) {
  .main, .page-content { min-width: 0; overflow-x: clip; }
  .sidebar { height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
  .sidebar-head { justify-content: space-between; padding-top: max(.85rem, env(safe-area-inset-top)); }
  .sidebar-close {
    display: inline-grid;
    width: 42px;
    height: 42px;
    border-color: var(--border-soft);
    background: var(--surface-2);
  }
  .nav-link { min-height: 44px; font-size: .9rem; }
  .main { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
  .page-title { overflow-wrap: anywhere; }
  .mobile-nav {
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    min-height: 64px;
    padding-bottom: .35rem;
  }
  .mobile-nav-item {
    min-height: 52px;
    gap: .2rem;
    font-size: .68rem;
    line-height: 1.1;
  }
  .mobile-nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-nav-item:active { background: var(--primary-soft); }
  .theme-switch { width: 72px; height: 44px; }
  .theme-switch-track { width: 58px; height: 30px; }
  .theme-switch-thumb { width: 22px; height: 22px; }
  html[data-theme="dark"] .theme-switch-thumb { transform: translateX(30px); }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px;
  }
  .action-disclosure > summary { min-height: 52px; padding-block: .8rem; }
  .action-disclosure summary strong { font-size: .84rem; }
  .mobile-actions-jump {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 44px;
    margin-top: .85rem;
    border: 1px solid var(--primary-border-soft);
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .82rem;
    font-weight: 700;
  }
  .chat-content, .readonly-text, .record-text { overflow-wrap: anywhere; }
  body:has(input:focus, textarea:focus, select:focus) .mobile-nav {
    transform: translateY(140%);
    pointer-events: none;
  }
}

@media (max-width: 760px) {
  .page-subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: .78rem;
    line-height: 1.35;
  }
  .section-header p { display: block; }
  .ticket-list-header__copy p,
  .ticket-list-card .filter-hint { display: none; }
  .topbar:has(.topbar-actions .btn:not(.mobile-redundant-action):not(.mobile-action)) {
    flex-wrap: wrap;
    align-items: flex-start;
    row-gap: .55rem;
  }
  .topbar:has(.topbar-actions .btn:not(.mobile-redundant-action):not(.mobile-action)) .topbar-main { flex: 1 1 100%; }
  .topbar:has(.topbar-actions .btn:not(.mobile-redundant-action):not(.mobile-action)) .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }
  .topbar:has(.topbar-actions .btn:not(.mobile-redundant-action):not(.mobile-action)) .topbar-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn { width: 100%; min-height: 44px; }
  .row-action { min-height: 42px; padding: .45rem .7rem; font-size: .78rem; }
  .lista-pagination { flex-direction: column; align-items: stretch; gap: .5rem; }
  .lista-pagination__controls { display: grid; grid-template-columns: 1fr auto 1fr; }
  .lista-page-btn, .report-page-nav { min-height: 44px; }
  .report-page-number { width: 40px; min-height: 40px; }
  .lista-pagination__summary { text-align: center; }
  .entity-table.mobile-stack-table td:first-child,
  .mobile-stack-table td[data-label="Chamado"] {
    grid-template-columns: minmax(0, 1fr);
  }
  .entity-table.mobile-stack-table td.actions-col {
    width: auto;
    justify-self: stretch;
    white-space: normal;
    grid-template-columns: minmax(0, 1fr);
  }
  .entity-table.mobile-stack-table td.actions-col::before { content: none; }
  .entity-table.mobile-stack-table .row-action { width: 100%; justify-content: center; }
  .entity-cell__copy .cell-subtext, .cell-subtext { white-space: normal; }
  .modal-backdrop {
    padding: 0;
    align-items: end;
  }
  .modal, .modal.modal-lg {
    width: 100%;
    max-height: 96dvh;
    border-radius: 16px 16px 0 0;
  }
  .modal-actions .btn, .chamix-confirm-actions .btn { min-height: 44px; }
  .modal-actions {
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
  }
  .chamix-confirm-backdrop { align-items: end; padding: 0; }
  .chamix-confirm-dialog {
    width: 100%;
    border-radius: 16px 16px 0 0;
  }
  .chamix-confirm-actions {
    flex-direction: column-reverse;
    align-items: stretch;
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
  }
  .chamix-confirm-actions .btn { width: 100%; }
  .report-activity-table-wrap { overflow: visible; }
  .report-activity-table, .report-activity-table tbody { display: block; width: 100%; }
  .report-activity-table thead { display: none; }
  .report-activity-table tr:not(.report-activity-detail-row) {
    display: grid;
    gap: .42rem;
    margin: 0;
    padding: .75rem .8rem .35rem;
    border: 1px solid var(--border-soft);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: var(--surface);
  }
  .report-activity-table tr.report-activity-detail-row {
    display: block;
    margin: 0 0 .6rem;
    padding: 0 .8rem .75rem;
    border: 1px solid var(--border-soft);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    background: var(--surface);
  }
  .report-activity-table tbody tr td:nth-child(n) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .12rem;
    align-items: start;
    height: auto;
    padding: 0;
    border: 0;
    white-space: normal;
  }
  .report-activity-table td[data-label]::before {
    content: attr(data-label);
    padding-top: .12rem;
    color: var(--mobile-label);
    font-size: .62rem;
    font-weight: 720;
    letter-spacing: .03em;
    text-transform: uppercase;
  }
  .report-activity-table tr.report-activity-detail-row td:nth-child(n) { display: block; }
  .report-activity-detail { display: grid; gap: .35rem; white-space: normal; }
  .report-activity-detail > span { white-space: normal; }
  .report-detail-text { white-space: normal; overflow: visible; text-overflow: unset; }
  .report-activity-table tr:has(.report-empty-state) {
    display: block;
    margin-bottom: .6rem;
    padding: .9rem;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
  }
  .report-activity-table tr:has(.report-empty-state) td:nth-child(n) { display: block; }
  .auth-page {
    align-items: start;
    justify-items: center;
    min-height: 100dvh;
    padding: calc(4.4rem + env(safe-area-inset-top)) .85rem calc(1.2rem + env(safe-area-inset-bottom));
  }
  .auth-card { width: min(100%, 420px); }
  .auth-footnote { font-size: .75rem; }
  .login-brand h1 { font-size: 1.15rem; }
  .login-brand p { font-size: .82rem; }
}

@media (max-width: 520px) {
  .mobile-nav { left: .4rem; right: .4rem; }
  .mobile-nav-item { font-size: .64rem; }
  .topbar-actions .mobile-action { flex: 0 0 44px; }
}
