:root {
  /* UdL Tokens */
  --udl: #831453;
  --udl-dark: #5f0c3a;
  --udl-deep: #39071f;
  --base-dark: #831453;
  --base-soft: #F5ECF1;
  --paper: #ffffff;
  --wash: #FAF8FC;
  --line: #8e9595;
  --ink: #252124;
  --muted: #595750;
  --focus: #831453;
  --focus-dark: #ffbf47;

  /* Semantic UI mapped to UdL */
  --bg: var(--wash);
  --surface: var(--paper);
  --surface-2: var(--base-soft);
  --text: var(--ink);
  --border: var(--line);
  --primary: var(--udl);
  --primary-hover: var(--udl-dark);
  --primary-soft: var(--base-soft);

  --ok: #0d5f13;
  --ok-bg: #e7f4e7;

  --warn: #7a4b00;
  --warn-bg: #fff2de;

  --manual: #5d3d94;
  --manual-bg: #efe8fb;

  --error: #a81d48;
  --error-bg: #fbe9ee;

  --auto: #0d5f63;
  --auto-bg: #dff3f1;

  --partial: #7a4b00;
  --partial-bg: #fff2de;

  --notver: #55544f;
  --notver-bg: #efefef;

  --critical: #a81d48;
  --critical-bg: #fbe9ee;

  --major: #a04500;
  --major-bg: #ffe8d8;

  --minor: #5f5b00;
  --minor-bg: #f7f3cf;

  --info: #274b7a;
  --info-bg: #e1ebfb;

  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}

.a11ysaurio-wrap * {
  box-sizing: border-box;
}

.a11ysaurio-wrap {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Atkinson Hyperlegible", Arial, sans-serif;
}

.a11ysaurio-wrap {
  padding: 12px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -56px;
  background: #fff;
  color: #000;
  padding: 10px 14px;
  border: 2px solid var(--focus);
  border-radius: 10px;
  z-index: 9999;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.topbar,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.topbar {
  display: none !important;
}

.topbar .brand {
  display: flex;
  flex-direction: column;
}

.topbar h2, .topbar h1 {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 1.25rem;
  line-height: 1.2;
  float: none !important;
}

.sub {
  margin: 4px 0 0 !important;
  color: var(--muted);
  font-size: 0.9375rem;
  float: none !important;
}

.panel,
.inner-panel {
  padding: 12px;
}

.inner-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 12px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 1rem;
}

.subsection-title {
  margin: 0 0 10px;
  font-size: 1rem;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

input[type="text"],
input[type="url"],
input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
  padding: 0;
  margin: 0 16px 0 0;
  cursor: pointer;
  accent-color: var(--primary);
}

button {
  min-height: 44px;
  min-width: 44px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

button:hover {
  background: var(--surface-2);
}

#analyzeBtn,
#useManualUrlBtn,
#downloadReportBtn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

#analyzeBtn:hover,
#useManualUrlBtn:hover,
#downloadReportBtn:hover {
  background: var(--primary-hover);
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 2px #fff;
}

.status {
  white-space: pre-wrap;
}

.meta dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 10px;
}

.meta dt {
  font-weight: 700;
}

.row,
.tree-toolbar,
.validation-toolbar,
.tab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row input {
  flex: 1 1 260px;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.tabs {
  padding: 12px;
}

.tab-btn {
  font-weight: 700;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab-panel {
  margin-top: 12px;
}

.tab-panel:not(.active) {
  display: none;
}

.toolbar-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.tree details {
  margin-left: 12px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

.tree summary {
  cursor: pointer;
  list-style: none;
  margin: 6px 0;
}

.tree summary::-webkit-details-marker {
  display: none;
}

.node-line {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 32px;
}

.tag {
  background: var(--primary-soft);
  color: var(--udl-deep);
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 700;
}

.text-snippet {
  color: var(--muted);
}

.attr {
  background: #f1f1f1;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.875rem;
}

.empty,
.error,
.warning {
  padding: 12px;
  border-radius: 10px;
}

.empty {
  background: #f8f8f8;
}

.error {
  background: var(--error-bg);
  color: var(--error);
}

.warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.validation-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.summary-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.summary-card strong {
  display: block;
  font-size: 1.25rem;
}

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

.validation-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.validation-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}

.status-badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.875rem;
  font-weight: 700;
}

.status-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-manual {
  background: var(--manual-bg);
  color: var(--manual);
}

.status-error {
  background: var(--error-bg);
  color: var(--error);
}

.status-auto {
  background: var(--auto-bg);
  color: var(--auto);
}

.status-partial {
  background: var(--partial-bg);
  color: var(--partial);
}

.status-notver {
  background: var(--notver-bg);
  color: var(--notver);
}

.status-critical {
  background: var(--critical-bg);
  color: var(--critical);
}

.status-major {
  background: var(--major-bg);
  color: var(--major);
}

.status-minor {
  background: var(--minor-bg);
  color: var(--minor);
}

.status-info {
  background: var(--info-bg);
  color: var(--info);
}

.validation-code {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 6px;
}

.validation-evidence,
.coverage-meta {
  color: var(--text);
}

.report-section-title {
  margin: 0 0 10px;
  font-size: 1rem;
}

@media (max-width: 640px) {
  .validation-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-header {
    align-items: start;
  }

  .topbar {
    align-items: stretch;
  }
}

.node-selected {
  background: var(--primary-soft);
  border-radius: 8px;
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.node-content {
  margin: 2px 0 6px 12px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
  font-size: 0.875rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}

/* Checklist Styles */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  text-wrap: nowrap;
  border: 0;
}

.checklist-container {
  border: 0;
  padding: 0;
  margin: 0;
}

.checklist-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.checklist-item:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.check-icon {
  font-size: 1.5rem;
  line-height: 1.2;
  flex-shrink: 0;
  user-select: none;
}

.check-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.check-desc {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.check-ok {
  border-left: 4px solid var(--ok);
  background: var(--ok-bg);
}

.check-warn {
  border-left: 4px solid var(--warn);
  background: var(--warn-bg);
}

.check-error {
  border-left: 4px solid var(--error);
  background: var(--error-bg);
}

/* Acciones de checklist */
.check-action-btn {
  margin-top: 8px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  transition: all 0.2s ease;
}

.check-action-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.check-action-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Árbol: Resaltado de fallas */
.node-affected {
  outline: 2px solid var(--error) !important;
  background-color: var(--error-bg) !important;
  border-radius: 4px;
  animation: pulse-error 2s infinite ease-in-out;
}

@keyframes pulse-error {
  0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* Modal nativo de Errores aislados */
.error-modal {
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
  width: 400px;
  max-height: 85vh;
  display: none;
  flex-direction: column;
}

.error-modal[open] {
  display: flex;
}

.error-modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}

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

.close-modal-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.close-modal-btn:hover {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error);
}

.close-modal-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.modal-content {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-card {
  padding: 12px;
  background: var(--surface-2);
  border-left: 4px solid var(--error);
  border-radius: 4px;
  line-height: 1.4;
}

.error-card strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: var(--text);
}

.error-card span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Botón de Información Tooltip */
.info-btn {
  background: none;
  border: 2px solid var(--muted);
  border-radius: 50%;
  color: var(--muted);
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
  padding: 0;
  transition: all 0.2s ease;
}

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

.info-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

