* {
  box-sizing: border-box;
}

/* The [hidden] attribute must always win over any display declared below
   (e.g. #pagination and .dropdown-menu use display:flex, which otherwise
   overrides the browser's default [hidden]{display:none} at equal specificity). */
[hidden] {
  display: none !important;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 0;
  color: #1a1a2e;
  background: #f7f7fb;
}

header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #1e3a5f;
  color: white;
  padding: 1.5rem 2rem;
}

.header-logo {
  max-height: 64px;
  filter: brightness(0) invert(1);
}

header h1 {
  margin: 0 0 0.25rem 0;
}

.header-text p {
  margin: 0;
}

.header-refs {
  margin-left: auto;
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.refs-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
}
.refs-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}
.refs-panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  padding: 0.75rem 1rem;
  min-width: 260px;
  max-width: 320px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.refs-panel a {
  color: #1e3a5f;
  font-size: 0.83rem;
  line-height: 1.4;
  text-decoration: none;
}
.refs-panel a:hover {
  text-decoration: underline;
}

main {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}

footer {
  margin-top: 3rem;
  padding: 1.5rem 2rem;
  background: #1e3a5f;
  color: white;
  text-align: center;
}

.footer-logo {
  max-height: 64px;
  margin-bottom: 0.5rem;
  filter: brightness(0) invert(1);
}

footer p {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

#search-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.field label {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  font: inherit;
}

.dropdown {
  position: relative;
  min-width: 0;
}

.dropdown-toggle {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  font: inherit;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.dropdown-toggle:disabled {
  color: #777;
  cursor: not-allowed;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  width: 100%;
  max-width: 100%;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  z-index: 20;
}

.dropdown-search-wrap {
  flex: none;
  box-sizing: border-box;
  width: 100%;
  padding: 0.5rem;
}

.dropdown-search {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  font-size: 0.85rem;
}

.dropdown-options {
  overflow-y: auto;
  border-top: 1px solid #eee;
}

.dropdown-empty {
  padding: 0.6rem 0.7rem;
  font-size: 0.85rem;
  color: #777;
  font-style: italic;
}

.dropdown-option {
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: break-word;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.dropdown-option:last-child {
  border-bottom: none;
}

.dropdown-option:hover,
.dropdown-option.active {
  background: #e2eefd;
}

#search-button {
  grid-column: span 3;
  padding: 0.75rem;
  background: #1e3a5f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

#search-button:disabled {
  background: #999;
  cursor: not-allowed;
}

#export-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1.2rem;
}

#export-button {
  grid-column: span 3;
  padding: 0.75rem;
  background: #1e3a5f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}
#export-button:hover { background: #16304e; }

.advisor-picker { position: relative; }

.advisor-results {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: auto;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  z-index: 20;
  box-sizing: border-box;
}

.advisor-result-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  line-height: 1.35;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.advisor-result-item:last-child { border-bottom: none; }
.advisor-result-item:hover { background: #e2eefd; }

/* Selector de dos clases a propósito: .field input (ancho:100%, para los campos
   normales del formulario) tiene más especificidad que una sola clase y le
   ganaba a esta regla, dejando el checkbox a ~121px en vez de 15px. */
.advisor-picker .advisor-result-checkbox {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.advisor-result-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
}

.advisor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.advisor-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #e2eefd;
  color: #0a4d8f;
  border-radius: 999px;
  padding: 0.25rem 0.5rem 0.25rem 0.75rem;
  font-size: 0.8rem;
}

.advisor-chip button {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.message {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 4px;
}

.message.error {
  background: #fde2e2;
  color: #a30000;
}

.message.info {
  background: #e2eefd;
  color: #0a4d8f;
}

.message.empty {
  background: #f0f0f0;
  color: #555;
}

.table-wrapper {
  overflow-x: auto;
  margin-top: 1.5rem;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

th, td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #eee;
  text-align: left;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  background: #1e3a5f;
  color: white;
}

thead th:nth-child(1) { width: 5%; }  /* Estado */
thead th:nth-child(2) { width: 18%; } /* Título */
thead th:nth-child(3) { width: 14%; } /* Autor(es) */
thead th:nth-child(4) { width: 12%; } /* Tutor(es) */
thead th:nth-child(5) { width: 9%; }  /* Fecha (issued) */
thead th:nth-child(6) { width: 12%; } /* Tipo */
thead th:nth-child(7) { width: 20%; } /* dc.publisher */
thead th:nth-child(8) { width: 10%; } /* Handle / URL */

#pagination {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.pagination-pill {
  display: inline-flex;
  align-items: stretch;
  background: white;
  border: 1px solid #1e3a5f;
  border-radius: 999px;
  overflow: hidden;
}

.pagination-pill button {
  border: none;
  background: transparent;
  color: #1e3a5f;
  width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pagination-pill button:hover:not(:disabled) {
  background: #1e3a5f;
  color: #fff;
}

.pagination-pill button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  align-items: stretch;
  border-left: 1px solid #e3e9f0;
  border-right: 1px solid #e3e9f0;
}

.page-numbers button {
  border: none;
  background: transparent;
  color: #1e3a5f;
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 34px;
  padding: 0 0.4rem;
  cursor: pointer;
}

.page-numbers button:hover {
  background: #eef2f7;
}

.page-numbers button[aria-current="page"] {
  background: #1e3a5f;
  color: #fff;
  cursor: default;
}

.page-numbers .page-ellipsis {
  display: flex;
  align-items: center;
  padding: 0 0.3rem;
  color: #8a97a8;
  font-size: 0.85rem;
}

.section-divider {
  grid-column: 1 / -1;
  margin-top: 0.5rem;
  padding-top: 0.8rem;
  border-top: 1px dashed #ccc;
}

.section-divider span {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #555;
}

.sem-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
}
.sem-red { background: #d64545; }
.sem-orange { background: #e08a1e; }
.sem-green { background: #2e9e5b; }
.chart-bar-magnitude { background: #2a78d6; }

.estado-cell { text-align: center; }

.result-row { cursor: pointer; }
.result-row:hover { background: #f2f6fc; }

.detail-row td {
  background: #fafafa;
  white-space: normal;   /* override the nowrap/ellipsis truncation from the th,td rule */
  overflow: visible;
  text-overflow: clip;
}
.issues-detail { padding: 0.3rem 0.2rem; }
.issues-title { font-weight: 600; font-size: 0.82rem; margin: 0 0 0.35rem; }
.issues-ok { font-size: 0.82rem; color: #2e9e5b; margin: 0; }
.issue-line { padding: 0.5rem 0; border-bottom: 1px solid #eee; }
.issue-line:last-child { border-bottom: none; }
.issue-message { font-size: 0.82rem; line-height: 1.5; }
.issue-message .sem-dot { margin-right: 0.35rem; }
.issue-fix { font-size: 0.78rem; line-height: 1.4; color: #333; margin-top: 0.2rem; padding-left: 1.05rem; }
.issue-norm { font-size: 0.72rem; color: #888; font-style: italic; margin-top: 0.15rem; padding-left: 1.05rem; }

#quality-summary {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 1.5rem 0 0;
  padding: 0.6rem 0.9rem;
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 0.9rem;
}
#quality-summary {
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
}
.summary-label { color: #555; }
.quality-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.quality-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 999px;
  background: white;
  color: #1a1a2e;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.quality-filter:hover:not(:disabled) { background: #f2f6fc; }
.quality-filter.is-active {
  border-color: #1e3a5f;
  background: #1e3a5f;
  color: white;
}
.quality-filter:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.qf-count { font-weight: 600; }

#results-body.qf-red tr[data-overall="orange"],
#results-body.qf-red tr[data-overall="green"],
#results-body.qf-orange tr[data-overall="red"],
#results-body.qf-orange tr[data-overall="green"],
#results-body.qf-green tr[data-overall="red"],
#results-body.qf-green tr[data-overall="orange"] { display: none; }

.harvest-date {
  font-size: 0.8rem;
  opacity: 0.85;
}
.harvest-date--stale {
  color: #e08a00;
  font-weight: 600;
  opacity: 1;
}

.refresh-bar {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e3e3e3;
}
.refresh-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #1e3a5f;
  background: #fff;
  color: #1e3a5f;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem 0.45rem;
  border-radius: 6px;
}
.refresh-btn:hover { background: #1e3a5f; color: #fff; }
.refresh-btn:disabled { cursor: default; }
.refresh-btn--error { border-color: #c0392b; color: #c0392b; }

/* Barra de progreso indeterminada: no sabemos cuánto tarda el refresco, así
   que un segmento corto barre de un lado a otro en bucle, en vez de un
   porcentaje real. Sustituye al icono girando. */
.refresh-btn__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  overflow: hidden;
  display: none;
}
.refresh-btn--loading .refresh-btn__progress { display: block; }
.refresh-btn__progress-fill {
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: #1e3a5f;
  border-radius: 2px;
  animation: barrido-progreso 1.1s ease-in-out infinite;
}
@keyframes barrido-progreso {
  0%   { left: -40%; }
  100% { left: 100%; }
}

.actions-cell {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  white-space: nowrap;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: none;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: white;
  color: #555;
  text-decoration: none;
}
.icon-btn:hover {
  background: #1e3a5f;
  border-color: #1e3a5f;
  color: white;
}
.icon-btn--edit:hover {
  background: #b3781c;
  border-color: #b3781c;
}

.section-title {
  font-size: 1rem;
  color: #1e3a5f;
  margin: 1.6rem 0 0.8rem;
}
.section-title:first-of-type { margin-top: 0; }

.subsection-title {
  font-size: 0.85rem;
  color: #555;
  margin: 1rem 0 0.5rem;
}

.section-hint {
  font-size: 0.8rem;
  color: #666;
  margin: -0.4rem 0 0.8rem;
  max-width: 62ch;
}

.area-wrapper {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 0.75rem;
}

.area-chart {
  width: 100%;
  height: auto;
  display: block;
}

.area-chart .area-band { opacity: 0.85; }
.area-chart .area-gridline { stroke: #e3e9f0; stroke-width: 1; }
.area-chart .area-axis-label { font-size: 10px; fill: #666; }
.area-chart .area-hit {
  fill: transparent;
  cursor: pointer;
}
.area-chart .area-hit:hover { fill: rgba(30, 58, 95, 0.08); }

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.zoom-controls button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid #dfe6f0;
  background: #f4f7fb;
  color: #1e3a5f;
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}
.zoom-controls button:hover { background: #e3e9f0; }
.zoom-controls .text-btn {
  width: auto;
  padding: 0 0.6rem;
  font-size: 0.78rem;
}
#zoom-level {
  min-width: 3.4em;
  text-align: center;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: #5b6b85;
}

.visible-count {
  font-size: 0.78rem;
  color: #5b6b85;
  font-variant-numeric: tabular-nums;
}
.visible-count strong { color: #1e3a5f; }

.bubble-chart {
  width: 100%;
  height: auto;
  display: block;
  cursor: grab;
  touch-action: none;
  background: #f4f7fb;
  border-radius: 8px;
}
.bubble-chart.panning { cursor: grabbing; }
.bubble-chart .lod-hidden { display: none; }
.bubble-chart circle.bubble-fill {
  stroke: #f4f7fb;
  vector-effect: non-scaling-stroke;
  stroke-width: 1.5px;
  cursor: grab;
}
.bubble-chart circle.bubble-fill:hover { stroke: #1e3a5f; stroke-width: 2px; }
.bubble-chart circle.bubble-fill:active { cursor: grabbing; }

.bubble-chart text {
  fill: #000;
  font-family: inherit;
  pointer-events: none;
}

.donut-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.donut-block {
  flex: 1 1 320px;
  min-width: 280px;
}

.donut-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 0.75rem;
  flex-wrap: wrap;
}

.donut-chart {
  width: 160px;
  height: 160px;
  flex: none;
}

.donut-chart path { stroke: white; stroke-width: 1px; }

.donut-legend {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  max-height: 200px;
  overflow-y: auto;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.donut-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

.donut-legend-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-legend-count {
  flex: none;
  color: #666;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
  font-size: 0.85rem;
  color: #444;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }

.quality-chart {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.chart-row {
  display: block;
  background: white;
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  text-decoration: none;
  color: inherit;
}
a.chart-row { cursor: pointer; }
a.chart-row:hover { box-shadow: 0 2px 8px rgba(30, 58, 95, 0.25); }

.chart-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.chart-row-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-row-total {
  flex: none;
  font-size: 0.8rem;
  color: #666;
}

.chart-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: #eee;
}

.chart-bar-segment {
  height: 100%;
}

.chart-bar-empty {
  width: 100%;
  font-size: 0.75rem;
  color: #888;
  line-height: 14px;
  padding-left: 0.5rem;
  font-style: italic;
}

.graph-hint {
  font-size: 0.85rem;
  color: #555;
  background: white;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin: 0 0 1.2rem;
  line-height: 1.5;
}

.graph-wrapper {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
}

.materias-graph {
  width: 100%;
  height: auto;
  display: block;
  cursor: default;
}

.materias-graph .edge {
  stroke: #1e3a5f;
  transition: opacity 0.15s;
}

.materias-graph .node circle {
  fill: #3d6690;
  stroke: white;
  stroke-width: 1.5px;
  cursor: pointer;
  transition: opacity 0.15s, fill 0.15s;
}

.materias-graph .node text {
  font-size: 10px;
  fill: #1a1a2e;
  pointer-events: none;
  transition: opacity 0.15s;
}

.materias-graph.has-active .node:not(.active):not(.neighbor) circle,
.materias-graph.has-active .node:not(.active):not(.neighbor) text {
  opacity: 0.15;
}
.materias-graph.has-active .edge:not(.active) {
  opacity: 0.04 !important;
}
.materias-graph .node.active circle {
  fill: #b3781c;
}
.materias-graph .node.neighbor circle {
  fill: #1e3a5f;
}
.materias-graph .edge.active {
  stroke: #b3781c;
  opacity: 0.9 !important;
}
