:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --success: #22c55e;
  --warning: #f59e0b;
  --page-pad: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: var(--page-pad);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: var(--text);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ===== Barra de autenticación ===== */
.auth-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  color: var(--muted);
}

.auth-bar span {
  flex: 1;
}

/* ===== Formulario de login ===== */
.modal-content--narrow {
  max-width: 380px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.login-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.88rem;
}

.card {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.card-full-width {
  width: calc(100vw - (var(--page-pad) * 2));
  margin-left: calc(50% - 50vw + var(--page-pad));
}

.month-grid-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.month-grid-header > div {
  padding: 8px;
  border-radius: 8px;
  background: rgba(51, 65, 85, 0.55);
  color: #cbd5e1;
  font-size: 0.8rem;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.month-day {
  min-height: 110px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.month-day-number {
  font-weight: 800;
  color: #e2e8f0;
}

.month-day-label {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.25;
}

.month-day--today {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.month-day--holiday {
  background: rgba(127, 29, 29, 0.25);
  border-color: rgba(248, 113, 113, 0.45);
}

.month-day--empty {
  background: transparent;
  border-style: dashed;
  opacity: 0.45;
}

h1, h2 {
  margin-top: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

input, select, button {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: var(--panel-soft);
  color: var(--text);
  padding: 10px 12px;
}

button {
  cursor: pointer;
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 600;
}

button.secondary {
  background: #334155;
}

button.warn {
  background: #b45309;
}

button.small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.inline-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.inline-check input {
  width: 18px;
  height: 18px;
}

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

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge.active {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.badge.inactive {
  background: rgba(249, 115, 22, 0.2);
  color: #fdba74;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 10px;
  text-align: left;
}

th {
  background: rgba(30, 41, 59, 0.8);
  color: #cbd5e1;
}

.status {
  margin-top: 10px;
  min-height: 24px;
  color: #bfdbfe;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(148, 163, 184, 0.15);
  font-size: 0.85rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #0b1220;
  padding: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-subtitle {
  color: var(--muted);
}

.presence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.presence-day--today {
  border: 2px solid #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.today-badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  border-radius: 6px;
  padding: 2px 7px;
  margin-right: 6px;
  vertical-align: middle;
  line-height: 1.6;
}
.presence-day {
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.35);
  border-radius: 12px;
  padding: 12px;
}

.presence-day h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.presence-block {
  margin-bottom: 10px;
}

.presence-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.presence-title.office {
  color: #86efac;
}

.presence-title.remote {
  color: #93c5fd;
}

.presence-list {
  margin: 0;
  padding-left: 18px;
  color: #e2e8f0;
}

.presence-empty {
  font-style: italic;
  color: #94a3b8;
}

.holiday-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.holiday-cell small {
  color: #fca5a5;
}

.holiday-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

/* ===== Botón flotante de asistencia ===== */
.btn-assist {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-assist:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(220, 38, 38, 0.55);
}

/* ===== Modal de asistencia / contacto ===== */
.assist-contacts {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.assist-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 14px 18px;
}

.assist-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.assist-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assist-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.assist-value {
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.assist-value:hover {
  color: var(--accent);
  text-decoration: underline;
}

.assist-person-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.assist-date-label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: capitalize;
  margin-bottom: 8px;
}

.assist-loading,
.assist-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 12px 0;
  text-align: center;
}

.assist-value.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ===== Edición inline en tabla de colaboradores ===== */
.inline-input {
  width: 100%;
  min-width: 110px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 0.9rem;
}

button.primary {
  background: var(--success);
  color: #fff;
}

@media (max-width: 900px) {
  :root {
    --page-pad: 12px;
  }

  body {
    padding: 12px;
  }

  th, td {
    padding: 8px;
  }
}

/* ============================================================
   RESPONSIVE — tablet y móvil
   ============================================================ */

/* Tabla semanal: scroll horizontal en pantallas pequeñas */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.table-scroll table {
  min-width: 560px;
  width: 100%;
}

.employees-table,
.report-table {
  min-width: 100%;
}

@media (max-width: 768px) {
  :root {
    --page-pad: 8px;
  }

  body {
    padding: 8px;
  }

  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.1rem; }

  /* Toolbar: apilar en columna */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar label,
  .toolbar input,
  .toolbar button {
    width: 100%;
  }

  .container {
    max-width: 100%;
  }

  .card {
    padding: 14px;
    overflow: hidden;
  }

  .card-full-width {
    width: 100%;
    margin-left: 0;
  }

  .month-grid-header {
    display: none;
  }

  .month-grid {
    grid-template-columns: 1fr;
  }

  .month-day {
    min-height: auto;
  }

  /* Celdas más compactas */
  th, td {
    padding: 6px 8px;
    font-size: 0.82rem;
  }

  .table-scroll {
    overflow: visible;
  }

  .table-scroll table {
    min-width: 100%;
  }

  .stack-on-mobile {
    border-collapse: separate;
    border-spacing: 0;
  }

  .stack-on-mobile thead {
    display: none;
  }

  .stack-on-mobile,
  .stack-on-mobile tbody,
  .stack-on-mobile tr,
  .stack-on-mobile td {
    display: block;
    width: 100%;
  }

  .stack-on-mobile tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.55);
  }

  .stack-on-mobile td {
    border: none;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.18);
    padding: 8px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
  }

  .stack-on-mobile td::before {
    content: attr(data-label);
    flex: 0 0 108px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .stack-on-mobile td:last-child {
    border-bottom: none;
  }

  .stack-on-mobile td[colspan] {
    display: block;
    text-align: center;
    padding: 12px 0;
  }

  .stack-on-mobile td[colspan]::before {
    content: none;
  }

  .stack-on-mobile td > * {
    min-width: 0;
  }

  .weekly-table td,
  .employees-table td[data-label="Acciones"],
  .report-table td[data-label="Detalle por modalidad"] {
    flex-direction: column;
    align-items: stretch;
  }

  .weekly-table td::before,
  .employees-table td[data-label="Acciones"]::before,
  .report-table td[data-label="Detalle por modalidad"]::before {
    flex: none;
    margin-bottom: 6px;
  }

  .weekly-table select,
  .employees-table .inline-input,
  .employees-table .inline-check,
  .employees-table .actions,
  .report-table td,
  .holiday-cell {
    width: 100%;
  }

  /* Selects más pequeños en planificación semanal */
  #week-body select {
    font-size: 0.78rem;
    padding: 4px 6px;
  }

  /* Modal: ocupar pantalla completa */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    padding: 16px;
  }

  .modal-content--narrow {
    max-width: 100%;
  }

  /* Grid de presencia: 1 columna */
  .presence-grid {
    grid-template-columns: 1fr;
  }

  /* Auth bar más compacta */
  .auth-bar {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.82rem;
  }

  /* Barra de acciones de tabla */
  .actions {
    flex-direction: column;
    gap: 4px;
  }

  .actions button {
    width: 100%;
  }

  /* Botón flotante más pequeño en móvil */
  .btn-assist {
    bottom: 16px;
    right: 16px;
    padding: 11px 16px;
    font-size: 0.85rem;
  }

  /* Inputs de edición inline: ancho completo */
  .inline-input {
    min-width: 80px;
  }
}

@media (max-width: 480px) {
  h1 { font-size: 1.2rem; }

  .card {
    padding: 12px;
    border-radius: 12px;
  }

  .stack-on-mobile td {
    gap: 8px;
  }

  .stack-on-mobile td::before {
    flex-basis: 92px;
    font-size: 0.72rem;
  }

  .modal-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
