:root {
  --bg: #f7f8f4;
  --surface: #ffffff;
  --surface-strong: #fbfcf8;
  --text: #202323;
  --muted: #66706b;
  --line: #d9ded4;
  --primary: #146c5d;
  --primary-dark: #0d5045;
  --accent: #d96038;
  --warning: #e7b93d;
  --danger: #b83232;
  --success: #278457;
  --shadow: 0 18px 45px rgba(32, 35, 35, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(20, 108, 93, 0.08), transparent 260px),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

dialog {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand p,
.section-kicker {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1,
.section-head h2 {
  margin: 0;
  line-height: 1.1;
}

.brand h1 {
  font-size: clamp(1.25rem, 3vw, 1.7rem);
}

.top-actions {
  display: inline-flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.nav-button,
.secondary-button,
.primary-button,
.danger-button,
.role-button {
  border: 0;
  border-radius: 8px;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.nav-button {
  min-height: 38px;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.nav-button.active {
  background: var(--primary);
  color: #fff;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.section-head {
  margin-bottom: 18px;
}

.section-head h2 {
  font-size: clamp(1.55rem, 3.6vw, 2.3rem);
}

.section-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.role-button {
  min-height: 126px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: clamp(1rem, 2.3vw, 1.2rem);
  font-weight: 800;
  text-align: left;
  box-shadow: var(--shadow);
}

.role-button:hover,
.role-button:focus-visible {
  border-color: rgba(20, 108, 93, 0.35);
  box-shadow: 0 22px 52px rgba(20, 108, 93, 0.14);
  transform: translateY(-2px);
  outline: none;
}

.panel,
.report-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 18px;
  padding: 22px;
}

.panel-title,
.report-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title-spread,
.report-title {
  justify-content: space-between;
}

.panel-title h3,
.report-title h3 {
  margin: 0;
  font-size: 1.04rem;
}

.panel-title output,
.report-title span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 108, 93, 0.1);
  color: var(--primary-dark);
  font-size: 0.88rem;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

small {
  color: #858d88;
  font-size: 0.76rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 108, 93, 0.13);
}

.checklist {
  display: grid;
  gap: 14px;
}

.criterion {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  overflow: hidden;
}

.criterion-main {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 0.7fr);
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.criterion-title {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.criterion-title strong {
  line-height: 1.35;
}

.criterion-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.category {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.risk-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef1ea;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.risk-alta,
.risk-critica {
  background: rgba(184, 50, 50, 0.1);
  color: var(--danger);
}

.risk-media {
  background: rgba(231, 185, 61, 0.16);
  color: #76590f;
}

.risk-baja {
  background: rgba(39, 132, 87, 0.1);
  color: var(--success);
}

.status-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.status-option {
  min-width: 0;
}

.status-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.status-option span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
}

.status-option input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(20, 108, 93, 0.16);
}

.status-option input:checked + span {
  border-color: var(--primary);
  background: rgba(20, 108, 93, 0.11);
  color: var(--primary-dark);
}

.status-option input[value="No cumple"]:checked + span {
  border-color: var(--danger);
  background: rgba(184, 50, 50, 0.1);
  color: var(--danger);
}

.status-option input[value="No aplica"]:checked + span {
  border-color: var(--warning);
  background: rgba(231, 185, 61, 0.16);
  color: #76590f;
}

.noncompliance-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.noncompliance-fields[hidden] {
  display: none;
}

.wide-field {
  grid-column: span 2;
}

.full-field {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-height: 54px;
}

.form-message {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  padding: 10px 16px;
  font-weight: 800;
}

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

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--primary-dark);
  outline: none;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.danger-button {
  border: 1px solid rgba(184, 50, 50, 0.32);
  background: var(--danger);
  color: #fff;
}

.danger-button:hover,
.danger-button:focus-visible {
  background: #8f2424;
  outline: none;
}

.danger-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

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

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--primary);
  color: var(--primary-dark);
  outline: none;
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.report-panel {
  min-height: 310px;
  padding: 18px;
}

.report-list {
  display: grid;
  gap: 10px;
}

.report-row {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
}

.report-row-button:hover,
.report-row-button:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(20, 108, 93, 0.11);
  outline: none;
}

.report-row strong {
  line-height: 1.3;
}

.report-row span,
.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-bar {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: #e7ebe2;
  overflow: hidden;
}

.metric-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.severity-critical {
  color: var(--danger);
  font-weight: 800;
}

.report-open-label {
  justify-self: start;
  margin-top: 5px;
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.detail-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: min(82vh, 820px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(32, 35, 35, 0.28);
}

.detail-dialog::backdrop {
  background: rgba(32, 35, 35, 0.34);
}

.detail-dialog-shell {
  display: grid;
  max-height: inherit;
}

.detail-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.detail-dialog-head h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  line-height: 1.15;
}

.compact-button {
  min-height: 38px;
  padding: 8px 12px;
}

.detail-body {
  display: grid;
  gap: 16px;
  overflow: auto;
  padding: 20px 22px 22px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-field,
.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.detail-field span,
.detail-section span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-field strong,
.detail-section p {
  margin: 0;
  line-height: 1.45;
}

.detail-section {
  display: grid;
  gap: 12px;
}

.resolution-panel,
.delete-panel {
  display: grid;
  gap: 14px;
  border-radius: 8px;
  padding: 14px;
}

.resolution-panel {
  border: 1px solid rgba(20, 108, 93, 0.24);
  background: rgba(20, 108, 93, 0.06);
}

.delete-panel {
  border: 1px solid rgba(184, 50, 50, 0.24);
  background: rgba(184, 50, 50, 0.06);
}

.resolution-panel h3,
.delete-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.delete-panel p {
  margin: 0;
  color: var(--muted);
}

.resolution-actions,
.delete-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.resolution-message,
.delete-message {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.success-text {
  color: var(--success);
}

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

@media (max-width: 900px) {
  .role-grid,
  .reports-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .criterion-main,
  .noncompliance-fields {
    grid-template-columns: 1fr;
  }

  .wide-field,
  .full-field {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 14px;
  }

  .topbar,
  .section-head-row,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .nav-button,
  .secondary-button,
  .primary-button,
  .danger-button {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .report-panel {
    padding: 16px;
  }

  .status-group {
    grid-template-columns: 1fr;
  }

  .detail-dialog-head {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-summary {
    grid-template-columns: 1fr;
  }
}
