@page {
  size: A4 landscape;
  margin: 8mm 10mm;
}

* {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.page {
  width: 100%;
  color: #1a202c;
  max-width: 1200px;
  page-break-after: always;
  break-after: page;
  page-break-inside: avoid;
  break-inside: avoid;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 6mm 8mm;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  margin: 1.5rem auto 2.5rem;
}

.page:last-child {
  page-break-after: avoid;
  break-after: avoid;
  margin-bottom: 0;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 3px solid #1c64ba;
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  color: #0f1941;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header .subtitle {
  font-size: 13px;
  font-weight: 600;
  color: #1c64ba;
  background: #eef4fc;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.25;
  min-width: 600px;
}

thead th {
  background-color: #0f1941;
  color: #ffffff;
  font-weight: 600;
  text-align: left;
  padding: 5px 8px;
  text-transform: uppercase;
  font-size: 9.5px;
  letter-spacing: 0.5px;
}

thead th:first-child { border-top-left-radius: 4px; }
thead th:last-child { border-top-right-radius: 4px; }

tbody {
  border-bottom: 2px solid #cbd5e1;
}

tbody:last-child {
  border-bottom: none;
}

tbody tr {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

tbody.semana-1 tr { background-color: #f4f8fe; }
tbody.semana-1 tr:nth-child(even) { background-color: #e8f1fc; }

tbody.semana-2 tr { background-color: #f2faf5; }
tbody.semana-2 tr:nth-child(even) { background-color: #e4f5eb; }

tbody.semana-3 tr { background-color: #fefdf2; }
tbody.semana-3 tr:nth-child(even) { background-color: #fbf5de; }

tbody.semana-4 tr { background-color: #f9f5ff; }
tbody.semana-4 tr:nth-child(even) { background-color: #f0e6fc; }

tbody.semana-5 tr { background-color: #fff6f4; }
tbody.semana-5 tr:nth-child(even) { background-color: #fde8e5; }

tbody td {
  padding: 4px 8px;
  vertical-align: middle;
}

.col-semana {
  font-weight: 700;
  color: #334155;
  width: 11%;
  white-space: nowrap;
  border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.col-fecha {
  font-weight: 600;
  color: #0f1941;
  width: 11%;
  white-space: nowrap;
}

.col-categoria {
  font-weight: 600;
  width: 16%;
}

.col-partido {
  font-weight: 500;
  width: 28%;
}

.col-sede {
  width: 12%;
  text-align: center;
}

.col-pabellon {
  width: 22%;
  color: #475569;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.badge-casa {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-fuera {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-nacional {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
}

.badge-nacional-masc {
  background-color: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.badge-nacional-fem {
  background-color: #fce7f3;
  color: #9d174d;
  border: 1px solid #fbcfe8;
}

.sin-partidos {
  color: #94a3b8;
  font-style: italic;
}

.crest-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--yellow), #f59e0b);
  color: var(--ink);
  font-weight: 900;
  font-size: .8rem;
  line-height: 1.1;
  text-align: center;
  border: 2px solid var(--red);
}

.calendar-toolbar {
  max-width: 1200px;
  margin: 2rem auto 0.5rem;
  padding: 0 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
}

.calendar-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.calendar-tabs {
  display: inline-flex;
  background: #e2e8f0;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-top: 0.6rem;
  width: fit-content;
}

.calendar-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--muted);
  transition: all 0.2s ease;
}

.calendar-tab-btn:hover { color: var(--ink); }
.calendar-tab-btn.active { background: #ffffff; color: var(--ink); box-shadow: 0 2px 4px rgba(0,0,0,0.08); }

.calendar-toolbar .actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-bar {
  max-width: 1200px;
  margin: 0.5rem auto 1.5rem;
  padding: 0 1.25rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar input,
.filter-bar select {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--ink);
}

.filter-bar select {
  cursor: pointer;
  font-weight: 500;
  min-width: 170px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235e687a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

.filter-bar select::-ms-expand {
  display: none;
}

.multiselect-wrapper {
  position: relative;
  min-width: 240px;
}

.multiselect-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 500;
}

.multiselect-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 250px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
}

.multiselect-panel.show {
  display: flex;
}

.multiselect-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  user-select: none;
}

.multiselect-option:hover {
  background-color: #f1f5f9;
}

.multiselect-actions {
  display: flex;
  justify-content: space-between;
  padding-bottom: 0.35rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.multiselect-action-btn {
  background: none;
  border: none;
  color: var(--red);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.78rem;
}

@media (max-width: 768px) {
  .page {
    padding: 4mm 4mm;
  }
  .header h1 {
    font-size: 14px;
  }
  .calendar-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .multiselect-wrapper {
    min-width: unset;
    width: 100%;
  }
  .filter-bar input {
    width: 100%;
    box-sizing: border-box;
  }
}

@media print {
  header, .contact, .calendar-toolbar, .filter-bar { display: none !important; }
  body { background: transparent; }
  .page {
    box-shadow: none;
    margin: 0;
    padding: 4mm 6mm;
    border-radius: 0;
    page-break-after: always;
    break-after: page;
  }
}
