* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  color: #333;
  padding: 20px;
}

/* Login */
#loginOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.login-box {
  background: #fff; padding: 40px; border-radius: 10px; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3); max-width: 360px; width: 90%;
}
.login-box h1 { font-size: 22px; margin-bottom: 15px; color: #1a1a2e; }
.login-box p { font-size: 14px; margin-bottom: 12px; color: #555; }
.login-box input {
  width: 100%; padding: 10px; font-size: 16px; text-align: center;
  border: 2px solid #4a6fa5; border-radius: 6px; margin-bottom: 12px; outline: none;
}
.login-box button {
  background: #1a1a2e; color: #fff; border: none; padding: 10px 30px;
  font-size: 16px; border-radius: 6px; cursor: pointer;
}
.login-box button:hover { background: #16213e; }
.login-error { color: #c0392b; font-size: 13px; margin-top: 8px; }
.header-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.header-bar h1 { margin: 0; flex: 1; }
.usuario-label { font-size: 12px; color: #4a6fa5; font-weight: 600; }
.btn-logout {
  background: #c0392b; color: #fff; border: none; padding: 5px 14px;
  font-size: 12px; border-radius: 4px; cursor: pointer;
}
.btn-logout:hover { background: #a93226; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  padding: 30px;
}

h1 {
  color: #1a1a2e;
  margin-bottom: 25px;
  text-align: center;
  font-size: 28px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
}

.form label {
  font-weight: 600;
  font-size: 14px;
  color: #555;
}

.form input {
  padding: 10px 14px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.form input:focus {
  outline: none;
  border-color: #4a6fa5;
}

.form-divider {
  border: none;
  border-top: 1px solid #ddd;
  margin: 5px 0;
}

.form .subtitle {
  font-weight: 700;
  font-size: 14px;
  color: #1a1a2e;
  margin-top: 5px;
}

.form-row {
  display: flex;
  gap: 15px;
}

.form-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 13px;
}

.form button {
  padding: 12px 24px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 5px;
}

.form button:hover {
  background: #16213e;
}

/* Tabs */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.tabs.hidden {
  display: none;
}

.tab {
  padding: 10px 24px;
  background: #e0e0e0;
  border: none;
  border-radius: 6px 6px 0 0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  color: #666;
}

.tab:hover {
  background: #d0d0d0;
}

.tab.active {
  background: #1a1a2e;
  color: #fff;
}

/* Resultado header */

.resultado-header {
  margin-bottom: 20px;
  padding: 15px;
  background: #1a1a2e;
  color: #fff;
  border-radius: 8px;
}

.resultado-header h2 {
  margin-bottom: 5px;
  font-size: 22px;
}

.resultado-header p {
  font-size: 14px;
  opacity: 0.9;
  line-height: 1.6;
}

/* Tables */

.tabla-section {
  margin-bottom: 25px;
}

.tabla-section h3 {
  color: #1a1a2e;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 2px solid #e0e0e0;
  font-size: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 5px;
}

th {
  background: #1a1a2e;
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-size: 14px;
}

td {
  padding: 8px 14px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

tr:hover {
  background: #f5f7fa;
}

.valor {
  font-weight: 700;
  font-size: 18px;
  color: #1a1a2e;
  text-align: center;
}

.desc {
  color: #888;
  font-size: 13px;
}

.extras {
  display: flex;
  gap: 30px;
  margin-bottom: 25px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
}

.extra-item {
  font-size: 15px;
}

.vacio {
  color: #aaa;
  font-style: italic;
}

.edades-section {
  margin-top: 10px;
}

.edades-section h3 {
  color: #1a1a2e;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 2px solid #e0e0e0;
  font-size: 18px;
}

.tabla-edades th {
  background: #4a6fa5;
}

.tabla-edades td:last-child {
  text-align: center;
  font-weight: 600;
}

/* Destino tables */

.tabla-scroll {
  margin-bottom: 10px;
}

.tabla-destino {
  font-size: 13px;
  min-width: 100%;
  border-collapse: collapse;
}

.tabla-destino td {
  padding: 5px 8px;
  border: 1px solid #ddd;
  text-align: center;
  white-space: nowrap;
  font-size: 12px;
}

.tabla-destino td.row-name {
  background: #1a1a2e;
  color: #fff;
  font-weight: 600;
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 140px;
  white-space: nowrap;
  border: 1px solid #2a2a4e;
}

.tabla-destino td.col27 {
  background: #e8ecf1;
  font-weight: 600;
  color: #1a1a2e;
  position: sticky;
  right: 0;
  z-index: 1;
  min-width: 100px;
  white-space: nowrap;
  border: 1px solid #ddd;
}

/* Row group colors */
.row-anio td:not(.row-name):not(.col27) { background: #e3f2fd; }
.row-edad  td:not(.row-name):not(.col27) { background: #e8f5e9; }
.row-nombre td:not(.row-name):not(.col27) { background: #fff8e1; }
.row-paterno td:not(.row-name):not(.col27) { background: #fce4ec; }
.row-materno td:not(.row-name):not(.col27) { background: #f3e5f5; }
.row-alma td:not(.row-name):not(.col27) { background: #fffde7; }
.row-personal td:not(.row-name):not(.col27) { background: #e0f2f1; }
.row-eap td:not(.row-name):not(.col27) { background: #f5f5f5; }

.legend-item {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 3px 3px 0;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  color: #1a1a2e;
  border: 1px solid #ccc;
}

svg.grafo-svg { max-width: 100%; height: auto; }

.tabla-destino tr:hover td.row-name {
  background: #16213e;
}

.tabla-destino tr:hover td.col27 {
  background: #dce0e6;
}

.tabla-destino tr:hover td:not(.row-name):not(.col27) {
  filter: brightness(0.93);
}

/* Month calendar cards */

.mes-card {
  display: inline-block;
  width: 280px;
  margin: 8px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  vertical-align: top;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.mes-card h4 {
  color: #1a1a2e;
  font-size: 14px;
  margin-bottom: 8px;
  text-align: center;
}

.tabla-semanas {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.tabla-semanas th {
  background: #4a6fa5;
  color: #fff;
  padding: 6px 8px;
  font-size: 12px;
  text-align: center;
}

.tabla-semanas td {
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
  text-align: center;
  font-size: 12px;
}

.tabla-semanas td.valor {
  font-weight: 700;
  font-size: 14px;
  color: #1a1a2e;
}

.tabla-semanas tr:hover {
  background: #f5f7fa;
}

/* Daily calendar grid */

.semana-header {
  font-size: 12px;
  padding: 6px 4px 4px;
  color: #1a1a2e;
  border-bottom: 1px solid #eee;
  margin-top: 6px;
}

.semana-header .valor {
  font-weight: 700;
  font-size: 14px;
  color: #4a6fa5;
}

.day-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px 2px;
}

.day-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 30px;
  padding: 2px 0;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #e8e8e8;
}

.day-num {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.3;
}

.day-val {
  font-size: 11px;
  font-weight: 600;
  color: #4a6fa5;
  line-height: 1.2;
}

.day-val.master {
  color: #c0392b;
}

/* Resumen destino */

.resumen-destino .tabla-section {
  margin-top: 10px;
}

.resumen-destino table {
  max-width: 600px;
}

.resumen-destino td.valor {
  font-size: 15px;
}

/* Imprimir */
#printArea { display: none; }

@media print {
  #loginOverlay { display: none !important; }
  body > *:not(#printArea):not(#printFooter) { display: none !important; }
  #printArea { display: block !important; position: static; margin: 0 auto; max-width: 1000px; padding-bottom: 40px; }
  #printArea, #printArea * { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }
  #printArea .tabla-destino { font-size: 9px; }
  #printArea .tabla-section table { font-size: 12px; }
  #printArea h2, #printArea h3 { page-break-after: avoid; }
  #printArea .tabla-edades, #printArea svg { page-break-inside: avoid; }
  #printArea .print-section { page-break-before: always; }
  #printArea .print-section:first-of-type { page-break-before: avoid; }
  #printFooter {
    display: block !important; position: fixed; bottom: 0; left: 0; width: 100%;
    text-align: center; font-size: 8px; color: #999;
    border-top: 1px solid #ccc; padding: 3px 0;
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
}
