* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #f4f6f9;
  color: #1c2733;
  font-size: 14px;
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: #1f4e79;
  color: #fff;
}
header h1 { font-size: 18px; margin: 0; }
.monthnav { display: flex; align-items: center; gap: 8px; }
#monthLabel {
  min-width: 170px;
  text-align: center;
  font-weight: 600;
  font-size: 16px;
  text-transform: capitalize;
}
.actions { margin-left: auto; display: flex; gap: 8px; }

button {
  font: inherit;
  padding: 5px 12px;
  border: 1px solid #c6d2e0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
button:hover { background: #eef3f9; }
header button { border-color: #3a6ea5; }
.toggle.on { background: #ffd54d; border-color: #d4a800; font-weight: 600; }

#swapHint {
  background: #fff3c4;
  border-bottom: 1px solid #e0c341;
  padding: 6px 18px;
  font-weight: 500;
}

.layout {
  display: flex;
  gap: 16px;
  padding: 16px 18px;
  align-items: flex-start;
}
.calendar { flex: 1; min-width: 0; }

/* ---- rejilla del calendario ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.dow {
  text-align: center;
  font-weight: 600;
  color: #4a5b6e;
  padding: 4px 0;
  text-transform: capitalize;
}
.day {
  background: #fff;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  min-height: 96px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.day.out { opacity: 0.38; }
.day.weekend { background: #eef0f4; }
.day.today { border: 2px solid #1f4e79; }
.day.holiday { background: #fbe4e6; }
.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
}
.day-head .cycle {
  font-size: 11px;
  color: #fff;
  background: #7030a0;
  border-radius: 4px;
  padding: 0 5px;
}
.festivo-name {
  color: #a02030;
  font-weight: 600;
  font-size: 12px;
  margin-top: auto;
}

/* ---- chips de turno ---- */
.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  border-radius: 6px;
  padding: 3px 7px;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}
.chip.manana { background: #fff3c4; border-color: #e0c341; }
.chip.tarde { background: #d6e4f0; border-color: #7ba2cc; }
.chip:hover { filter: brightness(0.95); }
.chip .lbl {
  font-weight: 700;
  font-size: 11px;
  color: #55503a;
}
.chip.tarde .lbl { color: #2d4a66; }
.chip .name { flex: 1; }
.chip .name.empty { color: #98a4b3; }
.chip.selected { outline: 3px solid #ff9800; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #c00000;
  display: inline-block;
  flex: none;
}
.pencil { color: #7030a0; font-size: 12px; }
.chip.conflict {
  background: #fbe4e6;
  border-color: #c00000;
  color: #a02030;
}
.chip.conflict .name { text-decoration: line-through; }
.vacas {
  font-size: 11px;
  color: #b06000;
  background: #fff3e0;
  border: 1px solid #f0c380;
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---- barra lateral ---- */
.sidebar { width: 320px; flex: none; display: flex; flex-direction: column; gap: 12px; }
.panel {
  background: #fff;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  padding: 10px 12px;
}
.panel h2 { font-size: 14px; margin: 0 0 8px; color: #1f4e79; }
.muted { color: #71808f; font-size: 12px; }
table.eq { width: 100%; border-collapse: collapse; margin-top: 4px; }
table.eq th, table.eq td {
  border: 1px solid #e2e8f0;
  padding: 3px 6px;
  text-align: center;
}
table.eq th { background: #eef3f9; font-weight: 600; }
table.eq td:first-child, table.eq th:first-child { text-align: left; }
table.eq .max { background: #fde8c8; }
.legend div { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.chip.demo { display: inline-flex; padding: 1px 8px; cursor: default; }
.swatch {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  display: inline-block;
}
.swatch.holiday { background: #fbe4e6; }
.swatch.weekend { background: #eef0f4; }

/* ---- popover de edicion ---- */
.popover {
  position: absolute;
  z-index: 50;
  background: #fff;
  border: 1px solid #b8c4d2;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(20, 40, 70, 0.25);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 170px;
}
.popover .title { font-weight: 600; font-size: 12px; color: #4a5b6e; padding: 2px 4px; }
.popover button { text-align: left; border: none; padding: 5px 8px; }
.popover button:hover { background: #e8f0fa; }
.popover button.current { font-weight: 700; background: #eef3f9; }
.popover hr { border: none; border-top: 1px solid #e2e8f0; margin: 3px 0; }

/* ---- dialogos ---- */
dialog {
  border: 1px solid #b8c4d2;
  border-radius: 10px;
  padding: 18px;
  width: min(480px, 92vw);
}
dialog::backdrop { background: rgba(15, 30, 50, 0.4); }
dialog h2 { margin-top: 0; color: #1f4e79; }
dialog label { display: block; margin: 10px 0; font-weight: 500; }
dialog input[type="date"], dialog input[type="text"], dialog textarea {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid #c6d2e0;
  border-radius: 6px;
  margin-top: 4px;
}
dialog textarea { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
#festivoList { list-style: none; padding: 0; max-height: 200px; overflow-y: auto; }
#festivoList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  border-bottom: 1px solid #eef1f5;
}
#festivoList li .del { margin-left: auto; color: #c00000; border: none; padding: 1px 8px; }

#vacaList { list-style: none; padding: 0; max-height: 240px; overflow-y: auto; }
#vacaList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-bottom: 1px solid #eef1f5;
}
.pill {
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 8px;
  flex: none;
}
.pill.pendiente { background: #fff3c4; color: #8a6d00; }
.pill.aprobada { background: #d9f2d9; color: #1e7a1e; }
.pill.rechazada { background: #fbe4e6; color: #a02030; }
.vac-actions { margin-left: auto; display: flex; gap: 3px; }
.vac-actions button { border: none; padding: 2px 6px; }

/* ---- autenticacion ---- */
#authView {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #1f4e79;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px 26px;
  width: min(360px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.auth-card h1 { font-size: 20px; margin: 0 0 6px; color: #1f4e79; text-align: center; }
.auth-card form { display: flex; flex-direction: column; gap: 8px; }
.auth-card input, .auth-card select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid #c6d2e0;
  border-radius: 6px;
}
.auth-card button[type="submit"] {
  background: #1f4e79;
  color: #fff;
  border: none;
  padding: 9px;
  font-weight: 600;
}
.auth-card button[type="submit"]:hover { background: #2d6da8; }
.linklike {
  border: none;
  background: none;
  color: #1f4e79;
  text-decoration: underline;
  padding: 2px;
}
.linklike:hover { background: none; }
.auth-error {
  background: #fbe4e6;
  color: #a02030;
  border: 1px solid #eaa;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}

/* Controles solo-admin y estado sin sesion */
body:not(.is-admin) .admin-only { display: none; }
body:not(.logged) header, body:not(.logged) main { visibility: hidden; }
.userinfo { font-size: 13px; align-self: center; opacity: 0.9; }

/* ---- editor de semana base ---- */
#dlgBase { width: min(700px, 96vw); }
.base-head, .base-row {
  display: grid;
  grid-template-columns: 90px 1fr 1fr;
  gap: 6px;
  align-items: start;
}
.base-head { font-weight: 600; color: #1f4e79; margin-bottom: 4px; }
.base-row { border-top: 1px solid #eef1f5; padding: 5px 0; }
.base-day { font-weight: 600; text-transform: capitalize; padding-top: 6px; }
.base-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  border-radius: 6px;
  padding: 4px;
  min-height: 34px;
}
.base-cell.manana { background: #fff8dd; }
.base-cell.tarde { background: #e8f0f8; }
.base-chip {
  background: #fff;
  border: 1px solid #c6d2e0;
  border-radius: 10px;
  padding: 1px 2px 1px 8px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
}
.base-chip button { border: none; padding: 0 5px; color: #c00000; background: none; }
.base-cell select {
  font: inherit;
  font-size: 12px;
  border: 1px dashed #b8c4d2;
  border-radius: 6px;
  padding: 2px 4px;
  background: none;
  color: #71808f;
}

#workerList { list-style: none; padding: 0; max-height: 300px; overflow-y: auto; }
#workerList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-bottom: 1px solid #eef1f5;
  flex-wrap: wrap;
}
#workerList strong { flex: 1; min-width: 90px; }
#workerList input[type="date"] {
  font: inherit;
  font-size: 13px;
  padding: 2px 4px;
  border: 1px solid #c6d2e0;
  border-radius: 6px;
}

#userList { list-style: none; padding: 0; max-height: 260px; overflow-y: auto; }
#userList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-bottom: 1px solid #eef1f5;
  flex-wrap: wrap;
}
#userList strong { flex: 1; min-width: 90px; }
#userList select { font: inherit; padding: 3px 6px; border: 1px solid #c6d2e0; border-radius: 6px; }
#userList .del { margin-left: 4px; color: #c00000; border: none; padding: 1px 8px; }

/* ---- responsive ---- */
.wd-name { display: none; }

@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: stretch; }
  .sidebar { width: 100%; }
}

@media (max-width: 700px) {
  body { font-size: 15px; }
  header { gap: 10px; padding: 8px 10px; }
  header h1 { font-size: 16px; width: 100%; text-align: center; }
  .monthnav { width: 100%; justify-content: center; }
  .actions { margin-left: 0; width: 100%; justify-content: center; flex-wrap: wrap; }
  .layout { padding: 10px; }

  /* Calendario como lista vertical: un dia por fila */
  .grid { grid-template-columns: 1fr; gap: 8px; }
  .dow { display: none; }
  .day.out { display: none; }
  .day { min-height: 0; }
  .wd-name {
    display: inline;
    margin-right: 6px;
    text-transform: capitalize;
    color: #4a5b6e;
  }
  .chip { padding: 7px 10px; }
  .popover { min-width: 200px; }
  .popover button { padding: 9px 10px; }
}
