/* Extranet de clientes — estilo "membrete corporativo" CARCABA.
   Claro/premium, calcado de los documentos PDF (azul #0B5FA5). Sin build ni
   dependencias. TODO el estilo vive aquí: la CSP del DMZ es `style-src 'self'`
   (sin unsafe-inline), así que los atributos style="" en el HTML se ignoran. */

:root {
  /* Paleta corporativa (misma que los PDF de carta de porte / CMR) */
  --brand: #0B5FA5;
  --brand-dark: #084A82;
  --brand-accent: #0EA5E9;
  --red: #E2342B;            /* rojo del emblema, uso muy puntual */
  --ink: #0F172A;
  --muted: #64748B;
  --muted-2: #94A3B8;
  --surface: #F4F7FB;        /* fondo de página */
  --surface-2: #EEF3F9;      /* cabeceras de tabla / fills sutiles */
  --card: #FFFFFF;
  --line: #E2E8F0;
  --line-strong: #CBD8E6;
  --ok: #15835A;
  --ok-bg: #E7F6EF;
  --go: #0B5FA5;
  --go-bg: #E8F1FB;
  --warn: #9A6512;
  --warn-bg: #FBF1DF;
  --danger: #B4231A;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 28px -16px rgba(11, 95, 165, .28);
  --shadow-lg: 0 24px 60px -24px rgba(11, 95, 165, .35), 0 2px 6px rgba(15, 23, 42, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --ring: 0 0 0 3px rgba(11, 95, 165, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: .15rem .4rem; border-radius: 6px; font-size: .85em; letter-spacing: .04em;
}

/* El logo de Carcaba trae fondo BLANCO opaco. `multiply` funde ese blanco con
   el color (claro) de cada superficie, así el logo se integra sin caja blanca
   sobre el fondo de la pantalla, la cabecera, el splash o el membrete. */
.brand-logo, .auth-logo, .splash-logo, .doc-head img { mix-blend-mode: multiply; }

/* ── Pantalla de carga ─────────────────────────────────────────────────── */
.loading {
  min-height: 100vh; display: grid; place-items: center; gap: 1.4rem;
  color: var(--muted); letter-spacing: .16em; font-size: .76rem; font-weight: 600;
}
.splash-logo { width: 220px; max-width: 64%; height: auto; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cabecera (sesión iniciada) ────────────────────────────────────────── */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1.5rem;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
/* Filo de membrete: línea azul→turquesa bajo la cabecera */
header.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--brand-accent) 60%, transparent);
}
.brand { display: inline-flex; align-items: center; gap: .8rem; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-sub {
  color: var(--muted); font-size: .72rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  padding-left: .8rem; border-left: 1px solid var(--line);
}
.topnav { display: flex; gap: 1.6rem; margin-left: auto; }
.topnav a {
  position: relative; color: var(--muted); font-weight: 600;
  font-size: .78rem; letter-spacing: .08em; padding: .35rem 0;
}
.topnav a:hover { color: var(--brand); text-decoration: none; }
.topnav a.active { color: var(--ink); }
.topnav a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -.2rem; height: 2px;
  border-radius: 2px; background: var(--brand);
}
.topright { display: flex; align-items: center; gap: 1rem; flex: 0 0 auto; }
.who {
  color: var(--ink); font-size: .8rem; font-weight: 600; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
main {
  max-width: 1040px; margin: 0 auto; padding: 2rem 1.5rem 4rem;
  animation: rise .45s ease both;
}
main > * { animation: rise .5s ease both; }
main > *:nth-child(2) { animation-delay: .05s; }
main > *:nth-child(3) { animation-delay: .1s; }
main > *:nth-child(4) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, .page-title {
  font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em;
  margin: 0 0 1.2rem; color: var(--ink);
}
h2, .section-title {
  font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 1.8rem 0 .7rem;
}
.muted { color: var(--muted); }

/* ── Botones ───────────────────────────────────────────────────────────── */
button { font: inherit; cursor: pointer; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--brand); color: #fff; border: 1px solid var(--brand-dark);
  font-weight: 600; letter-spacing: .04em; padding: .65rem 1.2rem;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.btn-primary, .btn-primary:hover { text-decoration: none; }
.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn-block { width: 100%; margin-top: .4rem; }

.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  font-weight: 600; font-size: .76rem; letter-spacing: .06em;
  padding: .45rem .8rem; border-radius: 999px; transition: all .15s ease;
}
.btn-ghost:hover { color: var(--brand); border-color: var(--line-strong); background: var(--card); }

.btn-back {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--card); color: var(--brand); border: 1px solid var(--line);
  font-weight: 600; font-size: .8rem; letter-spacing: .03em;
  padding: .45rem .9rem; border-radius: 999px; box-shadow: var(--shadow-sm);
  transition: all .15s ease;
}
.btn-back:hover { border-color: var(--line-strong); transform: translateX(-2px); }

.btn-link {
  background: none; border: none; color: var(--brand); font-weight: 600;
  letter-spacing: .03em; padding: .2rem .1rem; border-radius: 6px;
}
.btn-link:hover { color: var(--brand-dark); text-decoration: underline; }

/* ── Login / set-password ──────────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(900px 480px at 50% -10%, rgba(14, 165, 233, .12), transparent 60%),
    radial-gradient(700px 500px at 85% 110%, rgba(11, 95, 165, .10), transparent 60%),
    var(--surface);
}
.auth-card {
  position: relative; width: 380px; max-width: 100%;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 2.2rem 2rem 1.6rem;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise .5s ease both;
}
/* Filo superior del "membrete": azul corporativo con remate rojo del emblema */
.auth-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand) 0 70%, var(--red) 70% 100%);
}
.auth-head { text-align: center; margin-bottom: 1.6rem; }
.auth-logo { width: 220px; max-width: 80%; height: auto; }
.auth-tagline {
  margin: .9rem 0 0; color: var(--muted); font-size: .72rem;
  font-weight: 700; letter-spacing: .22em; text-transform: uppercase;
}
.auth-form { display: block; }
.auth-foot {
  margin: 1.6rem 0 0; text-align: center; color: var(--muted-2);
  font-size: .64rem; font-weight: 600; letter-spacing: .16em;
}
.auth-note { text-align: center; color: var(--muted); margin: -.4rem 0 .6rem; font-size: .82rem; }

label {
  display: block; font-size: .72rem; color: var(--muted); font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; margin: .9rem 0 .3rem;
}
input {
  width: 100%; padding: .65rem .75rem; background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  color: var(--ink); font: inherit; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.error { color: var(--danger); font-size: .82rem; margin-top: .8rem; min-height: 1rem; font-weight: 500; }
.hidden { display: none; }

/* ── Tarjetas / tablas ─────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-pad { padding: 1.3rem 1.4rem; }
.card + .card { margin-top: 1rem; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
thead th {
  text-align: left; padding: .7rem 1rem; background: var(--surface-2);
  color: var(--muted); font-size: .68rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr[data-id], tbody tr.clickable { cursor: pointer; }
tbody tr[data-id]:hover, tbody tr.clickable:hover { background: var(--go-bg); }
.num { text-align: right; }
.empty { padding: 2.6rem 1rem; text-align: center; color: var(--muted); letter-spacing: .06em; font-size: .85rem; }

/* Tabla con scroll horizontal en móvil */
.card { -webkit-overflow-scrolling: touch; }
@media (max-width: 640px) { .card > table { display: block; overflow-x: auto; white-space: nowrap; } }

/* ── Badges de estado ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .2rem .6rem .2rem .55rem; border-radius: 999px;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: #BCE6D2; }
.badge.go { color: var(--go); background: var(--go-bg); border-color: #C7DDF4; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: #F0DDB4; }

/* ── Detalle (clave / valor) ───────────────────────────────────────────── */
.detail-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 2rem;
}
.detail-grid .k {
  color: var(--muted); font-size: .68rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; margin-bottom: .2rem;
}
.detail-grid .v { font-weight: 600; color: var(--ink); }
.mercancia { margin-top: 1.3rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }

.toolbar { display: flex; gap: .7rem; align-items: center; margin-bottom: 1.2rem; }

/* ── Documento público (carta de porte) — membrete oficial ─────────────── */
.pubwrap { max-width: 760px; margin: 2.5rem auto; padding: 0 1.2rem; }
.doc-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise .5s ease both;
}
.doc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.3rem 1.6rem; background: var(--surface-2); border-bottom: 2px solid var(--brand);
}
.doc-head img { height: 38px; width: auto; }
.doc-head .doc-kicker {
  color: var(--brand-dark); font-size: .72rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; text-align: right;
}
.doc-body { padding: 1.6rem; }
.doc-body h1 { font-size: 1.15rem; margin: 0 0 1.2rem; }
.doc-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem;
}
.doc-titlebar h1 { margin: 0; }
.doc-foot {
  margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .72rem; letter-spacing: .06em;
}

/* ── Seguridad (MFA) ───────────────────────────────────────────────────── */
.narrow { max-width: 560px; }
.tight { margin-top: 0; }
.mfa-secret { display: block; margin: .4rem 0; font-size: 1rem; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  header.top { flex-wrap: wrap; gap: .8rem 1.2rem; padding: .7rem 1rem; }
  .topnav { order: 3; width: 100%; margin-left: 0; gap: 1.3rem; }
  .brand-sub { display: none; }
  .detail-grid { grid-template-columns: 1fr; gap: .9rem; }
  main { padding: 1.4rem 1rem 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, main, main > *, .auth-card, .doc-card { animation: none !important; transition: none !important; }
}
