/* EP International · Portal de clientes
   Paleta: asfalto, papel frío, acero, mar y amarillo de señalización vial. Tipografía: Archivo (eje de anchura). */
:root {
  --asphalt: #1E2328;
  --asphalt-2: #2B3239;
  --paper: #F6F7F5;
  --white: #FFFFFF;
  --steel: #5B6670;
  --line: #D9DEE2;
  --line-soft: #E8EBEE;
  --sea: #1F5F8B;
  --sea-dark: #174A6C;
  --signal: #F2B705;
  --signal-soft: #FFF4CC;
  --green: #2E7D4F;
  --red: #B3261E;
  --amber: #A86500;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--asphalt);
  font: 400 15px/1.5 var(--font); font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--sea); text-underline-offset: 2px; }
a:hover { color: var(--sea-dark); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
h1 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 760; font-stretch: 112%; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 12px; }
.num, td.n, th.n, .code { font-variant-numeric: tabular-nums; }
.code { letter-spacing: 0.02em; font-weight: 550; }
.muted { color: var(--steel); }
.strong { font-weight: 700; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.visually-hidden { position: absolute !important; left: 0 !important; top: 0 !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; border: 0 !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--signal); color: var(--asphalt); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- Barra superior ---------- */
.topbar { background: var(--asphalt); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); display: flex; align-items: center; gap: 22px; min-height: 60px; flex-wrap: wrap; }
.wordmark { display: inline-flex; align-items: baseline; gap: 6px; color: inherit; text-decoration: none; }
.wordmark:hover { color: inherit; }
.wm-ep { font-weight: 800; font-stretch: 125%; font-size: 21px; letter-spacing: 0.02em; padding: 0 6px; background: var(--signal); color: var(--asphalt); border-radius: 2px; }
.wm-rest { font-weight: 500; font-stretch: 88%; font-size: 15px; opacity: .9; }
.who { color: #AEB7BF; font-size: 14px; border-left: 1px solid #47505A; padding-left: 16px; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a { color: #D8DDE1; text-decoration: none; padding: 8px 12px; border-radius: var(--radius-s); font-weight: 550; display: inline-flex; gap: 6px; align-items: center; }
.nav a:hover { background: var(--asphalt-2); color: #fff; }
.nav a.active { color: #fff; box-shadow: inset 0 -3px 0 var(--signal); border-radius: 0; }
.topbar-end { display: flex; align-items: center; gap: 10px; }
.badge { background: var(--signal); color: var(--asphalt); font-size: 12px; font-weight: 700; border-radius: 10px; padding: 1px 7px; }

/* ---------- Contenido ---------- */
.content { max-width: 1180px; margin: 0 auto; padding: 28px var(--gutter) 80px; outline: none; }
.page-head { margin: 4px 0 24px; }
.page-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.page-head .sub { color: var(--steel); margin: 6px 0 0; }
.back { display: inline-block; margin-bottom: 8px; font-size: 14px; color: var(--steel); text-decoration: none; }
.back::before { content: '‹ '; }
.back:hover { color: var(--asphalt); }
.block { position: relative; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 22px clamp(16px, 2.5vw, 26px); margin: 18px 0; }
.block.internal { background: #FBFAF4; border-color: #E9E3C8; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.block-head h2 { margin: 0; }
.empty { color: var(--steel); margin: 4px 0; }
.empty.big { font-size: 17px; padding: 40px 0; }
.hint { color: var(--steel); font-size: 13px; }
.notice { background: var(--signal-soft); border-left: 4px solid var(--signal); padding: 12px 16px; border-radius: var(--radius-s); margin: 12px 0 18px; }
.notice summary { cursor: pointer; font-weight: 600; }
.notice-error { background: #FBEAE8; border-left-color: var(--red); }
.tag { display: inline-block; font-size: 12px; color: var(--steel); border: 1px solid var(--line); border-radius: 3px; padding: 0 6px; margin-left: 6px; white-space: nowrap; background: var(--white); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--white); border-radius: 14px; padding: 3px 10px; font-size: 13px; text-decoration: none; color: var(--asphalt); }
.chip:hover { border-color: var(--sea); color: var(--sea); }

/* ---------- Estado ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 3px; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-planned { color: var(--steel); background: #EEF0F2; }
.pill-loading { color: var(--amber); background: #FFF1D9; }
.pill-loaded { color: #6B4E00; background: var(--signal-soft); }
.pill-in_transit { color: var(--sea); background: #E3EEF6; }
.pill-arrived, .pill-delivered { color: var(--green); background: #E3F2E9; }
.pill-cancelled { color: var(--red); background: #FBEAE8; text-decoration: line-through; }

/* ---------- Lista de pedidos (cliente) ---------- */
.order-list, .ship-list, .client-list, .docs, .thread, .plain-list, .events, .warnings { list-style: none; margin: 0; padding: 0; }
.order-list { border-top: 2px solid var(--asphalt); }
.order-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(160px, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: center; padding: 18px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.order-row:hover { background: var(--white); color: inherit; }
.order-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.order-no { font-size: 24px; font-weight: 780; font-stretch: 118%; font-variant-numeric: tabular-nums; }
.order-products { color: var(--steel); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-progress { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.small { font-size: 13px; }
.order-progress .minibar { flex: 1; }
.order-ships { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ship-chip { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: inherit; }
.ship-chip .code { font-weight: 700; font-size: 13px; }
.minibar { position: relative; height: 8px; background: var(--line-soft); border-radius: 2px; overflow: hidden; min-width: 90px; }
.minibar span { position: absolute; left: 0; top: 0; bottom: 0; }
.mb-produced { background: #9FB4C4; }
.mb-loaded { background: var(--asphalt); }

/* ---------- Producción ---------- */
.lines { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px 32px; }
.line h3 { margin-bottom: 10px; }
.progress { margin-bottom: 10px; }
.progress-top { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--steel); margin-bottom: 4px; }
.progress-top .num { color: var(--asphalt); font-weight: 600; }
.bar { height: 10px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--asphalt); }

/* ---------- La ruta (elemento distintivo) ---------- */
.route { display: grid; grid-template-columns: minmax(110px, auto) 1fr minmax(110px, auto); align-items: start; gap: 18px; margin: 10px 0 6px; }
.port { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.port-to { text-align: right; }
.port-name { font-weight: 750; font-stretch: 110%; font-size: 17px; }
.port-date { font-size: 13px; color: var(--steel); font-variant-numeric: tabular-nums; }
.stops { display: flex; justify-content: space-between; position: relative; padding: 0; margin: 0; list-style: none; }
.stops::before { /* la carretera */
  content: ''; position: absolute; left: 0; right: 0; top: 7px; height: 10px; border-radius: 2px;
  background: var(--asphalt);
}
.stops::after { /* marca vial discontinua */
  content: ''; position: absolute; left: 6px; right: 6px; top: 11px; height: 2px;
  background: repeating-linear-gradient(90deg, #E9ECEF 0 14px, transparent 14px 26px);
}
.stop { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 0 auto; min-width: 0; }
.stop .mark { width: 24px; height: 24px; border-radius: 3px; background: var(--white); border: 3px solid var(--asphalt); }
.stop.done .mark { background: var(--asphalt); border-color: var(--asphalt); box-shadow: inset 0 0 0 4px var(--white); }
.stop.current .mark { background: var(--signal); border-color: var(--asphalt); width: 30px; height: 30px; margin-top: -3px; transform: rotate(45deg); }
.stop-label { font-size: 12.5px; color: var(--steel); white-space: nowrap; }
.stop.current .stop-label { color: var(--asphalt); font-weight: 700; }
.route-cancelled .stops::before { background: #B7BEC4; }
.route-cancelled .stop .mark { border-color: #B7BEC4; }
.route-compact .stop .mark { width: 16px; height: 16px; border-width: 2px; }
.route-compact .stop.current .mark { width: 20px; height: 20px; }
.route-compact .stops::before { top: 4px; height: 8px; }
.route-compact .stops::after { top: 7px; }

/* ---------- Envíos ---------- */
.ship-list { display: flex; flex-direction: column; gap: 4px; }
.ship-row { display: block; padding: 16px 4px 12px; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: inherit; }
.ship-row:hover { background: var(--paper); color: inherit; }
.ship-row-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.ship-code { font-weight: 780; font-stretch: 118%; font-size: 18px; font-variant-numeric: tabular-nums; }
.ship-status { margin: -12px 0 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px 24px; margin: 0; }
.fact dt { font-size: 13px; color: var(--steel); }
.fact dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.big-code { font-size: 22px; letter-spacing: .06em; }
.notes { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.notes p { white-space: pre-wrap; max-width: 75ch; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 600; color: var(--steel); font-size: 13px; padding: 8px 10px; border-bottom: 2px solid var(--asphalt); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr:hover { background: #FAFBFA; }
table.data tfoot td, table.data tfoot th { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 700; color: var(--asphalt); padding-top: 10px; }
table.data .n { text-align: right; }
.orders-table td.products { color: var(--steel); max-width: 34ch; }
.orders-table .ship-chip { margin: 2px 8px 2px 0; }
.row-actions { text-align: right; white-space: nowrap; }

/* ---------- Documentos ---------- */
.docs { display: flex; flex-direction: column; }
.doc { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.doc:last-child { border-bottom: 0; }
.doc-internal { background: repeating-linear-gradient(135deg, transparent 0 10px, #FAF7EA 10px 20px); }
.file-badge { flex: 0 0 auto; width: 40px; height: 46px; border: 2px solid var(--asphalt); border-radius: 2px 10px 2px 2px; display: grid; place-items: end center; padding-bottom: 5px; font-size: 10.5px; font-weight: 800; font-stretch: 80%; }
.doc-main { flex: 1 1 220px; display: flex; flex-direction: column; min-width: 0; }
.doc-title { font-weight: 600; overflow-wrap: anywhere; }
.doc-meta { font-size: 13px; color: var(--steel); }
.doc-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

/* ---------- Tracking ---------- */
.events { border-left: 3px solid var(--asphalt); margin: 12px 0 0 6px; padding-left: 16px; }
.event { position: relative; padding: 4px 0 10px; display: flex; gap: 12px; flex-wrap: wrap; }
.event::before { content: ''; position: absolute; left: -23px; top: 9px; width: 11px; height: 11px; background: var(--white); border: 3px solid var(--asphalt); }
.event:first-child::before { background: var(--signal); }
.event time { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 110px; }
.event-loc { color: var(--steel); }
.event-est time { font-weight: 400; color: var(--steel); }

/* ---------- Mensajes ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; max-width: 760px; }
.msg { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 14px; max-width: 85%; }
.msg-mine { align-self: flex-end; background: #EEF3F7; border-color: #D3E0EA; }
.msg-meta { font-size: 13px; color: var(--steel); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.msg-meta strong { color: var(--asphalt); }
.msg-ship { font-weight: 600; color: var(--sea); }
.msg-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { max-width: 760px; }

/* ---------- Clientes ---------- */
.client-list { border-top: 2px solid var(--asphalt); }
.client-row { display: flex; align-items: center; gap: 16px; padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; flex-wrap: wrap; }
.client-row:hover { background: var(--white); color: inherit; }
.client-row .badge { margin-left: auto; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field label { font-size: 13.5px; font-weight: 600; }
.field small { color: var(--steel); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=file], select, textarea {
  font: inherit; color: inherit; background: var(--white); border: 1px solid #C4CBD1; border-radius: var(--radius-s); padding: 9px 11px; width: 100%; min-width: 0;
}
input[type=file] { padding: 7px; }
select[multiple] { padding: 4px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sea); outline-offset: 0; border-color: var(--sea); }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--asphalt); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 18px; }
.narrow-form { max-width: 520px; }
.inline-form, .upload-form { display: flex; flex-wrap: wrap; gap: 0 14px; align-items: flex-end; margin: 14px 0 6px; padding-top: 14px; border-top: 1px dashed var(--line); }
.inline-form .field, .upload-form .field { flex: 1 1 180px; }
.inline-form .check, .upload-form .check { margin-bottom: 22px; }
.inline-form .btn, .upload-form .btn { margin-bottom: 14px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }
.form-error { color: var(--red); font-weight: 600; min-height: 1px; }
.form-error:empty { display: none; }
.toolbar { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 2 1 260px; }
.toolbar select { flex: 1 1 200px; width: auto; }

/* ---------- Botones ---------- */
.btn { font: inherit; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: var(--radius-s); border: 1px solid transparent; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--asphalt); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--asphalt-2); color: #fff; }
.btn-line { background: var(--white); color: var(--asphalt); border-color: var(--asphalt); }
.btn-line:hover { background: var(--asphalt); color: #fff; }
.btn-quiet { background: transparent; color: var(--sea); padding: 6px 10px; }
.btn-quiet:hover { background: #E8F0F6; }
.btn-ghost { background: transparent; color: #D8DDE1; border-color: #47505A; padding: 6px 12px; }
.btn-ghost:hover { color: #fff; border-color: #fff; }
.btn-danger { color: var(--red); }
.btn.btn-danger:not(.btn-quiet) { background: var(--red); color: #fff; }
.btn-block { width: 100%; padding: 12px; }
.icon-btn { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--steel); padding: 2px 8px; }

/* ---------- Idioma ---------- */
.lang { display: inline-flex; border: 1px solid #47505A; border-radius: var(--radius-s); overflow: hidden; }
.lang-btn { background: transparent; border: 0; color: #AEB7BF; font: inherit; font-size: 12.5px; font-weight: 700; padding: 5px 9px; cursor: pointer; }
.lang-btn.active { background: var(--signal); color: var(--asphalt); }
.login .lang { border-color: var(--line); margin-top: 28px; align-self: flex-start; }
.login .lang-btn { color: var(--steel); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 480px) 1fr; }
.login-panel { background: var(--white); padding: clamp(32px, 7vh, 80px) clamp(24px, 5vw, 56px); display: flex; flex-direction: column; justify-content: center; }
.login-panel .wordmark { color: var(--asphalt); margin-bottom: 48px; }
.login-panel h1 { margin-bottom: 6px; }
.login-panel .sub { color: var(--steel); margin-bottom: 28px; }
.login-art { background: var(--asphalt); position: relative; overflow: hidden; }
.road { position: absolute; left: -10%; right: -10%; top: 58%; height: 22px; transform: rotate(-8deg);
  background: repeating-linear-gradient(90deg, var(--signal) 0 90px, transparent 90px 150px); }
.road::before, .road::after { content: ''; position: absolute; left: 0; right: 0; height: 3px; background: #4A535C; }
.road::before { top: -80px; } .road::after { bottom: -80px; }

/* ---------- Modal, avisos, carga ---------- */
.modal { border: 0; border-radius: var(--radius-m); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(30, 35, 40, .35); }
.modal-wide { width: min(1000px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(30, 35, 40, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--white); z-index: 1; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px 22px 22px; }
.modal-body h3 { margin: 20px 0 10px; }
.warnings { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.warnings li { display: flex; gap: 10px; align-items: baseline; font-size: 14px; }
.w-level { flex: 0 0 64px; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 3px; text-align: center; }
.w-error .w-level { background: #FBEAE8; color: var(--red); }
.w-warning .w-level { background: var(--signal-soft); color: #6B4E00; }
.w-info .w-level { background: #EEF0F2; color: var(--steel); }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(480px, calc(100vw - 32px)); }
.toast { background: var(--asphalt); color: #fff; padding: 11px 16px; border-radius: var(--radius-s); border-left: 5px solid var(--signal); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast-error { border-left-color: #FF6B5E; }
.loading { display: flex; gap: 6px; padding: 40px 0; justify-content: center; }
.loading .dot { width: 10px; height: 10px; background: var(--asphalt); animation: blink 1s infinite ease-in-out; }
.loading .dot:nth-child(2) { animation-delay: .15s; } .loading .dot:nth-child(3) { animation-delay: .3s; background: var(--signal); }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.content > .loading:not(:only-child) { display: none; }
.boot { min-height: 100vh; display: grid; place-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .order-row { grid-template-columns: 1fr; gap: 10px; }
  .order-ships { justify-content: flex-start; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .who { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar-inner { gap: 8px 12px; padding-top: 8px; padding-bottom: 6px; }
  .nav { order: 3; width: 100%; margin: 0 -8px; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { padding: 8px 10px; white-space: nowrap; }
  .topbar-end { margin-left: auto; }
  .route { grid-template-columns: 1fr 1fr; }
  .route .stops { grid-column: 1 / -1; grid-row: 2; }
  .stop-label { display: none; }
  .stop.current .stop-label { display: block; position: absolute; top: 34px; left: 50%; transform: translateX(-50%); white-space: nowrap; }
  .route .stops { margin-bottom: 22px; }
  .msg { max-width: 100%; }
  .facts { grid-template-columns: 1fr 1fr; gap: 14px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
