:root {
  /* Fondo gris oscuro, sin saturación */
  --bg-body: #1a1a1a;
  --bg-table: #181818;
  --row-alt-1: #181818;
  --row-alt-2: #101010e0;
  --row-hover: #1a1a1a;
  --header-bg: #181818;

  --border-subtle: #2a2a2a;
  --text-main: #e5e7eb;
  --text-soft: #9ca3af;

  /* Fondo de celda con alguna tensión (solo si se activa highlight) */
  --cell-tension-bg: #202020;
  --cell-tension-border: #3a3a3a;

  /* Colores para PARES de tritonos (máx 3 por fila, luego repite) */
  --tri-1: #ef4444;
  --tri-2: #f5e875ff;
  --tri-3: #f97316;

  /* Colores para PARES de b9 (máx 3 por fila, luego repite) */
  --b9-1: #80cf47;
  --b9-2: #64c8ff;
  --b9-3: #b464ff;

  /* Colores para botones (inputs) seleccionados */
  --bg-highlighted: #7aa2ff38;
  --border-highlighted: #7aa2ffa8;
  --color-highlighted: #ffffff; /*Color de texto*/

  /* Color rojo para los primeros dos inputs */
  --bg-highlighted-red: #c45646;
  --bg-hover-red: #c45646;
  --border-highlighted-red: #c45646;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px 20px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.container {
  margin: 0 auto;
  max-width: 1000px;
  padding: 10px 20px;
  box-sizing: border-box;
}

.page-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-inline: 2px;
  margin-bottom: 20px;
}

.logo {
  height: 38px;
  width: auto;
  display: block;
}

h1 {
  margin: 0 0 8px 0;
  font-size: 22px;
  letter-spacing: 0.02em;
  font-weight: 600;
  text-align: left;
  max-width: 60%;
}

.subtitle {
  margin: 0 0 20px 0;
  font-size: 13px;
  color: var(--text-soft);
  text-align: left;
  line-height: 1.5;
  max-width: 60%;
}

.controls-block {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  width: fit-content;
  gap: 8px;
  background: var(--bg-body);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
}

.controls-row-notes {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  gap: 8px;
  background: var(--bg-body);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
}

.control-group legend {
  position: static;
  font-weight: 600;
  font-size: 13px;
  color: #e5e7eb;
  padding: 0;
  margin: 0 0 8px 0;
}

.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.controls-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 14px;
  background: transparent;
  border: 2px solid #4a6fa5;
  border-radius: 20px;
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.controls-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 16px;
  background: transparent;
  border: 2px solid #4a6fa5;
  border-radius: 20px;
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.controls-row label:hover {
  background: #1a2a3a;
  border-color: #5a7fb5;
}

.controls-row input[type="radio"],
.controls-row input[type="checkbox"] {
  display: none;
}

.controls-row label:has(input[type="radio"]:checked),
.controls-row label:has(input[type="checkbox"]:checked) {
  background: var(--bg-highlighted);
  border-color: var(--border-highlighted);
  color: var(--color-highlighted);
}

.controls-row-notes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 14px;
  background: transparent;
  border: 2px solid #4a6fa5;
  border-radius: 20px;
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.controls-row-notes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 16px;
  background: transparent;
  border: 2px solid #4a6fa5;
  border-radius: 20px;
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.controls-row-notes label:hover {
  background: #1a2a3a;
  border-color: #5a7fb5;
}

.controls-row-notes input[type="radio"],
.controls-row-notes input[type="checkbox"] {
  display: none;
}

.controls-row-notes label:has(input[type="radio"]:checked),
.controls-row-notes label:has(input[type="checkbox"]:checked) {
  background: var(--bg-highlighted);
  border-color: var(--border-highlighted);
  color: var(--color-highlighted);
}

/*Color de input rojo no seleccionado*/
.controls-row label:has(input.red-highlight) {
  border-color: var(--bg-highlighted-red);
}

/*Color de input rojo hover*/
.controls-row label:has(input.red-highlight):hover {
  background: var(--bg-hover-red);
  border-color: var(--bg-highlighted-red);
}

/*Color de input rojo seleccionado*/
.controls-row label:has(input.red-highlight:checked) {
  background: var(--bg-highlighted-red);
  border-color: var(--bg-highlighted-red);
  color: var(--color-highlighted);
}

.controls-row-wrapper {
  display: flex;
  gap: 12px;
  width: 100%;
}

.controls-row-wrapper .controls-row {
  display: flex;
  flex: 1 1 auto;
  min-width: fit-content;
  justify-content: space-around;
  gap: 16px;
}

.controls-row-wrapper .controls-row label {
  white-space: nowrap;
  flex-shrink: 0;
}

.controls-row-wrapper .controls-row:last-child {
  flex: 1 1 auto;
}

/*Clases de los primeros dos control rows, los rojos que estan juntos*/
.controls-row-wrapper-red {
  display: flex;
  gap: 12px;
  width: 100%;
}

.controls-row-wrapper-red .controls-row {
  display: flex;
  flex: 1 1 auto;
  min-width: fit-content;
  flex-wrap: nowrap;
  justify-content: space-around;
  gap: 16px;
}

.controls-row-wrapper-red .controls-row label {
  white-space: nowrap;
  flex-shrink: 0;
}

.controls-row-wrapper-red .controls-row:first-child .control-buttons,
.controls-row-wrapper-red .controls-row:first-child {
  gap: 8px;
}

.controls-row-wrapper-red .controls-row:last-child {
  flex: 0 0 auto;
}

/*Clases de Ordenar por*/
.controls-row-orderby {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-body);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  max-width: 100%;
  width: fit-content;
  margin: 0 auto;
}

.controls-row-orderby legend {
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #e5e7eb;
}

.controls-row-orderby label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 16px;
  background: transparent;
  border: 2px solid #4a6fa5;
  border-radius: 20px;
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.controls-row-orderby label:hover {
  background: #1a2a3a;
  border-color: #5a7fb5;
}

.controls-row-orderby input[type="radio"],
.controls-row-orderby input[type="checkbox"] {
  display: none;
}

.controls-row-orderby label:has(input[type="radio"]:checked),
.controls-row-orderby label:has(input[type="checkbox"]:checked) {
  background: var(--bg-highlighted);
  border-color: var(--border-highlighted);
  color: var(--color-highlighted);
}

.legend {
  margin: 0 0 16px;
  font-size: 11px;
  font-weight: bold;
  color: var(--text-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 12px;
  max-width: 100%;
  background: var(--bg-body);
  border-radius: 8px;
  border: 1px solid #2a2a2a;
}

.dot-swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}
.dot-swatch-tri1 {
  background: var(--tri-1);
}
.dot-swatch-b9_1 {
  background: var(--b9-1);
}

table {
  border-collapse: collapse;
  background: var(--bg-table);
  border: 1px solid var(--border-subtle);
  width: 100%;
  margin: 16px auto;
  overflow-x: auto;
  table-layout: fixed;
}

thead th {
  background: var(--header-bg);
  padding: 6px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-soft);
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

thead th:first-child {
  text-align: left;
  width: 180px;
}

tbody td {
  padding: 4px 6px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  text-align: center;
}

tbody tr:nth-child(odd) {
  background: var(--row-alt-1);
}
tbody tr:nth-child(even) {
  background: var(--row-alt-2);
}

tbody tr:hover {
  background: var(--row-hover);
}

tbody td:first-child {
  max-width: 180px;
  text-overflow: ellipsis;
  overflow: hidden;
  font-size: 11px;
  color: var(--text-soft);
  text-align: left;
}

.section-row td {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-subtle);
  padding-top: 8px;
  padding-bottom: 5px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-soft);
}
.section-row td:first-child {
  font-weight: 600;
  color: var(--text-main);
}

.note-cell {
  text-align: center;
  min-width: 44px;
  width: auto;
}

.note-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.note-main {
  line-height: 1.1;
}

.note-empty {
  color: #4b4b4b;
  font-size: 11px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: false;
  display: none; /* por defecto no se ven */
}

.dot-tri {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 7px solid;
  display: none; /* por defecto no se ven */
}

/* Dots de tritono (se activan con clase en body) */
.dot-tri-1 {
  border-bottom-color: var(--tri-1);
}
.dot-tri-2 {
  border-bottom-color: var(--tri-2);
}
.dot-tri-3 {
  border-bottom-color: var(--tri-3);
}

body.show-tri-dots .dot-tri-1,
body.show-tri-dots .dot-tri-2,
body.show-tri-dots .dot-tri-3 {
  display: inline-block;
}

/* Dots de b9 (se activan con clase en body) */
.dot-b9-1 {
  background: var(--b9-1);
}
.dot-b9-2 {
  background: var(--b9-2);
}
.dot-b9-3 {
  background: var(--b9-3);
}

body.show-b9-dots .dot-b9-1,
body.show-b9-dots .dot-b9-2,
body.show-b9-dots .dot-b9-3 {
  display: inline-block;
}

/* Fondo de celdas con tensión: solo si body tiene show-highlight */
.cell-has-tension {
  background: transparent;
  border: 1px solid transparent;
}

body.show-highlight .cell-has-tension {
  background: var(--cell-tension-bg);
  border-color: var(--cell-tension-border);
}

/* Borde blanco para notas marcadas por los nuevos checkboxes */
.cell-note-marked {
  outline: 1px solid #f9fafb;
  outline-offset: -1px;
}

.meta {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-soft);
  padding: 8px 12px;
  background: var(--bg-body);
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  max-width: 100%;
}
@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  body > * {
    max-width: 100%;
  }

  table {
    font-size: 11px;
  }

  .controls-block {
    gap: 12px;
  }

  .controls-row {
    padding: 12px;
  }

  .controls-row label {
    padding: 6px 12px;
    font-size: 12px;
  }

  .logo {
    width: 60px;
    top: 16px;
    right: 16px;
  }

  .controls-row-wrapper,
  .controls-row-wrapper-red {
    flex-direction: column;
    align-items: stretch;
  }

  .controls-row-wrapper-red {
    width: 100%;
  }

  .controls-row-wrapper .controls-row,
  .controls-row-wrapper-red .controls-row {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  h1 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 12px;
  }

  .controls-row-wrapper,
  .controls-row-wrapper-red {
    flex-direction: column;
    align-items: stretch;
  }

  .controls-row-wrapper .controls-row,
  .controls-row-wrapper-red .controls-row {
    width: 100%;
    justify-content: center;
  }

  .controls-row legend {
    font-size: 12px;
  }

  .controls-row label {
    font-size: 11px;
    padding: 5px 10px;
  }
}
