/* ════════════════════════════════════════════════════════════
   FLOTA OPERATIVA 2.0 — Estilos v2
   ════════════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
html, body { height: 100%; }
body {
  padding: 10px; max-width: 1200px; margin: 0 auto;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
  color: #2c3e50; min-height: 100vh;
}

/* ───────── TOASTS FLOTANTES ───────── */
.zona-toasts {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 100000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: 90%; max-width: 420px;
}
.toast {
  background: white; padding: 12px 16px;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  display: flex; align-items: center; gap: 10px;
  pointer-events: auto;
  animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-left: 4px solid #3498db;
}
.toast.ok    { border-left-color: #27ae60; color: #1e7e34; }
.toast.aviso { border-left-color: #f39c12; color: #9a6d00; }
.toast.error { border-left-color: #e74c3c; color: #a82a2a; }
.toast .toast-ico { font-size: 20px; }
.toast .toast-cerrar {
  margin-left: auto; cursor: pointer; opacity: 0.5;
  font-size: 18px; line-height: 1; background: none; border: none; padding: 0 4px;
}
.toast .toast-cerrar:hover { opacity: 1; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.toast.saliendo { animation: toast-out 0.25s ease-in forwards; }
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

/* ───────── LOGIN ELEGANTE ───────── */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  position: fixed; inset: 0; z-index: 1; padding: 20px;
}
.login-card {
  background: rgba(255, 255, 255, 0.97); backdrop-filter: blur(10px);
  border-radius: 20px; padding: 40px 35px;
  width: 100%; max-width: 400px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: card-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes card-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.login-logo {
  font-size: 60px; margin-bottom: 10px;
  display: inline-block;
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.login-card h1 {
  font-size: 26px; color: #2c3e50; margin-bottom: 4px; font-weight: 700;
}
.login-sub {
  color: #7f8c8d; font-size: 14px; margin-bottom: 28px;
}
.login-campo {
  position: relative; margin-bottom: 14px;
}
.login-ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 16px; opacity: 0.6;
}
.login-campo input {
  width: 100%; padding: 14px 14px 14px 44px;
  border: 2px solid #e0e6ed; border-radius: 10px;
  font-size: 15px; background: #f8fafc;
  transition: all 0.2s;
}
.login-campo input:focus {
  outline: none; border-color: #667eea; background: white;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}
.btn-login {
  width: 100%; padding: 14px; margin-top: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.7; cursor: wait; }
.login-msg {
  margin-top: 12px; font-size: 13px; min-height: 18px; font-weight: 500;
}
.login-msg.error { color: #c0392b; }
.login-msg.ok    { color: #27ae60; }
.login-foot {
  margin-top: 24px; color: #95a5a6; font-size: 11px; letter-spacing: 0.5px;
}

/* ───────── HEADER APP ───────── */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
  padding: 12px 18px; background: white;
  border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.app-title { display: flex; align-items: center; gap: 12px; }
.app-logo {
  font-size: 32px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  width: 50px; height: 50px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}
.app-title h2 { font-size: 18px; color: #2c3e50; font-weight: 700; margin: 0; }
.app-title small { color: #7f8c8d; font-size: 12px; }

.usuario-tag {
  display: flex; align-items: center; gap: 10px;
  background: #f8fafc; padding: 6px 12px 6px 6px;
  border-radius: 30px; border: 1px solid #e0e6ed;
}
.usuario-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.usuario-info { display: flex; flex-direction: column; line-height: 1.1; }
.usuario-info strong { font-size: 13px; color: #2c3e50; }
.usuario-info small  { font-size: 11px; color: #7f8c8d; }
.btn-mini {
  border: none; background: #ecf0f1; color: #7f8c8d;
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
  font-size: 11px; font-weight: 600; transition: all 0.15s;
}
.btn-mini:hover { background: #e74c3c; color: white; }

/* ───────── CONTROLES ───────── */
.controles {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; align-items: center;
  margin-bottom: 12px; padding: 12px;
  background: white; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.controles label { font-size: 13px; font-weight: 600; color: #34495e; }
.controles input[type="date"],
.controles input[type="password"],
.controles input[type="text"],
.controles select {
  padding: 7px 10px; font-size: 13px;
  border: 1px solid #d4dae0; border-radius: 6px; background: #f8fafc;
  transition: all 0.15s;
}
.controles input:focus, .controles select:focus {
  outline: none; border-color: #667eea; background: white;
}

/* ───────── BOTONES ───────── */
button {
  padding: 7px 14px; border: none; border-radius: 6px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: all 0.15s;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-cargar    { background: #f39c12; color: white; }
.btn-cargar:hover    { background: #d68910; box-shadow: 0 3px 8px rgba(243, 156, 18, 0.3); }
.btn-guardar   { background: #27ae60; color: white; }
.btn-guardar:hover   { background: #1e8449; box-shadow: 0 3px 8px rgba(39, 174, 96, 0.3); }
.btn-resumen   { background: #3498db; color: white; }
.btn-resumen:hover   { background: #2874a6; box-shadow: 0 3px 8px rgba(52, 152, 219, 0.3); }
.btn-graficos  { background: #8e44ad; color: white; }
.btn-graficos:hover  { background: #6c3483; box-shadow: 0 3px 8px rgba(142, 68, 173, 0.3); }
.btn-historial { background: #16a085; color: white; }
.btn-historial:hover { background: #117864; box-shadow: 0 3px 8px rgba(22, 160, 133, 0.3); }
.btn-accion    { background: #667eea; color: white; }
.btn-accion:hover    { background: #4c5fc9; }
.btn-peligro   { background: #e74c3c; color: white; }
.btn-peligro:hover   { background: #c0392b; }

/* ───────── TABLA ───────── */
.tabla-contenido {
  background: white; border-radius: 12px;
  overflow-x: auto; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 12px;
}
.placeholder { padding: 50px; text-align: center; color: #95a5a6; font-style: italic; }
.msg-inferior { text-align: center; font-size: 12px; color: #95a5a6; min-height: 16px; }

table {
  border-collapse: collapse; width: 100%;
  font-size: 12.5px; background: white;
}
th {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: white; padding: 9px 6px; font-size: 11.5px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
  position: sticky; top: 0; z-index: 1;
}
td {
  border: 1px solid #ecf0f1; padding: 6px 6px;
  text-align: center; vertical-align: middle;
}
tr.tipo-troncal td      { background: #eaf2f8; }
tr.tipo-alimentadora td { background: #fef9e7; }
tr:hover td              { background: #f0f6fc !important; }

input[type="number"] {
  width: 52px; padding: 4px; text-align: center;
  border: 1px solid #d4dae0; border-radius: 4px;
  font-size: 12.5px; background: white; transition: all 0.15s;
}
input[type="number"]:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); }
input[type="number"].bloqueado { background: #ecf0f1; color: #95a5a6; cursor: not-allowed; }
input[type="number"].modificado { background: #fff3cd; border-color: #ffc107; font-weight: bold; }
input[type="number"].real-menor { background: #ffebee; color: #c0392b; border-color: #e74c3c; font-weight: bold; }
input[type="number"].real-mayor { background: #e8f5e9; color: #1e7e34; }

.fila-totales td {
  background: linear-gradient(180deg, #d4e4f7 0%, #b9d3f4 100%) !important;
  font-weight: bold; color: #2b4b72; border-top: 2px solid #5a9bd4 !important;
}

.bloqueado { background: #ecf0f1; color: #95a5a6; cursor: not-allowed; }

/* ───────── MODAL ───────── */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.75); z-index: 9999; padding: 8px;
  animation: fade-in 0.2s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-contenido {
  background: white; margin: 0 auto; width: 100%;
  max-width: 950px; max-height: 95vh;
  border-radius: 12px; position: relative;
  overflow-y: auto; padding: 20px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
  animation: modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-imagen-contenido { max-width: 700px; }
.cerrar {
  position: absolute; top: 10px; right: 14px;
  font-size: 24px; font-weight: bold; cursor: pointer;
  color: #95a5a6; z-index: 10; line-height: 1;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all 0.15s;
}
.cerrar:hover { color: #c0392b; background: #fdeeee; }

.modal h3 { color: #2c3e50; margin-bottom: 12px; font-size: 18px; }

.modal-ajustes {
  display: flex; flex-wrap: wrap; gap: 14px; padding: 12px;
  background: #f8fbfe; border: 1px solid #d4e4f7; border-radius: 8px;
  margin: 12px 0; font-size: 13px;
}
.modal-ajustes label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.modal-ajustes input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.modal-botones {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid #ecf0f1;
}

/* ───────── RESUMEN ───────── */
.resumen-header {
  background: linear-gradient(135deg, #2c3e50 0%, #4a6580 100%);
  color: white; padding: 14px; text-align: center; font-size: 17px;
  font-weight: 700; border-radius: 10px; margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.resumen-header small { display: block; font-size: 11px; font-weight: 400; margin-top: 4px; opacity: 0.9; }
.totales-superior {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 6px; margin-bottom: 12px; text-align: center; font-size: 12.5px;
}
.totales-superior div {
  padding: 8px 4px; background: #f0f4f8;
  border: 1px solid #d4e4f7; border-radius: 6px;
}
.totales-superior strong { display: block; font-size: 17px; color: #2b4b72; margin-top: 2px; }
.totales-superior small { font-size: 10px; color: #7f8c8d; }
.resumen-tabla { font-size: 12px; border-radius: 8px; overflow: hidden; }
.resumen-tabla th { background: #34495e; }
.resumen-tabla .fila-total td {
  background: linear-gradient(180deg, #d4e4f7 0%, #b9d3f4 100%) !important;
  font-weight: bold; color: #2b4b72;
}

/* Indicadores visuales de cumplimiento por celda */
.cell-real.bajo  { background: #ffebee !important; color: #c0392b; font-weight: bold; }
.cell-real.ok    { background: #e8f5e9 !important; color: #1e7e34; font-weight: bold; }
.cell-real.crit  { background: #c0392b !important; color: white; font-weight: bold; }

/* Bandas alternadas por troncal en el resumen */
.resumen-tabla tr.troncal-grupo td {
  background: #d6e4f0 !important;
  font-weight: 700; color: #2c3e50;
  border-top: 2px solid #4a6580;
}

/* ───────── GRÁFICOS ───────── */
.grafico-filtros {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px; align-items: center;
  padding: 10px; background: #f8fafc; border-radius: 8px;
}
.grafico-filtros label { font-size: 13px; display: flex; align-items: center; gap: 5px; }
.grafico-filtros input, .grafico-filtros select {
  padding: 5px 8px; border: 1px solid #d4dae0; border-radius: 4px;
}
.grafico-container {
  background: white; padding: 10px; border-radius: 8px;
  margin-bottom: 14px; border: 1px solid #ecf0f1;
  height: 280px; position: relative;
}

/* ───────── HISTORIAL ───────── */
.historial-tabla { font-size: 12px; }
.historial-tabla td { padding: 5px; }
.historial-filtros {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
  align-items: center; padding: 10px; background: #f8fafc; border-radius: 8px;
}
.historial-filtros label { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.historial-filtros input, .historial-filtros select {
  padding: 5px 8px; border: 1px solid #d4dae0; border-radius: 4px;
}
.historial-tabla tr.troncal-separador td {
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%) !important;
  color: white; font-weight: 700; text-align: left;
  padding: 6px 10px !important; font-size: 12px;
}
.historial-tabla tr.troncal-separador td small { opacity: 0.9; font-weight: 400; margin-left: 8px; }
.historial-tabla tr.fecha-separador td {
  background: #d4e4f7 !important;
  color: #2b4b72; font-weight: 700; text-align: left;
  padding: 6px 10px !important; font-size: 11.5px;
}

/* ───────── MODAL DE IMAGEN ───────── */
.preview-imagen {
  max-width: 100%; border: 1px solid #ecf0f1;
  border-radius: 8px; margin: 10px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.preview-info {
  background: #f0f4f8; padding: 12px; border-radius: 8px;
  margin: 10px 0; font-size: 13px; color: #34495e;
}
.preview-info strong { color: #2c3e50; }
.preview-botones {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center; margin-top: 14px;
}
.preview-botones button { padding: 10px 18px; font-size: 14px; }
.btn-whatsapp { background: #25D366 !important; color: white; }
.btn-whatsapp:hover { background: #1ea952 !important; box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3); }
.btn-descarga { background: #3498db !important; color: white; }
.btn-descarga:hover { background: #2874a6 !important; }

/* ════════════ MÓDULO ADMIN ════════════ */
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 14px;
  border-bottom: 2px solid #ecf0f1; flex-wrap: wrap;
}
.admin-tab {
  padding: 8px 14px; background: transparent; border: none;
  border-bottom: 3px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; color: #7f8c8d;
  transition: all 0.15s; border-radius: 0;
}
.admin-tab:hover { color: #2c3e50; background: #f8fafc; }
.admin-tab.activo {
  color: #6c3483; border-bottom-color: #6c3483; background: #f8fafc;
}

.admin-toolbar {
  display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
  align-items: center; padding: 8px; background: #f8fafc;
  border-radius: 6px; font-size: 13px;
}

.admin-tabla { font-size: 12.5px; }
.admin-tabla input, .admin-tabla select {
  width: 100%; padding: 4px 6px; border: 1px solid #d4dae0;
  border-radius: 3px; font-size: 12.5px; box-sizing: border-box;
}
.admin-tabla input:focus, .admin-tabla select:focus {
  outline: none; border-color: #6c3483; box-shadow: 0 0 0 2px rgba(108, 52, 131, 0.15);
}
.admin-tabla td { padding: 4px 5px !important; }
.admin-tabla tr.fila-nueva { background: #fef9e7 !important; }
.admin-tabla tr.fila-eliminada { background: #fdeeee !important; opacity: 0.5; }

.admin-form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; padding: 10px; background: #f8fafc;
  border-radius: 6px; margin-bottom: 10px;
}
.admin-form-grid label { font-size: 12px; font-weight: 600; color: #34495e; }
.admin-form-grid input, .admin-form-grid select {
  width: 100%; padding: 6px 8px; border: 1px solid #d4dae0;
  border-radius: 4px; font-size: 13px; box-sizing: border-box;
}

.btn-admin-accion { background: #6c3483; color: white; padding: 5px 10px; font-size: 12px; }
.btn-admin-accion:hover { background: #4a1f5c; }
.btn-admin-peligro { background: #c0392b; color: white; padding: 5px 10px; font-size: 12px; }
.btn-admin-peligro:hover { background: #922b1f; }
.btn-admin-mini {
  background: transparent; color: #6c3483; border: 1px solid #6c3483;
  padding: 2px 6px; font-size: 11px;
}
.btn-admin-mini:hover { background: #6c3483; color: white; }

/* ════════════ ALERTA NOCTURNA COMO MODAL FLOTANTE ════════════ */
.alerta-nocturna-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 99998; display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fade-in 0.2s;
}
.alerta-nocturna-card {
  background: white; border-radius: 12px; padding: 24px;
  max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  animation: modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.alerta-nocturna-card h3 {
  color: #e67e22; margin-bottom: 8px; font-size: 18px;
}
.alerta-nocturna-card p {
  color: #7f8c8d; font-size: 13px; margin-bottom: 18px; line-height: 1.5;
}
.alerta-nocturna-botones {
  display: flex; flex-direction: column; gap: 8px;
}
.alerta-nocturna-botones button {
  padding: 12px; font-size: 14px; font-weight: 600;
  border: 2px solid transparent; border-radius: 8px;
  cursor: pointer; transition: all 0.15s;
}
.alerta-nocturna-botones .btn-hoy {
  background: #27ae60; color: white;
}
.alerta-nocturna-botones .btn-hoy:hover { background: #1e8449; }
.alerta-nocturna-botones .btn-ayer {
  background: #3498db; color: white;
}
.alerta-nocturna-botones .btn-ayer:hover { background: #2874a6; }
.alerta-nocturna-botones .btn-cambiar {
  background: white; color: #2c3e50; border-color: #d4dae0;
}
.alerta-nocturna-botones .btn-cambiar:hover { background: #f8fafc; }
.alerta-nocturna-botones .btn-cancelar {
  background: transparent; color: #95a5a6; font-size: 12px;
  text-decoration: underline; padding: 6px;
}
.alerta-nocturna-botones .btn-cancelar:hover { color: #7f8c8d; }

.aviso-header {
  background: #fff9e6; color: #946c00; padding: 6px 12px;
  border-radius: 6px; font-size: 12px; margin-bottom: 8px;
  border: 1px solid #ffe699; display: flex; align-items: center; gap: 8px;
}
.aviso-header button {
  margin-left: auto; background: transparent; color: #946c00;
  font-size: 11px; padding: 2px 6px; text-decoration: underline;
}

