/* Paleta tomada del prototipo (TOKENS en sistema-gestion-personal.jsx)
   para que la versión de servidor se vea como la que ya está en uso. */
:root {
  --bg: #12161C;
  --surface: #1A2029;
  --surface-alt: #212A35;
  --border: #2B3440;
  --text: #E8EDF2;
  --muted: #8B96A5;
  --amber: #F2A93B;
  --teal: #2FB8A6;
  --red: #E2564D;
  --blue: #4C8DFF;
}

* { box-sizing: border-box; }

/* El atributo `hidden` oculta poniendo display:none, pero cualquier regla
   propia con `display` (como .modal o .login-wrap, que usan grid) le gana en
   especificidad y el elemento se queda visible. Esta regla le devuelve la
   última palabra a `hidden`. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--red); font-size: 13px; }
.ok { color: var(--teal); }

/* ---------- Acceso ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-card h1 { margin-bottom: 2px; }
.login-card p { margin: 0 0 18px; }

/* ---------- Estructura ---------- */
.barra {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.barra-izq { display: flex; flex-direction: column; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs button {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
  font-family: inherit;
}
.tabs button:hover { background: var(--surface-alt); color: var(--text); }
.tabs button.activo { background: var(--surface-alt); color: var(--text); font-weight: 600; }

main { padding: 22px; max-width: 1180px; margin: 0 auto; }

/* ---------- Formularios ---------- */
label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
}
textarea { min-height: 76px; resize: vertical; }
input[type="checkbox"] { width: auto; margin: 0 8px 0 0; }
.fila-check { display: flex; align-items: center; color: var(--text); font-size: 14px; }

.btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.peligro { background: var(--red); border-color: var(--red); color: #fff; }
.btn.exito { background: var(--teal); border-color: var(--teal); color: #06231f; font-weight: 600; }
.btn.ghost { background: none; }
.btn.chico { padding: 6px 11px; font-size: 13px; }

.acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Tarjetas y rejillas ---------- */
.rejilla {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.tarjeta .cifra { font-size: 28px; font-weight: 600; margin-top: 4px; }
.tarjeta.clic { cursor: pointer; }
.tarjeta.clic:hover { border-color: var(--muted); }
.tarjeta.aviso { border-color: var(--amber); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

/* ---------- Tablas ---------- */
.tabla-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--surface-alt); }
td.envuelve, th.envuelve { white-space: normal; min-width: 200px; }

/* ---------- Etiquetas de estado ---------- */
.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid currentColor;
}
.pill.activo { color: var(--teal); }
.pill.baja { color: var(--red); }
.pill.pendiente { color: var(--amber); }
.pill.aprobada { color: var(--teal); }
.pill.rechazada { color: var(--red); }
.pill.cancelada { color: var(--muted); }
.pill.nuevo { color: var(--blue); }
.pill.leido { color: var(--muted); }
.pill.archivado { color: var(--muted); }

/* ---------- Calendario ---------- */
.cal-cabeza {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.cal-rejilla {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-dia {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 86px;
  padding: 6px 7px;
  font-size: 12px;
}
.cal-dia.vacio { background: none; border-color: transparent; }
.cal-dia .num { color: var(--muted); font-size: 12px; }
.cal-dia.hoy { border-color: var(--blue); }
.cal-nombre-dia {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding-bottom: 4px;
}
.marca {
  display: block;
  margin-top: 3px;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.marca.verde { background: rgba(47,184,166,.18); color: var(--teal); }
.marca.azul  { background: rgba(76,141,255,.18); color: var(--blue); }
.marca.gris  { background: rgba(139,150,165,.18); color: var(--muted); }
.marca.ambar { background: rgba(242,169,59,.18); color: var(--amber); }

/* Calendario de selección de días */
.sel-rejilla { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.sel-dia {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 0;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}
.sel-dia:hover { border-color: var(--blue); }
.sel-dia.elegido { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.sel-dia.deshabilitado { opacity: .3; cursor: not-allowed; }
.sel-dia.vacio { background: none; border-color: transparent; cursor: default; }

/* ---------- Score ---------- */
.meses { display: flex; gap: 5px; flex-wrap: wrap; }
.mes-chip {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
  text-align: center;
  min-width: 56px;
  background: var(--bg);
}
.mes-chip .val { font-size: 15px; font-weight: 600; }
.mes-chip.sin-datos { color: var(--muted); }
.mes-chip.bien .val { color: var(--teal); }
.mes-chip.medio .val { color: var(--amber); }
.mes-chip.mal .val { color: var(--red); }

/* ---------- Aviso / modal / toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 10px;
  z-index: 60;
  max-width: 90vw;
}
.toast.malo { border-color: var(--red); color: var(--red); }
.toast.bueno { border-color: var(--teal); color: var(--teal); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
  overflow-y: auto;
}
.modal-caja {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-cabeza {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.modal-cabeza h2 { margin: 0; }

.vacio-msg { color: var(--muted); padding: 20px 0; text-align: center; }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filtros label { margin-bottom: 0; min-width: 150px; }

.dato { margin-bottom: 10px; }
.dato .etq { color: var(--muted); font-size: 12px; }
.dato .val { font-size: 14px; }
.dos-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 16px; }

@media (max-width: 620px) {
  main { padding: 14px; }
  .cal-dia { min-height: 62px; }
}

/* AVATAR */
.avatar {
  border-radius: 50%;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
}
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar.con-foto {
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.avatar.con-foto:hover {
  transform: scale(1.12);
  border-color: var(--blue);
  box-shadow: 0 4px 12px rgba(76, 141, 255, 0.35);
}

/* Visor de foto en grande (Lightbox) */
.modal-foto-wrap {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 16, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  cursor: pointer;
}
.modal-foto-caja {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  cursor: default;
  animation: modalFotoFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalFotoFadeIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
.modal-foto-cerrar {
  position: absolute;
  top: -14px;
  right: -14px;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: bold;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.modal-foto-cerrar:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  transform: scale(1.1);
}
.img-foto-grande {
  max-width: 82vw;
  max-height: 72vh;
  min-width: 200px;
  min-height: 200px;
  border-radius: 12px;
  object-fit: contain;
  background: #090c10;
  display: block;
}
.modal-foto-nombre {
  font-size: 18px;
  font-weight: 600;
  margin-top: 14px;
  text-align: center;
  color: var(--text);
}
.modal-foto-sub {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 3px;
}

