/* Manza AmzAdsIA · estilos propios (sin build) */
:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #f9fafc;
  --line: #e4e7ee;
  --text: #182033;
  --muted: #667085;
  --brand: #ff9900;
  --brand-ink: #b46a00;
  --accent: #2f5bea;
  --good: #12805c;
  --good-bg: #e6f6ef;
  --bad: #c2312b;
  --bad-bg: #fdecea;
  --warn: #a15c00;
  --warn-bg: #fff4e0;
  --info-bg: #eaf0ff;
  --side: #121a2c;
  --side-ink: #c9d1e3;
  --side-active: #1f2a44;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Series de los gráficos, siempre en este orden (paleta validada para daltonismo) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  --grid: #e9ecf2;
  --axis: #c9ced8;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1320;
  --panel: #161d2e;
  --panel-2: #1b2336;
  --line: #283149;
  --text: #e6eaf3;
  --muted: #97a1b8;
  --accent: #7d9bff;
  --good: #43c08f;
  --good-bg: #133227;
  --bad: #ff7b72;
  --bad-bg: #3a1b1b;
  --warn: #f2b45a;
  --warn-bg: #3a2a12;
  --info-bg: #1b2747;
  --side: #0a0f1a;
  --side-active: #1a2337;
  --shadow: none;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --grid: #222a3e;
  --axis: #36405a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.45 var(--sans);
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[x-cloak] { display: none !important; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* --- layout --- */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
a.logo:hover { text-decoration: none; }
.app-logo { width: 138px; height: 36px; display: block; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--side-ink); font-weight: 500;
}
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav .sep { height: 1px; background: #24304b; margin: 10px 6px; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.sidebar .foot { margin-top: auto; font-size: 12px; color: #8d97ad; padding: 8px; }
.sidebar .foot form { display: inline; }
.sidebar .foot button { background: none; border: 0; color: #c9d1e3; cursor: pointer; padding: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 24px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.topbar h1 { font-size: 18px; }
.topbar .spacer { margin-right: auto; }
.demo-pill .short { display: none; }
.demo-pill { font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--info-bg); border-radius: 999px;
  padding: 2px 9px; cursor: help; }
.menu-toggle { display: none; }
.content { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 18px; }

.mp-switch { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; }
.mp-switch a { padding: 4px 11px; border-radius: 999px; color: var(--text); font-weight: 600;
  font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.mp-switch a:hover { text-decoration: none; background: var(--line); }
.mp-switch a.active { background: var(--text); color: var(--panel); }
.ccy-switch a { font-size: 12px; padding: 4px 9px; }
.fx-badge { font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.theme-toggle { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); color: var(--text); cursor: pointer; }
.theme-toggle:hover { background: var(--line); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .moon, [data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }
.fx-badge.stale { color: var(--warn); background: var(--warn-bg); border-color: transparent; }

.banner { padding: 9px 12px; border-radius: 8px; font-size: 13px; line-height: 1.4; }
.banner.info { background: var(--info-bg); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }

/* --- cards & kpis --- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { margin: 0; margin-right: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kpi .label { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.kpi .value { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.2; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero { border-color: transparent; background: linear-gradient(135deg, #1d2a4a, #2c3c66); color: #fff; }
.kpi.hero .value { font-size: 26px; }
.kpi.hero .label, .kpi.hero .sub { color: #c4cdf0; }
.delta { font-size: 12px; font-weight: 650; white-space: nowrap; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.flat { color: var(--muted); }
.kpi.hero .delta.good { color: #7fe0b3; }
.kpi.hero .delta.bad { color: #ffb4ad; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.pos { color: var(--good); }
.neg { color: var(--bad); }
.warn-t { color: var(--warn); }

/* --- toolbar / forms --- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .grow { flex: 1; }
input, select, textarea, button { font: inherit; }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=email],
input[type=password], select, textarea {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; min-height: 34px;
}
/* Desplegables: la flecha del navegador se pegaba al borde redondeado y lo pisaba. Se quita la
   suya y se dibuja una propia con sitio fijo a la derecha, igual en todos los navegadores.
   El hueco de la flecha manda sobre los rellenos puestos a mano en los desplegables pequeños. */
select { appearance: none; -webkit-appearance: none; padding-right: 30px !important; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237d879b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px 14px; }
select:disabled { opacity: 0.6; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { width: 100%; min-height: 70px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; min-height: 34px; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 8px; min-height: 26px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; max-width: 100%; }
.seg button { white-space: nowrap; flex: none; }
.seg button { border: 0; background: var(--panel); padding: 6px 11px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--text); color: var(--panel); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
/* Campos alineados por abajo: una etiqueta de dos líneas no baja su casilla respecto a las demás */
.form-grid.ends { align-items: end; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > * { grid-column: 1 / -1 !important; }
}
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* --- tables --- */
.table-wrap { overflow: auto; max-width: 100%; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
table.data th { position: sticky; top: 0; background: var(--panel-2); font-size: 12px; color: var(--muted);
  font-weight: 650; z-index: 1; }
/* Tablas largas de productos: se desplazan dentro de su marco y el encabezado queda siempre a la vista */
.table-wrap.sticky-head { max-height: calc(100vh - 76px); max-height: calc(100dvh - 76px); }
.table-wrap.sticky-head > table.data > thead th { z-index: 3; box-shadow: 0 1px 0 var(--line); }
.table-wrap.sticky-head td table.data th { position: static; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .arrow { font-size: 10px; margin-left: 3px; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
table.data tr.expanded td { background: var(--panel-2); }
table.data td.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
table.data td.reason { white-space: normal; min-width: 340px; max-width: 560px; }
table.data tfoot td { font-weight: 700; background: var(--panel-2); position: sticky; bottom: 0; }
.title-cell { display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 420px; white-space: normal; }
.title-cell > div { min-width: 0; }
.title-cell img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); flex: none; }
.title-cell .t { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.title-cell .ids { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px;
  font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.info { background: var(--info-bg); color: var(--accent); border-color: transparent; }
.stars { color: #f5a623; letter-spacing: 1px; }
.actions-list { display: flex; flex-direction: column; gap: 3px; white-space: normal; min-width: 260px; }
.actions-list .a { font-size: 12px; padding-left: 10px; border-left: 3px solid var(--line); }
.actions-list .a.bad { border-color: var(--bad); }
.actions-list .a.warn { border-color: #f0b44c; }
.actions-list .a.good { border-color: var(--good); }
.actions-list .more { font-size: 11.5px; color: var(--accent); padding-left: 13px; cursor: help; }

.breakdown { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 16px; padding: 4px 0; }
.breakdown div { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.breakdown div span:first-child { color: var(--muted); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 16px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.loading { opacity: 0.55; pointer-events: none; transition: opacity 0.15s; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 11px 12px; cursor: pointer; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-color: var(--brand); }
.tabs .count { font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 4px; }

/* --- chart --- */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.waterfall { display: flex; flex-direction: column; gap: 6px; }
.waterfall .row { display: grid; grid-template-columns: 140px 1fr 90px; gap: 10px; align-items: center; font-size: 12.5px; }
.waterfall .track { height: 10px; background: var(--panel-2); border-radius: 5px; overflow: hidden; }
.waterfall .fill { height: 100%; border-radius: 5px; background: var(--bad); opacity: 0.75; }
.waterfall .fill.rev { background: var(--accent); }
.waterfall .fill.net { background: var(--good); opacity: 1; }
.waterfall .row .v { text-align: right; font-variant-numeric: tabular-nums; }

.toast { position: fixed; right: 18px; bottom: 18px; background: var(--text); color: var(--panel); padding: 10px 14px;
  border-radius: 8px; box-shadow: var(--shadow); z-index: 100; max-width: 420px; }
.toast.err { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .toast.err { color: var(--bg); }  /* el rojo claro del modo oscuro, con texto oscuro */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo { color: var(--text); padding: 0 0 18px; }
.auth-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.login-card { display: flex; flex-direction: column; gap: 12px; }
.banner.good { background: var(--good-bg); color: var(--good); }
.auth-title { font-size: 17px; margin: 0; }
.auth-alt { margin: 4px 0 0; font-size: 13px; text-align: center; }
.auth-cmd { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--text); width: min(620px, 94vw); }
dialog::backdrop { background: rgba(10, 15, 26, 0.45); }
dialog .dlg-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
dialog .dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 60; transform: translateX(-100%);
    transition: transform 0.2s ease; overflow-y: auto; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 15, 26, 0.45); }
  .menu-toggle { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line);
    border-radius: 8px; background: var(--panel-2); color: var(--text); cursor: pointer; }
  .menu-toggle svg { width: 18px; height: 18px; }
  /* Arriba menú, título, «Demo» y modo oscuro; debajo, país y moneda */
  .topbar { padding: 10px 14px; gap: 8px; row-gap: 4px; }
  .topbar h1 { font-size: 16px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; order: 2; }
  .topbar .menu-toggle { order: 1; }
  .topbar .demo-pill { order: 3; }
  .topbar .theme-toggle { order: 4; }
  .topbar .spacer { display: block; order: 5; flex-basis: 100%; height: 0; margin: 0; }
  .topbar .mp-switch { order: 6; }
  .fx-badge { display: none; }
  .demo-pill .long { display: none; }
  .demo-pill .short { display: inline; }
  .content { padding: 14px; }
  .toolbar > span.muted { overflow-wrap: anywhere; }
  .kpi .value { font-size: 19px; }
}

/* --- pedido de compra (imprimible, D-037) ---
   Papel A4 en cualquier tema. Archivo (OFL) autoalojada: la política de seguridad no deja
   cargar fuentes de fuera. Lo único llamativo es el número del pedido, en estrecha y en el
   azul del acero templado; lo demás, filetes finos y cifras tabulares, legible en B/N. */
@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-stretch: 62% 125%;
  font-display: swap;
}
.po-page { background: var(--bg); }
.po-toolbar { display: flex; align-items: center; gap: 10px; max-width: 210mm; margin: 18px auto 10px; padding: 0 4px; }
.po-toolbar .grow { flex: 1; }
.po-state { font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--info-bg); color: var(--accent); }
.po-state-sent { background: var(--warn-bg); color: var(--warn); }
.po-state-received { background: var(--good-bg); color: var(--good); }
.po-state-cancelled { background: var(--panel-2); color: var(--muted); }
.po-hint { max-width: 210mm; margin: 0 auto 10px; padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.po-sheet {
  --po-ink: #000;
  --po-steel: #4a5160;
  --po-edge: #c7ccd4;
  --po-temper: #1d4f91;
  --po-blued: #eef1f5;
  box-sizing: border-box; width: 210mm; min-height: 297mm; margin: 0 auto 40px; padding: 16mm 15mm 18mm;
  background: #fff; color: var(--po-ink); box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12), 0 8px 28px rgba(16, 24, 40, 0.1);
  font-family: "Archivo", "Segoe UI", system-ui, sans-serif; font-size: 9.5pt; line-height: 1.38;
  font-variant-numeric: tabular-nums; color-scheme: light;
}
.po-sheet p, .po-sheet h1, .po-sheet h2, .po-sheet dl, .po-sheet dd { margin: 0; }
.po-letterhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12mm; padding-bottom: 5mm; border-bottom: 2.5pt solid var(--po-temper); }
.po-buyer { color: var(--po-steel); }
.po-buyer-name { font-size: 16pt; font-weight: 720; font-stretch: 82%; color: var(--po-ink); line-height: 1.1; margin-bottom: 1.5mm !important; }
.po-id { text-align: right; color: var(--po-steel); }
.po-id h1 { display: flex; flex-direction: column; align-items: flex-end; font-weight: 400; margin-bottom: 1mm; }
.po-doc { font-size: 9.5pt; font-weight: 600; color: var(--po-steel); }
.po-number { font-size: 30pt; font-weight: 760; font-stretch: 70%; letter-spacing: -0.01em; line-height: 1; color: var(--po-temper); }
.po-parties { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10mm; padding: 6mm 0; }
.po-party { color: var(--po-steel); }
.po-sheet h2 { font-size: 8.5pt; font-weight: 600; color: var(--po-steel); margin-bottom: 1.5mm; }
.po-party-name { font-size: 11pt; font-weight: 680; font-stretch: 90%; color: var(--po-ink); }
.po-email { margin-top: 1.5mm !important; overflow-wrap: anywhere; }
.po-lines { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9pt; }
.po-lines col.c-qty { width: 18mm; }
.po-lines col.c-cost { width: 22mm; }
.po-lines col.c-total { width: 24mm; }
.po-lines th { text-align: left; font-size: 8.5pt; font-weight: 600; color: var(--po-steel); padding: 0 2mm 1.6mm; border-bottom: 1pt solid var(--po-ink); }
.po-lines td { padding: 1.1mm 2mm; border-bottom: 0.5pt solid var(--po-edge); vertical-align: baseline; }
.po-lines th:first-child, .po-lines td:first-child { padding-left: 1mm; }
.po-lines th:last-child, .po-lines td:last-child { padding-right: 1mm; }
.po-lines .num { text-align: right; white-space: nowrap; }
.po-lines tbody tr:nth-child(even) td { background: var(--po-blued); }
.po-lines tr { break-inside: avoid; }
.po-ref { font-weight: 640; font-stretch: 88%; overflow-wrap: anywhere; }
.po-product span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--po-steel); font-size: 8.25pt; line-height: 1.45; }
.po-qty { font-weight: 700; font-size: 10pt; }
.po-totals { display: flex; flex-direction: column; align-items: flex-end; margin-top: 5mm; break-inside: avoid; }
.po-totals dl { min-width: 72mm; border-top: 1pt solid var(--po-ink); padding-top: 2mm; }
.po-totals dl > div { display: flex; justify-content: space-between; gap: 8mm; padding: 0.8mm 1mm; }
.po-totals dt { color: var(--po-steel); }
.po-totals dd { font-weight: 640; }
.po-grand { margin-top: 1mm; padding-top: 2mm !important; border-top: 0.5pt solid var(--po-edge); }
.po-grand dt { color: var(--po-ink); font-weight: 600; align-self: flex-end; }
.po-grand dd { font-size: 15pt; font-weight: 740; font-stretch: 86%; color: var(--po-temper); }
.po-missing { margin-top: 2mm !important; font-size: 8.5pt; color: var(--po-steel); }
.po-notes { margin-top: 8mm; padding-top: 3mm; border-top: 0.5pt solid var(--po-edge); break-inside: avoid; }
.po-notes p { white-space: pre-wrap; }
@media screen and (max-width: 230mm) {
  .po-sheet { width: auto; min-height: 0; margin: 0 12px 24px; padding: 18px 16px; }
  .po-letterhead { flex-direction: column; align-items: flex-start; gap: 4mm; }
  .po-id { text-align: left; }
  .po-id h1 { align-items: flex-start; }
  .po-parties { grid-template-columns: 1fr; gap: 5mm; }
  .po-toolbar { margin: 12px; flex-wrap: wrap; }
  /* En el móvil basta la referencia: el título del producto no cabe */
  .po-lines col.c-product { visibility: collapse; }
}
@media print {
  .no-print { display: none !important; }
  :root { --bg: #fff; --panel: #fff; --panel-2: #f4f4f4; --text: #000; --muted: #555; --line: #ccc; color-scheme: light; }
  .po-page { background: #fff; }
  .po-sheet { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  .po-lines tbody tr:nth-child(even) td { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .po-lines thead { display: table-header-group; }
  table.data th { position: static; }
  .table-wrap.sticky-head { max-height: none; overflow: visible; }
}

/* Copiar SKU o ASIN (D-041): el icono va pegado a su valor (la línea sólo se parte por los «·»),
   no hace más alta la línea y casi no la alarga: los « · » van en la letra normal, más estrecha,
   y el botón se mete en el espacio que les precede */
.copy-pair { white-space: nowrap; }
.title-cell .ids .sep { font-family: var(--sans); }
.copy-btn { position: relative; display: inline-block; width: 14px; height: 20px; margin: -4px -3px -4px 1px; padding: 0; border: 0;
  border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; vertical-align: middle; line-height: 20px;
  text-align: center; opacity: 0.85; user-select: none; }
/* Más superficie para pulsarlo que lo que ocupa en la línea */
.copy-btn::before { content: ""; position: absolute; inset: -3px -4px; }
.copy-btn:hover { opacity: 1; color: var(--text); background: var(--panel-2); }
.copy-btn:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: -2px; }
.copy-btn svg { width: 12px; height: 12px; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.copy-btn .i-done, .copy-btn.copied .i-copy { display: none; }
.copy-btn.copied { opacity: 1; color: var(--good); }
.copy-btn.copied .i-done { display: inline; }
/* Iconos del ASIN en Contenido A+ (D-046): copiar, Seller Central y página pública, más grandes
   y separados que el botón de Reposición para acertar con cada uno */
.asin-tools .copy-btn { width: 24px; height: 24px; line-height: 24px; margin: -4px 0 -4px 6px; border-radius: 5px; opacity: 1; }
.asin-tools .copy-btn::before { inset: -2px; }
.asin-tools .copy-btn svg { width: 16px; height: 16px; stroke-width: 1.4; }
@media print { .copy-btn { display: none; } }

/* Texto sólo para lectores de pantalla */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Detalle de un pedido de compra dentro de la tabla de pedidos (D-040): donde la tabla se
   desplaza a lo ancho (pantallas estrechas), se queda a la vista y no más ancho que ella */
.po-detail { position: sticky; left: 0; max-width: 820px; white-space: normal; }
.qty-edit { display: inline-flex; align-items: center; gap: 6px; }
.po-notes-field { flex: 1 1 240px; min-width: 0; max-width: 420px; }
/* El botón que abre el detalle de un pedido: la columna, tan estrecha como era la flecha */
table.data td.expand-cell { padding-left: 2px; padding-right: 2px; }
.btn.expand { padding: 0 6px; min-width: 24px; color: var(--muted); }
@media (max-width: 1160px) { .po-detail { max-width: calc(100vw - 335px); } }
/* En el móvil, cada línea en dos filas: el producto y, debajo, su coste, importe y unidades */
@media (max-width: 860px) {
  .po-detail { max-width: calc(100vw - 80px); }
  .po-detail table.data, .po-detail table.data tbody { display: block; }
  .po-detail table.data thead { display: none; }
  .po-detail table.data tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0;
    border-bottom: 1px solid var(--line); }
  .po-detail table.data td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; }
  .po-detail table.data td:nth-child(1) { grid-column: 1 / -1; }
  .po-detail table.data td:nth-child(2), .po-detail table.data td:nth-child(4) { grid-column: 1; font-size: 12.5px; }
  .po-detail table.data td:nth-child(2)::before { content: "Coste ud.: "; color: var(--muted); }
  .po-detail table.data td:nth-child(4)::before { content: "Importe: "; color: var(--muted); }
  .po-detail table.data td:nth-child(3) { grid-column: 2; grid-row: 2 / span 2; align-self: center; }
  .po-detail .title-cell { min-width: 0; }
}
/* Añadir referencias a un pedido en borrador (D-040) */
.add-lines { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; max-width: 820px; margin-top: 10px; padding: 10px 12px;
  border: 1px dashed var(--line); border-radius: 10px; white-space: normal; }
/* Dentro de una celda de tabla (que no parte el texto): la ayuda salta de línea */
.detail-note { white-space: normal; }
.add-lines label .muted { font-size: 12.5px; }
.add-lines textarea { font-family: var(--mono); font-size: 12.5px; }
.add-rejected { font-size: 12.5px; display: grid; gap: 2px; overflow-wrap: anywhere; }

/* Proveedores: datos de tu empresa y datos fiscales de cada proveedor (D-037) */
.company-box { display: grid; gap: 8px; margin: 14px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
.company-box .muted { font-size: 12.5px; }
.fiscal-row td { background: var(--panel-2); }
.fiscal-row .toolbar > .muted { font-size: 12.5px; }

/* Contenido A+ (D-025) */
.aplus-module { display: flex; flex-direction: column; gap: 12px; }
.aplus-title { font-weight: 700; }
.aplus-row { display: grid; grid-template-columns: minmax(260px, 1.1fr) 1fr; gap: 16px; align-items: start; }
.aplus-row.side { grid-template-columns: minmax(200px, 300px) 1fr; }
.aplus-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.aplus-col, .aplus-fields, .aplus-slot { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.aplus-img { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel-2); }
.aplus-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aplus-ph { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.aplus-es { font-size: 12px; color: var(--muted); line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.aplus-check { font-size: 12px; line-height: 1.35; padding: 5px 8px; border-radius: 6px; overflow-wrap: anywhere; }
.aplus-check.ok { background: var(--info-bg); }
.aplus-check.bad { background: var(--bad-bg); color: var(--bad); }
.marks { display: flex; flex-direction: column; gap: 6px; }
.marks label .muted { font-weight: 400; font-size: 12.5px; }
.marks textarea { width: 100%; font: inherit; }
.aplus-check.wait { background: var(--warn-bg); color: var(--warn); }
.agent-wait { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; padding: 10px; color: var(--muted); font-weight: 600; text-align: center; }
.agent-wait .spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: aplus-spin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) { .agent-wait .spin { animation: none; } }
.aplus-count { font-weight: 400; margin-left: 4px; }
/* Logotipo de la marca sobre fondo oscuro, como irá en la imagen */
.hero-logo { width: 150px; height: 84px; padding: 8px; border-radius: var(--radius); background: #14161a; color: #9aa1ab; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.hero-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* Respuesta de Amazon sobre el A+ de un producto, en su misma fila */
.aplus-bubble { margin-top: 6px; padding: 8px 10px; max-width: 380px; white-space: normal; overflow-wrap: anywhere; font-size: 12px; line-height: 1.4; background: var(--info-bg); border: 1px solid var(--line); border-radius: var(--radius); user-select: text; }
.aplus-count.over { color: var(--bad); }
.aplus-progress { margin-top: 8px; color: var(--accent); font-weight: 600; }
.aplus-module textarea, .aplus-module input[type=text] { width: 100%; }
.aplus-module textarea { resize: vertical; }
.aplus-profile { margin-top: 12px; color: var(--text); }
.aplus-cols.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.aplus-compare th, .aplus-compare td { vertical-align: top; min-width: 130px; }
.aplus-compare th img { width: 120px; height: 90px; object-fit: contain; display: block; margin-bottom: 6px; background: #fff; border-radius: 6px; }
.aplus-compare input.empty { border-color: var(--bad); }
label.btn.disabled { opacity: .5; pointer-events: none; }
/* Maquetado libre (D-052): lista de módulos, imagen en la que trabaja Gemini y su ✕ */
.aplus-layout { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.aplus-layout li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.aplus-layout .n { width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.aplus-go { flex: 1; min-width: 180px; background: none; border: 0; padding: 4px 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.aplus-go:hover b { text-decoration: underline; }
.aplus-cols.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.aplus-rowline { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr auto; gap: 6px 10px; align-items: start; }
.aplus-img { position: relative; }
.aplus-img.working { outline: 3px solid var(--accent); outline-offset: 2px; }
.aplus-working { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; padding: 10px; background: rgba(15, 17, 17, .74); color: #fff; font-weight: 600; text-align: center; }
.aplus-working .spin { width: 26px; height: 26px; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: aplus-spin 1s linear infinite; }
@keyframes aplus-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .aplus-working .spin { animation: none; } }
.aplus-queued { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(15, 17, 17, .74); color: #fff; font-size: 12px; }
.aplus-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(15, 17, 17, .78); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }
.aplus-x:hover, .aplus-x:focus-visible { background: var(--bad); }
@media (max-width: 1100px) { .aplus-cols.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .aplus-row, .aplus-cols, .aplus-cols.four, .aplus-cols.two { grid-template-columns: 1fr; } }
/* Mejorar fichas (D-054): lo que hay en Amazon junto a la propuesta, y la galería */
.listing-field { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.listing-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.listing-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.listing-cap { font-size: 12px; margin-bottom: 4px; }
.listing-cap .over { color: var(--bad); }
.listing-now { padding: 8px 10px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--panel-2); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.listing-gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.listing-gallery figure { margin: 0; width: 96px; text-align: center; font-size: 12px; color: var(--muted); }
.listing-gallery img, .listing-gallery .free > div { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; display: flex; align-items: center; justify-content: center; }
.listing-gallery .free > div { border-style: dashed; background: var(--panel-2); }
.listing-gallery .photo-open { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--radius); }
.listing-gallery .photo-open:hover img, .listing-gallery .photo-open:focus-visible img { border-color: var(--accent); }
.listing-gallery figure.movable { cursor: grab; }
.listing-gallery figure.dragging { opacity: .4; }
.listing-gallery figure.drop-here img { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.listing-gallery figcaption { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 2px; }
.listing-gallery .photo-move { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px; font-size: 11px; line-height: 1; border-radius: 4px; }
.listing-gallery .photo-move:hover:not(:disabled), .listing-gallery .photo-move:focus-visible { color: var(--accent); background: var(--panel-2); }
.listing-gallery .photo-move:disabled { opacity: .25; cursor: default; }
dialog.view-dlg { width: min(900px, 97vw); }
.view-dlg .cmp-view { max-height: calc(96vh - 170px); max-width: calc(96vh - 170px); }
@media (max-width: 900px) { .listing-cols { grid-template-columns: 1fr; } }
/* Vista previa con el aspecto de la ficha de Amazon (siempre en claro, como en Amazon) */
.aplus-preview { background: #fff; color: #0f1111; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  max-width: 1018px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 28px;
  font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 1.45; }
.aplus-preview .img { width: 100%; background: #eef0f3; }
.aplus-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aplus-preview h3 { font-size: 20px; margin: 12px 0 4px; }
.aplus-preview h4 { font-size: 15px; margin: 8px 0 4px; }
.aplus-preview p { margin: 0 0 6px; white-space: pre-wrap; }
.aplus-preview .sub { font-weight: 700; }
.aplus-preview .cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.aplus-preview .cols3.four { grid-template-columns: repeat(4, 1fr); }
.aplus-preview .specs2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.aplus-preview .specs2 > div { display: grid; grid-template-columns: 40% 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid #e3e6e8; }
.aplus-preview .overlay { position: relative; }
.aplus-preview .overlay .box { position: absolute; right: 4%; top: 50%; transform: translateY(-50%); width: 36%;
  background: rgba(0, 0, 0, 0.62); color: #fff; padding: 14px 16px; }
.aplus-preview .side { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.aplus-preview .text { text-align: center; }
.aplus-preview .cols3.two { grid-template-columns: repeat(2, 1fr); }
.aplus-preview .specs2.one { grid-template-columns: 1fr; }
.aplus-preview .side.wide { grid-template-columns: 1fr 1fr; }
.aplus-preview .side.flip > .img { order: 2; }
.aplus-preview .overlay .box.left { right: auto; left: 4%; }
.aplus-preview .overlay .box.light { background: rgba(255, 255, 255, 0.82); color: #0f1111; }
@media (max-width: 700px) {
  .aplus-preview .cols3, .aplus-preview .cols3.four, .aplus-preview .cols3.two, .aplus-preview .side, .aplus-preview .side.wide, .aplus-preview .specs2 { grid-template-columns: 1fr; }
  .aplus-preview .side.flip > .img { order: 0; }
  .aplus-preview .overlay .box { position: static; transform: none; width: auto; }
}

/* Facturas de UPS (D-026) */
.aplus-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 22px;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--panel-2); cursor: pointer; text-align: center; }
.aplus-drop:hover { border-color: var(--accent); }
.aplus-drop.busy { cursor: progress; border-color: var(--accent); color: var(--accent); }

/* ===================================================================== */
/* Sistema visual común: avisos, ayudas, gráficos, ficha de pedido       */
/* ===================================================================== */

/* Avisos de una línea (lo que hay que arreglar) */
.notices { display: flex; flex-direction: column; gap: 6px; }
.notice { display: flex; gap: 8px; align-items: baseline; padding: 7px 12px; border-radius: 8px; font-size: 13px;
  line-height: 1.4; background: var(--panel); border: 1px solid var(--line); }
.notice::before { font-weight: 700; flex: none; }
.notice.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.notice.warn::before { content: "!"; }
.notice.bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.notice.bad::before { content: "!"; }
.notice.info { background: var(--info-bg); border-color: transparent; }
.notice.info::before { content: "i"; color: var(--accent); }
.notice a { white-space: nowrap; font-weight: 600; }

/* Notas y ayudas plegadas: la explicación está, pero no ocupa la pantalla */
details.notes, details.help { font-size: 13px; color: var(--muted); }
details.notes > summary, details.help > summary { cursor: pointer; list-style: none; display: inline-flex; gap: 6px;
  align-items: center; font-weight: 600; user-select: none; }
details.notes > summary::-webkit-details-marker, details.help > summary::-webkit-details-marker { display: none; }
details.notes > summary::before, details.help > summary::before { content: "i"; display: inline-grid; place-items: center;
  width: 16px; height: 16px; border-radius: 999px; background: var(--info-bg); color: var(--accent); font-size: 11px; font-weight: 700; }
details.notes[open] > summary, details.help[open] > summary { color: var(--text); }
details.notes ul { margin: 8px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
details.help > div { margin-top: 8px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); line-height: 1.5; }

/* Cabecera de sección dentro de una tarjeta */
.card-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-title h2 { margin: 0; }
.card-title .muted { font-size: 12.5px; }
.card-title .grow { flex: 1; }

/* Leyenda: el color va en la marca, el texto en tinta normal */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; vertical-align: 3px; }

/* Tooltip común (se rellena con textContent) */
#viz-tip { position: fixed; z-index: 120; pointer-events: none; background: var(--text); color: var(--panel);
  padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45; white-space: pre-line; max-width: 280px;
  box-shadow: 0 4px 14px rgba(10, 15, 26, 0.2); opacity: 0; transition: opacity 0.08s; }
#viz-tip.on { opacity: 1; }
[data-tip] { cursor: default; }

/* Gráfico de evolución */
.trend { width: 100%; height: auto; display: block; overflow: visible; }
.trend .grid { stroke: var(--grid); stroke-width: 1; }
.trend .base { stroke: var(--axis); stroke-width: 1; }
.trend text { fill: var(--muted); font-size: 11px; }
.trend .ptitle { fill: var(--text); font-size: 12px; font-weight: 600; }
.trend .col { fill: color-mix(in srgb, var(--s1) 28%, transparent); }
.trend .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .line.s6 { stroke: var(--s6); }
.trend .line.prev { stroke: var(--muted); opacity: 0.55; }
.trend .dot { stroke: var(--panel); stroke-width: 2; }
.trend .hit { fill: transparent; }
.trend .hit:hover, .trend .hit:focus-visible { fill: color-mix(in srgb, var(--text) 6%, transparent); outline: none; }

/* Barra de reparto (un todo dividido en partes) */
/* Barra de reparto: columnas de rejilla con el peso exacto de cada parte (minmax(0, Nfr)), así el
   ancho es proporcional aunque un tramo lleve texto o sea muy pequeño */
.segbar { display: grid; grid-auto-flow: column; gap: 2px; height: 28px; border-radius: 6px; overflow: hidden; }
.segbar.thin { height: 10px; border-radius: 999px; }
.segbar > div { min-width: 0; display: flex; align-items: center; padding-left: 7px; font-size: 11.5px; font-weight: 650;
  color: #fff; white-space: nowrap; overflow: hidden; }
.segbar > div.dark-ink { color: #0b0b0b; }
.segbar > div:hover { filter: brightness(1.08); }
.segbar.thin > div { padding: 0; }
/* Leyenda: una línea por concepto, el cuadradito a la altura de su texto y la cifra a la derecha */
.seg-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px 24px; margin-top: 12px; }
.seg-legend > div { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: start;
  font-size: 12.5px; line-height: 1.35; }
.seg-legend i { width: 10px; height: 10px; border-radius: 2px; margin-top: 3px; }
.seg-legend b { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.seg-legend b.none { font-weight: 500; color: var(--muted); }
.seg-legend small { color: var(--muted); margin-left: 4px; }
.c1 { background: var(--s1); } .c2 { background: var(--s2); } .c3 { background: var(--s3); }
.c4 { background: var(--s4); } .c5 { background: var(--s5); } .c6 { background: var(--s6); }

/* Barras horizontales de ranking (positivo / negativo desde el cero) */
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .name small { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { position: relative; height: 12px; }
.hbar .track .zero { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.hbar .bar { position: absolute; top: 0; height: 12px; background: var(--s1); }
.hbar .bar.pos { border-radius: 0 4px 4px 0; }
.hbar .bar.neg { background: #e34948; border-radius: 4px 0 0 4px; }
:root[data-theme="dark"] .hbar .bar.neg { background: #e66767; }
.hbar .val { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; min-width: 84px; }
.hbar .val small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }

/* Economía por unidad: una barra por producto con el reparto de su precio */
.unitbars { display: flex; flex-direction: column; gap: 10px; }
.unitbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 112px; gap: 12px; align-items: center; font-size: 13px; }
.unitbar .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unitbar .name small { display: block; color: var(--muted); font-size: 11.5px; }
.unitbar .segbar { height: 16px; border-radius: 4px; }
.unitbar .val { text-align: right; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.unitbar .val small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.unitbar .val.neg { color: var(--bad); }

/* Margen con barrita en tablas */
.mbar { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.mbar i { display: inline-block; height: 6px; border-radius: 3px; background: var(--s1); }
.mbar i.neg { background: #e34948; }

/* Ficha de pedido en cascada */
.ficha { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; padding: 6px 4px 4px; white-space: normal; }
.ficha .steps { display: flex; flex-direction: column; gap: 2px; }
.ficha .step { display: grid; grid-template-columns: minmax(0, 1fr) 120px 96px; gap: 10px; align-items: center;
  padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--grid); }
.ficha .step .what { min-width: 0; }
.ficha .step .what small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.ficha .step .track { height: 8px; position: relative; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.ficha .step .track b { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.ficha .step .amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ficha .step.start .amt, .ficha .step.result .amt { font-weight: 700; }
.ficha .step.result { border-bottom: 0; border-top: 2px solid var(--text); margin-top: 4px; padding-top: 8px; font-size: 14px; }
.ficha .origin { display: inline-flex; gap: 4px; align-items: center; }
.ficha .origin::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--muted); }
.ficha .origin.real::before { background: var(--good); }
.ficha .origin.est::before { background: #eda100; }
.ficha .origin.none::before { background: var(--bad); }
.ficha .side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ficha .verdict { padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.4; }
.ficha .verdict.good { background: var(--good-bg); color: var(--good); }
.ficha .verdict.bad { background: var(--bad-bg); color: var(--bad); }
.ficha .verdict.warn { background: var(--warn-bg); color: var(--warn); }
.ficha .verdict.info { background: var(--info-bg); color: var(--text); }  /* un reemplazo (D-042) */
.ficha .items { font-size: 12.5px; }
.ficha .items div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--grid); }
@media (max-width: 1000px) { .ficha { grid-template-columns: 1fr; } }

/* Analíticas */
.an-hero { display: grid; grid-template-columns: minmax(240px, 0.9fr) minmax(0, 2.1fr); gap: 12px; }
.an-hero .kpi.hero .value { font-size: 44px; letter-spacing: -0.02em; }
.an-hero .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .an-hero .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.an-hero .kpi.hero { justify-content: center; padding: 16px 18px; }
.an-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.an-grid > .wide { grid-column: 1 / -1; }
.todo { display: flex; flex-direction: column; gap: 8px; }
.todo a, .todo div { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
.todo a:hover { text-decoration: none; background: var(--panel-2); }
.todo .n { font-size: 18px; font-weight: 700; text-align: center; }
.todo .n.bad { color: var(--bad); } .todo .n.warn { color: var(--warn); } .todo .n.ok { color: var(--good); }
.todo small { display: block; color: var(--muted); }
.country-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 16px; }
.country { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 10px 12px; background: var(--panel-2); border-radius: 8px; font-size: 13px; }
.country .flag { font-size: 20px; }
/* Móvil: el nombre encima y la barra con su cifra debajo, sin cortar los nombres */
@media (max-width: 640px) {
  .hbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
  .hbar .name { grid-column: 1 / -1; white-space: normal; }
  .unitbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
  .unitbar .name { grid-column: 1 / -1; white-space: normal; }
  .country { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .country > :nth-child(3) { display: none; }
}
@media (max-width: 1100px) { .an-hero, .an-grid { grid-template-columns: 1fr; } }

/* --- carga inicial: huecos con la forma de la página mientras llegan los datos --- */
.sk-page { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.sk {
  height: 132px; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%);
  background-size: 200% 100%; animation: sk-move 1.3s linear infinite;
}
.sk.tall { height: 280px; grid-column: 1 / -1; }
@keyframes sk-move { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* Listas largas: de 25 en 25 */
.more-row { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--line); }

/* Comparar una imagen creada con la foto original (Mejorar fichas) */
dialog.cmp-dlg { width: min(1500px, 97vw); max-height: 96vh; }
.cmp { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.cmp-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cmp-bar .seg { display: inline-flex; gap: 4px; }
.cmp-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp-panes figure { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cmp-panes figcaption { font-weight: 700; font-size: 13px; }
.cmp-view { aspect-ratio: 1 / 1; max-height: calc(96vh - 190px); width: 100%; margin: 0 auto; overflow: hidden; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); touch-action: none; }
.cmp-view.zoomed { cursor: crosshair; }
.cmp-view img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; pointer-events: none; }
.cmp-thumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cmp-thumbs button { width: 48px; height: 48px; padding: 0; border: 2px solid var(--line); border-radius: 6px; background: #fff; overflow: hidden; cursor: pointer; }
.cmp-thumbs button.on { border-color: var(--accent); }
.cmp-thumbs img { width: 100%; height: 100%; object-fit: contain; display: block; }
@media (max-width: 700px) { .cmp-hint { display: none; } .cmp-view { max-height: none; } }
.cmp-bar .grow { flex: 1; }
.engine-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.engine-pick select { max-width: 260px; }
