/* Componentes reutilizáveis: botões, cartões, tabelas, formulários, badges, modais, toasts */

/* ------------------------------------------------------------ cabeçalho de página */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6);
}
.page-header p { color: var(--text-muted); margin: var(--sp-1) 0 0; }
.page-header__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--sp-2); }

/* ------------------------------------------------------------ botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 36px; padding: 0 var(--sp-4);
  border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  cursor: pointer; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--danger { background: transparent; border-color: var(--danger); color: #fca5a5; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-solid:hover { background: var(--danger-hover); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface); color: var(--text); }
.btn--sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.btn--icon { width: 32px; padding: 0; }
.btn--block { width: 100%; }

/* ------------------------------------------------------------ cartões */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: var(--sp-6);
}
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card__header p { margin: 2px 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.card__body { padding: var(--sp-5); }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: var(--sp-4); }
.grid--kpi { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: var(--sp-6); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid--2, .grid--3 { grid-template-columns: 1fr; } }

.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5); border-left: 3px solid var(--border-strong);
}
.kpi__label { color: var(--text-muted); font-size: var(--fs-sm); }
.kpi__value { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); margin-top: var(--sp-1); }
.kpi__hint { color: var(--text-faint); font-size: var(--fs-xs); }
.kpi--primary { border-left-color: var(--primary); }
.kpi--success { border-left-color: var(--success); }
.kpi--muted { border-left-color: var(--sev-none); }
.kpi--critical { border-left-color: var(--sev-critical); }
.kpi--high { border-left-color: var(--sev-high); }
.kpi--medium { border-left-color: var(--sev-medium); }
.kpi--low { border-left-color: var(--sev-low); }
.kpi--warning { border-left-color: var(--warning); }

.section-title { font-size: var(--fs-base); color: var(--text-muted); font-weight: var(--fw-medium); margin: 0 0 var(--sp-3); }

/* ------------------------------------------------------------ lista de definição */
.dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; }
.dl dt { color: var(--text-muted); font-size: var(--fs-sm); }
.dl dd { margin: 0; word-break: break-word; }

/* ------------------------------------------------------------ tabelas */
.table-wrap { overflow-x: auto; position: relative; } /* contém elementos absolutos (ex.: .sr-only) na rolagem */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--text-muted); font-weight: var(--fw-medium); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg-elevated); white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table__primary { color: var(--text); font-weight: var(--fw-medium); }
.table__sub { color: var(--text-faint); font-size: var(--fs-xs); }
.table-message { text-align: center; color: var(--text-muted); padding: var(--sp-8) var(--sp-4) !important; }
.truncate { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ filtros */
.toolbar { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.toolbar .field { margin: 0; min-width: 160px; }
.toolbar .field--grow { flex: 1; min-width: 220px; }

/* ------------------------------------------------------------ paginação */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-sm); flex-wrap: wrap; }
.pagination__buttons { display: flex; gap: var(--sp-2); align-items: center; }

/* ------------------------------------------------------------ formulários */
.form-section { margin-bottom: var(--sp-6); }
.form-section__title { font-size: var(--fs-base); font-weight: var(--fw-semibold); margin-bottom: var(--sp-1); }
.form-section__desc { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-4); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

.field { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.form-grid .field { margin-bottom: 0; }
.field label, .label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-medium); }
.field .req { color: var(--danger); margin-left: 2px; }
.field__help { font-size: var(--fs-xs); color: var(--text-faint); }
.field-error { font-size: var(--fs-xs); color: #fca5a5; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 var(--sp-3);
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: inherit; font-size: var(--fs-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.textarea { height: auto; min-height: 84px; padding: var(--sp-2) var(--sp-3); resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.input[readonly] { color: var(--text-muted); background: var(--surface); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input-group { display: flex; gap: var(--sp-2); }
.input-group .input { flex: 1; }
.checkbox { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; }
.checkbox input { accent-color: var(--primary); width: 16px; height: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); padding-top: var(--sp-4); border-top: 1px solid var(--border); }

/* ------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--sp-2); border-radius: 999px;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid transparent;
}
.badge--critical { background: var(--sev-critical-soft); color: #fda4af; border-color: rgba(225, 29, 72, 0.4); }
.badge--high { background: var(--sev-high-soft); color: #fdba74; }
.badge--medium { background: var(--sev-medium-soft); color: #fde047; }
.badge--low { background: var(--sev-low-soft); color: #86efac; }
.badge--none { background: var(--sev-none-soft); color: #cbd5e1; }
.badge--success { background: var(--success-soft); color: #86efac; }
.badge--warning { background: var(--warning-soft); color: #fde047; }
.badge--danger { background: var(--danger-soft); color: #fca5a5; }
.badge--info { background: var(--info-soft); color: #7dd3fc; }
.badge--primary { background: var(--primary-soft); color: var(--primary-text); }
.badge--muted { background: var(--surface-2); color: var(--text-faint); }
.score { font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); }

/* ------------------------------------------------------------ abas */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); padding: 0 var(--sp-5); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); padding: var(--sp-3) var(--sp-3); font: inherit; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary-text); border-bottom-color: var(--primary); }
.tab .badge { margin-left: 4px; }

/* ------------------------------------------------------------ alertas / estados */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); margin-bottom: var(--sp-4); }
.alert--info { border-color: rgba(56, 189, 248, 0.35); background: var(--info-soft); }
.alert--warning { border-color: rgba(234, 179, 8, 0.35); background: var(--warning-soft); }
.alert--danger { border-color: rgba(239, 68, 68, 0.4); background: var(--danger-soft); }
.alert--success { border-color: rgba(34, 197, 94, 0.35); background: var(--success-soft); }
.alert p:last-child { margin-bottom: 0; }

.empty { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--text-muted); }
.empty h3 { color: var(--text); margin-bottom: var(--sp-2); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.text-right { text-align: right; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }
.break { word-break: break-all; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }

/* ------------------------------------------------------------ progresso */
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--primary); transition: width 300ms ease; }
.scan-panel { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ------------------------------------------------------------ spinner */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: spin 0.7s linear infinite; vertical-align: -3px;
}
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ------------------------------------------------------------ modais */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh var(--sp-4); background: rgba(0, 0, 0, 0.6); overflow-y: auto; }
.modal__dialog { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; }
.modal__dialog--lg { max-width: 760px; }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.modal__body { padding: var(--sp-5); }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); }
body.modal-open { overflow: hidden; }

/* ------------------------------------------------------------ toasts */
.toasts { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2); max-width: min(420px, calc(100vw - 2rem)); }
.toast { display: flex; gap: var(--sp-3); align-items: flex-start; background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--primary); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow); font-size: var(--fs-sm); }
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
.toast__close { margin-left: auto; background: none; border: 0; color: var(--text-muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0; }

/* ------------------------------------------------------------ sugestões CPE */
.suggestions { border: 1px solid var(--border); border-radius: var(--radius); max-height: 240px; overflow-y: auto; margin-top: var(--sp-2); }
.suggestion { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--border); padding: var(--sp-2) var(--sp-3); color: var(--text); cursor: pointer; font: inherit; font-size: var(--fs-sm); }
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover { background: var(--surface-hover); }
.suggestion small { color: var(--text-faint); display: block; }

/* ------------------------------------------------------------ login */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: var(--sp-6) var(--sp-4);
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(59, 130, 246, 0.14), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, rgba(56, 189, 248, 0.08), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
}
.auth-shell {
  width: 100%; max-width: 960px; display: grid; grid-template-columns: 1.05fr 1fr; align-items: center;
  gap: var(--sp-8);
}

/* Apresentação (telas largas) */
.auth-intro { padding: var(--sp-6) var(--sp-4); }
.auth-intro__brand { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.auth-intro__brand img { width: 36px; height: 36px; }
.auth-intro__title { font-size: 1.75rem; line-height: 1.25; font-weight: var(--fw-semibold); margin: var(--sp-8) 0 var(--sp-6); max-width: 22ch; }
.auth-intro__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-5); }
.auth-intro__list li { display: flex; gap: var(--sp-3); align-items: flex-start; }
.auth-intro__list svg {
  flex: none; width: 36px; height: 36px; padding: 8px; border-radius: var(--radius);
  background: var(--primary-soft); color: var(--primary-text);
}
.auth-intro__list strong { display: block; font-weight: var(--fw-semibold); }
.auth-intro__list span { color: var(--text-muted); font-size: var(--fs-sm); }

/* Cartão de login */
.auth-card {
  width: 100%; max-width: 420px; justify-self: center; background: var(--surface);
  border: 1px solid var(--border); border-top: 3px solid var(--primary); border-radius: var(--radius-lg);
  padding: var(--sp-8); box-shadow: var(--shadow-lg);
}
.auth-card__brand { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); }
.auth-card__brand img { width: 40px; height: 40px; }
.auth-card__brand h1 { font-size: var(--fs-lg); }
.auth-card__brand p { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }
.auth-card__heading { margin-bottom: var(--sp-5); }
.auth-card__heading h2 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); margin: 0; }
.auth-card__heading p { margin: var(--sp-1) 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.auth-card .field { margin-bottom: var(--sp-5); }
.auth-card .input { height: 42px; }
.auth-card .alert { margin-bottom: var(--sp-5); }

/* Campos com ícone à esquerda */
.input-icon { position: relative; }
.input-icon .input { padding-left: 40px; }
.input-icon__icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; color: var(--text-faint); pointer-events: none;
}
.input-icon__icon svg { width: 18px; height: 18px; }
.input-icon:focus-within .input-icon__icon { color: var(--primary-text); }

.password-wrap { position: relative; }
.password-wrap .input { padding-right: 44px; }
.password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 34px; width: 36px;
  display: grid; place-items: center; background: none; border: 0; color: var(--text-muted);
  cursor: pointer; border-radius: var(--radius-sm);
}
.password-toggle:hover { color: var(--text); background: var(--surface-hover); }
.password-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.password-toggle svg { width: 18px; height: 18px; }
.btn--lg { height: 44px; font-size: var(--fs-base); margin-top: var(--sp-2); }

.auth-footer {
  margin: var(--sp-6) 0 0; padding-top: var(--sp-4); border-top: 1px solid var(--border);
  display: flex; gap: var(--sp-2); align-items: flex-start; color: var(--text-faint); font-size: var(--fs-xs);
}
.auth-footer__icon { display: grid; place-items: center; flex: none; margin-top: 1px; }
.auth-footer__icon svg { width: 14px; height: 14px; }

/* Tablet e celular: somente o cartão (com a marca) */
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 420px; }
  .auth-intro { display: none; }
}
@media (min-width: 861px) {
  .auth-card__brand { display: none; }  /* a marca já aparece na apresentação ao lado */
}
@media (max-width: 480px) {
  .auth-page { padding: var(--sp-4); place-items: start center; padding-top: 8vh; }
  .auth-card { padding: var(--sp-6) var(--sp-5); }
}

/* ------------------------------------------------------------ página de erro */
.error-page { text-align: center; padding: 10vh var(--sp-4); }
.error-page__code { font-size: 3rem; font-weight: var(--fw-semibold); color: var(--primary-text); }

.grid--3 > .col-span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid--3 > .col-span-2 { grid-column: 1 / -1; } }
@media (max-width: 760px) { .grid--3 > .col-span-2 { grid-column: auto; } }

/* ------------------------------------------------------------ botões compactos */
.btn--sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }

/* ------------------------------------------------------------ dashboard */
/* KPIs: 4 colunas no desktop, 2 no tablet, 1 no celular */
.grid--kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid--kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 340px) { .grid--kpi { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .kpi { padding: var(--sp-3) var(--sp-4); } .kpi__value { font-size: var(--fs-xl); } }
.kpi { display: flex; flex-direction: column; min-width: 0; }
.kpi__value { font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi__hint { margin-top: var(--sp-1); }
.dash-row { margin-bottom: var(--sp-6); }
.dash-row > .card { margin-bottom: 0; min-width: 0; }
@media (max-width: 1100px) { .dash-row { grid-template-columns: 1fr; } .dash-row > .col-span-2 { grid-column: auto; } }

/* Situação geral (faixa de postura de risco) */
.posture {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-6);
}
.posture__main { display: flex; align-items: flex-start; gap: var(--sp-3); min-width: 0; flex: 1 1 320px; }
.posture__icon {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-muted);
}
.posture__icon svg { width: 20px; height: 20px; }
.posture__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: 1.3; }
.posture__text { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }
.posture__scan { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; color: var(--text-muted); }
.posture__scan-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.posture[data-level="critical"] { border-left-color: var(--sev-critical); background: linear-gradient(90deg, var(--sev-critical-soft), var(--surface) 55%); }
.posture[data-level="critical"] .posture__icon { background: var(--sev-critical-soft); color: #fda4af; }
.posture[data-level="high"] { border-left-color: var(--sev-high); background: linear-gradient(90deg, var(--sev-high-soft), var(--surface) 55%); }
.posture[data-level="high"] .posture__icon { background: var(--sev-high-soft); color: #fdba74; }
.posture[data-level="medium"] { border-left-color: var(--sev-medium); }
.posture[data-level="medium"] .posture__icon { background: var(--sev-medium-soft); color: #fde047; }
.posture[data-level="ok"] { border-left-color: var(--success); }
.posture[data-level="ok"] .posture__icon { background: var(--success-soft); color: #86efac; }
.posture[data-level="info"] { border-left-color: var(--primary); }
.posture[data-level="info"] .posture__icon { background: var(--primary-soft); color: var(--primary-text); }

/* Distribuição por severidade */
.sev-bar {
  display: flex; height: 14px; border-radius: 999px; overflow: hidden;
  background: var(--surface-2); gap: 2px;
}
.sev-bar.is-empty { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--bg-elevated) 6px, var(--bg-elevated) 12px); }
.sev-bar__seg { display: block; min-width: 4px; }
.sev-bar__seg--critical, .sev-legend__item--critical .sev-dot { background: var(--sev-critical); }
.sev-bar__seg--high, .sev-legend__item--high .sev-dot { background: var(--sev-high); }
.sev-bar__seg--medium, .sev-legend__item--medium .sev-dot { background: var(--sev-medium); }
.sev-bar__seg--low, .sev-legend__item--low .sev-dot { background: var(--sev-low); }
.sev-bar__seg--none, .sev-legend__item--none .sev-dot { background: var(--sev-none); }

.sev-legend {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-3); margin-top: var(--sp-5);
}
@media (max-width: 1280px) { .sev-legend { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .sev-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sev-legend__item {
  display: flex; flex-direction: column; gap: 2px; padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated);
  color: var(--text); transition: border-color var(--transition), background var(--transition); min-width: 0;
}
.sev-legend__item:hover { border-color: var(--border-strong); background: var(--surface-hover); text-decoration: none; }
.sev-legend__item.is-zero { opacity: 0.55; }
.sev-legend__item--critical:not(.is-zero) { border-color: rgba(225, 29, 72, 0.45); }
.sev-legend__item--high:not(.is-zero) { border-color: rgba(249, 115, 22, 0.4); }
.sev-legend__label { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sev-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.sev-legend__value { font-size: var(--fs-xl); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.sev-legend__pct { color: var(--text-faint); font-size: var(--fs-xs); }

/* Lista de barras (ativos por categoria) */
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.bar-list__row { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-sm); margin-bottom: var(--sp-1); }
.bar-list__label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list__value { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.bar-list__track { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-list__fill { display: block; height: 100%; border-radius: 999px; background: var(--primary); min-width: 4px; }

/* Alertas prioritários: colunas fixas — textos longos são truncados em vez de alargar a tabela */
.table--alerts { table-layout: fixed; }
.table--alerts th:nth-child(1) { width: 150px; }
.table--alerts th:nth-child(3) { width: 84px; }
.table--alerts th:nth-child(5) { width: 132px; }
.table--alerts td { overflow: hidden; }
.table--alerts td:first-child { white-space: nowrap; }
.table--alerts td > a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table--alerts .truncate { max-width: 100%; }
.alert-row--critical td:first-child { box-shadow: inset 3px 0 0 var(--sev-critical); }
.alert-row--high td:first-child { box-shadow: inset 3px 0 0 var(--sev-high); }

/* Ativos mais expostos */
.exposed { list-style: none; margin: 0; padding: 0; }
.exposed__item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--border);
}
.exposed__item:first-child { padding-top: 0; }
.exposed__item:last-child { border-bottom: 0; padding-bottom: 0; }
.exposed__main { min-width: 0; display: flex; flex-direction: column; }
.exposed__main .table__primary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exposed__counts { display: flex; align-items: center; gap: var(--sp-1); flex: none; }
.exposed__total {
  min-width: 34px; text-align: right; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums;
}

/* Colunas secundárias ocultas em telas pequenas */
@media (max-width: 600px) {
  .hide-sm { display: none; }
  /* No celular a tabela rola dentro do cartão (a página não ganha rolagem horizontal) */
  .table--alerts { min-width: 520px; }
  .table--alerts th:nth-child(1) { width: 120px; }
  .posture { padding: var(--sp-4); }
  .posture__title { font-size: var(--fs-base); }
}

/* ------------------------------------------------------------ ativos e vulnerabilidades */
/* Faixa de indicadores que também funcionam como filtros rápidos */
.stat-strip {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5);
}
@media (max-width: 1100px) { .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0;
  padding: var(--sp-3) var(--sp-4); text-align: left; cursor: pointer;
  background: var(--surface); color: var(--text); font: inherit;
  border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius-lg);
  transition: background var(--transition), border-color var(--transition);
}
.stat:hover { background: var(--surface-hover); }
.stat:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.stat.is-active { background: var(--surface-2); border-color: var(--border-strong); box-shadow: inset 0 0 0 1px var(--primary); }
.stat__label { color: var(--text-muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stat__value { font-size: var(--fs-xl); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.stat--primary { border-left-color: var(--primary); }
.stat--success { border-left-color: var(--success); }
.stat--critical { border-left-color: var(--sev-critical); }
.stat--warning { border-left-color: var(--warning); }
.stat--muted { border-left-color: var(--sev-none); }

/* Linhas com destaque pela pior severidade (mesmo padrão dos alertas do Dashboard) */
.risk-row--critical td:first-child { box-shadow: inset 3px 0 0 var(--sev-critical); }
.risk-row--high td:first-child { box-shadow: inset 3px 0 0 var(--sev-high); }
.risk-row--medium td:first-child { box-shadow: inset 3px 0 0 var(--sev-medium); }
.risk-row--ok td:first-child { box-shadow: inset 3px 0 0 var(--sev-low); }
.risk { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); }
.risk__total { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; margin-left: 2px; }
.risk__total:hover { color: var(--primary-text); }
/* Vulnerabilidades: colunas fixas — descrições longas são truncadas em vez de alargar a tabela */
.table--vulns { table-layout: fixed; }
.table--vulns th:nth-child(1) { width: 150px; }
.table--vulns th:nth-child(3) { width: 84px; }
.table--vulns th:nth-child(5) { width: 150px; }
.table--vulns th:nth-child(6) { width: 112px; }
.table--vulns th:nth-child(7) { width: 100px; }
.table--vulns td { overflow: hidden; }
.table--vulns td:first-child { white-space: nowrap; }
.table--vulns td > a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table--vulns .truncate { max-width: 100%; }

/* Faixa de estado da atualização */
.scan-strip {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-5);
}
.scan-strip__main { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; flex: 1 1 360px; }
.scan-strip__title { font-weight: var(--fw-semibold); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.scan-strip__progress { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 200px; flex: 0 1 280px; }
.scan-strip__stats { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-1); }
.mini-stat {
  display: inline-flex; align-items: baseline; gap: var(--sp-2); padding: 2px var(--sp-2);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated);
  font-size: var(--fs-xs); color: var(--text-muted);
}
.mini-stat strong { color: var(--text); font-variant-numeric: tabular-nums; }
.mini-stat--warning { border-color: rgba(234, 179, 8, 0.4); }

/* Filtros por severidade (chips com contagem) */
.toolbar .field--full { flex-basis: 100%; min-width: 0; }
.field__label { display: block; font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-medium); }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2); height: 30px; padding: 0 var(--sp-3);
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-2);
  color: var(--text-muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.chip:hover { color: var(--text); background: var(--surface-hover); }
.chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.chip.is-active { color: var(--text); border-color: var(--primary); background: var(--primary-soft); }
.chip__count { color: var(--text); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.chip--critical .sev-dot { background: var(--sev-critical); }
.chip--high .sev-dot { background: var(--sev-high); }
.chip--medium .sev-dot { background: var(--sev-medium); }
.chip--low .sev-dot { background: var(--sev-low); }
.chip--none .sev-dot { background: var(--sev-none); }
.chip--critical.is-active { border-color: var(--sev-critical); background: var(--sev-critical-soft); }
.chip--high.is-active { border-color: var(--sev-high); background: var(--sev-high-soft); }
.chip--medium.is-active { border-color: var(--sev-medium); background: var(--sev-medium-soft); }
.chip--low.is-active { border-color: var(--sev-low); background: var(--sev-low-soft); }

/* Ajuda recolhível */
.help-box { border-bottom: 1px solid var(--border); padding: var(--sp-3) var(--sp-5); font-size: var(--fs-sm); color: var(--text-muted); }
.help-box summary { cursor: pointer; color: var(--text-muted); }
.help-box summary:hover { color: var(--text); }
.help-box ul { margin: var(--sp-3) 0 0; padding-left: var(--sp-5); display: grid; gap: var(--sp-1); }

/* Colunas secundárias */
.show-sm { display: none; }
@media (max-width: 1100px) { .hide-md { display: none; } }
@media (max-width: 600px) {
  .show-sm { display: inline; }
  .scan-strip { padding: var(--sp-4); }
  .scan-strip__progress { min-width: 0; flex-basis: 100%; }
  /* No celular a tabela rola dentro do cartão (a página não ganha rolagem horizontal) */
  .table--vulns { min-width: 640px; }
  .table--vulns th:nth-child(1) { width: 120px; }
  .stat__value { font-size: var(--fs-lg); }
}

/* ------------------------------------------------------------ agentes e sensores */
.stat-strip--static .stat { cursor: default; }
.stat-strip--static .stat:hover { background: var(--surface); }
.help-box--card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: var(--sp-6); }
.help-box ol { margin: var(--sp-3) 0; padding-left: var(--sp-5); display: grid; gap: var(--sp-1); }
.code-display {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4); margin: var(--sp-2) 0 var(--sp-2); border: 1px dashed var(--border-strong);
  border-radius: var(--radius); background: var(--bg-elevated);
}
.code-display__value { font-size: 1.5rem; letter-spacing: 0.08em; font-weight: var(--fw-semibold); color: var(--primary-text); word-break: break-all; }
