:root {
  --primary: #d63384;
  --secondary: #5a5a5a;
  --success: #2b8a3e;
  --danger: #dc3545;
  --light-bg: #f4f6f9;
  --card-bg: #ffffff;
  --border: #ddd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background-color: var(--light-bg);
  padding: 20px;
  color: #222;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--card-bg);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.top h2 {
  margin: 0;
  font-size: 1.5rem;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}



.btn:hover {
  opacity: .9;
}

.btn-secondary {
  background-color: var(--secondary);
}

.filters {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-top: 10px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.filter-select {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  min-width: 220px;
  background: #fff;
}

.prefs {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed #e6e6e6;
  border-radius: 8px;
  background: #fafafa;
}

.small {
  font-size: 13px;
  color: #666;
}

.pref-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  margin-bottom: 8px;
  user-select: none;
}

.layout {
  display: flex;
  gap: 20px;
  margin-top: 20px;
  align-items: flex-start;
}

#calendar {
  flex: 1 1 auto;
  min-width: 320px;
  min-height: 700px;
}

.list {
  width: 480px;
  max-width: 100%;
  max-height: 700px;
  overflow-y: auto;
  border-left: 1px solid #eee;
  padding-left: 20px;
  flex: 0 0 480px;
}

.list h3 {
  margin-top: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 8px;
  border-bottom: 1px solid #eee;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.action a {
  margin-right: 6px;
  text-decoration: none;
  color: #444;
  font-size: 16px;
}

.category-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  color: white;
  font-size: 12px;
  line-height: 1;
}

.debug-panel {
  margin-top: 30px;
  padding: 20px;
  background: #222;
  color: #0f0;
  border-radius: 8px;
  font-family: monospace;
  overflow-x: auto;
}

.debug-panel h3 {
  color: #fff;
  border-bottom: 1px solid #444;
  margin-top: 0;
  padding-bottom: 8px;
}

.debug-btn {
  padding: 8px 10px;
  cursor: pointer;
  background: #444;
  color: #fff;
  border: none;
  border-radius: 4px;
  margin-right: 5px;
  margin-top: 5px;
}

.debug-primary {
  background: #007bff;
}

@media (max-width: 900px) {
  body {
    padding: 10px;
  }

  .container {
    padding: 14px;
  }

  .layout {
    flex-direction: column;
  }

  #calendar {
    width: 100%;
    min-width: 0;
    min-height: 520px;
  }

  .list {
    width: 100%;
    flex: 1 1 auto;
    border-left: 0;
    padding-left: 0;
    max-height: none;
  }

  .top {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-select {
    min-width: 0;
    width: 100%;
  }
}
/* Forzar que el grupo de acciones esté visible */
.top .top-actions { display: flex !important; gap: 8px; align-items: center; }

.top .top-actions .btn {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important;
  pointer-events: auto !important;
}

/* En móviles: apilar botones si no caben */
@media (max-width: 700px) {
  .top { flex-wrap: wrap; gap: 10px; }
  .top .top-actions { width: 100%; justify-content: flex-end; }
  .top .top-actions .btn { padding: 8px 12px; font-size: 14px; }
}

.fab-add{
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  background:#d63384;
  color:#fff;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:28px;
  text-decoration:none;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  z-index: 9999;
}
.fab-add:hover{ background:#b02a6b; }

/* --- BOTONES DEL HEADER / ACCIONES --- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.top-actions {
  display: flex !important;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  min-width: 260px;
}

.top-actions .btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none !important;
  font-weight: 700;
  background: #d63384 !important;
  color: #fff !important;
  border: none;
  white-space: nowrap;
}

.top-actions .btn:hover {
  background: #b02a6b !important;
  color: #fff !important;
}

.top-actions .btn-secondary {
  background: #6c757d !important;
  color: #fff !important;
}

.top-actions .btn-secondary:hover {
  background: #565e64 !important;
  color: #fff !important;
}

@media (max-width: 700px) {
  .top {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* FIX VISIBILIDAD BOTONES CABECERA - pegar al final de style.css */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.top-actions {
  display: flex !important;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  /* elimina min-width forzado para que no salte a nueva línea en anchos ajustados */
  min-width: 0 !important;
}

/* Estilo base para .btn (si no existe) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

/* Asegurar que botones secundarios se vean */
.btn.btn-secondary,
.top-actions .btn-secondary {
  background: var(--secondary) !important;
  color: #fff !important;
}

/* Forzar visibilidad si alguna regla aplica opacity/visibility */
.top-actions .btn {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}

/* Móvil: apilar sin dejar huecos */
@media (max-width: 700px) {
  .top { flex-direction: column; align-items: stretch; }
  .top-actions { width: 100%; justify-content: flex-start; margin-top: 8px; }
  .top-actions .btn { width: auto; padding: 10px; }
}

/* Fallback: botón flotante si por alguna razón los botones siguen ocultos */
.fab-add{
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  background:var(--primary);
  color:#fff;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:28px;
  text-decoration:none;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  z-index: 99999;
}

/* Notificaciones in-site */
.notif-wrap { position: relative; display: inline-block; margin-left: 10px; }
.notif-bell { background: transparent; border: none; font-size: 18px; cursor: pointer; position: relative; padding:6px; }
.notif-count {
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 12px;
  position: absolute;
  top: -6px;
  right: -6px;
}

.notif-dropdown {
  position: absolute;
  right: 0;
  top: 34px;
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e6e6e6;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  border-radius: 8px;
  z-index: 9999;
}

.notif-item {
  padding: 10px;
  border-bottom: 1px solid #f1f1f1;
  font-size: 14px;
}
.notif-item.unread { background: #fff7f9; }
.notif-item .title { font-weight: 700; color: #222; }
.notif-item .body { color: #666; font-size: 13px; margin-top: 4px; }
.notif-item .time { color: #999; font-size: 12px; margin-top: 6px; }

.notif-footer { padding: 8px; text-align: center; background: #fafafa; border-top: 1px solid #eee; }

#toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  max-width: 360px;
}

.toast {
  background: #fff;
  border-left: 4px solid var(--primary);
  padding: 10px 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  border-radius: 8px;
  min-width: 250px;
  max-width: 360px;
}
.toast .close {
  float: right;
  cursor: pointer;
  color: #666;
  font-weight: 700;
  margin-left: 8px;
}
.toast .title { font-weight: 700; margin-bottom: 4px; }
.toast .body { color: #444; font-size: 14px; }

/* Ocultar preferencias y panel de diagnóstico sin eliminar HTML */
.prefs, .debug-panel {
  display: none !important;
}