/* ============================================================
   Verificador de Remisiones — sistema de diseño
   Registro product · tema claro papel · acento teal · tríada semántica
   ============================================================ */

:root {
  /* superficies / neutros cálidos (papel) */
  --bg:            oklch(0.985 0.004 85);
  --surface:       oklch(0.997 0.003 85);
  --surface-2:     oklch(0.966 0.006 85);
  --surface-3:     oklch(0.945 0.007 85);
  --border:        oklch(0.905 0.006 85);
  --border-strong: oklch(0.84 0.008 80);

  /* texto */
  --ink:    oklch(0.27 0.012 75);
  --ink-2:  oklch(0.44 0.012 75);
  --ink-3:  oklch(0.58 0.012 75);

  /* acento (acción / foco) — teal/petróleo, distinto de la tríada */
  --accent:      oklch(0.55 0.085 205);
  --accent-ink:  oklch(0.40 0.09 205);
  --accent-soft: oklch(0.95 0.025 205);
  --accent-ring: oklch(0.62 0.10 205 / 0.45);

  /* tríada semántica */
  --ok:        oklch(0.50 0.12 150);
  --ok-bg:     oklch(0.965 0.038 150);
  --ok-border: oklch(0.88 0.06 150);
  --err:        oklch(0.52 0.17 25);
  --err-bg:     oklch(0.965 0.042 25);
  --err-border: oklch(0.87 0.07 25);
  --warn:        oklch(0.55 0.10 75);
  --warn-bg:     oklch(0.955 0.05 80);
  --warn-border: oklch(0.86 0.07 80);

  --radius:   10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px oklch(0.4 0.02 75 / 0.06), 0 1px 1px oklch(0.4 0.02 75 / 0.04);
  --shadow-2: 0 4px 16px oklch(0.4 0.02 75 / 0.08), 0 1px 3px oklch(0.4 0.02 75 / 0.06);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1); /* ease-out-quint */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num  { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--accent); color: var(--surface);
  display: grid; place-items: center; font-weight: 600; font-size: 15px;
  box-shadow: var(--shadow-1);
}
.brand .name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; line-height: 1.15; }
.brand .name small { display: block; font-weight: 400; color: var(--ink-3); font-size: 11px; }

.nav-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); padding: 14px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500; font-size: 13.5px;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-1); }
.nav-item .ico { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.sidebar .spacer { flex: 1; }
.sidebar .user { font-size: 12px; color: var(--ink-3); padding: 10px 8px 0; border-top: 1px solid var(--border); }
.sidebar .user a { color: var(--ink-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.topbar .crumb { color: var(--ink-3); font-weight: 400; }
.content { padding: 28px; max-width: 1240px; width: 100%; }
.content.wide { max-width: none; }

/* ---------- Typography bits ---------- */
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); margin: 0 0 12px; }
.muted { color: var(--ink-3); }
.lead { color: var(--ink-2); max-width: 70ch; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-weight: 500; font-size: 13.5px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: background 140ms var(--ease), border-color 140ms var(--ease), box-shadow 140ms var(--ease), transform 60ms var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn-primary { background: var(--accent); color: var(--surface); }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--err-bg); color: var(--err); border-color: var(--err-border); }
.btn-danger:hover { background: oklch(0.94 0.06 25); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.input, .select, select, input[type=text], input[type=email], input[type=password], input[type=number] {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink);
  padding: 9px 11px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.input:focus, select:focus, input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
.input.num { text-align: right; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* ---------- Cards / panels (usados con criterio, no en rejilla) ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.panel-pad { padding: 20px 22px; }
.panel + .panel { margin-top: 18px; }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 9px 3px 7px; border-radius: 100px;
  border: 1px solid transparent; line-height: 1.4;
}
.pill .dot { width: 7px; height: 7px; border-radius: 100px; background: currentColor; flex: none; }
.pill-ok   { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-border); }
.pill-err  { color: var(--err);  background: var(--err-bg);  border-color: var(--err-border); }
.pill-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.pill-neutral { color: var(--ink-2); background: var(--surface-3); border-color: var(--border); }

/* ---------- Summary band (segmentada, no hero-metric) ---------- */
.summary {
  display: flex; align-items: stretch; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-1); overflow: hidden; margin-bottom: 20px;
}
.summary .seg { padding: 14px 20px; border-right: 1px solid var(--border); }
.summary .seg:last-child { border-right: none; }
.summary .seg .k { font-size: 11.5px; color: var(--ink-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
.summary .seg .v { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.summary .seg.grow { flex: 1; }
.summary .seg.ok .v   { color: var(--ok); }
.summary .seg.err .v  { color: var(--err); }
.summary .seg.warn .v { color: var(--warn); }
.summary .corte { display: flex; flex-direction: column; justify-content: center; background: var(--surface-2); }
.summary .corte .range { font-family: var(--mono); font-size: 13px; color: var(--ink); }

/* ---------- Filters (segmented control) ---------- */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.segmented button {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink-2);
  background: transparent; border: none; cursor: pointer; padding: 5px 12px; border-radius: 5px;
  display: inline-flex; align-items: center; gap: 7px; transition: background 140ms var(--ease), color 140ms var(--ease);
}
.segmented button .count { font-size: 11px; font-variant-numeric: tabular-nums; opacity: 0.75; }
.segmented button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.spacer-x { flex: 1; }

/* ---------- Tables (densas, header sticky) ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data thead th.r, table.data td.r { text-align: right; }
table.data tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background 120ms var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.is-error { background: oklch(0.985 0.02 25); }
table.data tbody tr.is-error:hover { background: oklch(0.975 0.03 25); }
td .sku { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
td .folio { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
td .article { color: var(--ink-3); font-size: 12px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td .money { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td .diff-neg { color: var(--err); font-weight: 600; }
td .reason { color: var(--ink-2); font-size: 12.5px; }
tr[hidden] { display: none; }

/* detalle expandible de fila */
.detail-row td { background: var(--surface-2); padding: 0; }
.detail-box { padding: 14px 18px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.breakdown { font-size: 12.5px; }
.breakdown .ln { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.breakdown .ln:last-child { border-bottom: none; font-weight: 600; }
.breakdown .ln .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.causes { font-size: 12.5px; }
.causes h4 { margin: 0 0 6px; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.03em; }
.causes ul { margin: 0; padding-left: 16px; color: var(--ink-2); }
.causes li { margin: 3px 0; }

/* ---------- Celdas editables en línea (catálogo) ---------- */
input.cell-edit {
  width: 74px; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 12px; padding: 3px 6px; border: 1px solid transparent; border-radius: 5px;
  background: transparent; color: var(--ink);
  transition: border-color 120ms var(--ease), background 120ms var(--ease), box-shadow 120ms var(--ease);
}
input.cell-edit::placeholder { font-size: 11px; color: var(--ink-3); }
input.cell-edit:hover  { border-color: var(--border-strong); background: var(--surface); }
input.cell-edit:focus  { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-ring); }
input.cell-edit.promo:not(:placeholder-shown) { color: var(--ok); font-weight: 600; }
input.cell-edit.saving { opacity: .55; }
input.cell-edit.saved  { border-color: var(--ok-border);  background: var(--ok-bg); }
input.cell-edit.err    { border-color: var(--err-border); background: var(--err-bg); }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); padding: 40px 24px; text-align: center;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font-size: 15px; font-weight: 600; color: var(--ink); }
.dropzone .hint { color: var(--ink-3); margin-top: 5px; font-size: 13px; }
.dropzone .file { margin-top: 12px; font-family: var(--mono); font-size: 13px; color: var(--accent-ink); }

/* ---------- Flash ---------- */
.flash { display: flex; align-items: center; gap: 10px; padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px; border: 1px solid transparent; }
.flash-ok   { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.flash-err  { background: var(--err-bg); color: var(--err); border-color: var(--err-border); }
.flash-info { background: var(--accent-soft); color: var(--accent-ink); border-color: oklch(0.86 0.05 205); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 24px; color: var(--ink-3); }
.empty .icon { width: 40px; height: 40px; margin: 0 auto 14px; color: var(--border-strong); }
.empty h3 { color: var(--ink); font-size: 16px; margin: 0 0 6px; font-weight: 600; }
.empty p { margin: 0 auto 16px; max-width: 44ch; }

/* ---------- Misc ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; font-size: 13.5px; max-width: 64ch; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.tag { font-size: 11.5px; font-family: var(--mono); color: var(--ink-2); background: var(--surface-3); padding: 2px 7px; border-radius: 5px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(120% 80% at 50% -10%, var(--accent-soft), transparent 60%), var(--bg); padding: 24px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-2); padding: 30px 28px; }
.login-card .brand { padding: 0 0 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .spacer, .sidebar .nav-label { display: none; }
  .sidebar .user { border-top: none; padding: 0; }
  .nav-item { padding: 7px 10px; }
  .detail-box { grid-template-columns: 1fr; }
  .content { padding: 18px; }
}
