/* ============================================================
   ERP Trituradora — Sistema de diseño corporativo
   Paleta azul marino, tipografía sobria, componentes serios.
   ============================================================ */
:root {
  /* Marca */
  --navy: #1a2b4a;          /* azul marino principal (topbar, acentos) */
  --navy-700: #243a63;
  --navy-600: #2f4a7c;
  --primary: #2563a8;        /* azul de acción */
  --primary-hover: #1f5391;

  /* Neutros */
  --bg: #f4f6f9;             /* fondo general (gris muy claro) */
  --surface: #ffffff;
  --border: #e2e6ec;
  --border-strong: #cbd2dc;
  --text: #1f2733;
  --text-soft: #5b6877;
  --text-muted: #8a95a3;

  /* Estado */
  --ok: #1d8a4e;
  --ok-bg: #e8f5ee;
  --warn: #b67410;
  --warn-bg: #fdf3e3;
  --danger: #c0392b;
  --danger-bg: #fbeae8;

  --radius: 6px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

/* Salvaguarda: ningún icono SVG debe desbordarse aunque falte tamaño explícito. */
svg { max-width: 24px; max-height: 24px; flex-shrink: 0; }
.login-card .logo svg { max-width: 28px; max-height: 28px; }
.topbar .marca svg { max-width: 22px; max-height: 22px; }

/* Miniatura de foto en historiales (ventas). Click = abre grande en pestaña. */
.mini-foto {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--linea, #d9dee8);
  cursor: pointer; display: block;
  transition: transform .12s ease;
}
.mini-foto:hover { transform: scale(1.05); }

/* El panel "Más" SOLO existe en móvil; en escritorio queda oculto siempre
   (si no, sus opciones e iconos aparecerían sueltos en la página). */
.mas-panel { display: none; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Barra superior ---- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .marca { display: flex; align-items: center; gap: 10px; flex: 1; }
.topbar h1 {
  font-size: 15px; font-weight: 600; margin: 0; letter-spacing: .2px;
  text-transform: uppercase;
}
.topbar h1 .sub { font-weight: 400; opacity: .65; text-transform: none; letter-spacing: 0; }
.topbar .usuario { font-size: 13px; opacity: .85; display: flex; align-items: center; gap: 7px; }
.topbar .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--navy-600);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.topbar button {
  background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff;
  padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.topbar button:hover { background: rgba(255,255,255,.1); }

/* ---- Layout con nav (escritorio: lateral más ancho y cómodo) ---- */
.contenedor { display: flex; min-height: calc(100vh - 56px); }
nav.lateral {
  background: var(--surface);
  border-right: 1px solid var(--border);
  width: 264px; padding: 18px 14px; flex-shrink: 0;
}
nav.lateral a {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: var(--radius);
  color: var(--text-soft); text-decoration: none; font-size: 15.5px; font-weight: 500;
  margin-bottom: 4px;
}
nav.lateral a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
nav.lateral a.activo { background: var(--navy); color: #fff; }
nav.lateral a.activo svg { stroke: #fff; }
nav.lateral a svg { width: 22px; height: 22px; stroke: var(--text-muted); flex-shrink: 0; }
/* Etiqueta "Más" oculta en escritorio (solo se usa en móvil) */
nav.lateral a.solo-movil { display: none; }

main { flex: 1; padding: 24px 28px; max-width: 1160px; }
h2.titulo { margin: 0 0 20px; font-size: 20px; font-weight: 600; color: var(--text); }

/* ---- Tarjetas ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card h3 {
  margin: 0 0 16px; font-size: 14px; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: .4px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.card h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ---- Métricas (dashboard) ---- */
.grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.metrica {
  text-align: left; padding: 18px 20px; position: relative;
  border-left: 3px solid var(--primary);
}
.metrica .valor { font-size: 26px; font-weight: 700; color: var(--navy); letter-spacing: -.5px; }
.metrica .etiqueta { color: var(--text-muted); font-size: 12px; margin-top: 4px; text-transform: uppercase; letter-spacing: .4px; font-weight: 500; }

/* ---- Desglose (dashboard + corte de caja) ---- */
.lista-desglose { margin-top: 6px; }
.desglose-fila {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 2px; border-bottom: 1px solid #eef1f5; font-size: 14px;
}
.desglose-fila:last-child { border-bottom: none; }
.desglose-fila .monto { font-weight: 600; color: var(--navy); }

/* ---- Corte de caja: número estrella ---- */
.caja-destacada { text-align: center; padding: 24px 18px; border-top: 4px solid var(--navy); }
.caja-destacada .etiqueta { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.caja-destacada .valor-grande { font-size: 40px; font-weight: 800; letter-spacing: -1px; margin: 6px 0; }

/* ---- Alertas (maquinaria que necesita servicio) ---- */
.alerta-card { border-left: 4px solid var(--warn); background: var(--warn-bg); }
.alerta-card h3 { color: var(--warn); }
.alerta-fila {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid #f0e4cf; flex-wrap: wrap;
}
.alerta-fila:last-child { border-bottom: none; }

/* ---- Formularios ---- */
label { display: block; font-size: 13px; color: var(--text-soft); margin: 12px 0 5px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 14px; background: var(--surface); color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 168, .12);
}
input::placeholder { color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--primary); color: #fff; border: 1px solid var(--primary);
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer;
  font-weight: 500; font-family: inherit;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-verde { background: var(--ok); border-color: var(--ok); }
.btn-verde:hover { background: #176b3d; border-color: #176b3d; }
/* Botón secundario (antes "gris") */
.btn-gris {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-soft);
}
.btn-gris:hover { background: var(--bg); border-color: var(--text-muted); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 13px; }

.fila { display: flex; gap: 14px; flex-wrap: wrap; }
.fila > * { flex: 1; min-width: 150px; }

/* ---- Selección con botones (despachador) ---- */
.botones-grandes { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.botones-grandes button {
  padding: 14px 12px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-soft); transition: all .1s; font-family: inherit;
}
.botones-grandes button:hover { border-color: var(--primary); color: var(--text); }
.botones-grandes button.sel { border-color: var(--primary); background: #eef4fb; color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* ---- Pasos (flujo de venta) ---- */
.paso {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.paso .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: #fff;
  font-weight: 600; font-size: 13px; margin-right: 11px;
}
.paso .cab { display: flex; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.paso .cab h3 { margin: 0; font-size: 15px; font-weight: 600; border: none; padding: 0; text-transform: none; letter-spacing: 0; }
.paso .cab .hint { color: var(--text-muted); font-size: 13px; margin-left: auto; }

/* Acento sutil por paso (línea izquierda, sin fondos llamativos) */
.paso.p-camion  { border-left: 3px solid var(--primary); }
.paso.p-carga   { border-left: 3px solid var(--navy-600); }
.paso.p-cliente { border-left: 3px solid var(--navy); }
.paso.p-resumen { border-left: 3px solid var(--ok); }

.sublabel { font-weight: 600; color: var(--text-soft); font-size: 13px; margin: 16px 0 7px; display: block; }
.sublabel:first-child { margin-top: 0; }

.botones-grandes.color button.sel { border-color: var(--navy); background: #eef1f6; color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }

/* ---- Captura de fotos (venta) ---- */
.foto-box {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 18px; text-align: center; cursor: pointer; background: #fafbfc;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.foto-box:hover { border-color: var(--primary); }
.foto-box.lista { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.foto-box svg { width: 30px; height: 30px; max-width: 30px; max-height: 30px; stroke: var(--text-muted); }
.foto-box.lista svg { stroke: var(--ok); }
.foto-box .txt { font-size: 13px; font-weight: 500; color: var(--text-soft); }
.foto-box.lista .txt { color: var(--ok); }
.foto-box img { max-width: 100%; max-height: 140px; border-radius: var(--radius-sm); margin-top: 6px; }
.foto-estado { font-size: 12px; font-weight: 600; }
.botones-grandes.color button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.punto-color { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--border-strong); display: inline-block; }

/* ---- Tablas ---- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th {
  color: var(--text-muted); font-weight: 600; background: #fafbfc; font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px;
}
tbody tr:hover td { background: #fafbfc; }
td .btn-sm { margin-right: 4px; }

/* ---- Chips de estado ---- */
.chip { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.err { background: var(--danger-bg); color: var(--danger); }

/* ---- Chip de conexión (topbar) ---- */
.chip-conexion {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
  margin-right: 10px; white-space: nowrap;
}
.chip-conexion::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor;
}
.chip-conexion.en-linea { background: rgba(255,255,255,.15); color: #b8f0cf; }
.chip-conexion.sin-conexion { background: rgba(255,255,255,.18); color: #ffd9a8; }
.chip-conexion.con-pendientes { background: var(--warn); color: #fff; }
@media (max-width: 768px) {
  /* En móvil solo mostramos el puntito + número de pendientes para ahorrar espacio. */
  .chip-conexion { font-size: 0; gap: 0; padding: 6px; margin-right: 6px; }
  .chip-conexion.con-pendientes { font-size: 11px; padding: 4px 8px; }
}

/* ---- Mensajes ---- */
.aviso { padding: 11px 14px; border-radius: var(--radius-sm); margin: 12px 0; font-size: 13.5px; display: none; border: 1px solid transparent; }
.aviso.ok { background: var(--ok-bg); color: #14613a; border-color: #bfe3cd; display: block; }
.aviso.error { background: var(--danger-bg); color: #8e2a20; border-color: #f0c5bf; display: block; }

/* ---- Login ---- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: var(--navy); }
.login-card { width: 100%; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.login-card .logo {
  text-align: center; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--navy); font-weight: 700; font-size: 17px; letter-spacing: .3px; text-transform: uppercase;
}
.login-card h2 { text-align: center; margin: 6px 0 20px; font-size: 14px; font-weight: 400; color: var(--text-muted); }

.muted { color: var(--text-muted); font-size: 13px; }

/* ---- Pestañas ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--text-soft);
  padding: 10px 16px; cursor: pointer; font-size: 14px; font-weight: 500; font-family: inherit; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.activo { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Fichas de detalle ---- */
.volver { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; font-size: 13px; cursor: pointer; color: var(--text-soft); }
.volver:hover { color: var(--primary); }
.datos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dato { background: var(--surface); padding: 12px 14px; }
.dato .et { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.dato .vl { font-size: 15px; font-weight: 600; margin-top: 3px; color: var(--text); }

/* ============================================================
   MÓVIL: barra de navegación inferior fija (tipo app)
   Pensado para uso 100% en celular, con una mano.
   ============================================================ */
@media (max-width: 768px) {
  .contenedor { flex-direction: column; }
  main { padding: 16px 14px 84px; }  /* espacio inferior para la barra */
  .topbar { padding: 0 14px; height: 52px; }
  .topbar h1 .sub { display: none; }
  .topbar h1 { font-size: 14px; }

  /* El menú lateral pasa a ser barra inferior fija */
  nav.lateral {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: 64px; padding: 0;
    display: flex; align-items: stretch;
    border-right: none; border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(16,24,40,.06);
    z-index: 40;
  }
  nav.lateral a {
    flex: 1; flex-direction: column; gap: 3px;
    justify-content: center; align-items: center;
    padding: 8px 2px; margin: 0; border-radius: 0;
    font-size: 11px; font-weight: 500; color: var(--text-muted);
    text-align: center;
  }
  nav.lateral a span { line-height: 1.1; }
  nav.lateral a svg { width: 24px; height: 24px; }
  /* Activo: solo cambia color (sin fondo azul que tape) */
  nav.lateral a.activo { background: transparent; color: var(--primary); }
  nav.lateral a.activo svg { stroke: var(--primary); }
  nav.lateral a:hover { background: transparent; }

  /* Botón "Más" visible solo en móvil */
  nav.lateral a.solo-movil { display: flex; }
  /* Los items "extra" no se muestran en la barra inferior (van en el panel "Más") */
  nav.lateral a.oculto-movil { display: none; }

  /* Panel desplegable "Más" (opciones que no caben abajo) */
  .mas-panel {
    position: fixed; bottom: 64px; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(16,24,40,.12);
    display: none; flex-direction: column; padding: 6px; z-index: 39;
  }
  .mas-panel.abierto { display: flex; }
  .mas-panel a {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    color: var(--text); font-size: 15px; border-radius: var(--radius); text-decoration: none;
  }
  .mas-panel a:hover { background: var(--bg); }
  .mas-panel a svg { width: 22px; height: 22px; stroke: var(--text-muted); }

  /* Métricas y formularios a una columna cómoda */
  .datos-grid { grid-template-columns: 1fr 1fr; }
  .fila > * { min-width: 100%; }
  .btn { padding: 12px 16px; font-size: 15px; }
  .botones-grandes button { padding: 16px 12px; font-size: 15px; }
}
