/* Portal de envíos: mismo aspecto que nuestro Panel de Pedidos (styles.css),
   con los colores y el logo de Vimasol. Sin fuentes ni recursos externos: la
   CSP del portal solo admite 'self'. */
:root {
  --font-heading: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;

  --color-page-bg: oklch(0.975 0.004 90);
  --color-dark-bg: oklch(0.18 0.015 260);
  --color-card-bg: white;
  --color-border: oklch(0.92 0.004 90);
  --color-border-row: oklch(0.94 0.004 90);
  --color-text: oklch(0.2 0.01 260);
  --color-text-soft: oklch(0.4 0.01 260);
  --color-text-muted: oklch(0.5 0.01 260);
  --color-error: oklch(0.55 0.16 25);

  --accent: oklch(0.62 0.17 45);          /* naranja Vimasol */
  --accent-hover: oklch(0.56 0.17 45);
  --accent-soft: oklch(0.96 0.03 45);
  --accent-petrol: oklch(0.58 0.19 25);
  --accent-aerofuel: oklch(0.55 0.13 235);

  --status-pendiente-bg: oklch(0.9 0.09 80);     --status-pendiente-fg: oklch(0.35 0.1 80);
  --status-preparacion-bg: oklch(0.9 0.05 250);  --status-preparacion-fg: oklch(0.4 0.12 250);
  --status-listo-bg: oklch(0.9 0.06 295);        --status-listo-fg: oklch(0.42 0.15 295);
  --status-parcial-bg: oklch(0.9 0.06 195);      --status-parcial-fg: oklch(0.4 0.09 200);
  --status-enviado-bg: oklch(0.88 0.1 150);      --status-enviado-fg: oklch(0.38 0.12 150);
  --status-incidencia-bg: oklch(0.9 0.08 25);    --status-incidencia-fg: oklch(0.45 0.17 25);
  --status-otro-bg: oklch(0.92 0.005 260);       --status-otro-fg: oklch(0.48 0.01 260);

  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px oklch(0.2 0.01 260 / 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body); background: var(--color-page-bg); color: var(--color-text);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-family: var(--font-heading); letter-spacing: -0.01em; }

/* --- Cabecera ------------------------------------------------------------ */
.cabecera {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 36px; background: oklch(0.985 0.003 90);
  border-bottom: 1px solid var(--color-border); border-top: 4px solid var(--accent);
  position: sticky; top: 0; z-index: 2;
}
.marca { display: flex; align-items: center; gap: 16px; color: inherit; }
.marca:hover { text-decoration: none; }
.marca img { height: 34px; width: auto; display: block; }
.marca-texto { display: flex; flex-direction: column; border-left: 1px solid var(--color-border); padding-left: 16px; }
.marca-titulo { font-family: var(--font-heading); font-weight: 800; font-size: 18px; color: var(--color-text); }
.marca-subtitulo { font-size: 12.5px; color: var(--color-text-muted); font-weight: 500; }
.salir { display: flex; gap: 12px; align-items: center; margin: 0; }
.usuario {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--color-text-soft);
}
.usuario::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--status-enviado-fg);
}

/* --- Botones ------------------------------------------------------------- */
button, .boton {
  display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: 9px;
  padding: 10px 16px; font: 600 14px var(--font-body); color: white; background: var(--accent);
  cursor: pointer; text-decoration: none;
}
button:hover, .boton:hover { background: var(--accent-hover); text-decoration: none; }
.salir button {
  padding: 7px 14px; font-size: 13px; color: var(--color-text-soft); background: white;
  border: 1px solid oklch(0.85 0.005 90); border-radius: var(--radius-sm);
}
.salir button:hover { background: oklch(0.97 0.003 90); }

/* --- Contenido ----------------------------------------------------------- */
.contenido { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 36px 48px; flex: 1; }
.titulo-seccion {
  display: flex; align-items: center; gap: 10px; margin: 0 0 14px;
  font-size: 19px; font-weight: 700;
}
.titulo-seccion + .tarjeta, .titulo-seccion + .tabla-tarjeta, .titulo-seccion + .vacio { margin-top: 0; }
.seccion + .seccion { margin-top: 32px; }
.cuenta {
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px;
  padding: 0 8px; border-radius: 100px; font: 700 12px var(--font-body);
  background: var(--accent-soft); color: var(--accent);
}
.tarjeta {
  background: var(--color-card-bg); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 22px 24px; margin-bottom: 20px;
}
.tarjeta h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 18px; font-size: 21px; }
.tarjeta h2 { margin: 0 0 14px; font-size: 16px; }
.volver { display: inline-block; margin-bottom: 16px; font-size: 13.5px; }
.aviso {
  padding: 10px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; margin-bottom: 16px;
  background: oklch(0.95 0.04 25); color: oklch(0.45 0.17 25); border: 1px solid oklch(0.88 0.06 25);
}
.vacio {
  margin: 0; padding: 18px 20px; font-size: 14px; color: var(--color-text-muted); font-style: italic;
  background: white; border: 1px dashed var(--color-border); border-radius: var(--radius-lg);
}

/* --- Tablas (como la lista de pedidos del panel) ------------------------- */
.tabla-tarjeta {
  background: white; border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); overflow-x: auto;
}
.envios { width: 100%; border-collapse: collapse; }
.envios th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: white; background: var(--accent); padding: 13px 14px; border-right: 1px solid oklch(1 0 0 / 0.3);
}
.envios th:first-child, .envios td:first-child { padding-left: 20px; }
.envios th:last-child, .envios td:last-child { padding-right: 20px; border-right: none; }
.envios td {
  padding: 14px; font-size: 13.5px; color: var(--color-text-soft); vertical-align: middle;
  border-top: 1px solid var(--color-border-row);
}
.envios tbody tr:hover td { background: oklch(0.985 0.006 45); }
.envios td.pedido { font-weight: 700; font-size: 14px; color: var(--color-text); white-space: nowrap; }
.envios td.fecha { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Empresa: su logo en pequeño (columna «Empresa» de «Todas» y detalle). */
.col-empresa { width: 1%; white-space: nowrap; vertical-align: middle; }
.logo-empresa { display: block; height: 22px; width: auto; max-width: 110px; object-fit: contain; object-position: left center; }
/* El de Petrol Components es casi cuadrado y con dos líneas: algo más alto para que se lea igual. */
.logo-empresa-petrol { height: 32px; }
.logo-empresa-vimasol, .logo-empresa-aerofuel { height: 20px; }
.datos .logo-empresa { height: 26px; max-width: 160px; }
.datos .logo-empresa-petrol { height: 40px; }

/* --- Filtros y ordenación ------------------------------------------------- */
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 22px; }
.filtros input, .filtros select {
  height: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid oklch(0.85 0.005 90);
  background: white; font: 14px var(--font-body); color: var(--color-text);
}
.filtros input:focus, .filtros select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.filtro-buscar { flex: 1 1 320px; }
.filtro-buscar input { width: 100%; }
.filtros button { height: 40px; }
.limpiar { font-size: 13.5px; }
.visualmente-oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.envios th a.ordenar { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.envios th a.ordenar:hover { text-decoration: underline; }
.flecha { font-size: 10px; opacity: 0.55; }
.envios th[aria-sort] .flecha { opacity: 1; }

/* --- Pestañas por empresa ------------------------------------------------ */
.pestanas {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 24px;
  border-bottom: 1px solid var(--color-border);
}
.pestana {
  --c: var(--color-dark-bg);
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px 11px; margin-bottom: -1px;
  font: 700 14px var(--font-body); color: var(--color-text-soft); text-decoration: none;
  border: 1px solid transparent; border-bottom: 3px solid transparent; border-radius: 10px 10px 0 0;
}
.pestana:hover { text-decoration: none; color: var(--c); background: color-mix(in oklch, var(--c) 6%, white); }
.pestana[aria-current="page"] { color: var(--c); background: white; border-color: var(--color-border); border-bottom: 3px solid var(--c); }
.pestana-cuenta {
  min-width: 22px; height: 20px; padding: 0 7px; border-radius: 100px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 11.5px; color: white; background: var(--c);
}
.pestana-vacia .pestana-cuenta { background: oklch(0.85 0.005 260); }
.pestana-vimasol { --c: var(--accent); }
.pestana-petrol { --c: var(--accent-petrol); }
.pestana-aerofuel { --c: var(--accent-aerofuel); }

/* La cabecera de las tablas toma el color de la empresa elegida; en «Todas», neutra. */
.vista-todas .envios th { background: var(--color-dark-bg); }
.vista-petrol .envios th { background: var(--accent-petrol); }
.vista-aerofuel .envios th { background: var(--accent-aerofuel); }
.vista-petrol .cuenta { background: color-mix(in oklch, var(--accent-petrol) 12%, white); color: var(--accent-petrol); }
.vista-aerofuel .cuenta { background: color-mix(in oklch, var(--accent-aerofuel) 12%, white); color: var(--accent-aerofuel); }
.vista-todas .cuenta { background: oklch(0.93 0.005 260); color: var(--color-text-soft); }
.sin-dato { color: var(--color-text-muted); font-style: italic; }
.tracking { color: var(--color-text-muted); font-size: 12px; margin-top: 6px; }
.descarga { white-space: nowrap; }

/* --- Estados (mismos colores que el panel) ------------------------------- */
.estado {
  display: inline-block; padding: 5px 12px; border-radius: 100px; font: 700 12px var(--font-body);
  white-space: nowrap; background: var(--status-otro-bg); color: var(--status-otro-fg);
}
.estado-pendiente { background: var(--status-pendiente-bg); color: var(--status-pendiente-fg); }
.estado-preparacion { background: var(--status-preparacion-bg); color: var(--status-preparacion-fg); }
.estado-listo { background: var(--status-listo-bg); color: var(--status-listo-fg); }
.estado-parcial { background: var(--status-parcial-bg); color: var(--status-parcial-fg); }
.estado-enviado { background: var(--status-enviado-bg); color: var(--status-enviado-fg); }
.estado-incidencia { background: var(--status-incidencia-bg); color: var(--status-incidencia-fg); }

/* --- Detalle ------------------------------------------------------------- */
.datos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 28px; margin: 0 0 20px; }
.datos div { min-width: 0; }
.datos dt {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-text-muted); margin-bottom: 4px;
}
.datos dd { margin: 0; font-size: 14px; color: var(--color-text); overflow-wrap: anywhere; }
.datos .ancho { grid-column: 1 / -1; }
.incidencia dd { color: var(--status-incidencia-fg); font-weight: 600; }
.pie-albaran { display: flex; align-items: center; gap: 12px; padding-top: 18px; border-top: 1px solid var(--color-border-row); }
.pie-albaran .vacio { padding: 0; border: 0; background: none; }

/* --- Login (como el del panel) ------------------------------------------- */
body.pantalla-login { background: var(--color-dark-bg); }
.pantalla-login .contenido { display: flex; align-items: center; justify-content: center; max-width: none; padding: 24px 16px; }
.login {
  background: white; border-radius: 18px; padding: 40px; width: 380px; max-width: 100%;
  display: flex; flex-direction: column; gap: 16px; box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
  border-top: 5px solid var(--accent);
}
.login-logo { display: block; width: 190px; max-width: 70%; height: auto; margin: 0 auto 4px; }
.login h1 { margin: 0; text-align: center; font-size: 20px; font-weight: 700; }
.login-texto { margin: -8px 0 4px; text-align: center; font-size: 13px; color: var(--color-text-muted); }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.login input {
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid oklch(0.85 0.005 90);
  font: 14px var(--font-body); color: var(--color-text);
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.login button { justify-content: center; margin-top: 4px; padding: 11px 16px; }
.pantalla-login .aviso { width: 380px; max-width: 100%; }
.pantalla-login .contenido { flex-direction: column; }

.pie { padding: 14px 36px; font-size: 12px; color: var(--color-text-muted); text-align: center; }
.pantalla-login .pie { color: oklch(0.6 0.01 260); }

@media (max-width: 760px) {
  .cabecera { padding: 12px 16px; }
  .marca img { height: 26px; }
  .marca-texto { display: none; }
  .contenido { padding: 20px 16px 40px; }
  .datos { grid-template-columns: 1fr; }
  .envios thead { display: none; }
  .envios tr { display: block; border-top: 1px solid var(--color-border-row); padding: 10px 0; }
  .envios td { display: block; border: 0; padding: 3px 16px; }
  .envios td:first-child, .envios td:last-child { padding-left: 16px; padding-right: 16px; }
}
