/* ============================================================
   SYSLAND Sistema — Estilos
   Paleta oficial: Navy #042860 · Royal #027DF7 · Sky #00A1E0
                   Slate #808FA5 · Polar #E7EDF2
   ============================================================ */

:root {
  --navy: #042860;
  --royal: #027DF7;
  --sky: #00A1E0;
  --slate: #8FA0B8;
  --polar: #E7EDF2;
  --bg: #0A1426;          /* fondo general (navy profundo) */
  --card: #11233F;        /* tarjetas */
  --input-bg: #0D1B33;    /* campos de formulario */
  --text: #E7EDF2;
  --ok: #2FB873;
  --warn: #E8A100;
  --danger: #E06060;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Public Sans', system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .btn { font-family: 'Montserrat', sans-serif; }

.hidden { display: none !important; }

/* ============ LOGIN ============ */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--royal) 70%, var(--sky) 100%);
  padding: 20px;
}
.login-card {
  background: #FDFDFE; border-radius: 16px; padding: 36px 28px;
  width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  color-scheme: light;
}
.login-logo-img { height: 52px; max-width: 80%; object-fit: contain; }
.login-sub { color: var(--slate); margin: 6px 0 24px; font-size: 14px; }
.login-card input {
  width: 100%; padding: 13px 14px; border: 1px solid rgba(128,143,165,0.4);
  border-radius: 8px; font-size: 16px; margin-bottom: 14px; font-family: inherit;
  background: #fff; color: var(--navy);
}
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ============ LAYOUT ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy); color: var(--polar);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
/* En la barra navy el logo va en blanco (versión monocroma, según manual de marca) */
.topbar-logo-img { height: 26px; filter: brightness(0) invert(1); }
.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  background: none; border: none; color: inherit; font-size: 19px;
  cursor: pointer; padding: 6px 10px; border-radius: 8px; line-height: 1;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); }
.modal .icon-btn:hover, .scanner-head .icon-btn:hover { background: rgba(231,237,242,0.1); }

main {
  max-width: 860px; margin: 0 auto;
  padding: 16px 14px 90px;
}

.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--card); border-top: 1px solid rgba(128,143,165,0.25);
  display: flex; justify-content: space-around;
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  text-decoration: none; color: var(--slate);
  font-size: 10px; font-weight: 600; padding: 4px 3px; border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
}
.nav-item.active { color: var(--royal); }
.nav-ico { font-size: 19px; }

/* ============ COMPONENTES ============ */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 8px; cursor: pointer;
  font-weight: 700; font-size: 14px; padding: 11px 18px;
  transition: opacity .15s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--royal); color: #fff; }
.btn-secondary { background: transparent; color: var(--royal); border: 1.5px solid var(--royal); }
.btn-ghost { background: transparent; color: var(--slate); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid rgba(128,143,165,0.22);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px;
}

.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input {
  flex: 1; padding: 11px 14px; border: 1px solid rgba(143,160,184,0.35);
  border-radius: 8px; font-size: 15px; font-family: inherit;
  background: var(--input-bg); color: var(--text);
}

.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.chip {
  white-space: nowrap; padding: 6px 13px; border-radius: 999px;
  border: 1px solid rgba(128,143,165,0.4); background: var(--card);
  color: var(--slate); font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: 'Montserrat', sans-serif;
}
.chip.active { background: var(--royal); color: #fff; border-color: var(--royal); }

/* Tarjeta de equipo */
.eq-card { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.eq-thumb {
  width: 62px; height: 62px; border-radius: 8px; flex-shrink: 0;
  background: var(--input-bg); object-fit: cover;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.eq-info { flex: 1; min-width: 0; }
.eq-title { font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: 15px; }
.eq-specs { color: var(--slate); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eq-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.eq-precio { font-family: 'Montserrat', sans-serif; font-weight: 700; color: var(--royal); font-size: 15px; }

.badge {
  display: inline-block; padding: 2.5px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; font-family: 'Montserrat', sans-serif;
}
.badge-disponible { background: rgba(47,184,115,0.16); color: var(--ok); }
.badge-reservado { background: rgba(232,161,0,0.16); color: #EBB44A; }
.badge-vendido { background: rgba(2,125,247,0.16); color: #4DA3FF; }
.badge-baja { background: rgba(143,160,184,0.18); color: var(--slate); }
.badge-recibido { background: rgba(232,161,0,0.16); color: #EBB44A; }
.badge-en_proceso { background: rgba(0,161,224,0.16); color: #4FC8F0; }
.badge-listo { background: rgba(47,184,115,0.16); color: var(--ok); }
.badge-entregado { background: rgba(143,160,184,0.18); color: var(--slate); }
.badge-borrador { background: rgba(143,160,184,0.18); color: var(--slate); }
.badge-enviada { background: rgba(0,161,224,0.16); color: #4FC8F0; }
.badge-aceptada { background: rgba(47,184,115,0.16); color: var(--ok); }
.badge-rechazada { background: rgba(224,96,96,0.15); color: var(--danger); }
.badge-garantia { background: rgba(224,96,96,0.15); color: var(--danger); }
.badge-mantenimiento { background: rgba(0,161,224,0.16); color: #4FC8F0; }

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  border: 1px solid rgba(128,143,165,0.22); box-shadow: var(--shadow);
}
.stat-num { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 24px; color: var(--text); }
.stat-num.royal { color: var(--royal); }
.stat-label { color: var(--slate); font-size: 12px; margin-top: 2px; }

.section-title { font-size: 16px; font-weight: 600; margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; }
.alert-count {
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 1px 8px;
}

/* Alertas */
.alerta-card { border-left: 4px solid var(--danger); }
.alerta-card.tipo-mantenimiento { border-left-color: var(--sky); }
.alerta-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.alerta-acciones { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-wsp { background: #25D366; color: #fff; }

/* Formularios */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--slate); margin-bottom: 4px; font-family: 'Montserrat', sans-serif; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid rgba(143,160,184,0.4);
  border-radius: 8px; font-size: 15px; font-family: inherit; background: var(--input-bg); color: var(--text);
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--royal); outline-offset: 0; border-color: transparent; }
.input-scan { display: flex; gap: 6px; }
.input-scan input { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions .btn { flex: 1; }

/* Fotos */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 8px; }
.foto-item { position: relative; }
.foto-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.foto-del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(4,40,96,0.75); color: #fff; border: none;
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 12px;
}
.foto-add {
  aspect-ratio: 1; border: 2px dashed rgba(128,143,165,0.5); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--slate); cursor: pointer; font-size: 22px; background: none; width: 100%;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4,40,96,0.45); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--bg); width: 100%; max-width: 600px;
  max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0;
}
@media (min-width: 640px) { .modal { border-radius: 16px; } }
.modal-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg); padding: 16px 18px 10px;
}
.modal-head h3 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 4px 18px 24px; }

/* Cotización items */
.cot-item-row {
  display: grid; grid-template-columns: 1fr 56px 84px 32px; gap: 6px;
  align-items: center; margin-bottom: 6px;
}
.cot-item-row input { padding: 8px 10px; border: 1px solid rgba(143,160,184,0.4); border-radius: 8px; font-size: 14px; font-family: inherit; width: 100%; background: var(--input-bg); color: var(--text); }
.cot-total { text-align: right; font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 18px; margin-top: 10px; }
.cot-total span { color: var(--royal); }

/* Tabla simple */
.row-flex { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.muted { color: var(--slate); font-size: 13px; }
.empty-state { text-align: center; color: var(--slate); padding: 40px 16px; }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }

/* Scanner */
.scanner-overlay {
  position: fixed; inset: 0; z-index: 90; background: #04122b;
  display: flex; flex-direction: column;
}
.scanner-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; color: var(--polar); font-family: 'Montserrat', sans-serif; font-weight: 600;
}
#scanner-video { flex: 1; }
#scanner-video video { width: 100% !important; height: 100%; object-fit: cover; }

/* Lightbox (visor de fotos/videos) */
.lightbox {
  position: fixed; inset: 0; z-index: 96;
  background: rgba(2, 12, 30, 0.96);
  display: flex; align-items: center; justify-content: center;
}
#lb-cont { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#lb-cont img, #lb-cont video {
  max-width: 96vw; max-height: 88vh; object-fit: contain; border-radius: 6px;
}
.lb-btn {
  position: absolute; z-index: 2; background: rgba(255,255,255,0.12);
  border: none; color: #fff; cursor: pointer; border-radius: 50%;
  width: 44px; height: 44px; font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.lb-cerrar { top: 14px; right: 14px; font-size: 18px; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-contador {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.8); font-size: 13px; font-family: 'Montserrat', sans-serif; font-weight: 600;
}

/* Miniaturas de video */
.foto-item video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: #04122b; }
.foto-item .video-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,0.6); pointer-events: none;
}

/* Toast */
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--polar); padding: 11px 20px;
  border-radius: 999px; font-size: 14px; z-index: 95;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3); max-width: 90vw; text-align: center;
}

/* Barra de ventas (mini chart) */
.mini-chart { display: flex; align-items: flex-end; gap: 8px; height: 90px; padding: 4px 2px 0; }
.mini-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.mini-bar .bar { width: 100%; max-width: 44px; background: linear-gradient(180deg, var(--sky), var(--royal)); border-radius: 5px 5px 0 0; min-height: 3px; }
.mini-bar .lbl { font-size: 10px; color: var(--slate); }
.mini-bar .val { font-size: 10.5px; font-weight: 700; color: var(--text); font-family: 'Montserrat', sans-serif; }

/* Vista detalle equipo */
.detail-fotos { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; }
.detail-fotos img { height: 150px; border-radius: 10px; }
.spec-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.spec-list dt { color: var(--slate); font-weight: 600; font-size: 12.5px; padding-top: 2px; font-family: 'Montserrat', sans-serif; }
.spec-list dd { font-size: 14px; }

/* Días en inventario */
.dias-ok { background: rgba(143,160,184,0.15); color: var(--slate); }
.dias-warn { background: rgba(232,161,0,0.16); color: #EBB44A; }
.dias-danger { background: rgba(224,96,96,0.15); color: var(--danger); }
.badge-seguimiento { background: rgba(47,184,115,0.16); color: var(--ok); }
.alerta-card.tipo-seguimiento { border-left-color: var(--ok); }

/* Selección para compartir (inventario) */
.eq-card.seleccionable { position: relative; }
.eq-card.seleccionado { outline: 2.5px solid var(--royal); outline-offset: -2px; }
.eq-card.seleccionado::after {
  content: '✓'; position: absolute; top: 8px; right: 8px;
  background: var(--royal); color: #fff; width: 24px; height: 24px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.share-bar {
  position: fixed; bottom: 68px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--polar);
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 999px; z-index: 60;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3); white-space: nowrap;
  font-size: 13px; font-weight: 600; font-family: 'Montserrat', sans-serif;
}
.share-bar .btn { padding: 7px 12px; font-size: 13px; }

/* Finanzas */
.gasto-cat {
  display: inline-block; padding: 2.5px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; font-family: 'Montserrat', sans-serif;
  background: rgba(128,143,165,0.18); color: var(--slate);
}
.util-pos { color: var(--ok) !important; }
.util-neg { color: var(--danger) !important; }
.mes-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 14px; }
.mes-nav strong { font-family: 'Montserrat', sans-serif; min-width: 140px; text-align: center; }

/* Certificación */
.cert-bar { background: var(--input-bg); border-radius: 999px; height: 10px; overflow: hidden; margin: 8px 0 4px; border: 1px solid rgba(143,160,184,0.2); }
.cert-bar div { height: 100%; background: linear-gradient(90deg, var(--sky), var(--royal)); border-radius: 999px; }
.cert-check {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 4px; border-bottom: 1px solid rgba(128,143,165,0.15);
  font-size: 14px; cursor: pointer;
}
.cert-check input { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; accent-color: var(--royal); }

/* Al imprimir (cotización): siempre en claro */
@media print {
  .topbar, .bottombar, .modal-head .icon-btn, .no-print { display: none !important; }
  body { background: #fff !important; color: #042860 !important; }
  .card { background: #fff !important; color: #042860 !important; border-color: #ccd5e0 !important; box-shadow: none !important; }
  .muted { color: #666 !important; }
  main { padding: 0; max-width: none; }
}
