/* Consolida — estilos de la app (mismo sistema visual que el sitio público) */
:root {
  --bg: #ffffff;
  --soft: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --ink: #0b1b3a;
  --ink-2: #33405c;
  --muted: #667089;
  --line: #e4e7ef;
  --line-2: #d6dbe7;
  --navy: #0b1b3a;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --good: #1f9d55;
  --bad: #d63b3b;
  --warn-bg: #fff6df;
  --warn-ink: #7a5300;
  --t-mint: #ecfaf5; --b-mint: #c7ecdf;
  --t-peach: #fff4ec; --b-peach: #f8d9c2; --k-peach: #b4510f;
  --t-lilac: #f4f1ff; --b-lilac: #ddd4fb; --k-lilac: #5b3fd1;
  --ch-ml: #a77d00; --ch-amazon: #e8590c; --ch-shopify: #2f9e44; --ch-woo: #7048e8; --ch-tiktok: #d6336c; --ch-other: #1c7ed6;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --script: Caveat, "Segoe Script", cursive;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 27, 58, .05), 0 8px 24px rgba(11, 27, 58, .06);
  --shadow-lg: 0 20px 60px rgba(11, 27, 58, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.15; color: var(--ink); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 8px; }
.end { justify-content: flex-end; }
.push { margin-left: auto; }
[hidden] { display: none !important; }

/* Tipografía de marca */
.display { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 6.4vw, 72px); letter-spacing: -0.02em; line-height: 1; max-width: 900px; margin: 0 auto; }
.display em { font-style: italic; color: var(--accent); }
.display-sm { font-family: var(--serif); font-weight: 400; font-size: clamp(32px, 4.4vw, 48px); letter-spacing: -0.015em; line-height: 1.05; }
.script { font-family: var(--script); font-size: 22px; color: var(--accent); margin: 0 0 2px; line-height: 1; }
.pill { display: inline-block; font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--soft); border: 1px solid var(--line); padding: 5px 12px; border-radius: 999px; margin: 0 0 16px; }
.lead { font-size: clamp(16px, 2vw, 18px); color: var(--ink-2); max-width: 680px; margin: 18px auto 0; }
.micro { font-size: 14px; color: var(--muted); margin: 12px 0 0; }

/* Encabezado (igual al sitio) */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .88); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 28px; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; }
.logo-mark { width: 30px; height: 30px; flex: none; }
.logo-mark rect { fill: var(--accent); }
.logo-mark path { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.app-nav { display: flex; gap: 24px; }
.app-nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 15px; }
.app-nav a:hover { color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.pro { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Botones y campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none;
  font: 600 14px/1 var(--sans); padding: 11px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12), 0 6px 14px rgba(37, 99, 235, .24);
  transition: transform .15s, background .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); background: #1d4fd8; }
.btn.outline, .btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-2); box-shadow: 0 1px 2px rgba(11, 27, 58, .05); }
.btn.outline:hover, .btn.ghost:hover { background: var(--soft); }
.btn.ghost { box-shadow: none; }
.btn.dark { background: var(--ink); border-color: var(--ink); box-shadow: none; }
.btn.dark:hover { background: #172a52; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn.danger { color: var(--bad); }
.btn.link { background: none; border: none; box-shadow: none; color: var(--accent); padding: 0; font-weight: 600; }
.btn.link:hover { transform: none; text-decoration: underline; background: none; }
.input, select, input[type="date"] {
  font: inherit; font-size: 14px; color: var(--ink); background: #fff; border: 1px solid var(--line-2);
  border-radius: 10px; padding: 9px 12px; min-width: 0;
}
.input.small { padding: 7px 11px; font-size: 13px; }
.input:focus, select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input:disabled { background: var(--soft); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Hero de carga */
.hero { padding: 64px 0 56px; text-align: center; background:
  radial-gradient(900px 420px at 50% -10%, #e5edff 0%, rgba(229, 237, 255, 0) 70%),
  linear-gradient(90deg, rgba(11, 27, 58, .035) 1px, transparent 1px) 0 0 / 56px 56px,
  linear-gradient(rgba(11, 27, 58, .035) 1px, transparent 1px) 0 0 / 56px 56px;
  border-bottom: 1px dashed var(--line-2); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  max-width: 760px; min-height: 260px; margin: 36px auto 0; padding: 32px 24px;
  border: 2px dashed #b9ccfb; border-radius: 22px; background: #fff; box-shadow: var(--shadow-lg);
  cursor: pointer; transition: border-color .15s, background .15s, transform .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: #f7f9ff; transform: translateY(-2px); }
.dropzone strong { font-size: 19px; }
.dz-badge { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); margin-bottom: 8px; }
.dz-icon { width: 32px; height: 32px; stroke: var(--accent); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dz-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.hero-foot { margin-top: 24px; display: flex; flex-direction: column; align-items: center; }
.mini-steps { list-style: none; padding: 0; margin: 40px auto 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 760px; text-align: left; }
.mini-steps li { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.mini-steps li > span { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--soft); border: 1px solid var(--line-2); font-weight: 700; font-size: 14px; }
.mini-steps b { display: block; font-size: 14px; }
.mini-steps small { color: var(--muted); font-size: 12.5px; }

.chip { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; background: #fff; }
.ch-ml { color: var(--ch-ml); } .ch-amazon { color: var(--ch-amazon); } .ch-shopify { color: var(--ch-shopify); }
.ch-woo { color: var(--ch-woo); } .ch-tiktok { color: var(--ch-tiktok); } .ch-other { color: var(--ch-other); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

/* Cuerpo de la app */
.app-body { padding-top: 28px; padding-bottom: 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; min-width: 0; }
.card.tint-peach { background: var(--t-peach); border-color: var(--b-peach); }
.card.tint-peach .script { color: var(--k-peach); }
.card.tint-lilac { background: var(--t-lilac); border-color: var(--b-lilac); }
.card.tint-lilac .script { color: var(--k-lilac); }
.card-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: -0.01em; }
.card h3 { font-family: var(--serif); font-weight: 400; font-size: 26px; letter-spacing: -0.01em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .card { margin-bottom: 18px; }
.dash-title { margin: 18px 0 16px; }

/* Archivos */
.file-list { display: grid; gap: 10px; margin-top: 12px; }
.file-item { display: grid; grid-template-columns: auto 1fr minmax(170px, 250px) auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.file-item.error { border-color: var(--bad); background: #fff5f5; }
.file-item.excluded { opacity: .55; }
.file-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.file-meta { font-size: 12.5px; color: var(--muted); }
.icon-btn { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 6px 9px; border-radius: 8px; }
.icon-btn:hover { background: var(--line); color: var(--ink); }
.notice { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #f3dc9c; }

/* Barra de periodo */
.toolbar { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; position: sticky; top: 80px; z-index: 5; padding: 16px 18px; }
.period-label { min-width: 190px; }
.period-label .strong { font-family: var(--serif); font-size: 22px; font-weight: 400; line-height: 1.1; }

/* KPIs (estilo de las tarjetas del sitio) */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 8px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(11, 27, 58, .04); min-width: 0; }
.kpi.main { border-color: #b9ccfb; background: #f7f9ff; }
.kpi .k-label { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.kpi .k-value { font-size: 26px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; letter-spacing: -0.01em; }
.kpi .k-prev { font-size: 12.5px; color: var(--muted); }
.delta { font-weight: 700; font-size: 12.5px; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--muted); }
#estNote { margin: 4px 0 18px; }

/* Gráficas */
.chart-box { position: relative; height: 270px; }
.chart-box.tall { height: 310px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
.scroll-y { max-height: 460px; overflow-y: auto; }
.table-wrap.inner { background: #fff; border: 1px solid var(--b-lilac); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: #fafbfd; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: #fafbff; }
.table.compact td, .table.compact th { padding: 8px; font-size: 13px; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.total td { font-weight: 700; border-top: 2px solid var(--line-2); background: var(--soft); }
.prod-title { font-size: 12px; color: var(--muted); max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sku { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; font-weight: 600; }
.split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--soft); min-width: 90px; }
.split span { display: block; height: 100%; }
.split-legend { font-size: 11px; color: var(--muted); white-space: nowrap; margin-top: 4px; }
.sku-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; width: 100%; min-width: 150px; }

/* Oportunidades y sugerencias */
.opp-list { display: grid; gap: 10px; }
.opp { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--b-peach); border-radius: 12px; background: #fff; }
.opp .tag { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 4px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.tag.dormido { background: #ff5a3c; color: #fff; }
.tag.intermitente { background: #ffe9a8; color: #6b4b00; }
.tag.sin_ventas { background: var(--soft); color: var(--ink-2); border: 1px solid var(--line-2); }
.sugg { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: #fff; border: 1px solid var(--b-lilac); margin-bottom: 8px; font-size: 13.5px; }
.empty { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; background: rgba(255, 255, 255, .6); border-radius: 12px; }

/* Ajustes */
.fee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 6px; }
.fee-grid .input { width: 100%; }

/* Diálogos */
.dialog { border: 1px solid var(--line); border-radius: 20px; padding: 28px; background: #fff; color: var(--ink); max-width: 700px; width: calc(100% - 32px); box-shadow: var(--shadow-lg); }
.dialog.narrow { max-width: 440px; }
.dialog::backdrop { background: rgba(11, 27, 58, .45); backdrop-filter: blur(2px); }
.dialog h2 { font-family: var(--serif); font-weight: 400; font-size: 36px; margin-bottom: 16px; }
.dialog .input { width: 100%; margin: 8px 0; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.plan-col { border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.plan-col.pro { border: 2px solid var(--accent); background: #f7f9ff; }
.plan-col h3 { font-size: 18px; }
.plan-col ul { padding-left: 18px; margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }
.plan-col li { margin-bottom: 6px; }
.price { font-family: var(--serif); font-size: 44px; line-height: 1; margin-top: 8px; }
.price small { font-family: var(--sans); font-size: 14px; color: var(--muted); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); box-shadow: var(--shadow-lg); }

/* Pie */
.footer { background: var(--navy); color: #c3cde3; padding: 28px 0; font-size: 13px; }
.footer-inner { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.footer .brand { color: #fff; font-size: 17px; }
.footer nav { display: flex; gap: 18px; }
.footer nav a { color: #c3cde3; text-decoration: none; }
.footer nav a:hover { color: #fff; }
.footer-inner > span { margin-left: auto; color: #8e9bbb; }

@media (max-width: 980px) {
  .app-nav { display: none; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .toolbar { position: static; }
}
@media (max-width: 640px) {
  .topbar-inner { gap: 12px; }
  .hide-sm, #upgradeBtn { display: none !important; }
  .hero { padding: 40px 0; }
  .mini-steps { grid-template-columns: 1fr; }
  .file-item { grid-template-columns: auto 1fr auto; }
  .file-item .acct { grid-column: 1 / -1; }
  .kpi .k-value { font-size: 20px; }
  .plans { grid-template-columns: 1fr; }
  .opp { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .toolbar .push { margin-left: 0; width: 100%; }
  .toolbar .push .btn { flex: 1; }
  .footer-inner > span { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .btn, .dropzone { transition: none; } }


/* Top productos: una tabla debajo de otra, a todo lo ancho */
.grid-2.stack { grid-template-columns: 1fr; gap: 0; }

/* Historial (Pro) */
.card.tint-mint { background: var(--t-mint); border-color: var(--b-mint); }
.card.tint-mint .script { color: #0f7a5c; }
.history-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 6px 0 18px; }
.history-stats > div { background: #fff; border: 1px solid var(--b-mint); border-radius: 12px; padding: 12px 14px; }
.history-stats small { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.history-stats b { display: block; font-size: 22px; margin-top: 2px; }
.history-stats span { font-size: 12.5px; color: var(--muted); }
.table-wrap.inner-mint { background: #fff; border: 1px solid var(--b-mint); border-radius: 12px; margin-top: 16px; }
.tag-partial { display: inline-block; font-size: 11px; font-weight: 600; color: var(--warn-ink); background: var(--warn-bg); border-radius: 4px; padding: 1px 6px; margin-left: 4px; }
.history-lock { display: grid; grid-template-columns: 1fr 1.2fr; gap: 24px; align-items: center; background: #fff; border: 1px solid var(--b-mint); border-radius: 14px; padding: 22px; }
.lock-preview { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 12px; border-radius: 10px; background: var(--soft); filter: blur(1.5px); opacity: .8; }
.lock-preview i { flex: 1; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #2f9e44, #9fd8ad); }
.lock-copy h4 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 0 0 8px; }
.lock-copy p { color: var(--ink-2); font-size: 14.5px; margin: 0 0 14px; }
@media (max-width: 980px) { .history-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .history-lock { grid-template-columns: 1fr; } }

/* Pagos */
#planBadge { cursor: pointer; }
.notice.ok { background: #ecfaf1; color: #145c34; border: 1px solid #bfe8cf; }
.pay-area { margin: 14px 0 18px; display: grid; gap: 12px; }
.pay-title { font-weight: 700; margin: 4px 0 0; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pay-method { text-align: left; font: inherit; background: #fff; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; cursor: pointer; display: grid; gap: 4px; transition: border-color .15s, box-shadow .15s; }
.pay-method b { font-size: 15px; color: var(--ink); }
.pay-method span { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.pay-method:hover { border-color: #b9ccfb; }
.pay-method.on { border: 2px solid var(--accent); box-shadow: 0 0 0 4px rgba(37, 99, 235, .1); padding: 11px 13px; }
.pay-box { background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 10px; justify-items: start; }
.pay-box .field, .pay-box .input { width: 100%; }
.pay-sub { font-weight: 700; margin: 4px 0 0; font-size: 14px; }
.bank-info { margin: 0; width: 100%; white-space: pre-wrap; font: 500 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; background: #fff; border: 1px dashed var(--line-2); border-radius: 10px; padding: 12px 14px; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.pay-grid .span-2 { grid-column: 1 / -1; }
.pay-grid select, .pay-grid input { width: 100%; }
.pay-login { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; color: var(--ink); font-size: 14px; }
@media (max-width: 640px) { .pay-methods, .pay-grid { grid-template-columns: 1fr; } }

.pay-recover { margin: 0; font-size: 13px; color: var(--muted); }

/* Selector Día / Semana / Mes y tabla semanal */
.seg { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { font: 600 13px/1 var(--sans); border: 0; background: transparent; color: var(--ink-2); padding: 7px 12px; border-radius: 7px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(11, 27, 58, .12); }
#trendNote { margin: -6px 0 10px; }
.weeks-more { margin-top: 12px; text-align: center; }
#weeksTable td:nth-child(9) { min-width: 140px; }
#weeksTable td:first-child { white-space: nowrap; }

/* ================= Menú lateral y vistas ================= */
.app-topbar { padding: 0 16px; max-width: none; }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; align-items: center; justify-content: center; }
.menu-toggle svg { width: 20px; height: 20px; stroke: var(--ink); stroke-width: 2; fill: none; stroke-linecap: round; }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.sidebar { position: sticky; top: 68px; height: calc(100vh - 68px); overflow-y: auto; background: #fbfcfe; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; z-index: 15; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 14px 10px 6px; }
.side-label:first-child { margin-top: 0; }
.side-nav > a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14.5px; }
.side-nav > a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-nav > a:hover { background: var(--soft); color: var(--ink); }
.side-nav > a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-pro { margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--accent); background: #fff; border: 1px solid #c9d7fb; border-radius: 999px; padding: 1px 7px; }
.side-sub { display: flex; flex-direction: column; margin: 2px 0 6px 28px; border-left: 2px solid var(--line); }
.side-sub a { padding: 6px 12px; font-size: 13.5px; color: var(--muted); text-decoration: none; border-radius: 0 8px 8px 0; }
.side-sub a:hover { color: var(--ink); background: var(--soft); }
.side-foot { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.side-btn { display: flex; align-items: center; gap: 8px; font: 600 13.5px var(--sans); color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 10px; cursor: pointer; text-align: left; }
.side-btn svg { width: 14px; height: 14px; fill: var(--accent); flex: none; }
.side-btn:hover { background: var(--soft); }
.side-back { font-size: 13.5px; color: var(--muted); text-decoration: none; padding: 4px 10px; }
.side-back:hover { color: var(--ink); }
.side-backdrop { position: fixed; inset: 68px 0 0 0; background: rgba(11, 27, 58, .35); z-index: 14; }
.app-main { min-width: 0; display: flex; flex-direction: column; }
.app-main > .view { flex: 1; }
.app-main .footer { margin-top: auto; }
.hero .wrap, .app-body { max-width: 1160px; }
.page-view { padding-top: 32px; }
.view-head { margin-bottom: 20px; }
.view-head .muted { margin: 8px 0 0; }
.settings-hint { text-align: center; margin: 4px 0 18px; }

/* Mi plan */
.plan-summary { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.plan-status { display: grid; gap: 8px; align-content: start; }
.plan-status .big { font-family: var(--serif); font-size: 44px; line-height: 1; }
.plan-status .row { margin-top: 8px; }
.plan-perks { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14.5px; }
.plan-perks li { margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 6px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* Ajustes: datos locales */
.data-actions { display: grid; gap: 10px; }
.data-actions > div { display: grid; grid-template-columns: 200px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }

/* Manual */
.manual { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.manual-toc { position: sticky; top: 84px; padding: 16px; font-size: 14px; }
.manual-toc p { font-weight: 700; margin: 0 0 8px; }
.manual-toc ol { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.manual-toc a { color: var(--ink-2); text-decoration: none; }
.manual-toc a:hover { color: var(--accent); }
.manual-body { font-size: 15.5px; line-height: 1.7; color: #1f2a44; }
.manual-body section { scroll-margin-top: 84px; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.manual-body section:last-child { border-bottom: 0; margin-bottom: 0; }
.manual-body h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0 0 10px; }
.manual-body h3 { font-size: 16px; margin: 16px 0 4px; }
.manual-body ol, .manual-body ul { padding-left: 20px; }
.manual-body li { margin-bottom: 6px; }
.tip { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; padding: 10px 14px; font-size: 14.5px; }
.defs { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
.defs dt { font-weight: 700; }
.defs dd { margin: 0; color: var(--ink-2); }

/* Soporte */
.support-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
.support-grid .faq { margin-bottom: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.support-grid .faq summary { cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: 14.5px; list-style: none; }
.support-grid .faq summary::-webkit-details-marker { display: none; }
.support-grid .faq summary::after { content: " +"; color: var(--muted); }
.support-grid .faq[open] summary::after { content: " –"; }
.support-grid .faq p { margin: 0; padding: 0 14px 12px; color: var(--ink-2); font-size: 14px; }
.support-form { display: grid; gap: 12px; justify-items: start; }
.support-form .field, .support-form .input, .support-form select { width: 100%; }
.support-form textarea { resize: vertical; font-family: inherit; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 980px) {
  .menu-toggle { display: inline-flex; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 68px; left: 0; bottom: 0; width: 280px; height: auto; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .plan-summary, .support-grid, .manual { grid-template-columns: 1fr; }
  .manual-toc { position: static; }
  .data-actions > div { grid-template-columns: 1fr; }
  .defs { grid-template-columns: 1fr; }
}

/* Encabezados ordenables */
th.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable-th:hover { color: var(--ink); }
th.sortable-th::after { content: "↕"; margin-left: 4px; opacity: .35; font-size: 11px; }
th.sortable-th[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--accent); }
th.sortable-th[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--accent); }
th.sortable-th[aria-sort="ascending"], th.sortable-th[aria-sort="descending"] { color: var(--accent); }
th.sortable-th:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f3f6ff !important; }

/* Buscador de productos */
.product-search { border-color: #c9d7fb; }
.ps-box { position: relative; }
.ps-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
#prodSearch { width: 100%; padding: 13px 14px 13px 42px; font-size: 15px; border-radius: 12px; }
.ps-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 12; list-style: none; margin: 0; padding: 6px; background: #fff; border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 340px; overflow-y: auto; }
.ps-results li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.ps-results li.on, .ps-results li:hover { background: var(--accent-soft); }
.ps-title { color: var(--ink-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-units { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.ps-empty { color: var(--muted); font-size: 14px; cursor: default !important; }
kbd { font: 600 11px ui-monospace, Menlo, monospace; background: var(--soft); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }

/* Ficha de producto */
.pd { margin-top: 16px; border-top: 1px dashed var(--line-2); padding-top: 16px; display: grid; gap: 12px; }
.pd-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.pd-sku { font: 700 20px ui-monospace, SFMono-Regular, Menlo, monospace; }
.pd-title { font-family: var(--serif); font-size: 24px; line-height: 1.15; margin-top: 2px; }
.pd-skus { margin-top: 6px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pd-skus code { font-size: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.pd .muted.small { margin: 0; }
.pd-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pd-kpis .kpi .k-value { font-size: 22px; }
.pd-alerts { background: var(--t-peach); border: 1px solid var(--b-peach); border-radius: 12px; padding: 10px 14px; font-size: 14px; line-height: 1.8; }
.pd-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.pd-weeks { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 8px 4px 0; border-bottom: 1px solid var(--line); }
.pd-w { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.pd-w i { display: block; width: 100%; max-width: 28px; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.pd-w i.partial { background: repeating-linear-gradient(45deg, #9db8ff, #9db8ff 4px, #c9d7fb 4px, #c9d7fb 8px); }
.pd-wv { font-size: 10.5px; color: var(--ink-2); margin-bottom: 2px; }
.pd-w small { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; height: 14px; line-height: 14px; transform: translateY(16px); }
.pd-weeks { margin-bottom: 18px; }
@media (max-width: 980px) { .pd-kpis { grid-template-columns: repeat(2, 1fr); } .pd-grid { grid-template-columns: 1fr; } }
/* Ficha: siempre en una columna para que nada se recorte */
.pd-grid { grid-template-columns: 1fr; }
.pd-grid > * { min-width: 0; }
.pd-kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.pd-weeks { height: 150px; }
.merge-hint { display: block; margin-top: 6px; }
.merge-hint .btn { margin-left: 6px; }

/* Montos con centavos sin partirse */
.kpi .k-value { font-size: clamp(18px, 1.75vw, 26px); white-space: nowrap; overflow-wrap: normal; }
.kpi .k-value .cents { font-size: .62em; font-weight: 600; color: var(--ink-2); margin-left: 1px; }
.table td.num { white-space: nowrap; }

/* Descripción breve de cada sección */
.section-help { font-size: 13.5px; line-height: 1.55; color: var(--muted); margin: -4px 0 14px; max-width: 860px; }
.section-help b { color: var(--ink-2); font-weight: 600; }
.dash-title .section-help { margin-top: 8px; }
.view-head .section-help { margin-top: 8px; }
.table td.nowrap { white-space: nowrap; }

/* Utilidad y costos */
.profit-card { border-color: #bfe8cf; }
.profit-card .script { color: #0f7a5c; }
.profit-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 10px; }
.profit-kpis .kpi.main { border-color: #9fdcb5; background: #f1fbf5; }
.profit-lock .lock-preview i { background: linear-gradient(180deg, #2f9e44, #9fd8ad); }
.costs-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.costs-cov { min-width: 240px; font-size: 14px; }
#costSearch { width: 100%; margin-bottom: 8px; }
.cost-input { width: 130px; }
.cost-date { width: 150px; }
.cost-hist { min-width: 200px; }
.cost-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 9px; margin: 2px 4px 2px 0; white-space: nowrap; }
.cost-del { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.cost-del:hover { background: var(--line); color: var(--bad); }
@media (max-width: 980px) { .profit-kpis { grid-template-columns: repeat(2, 1fr); } }

.notice.info { background: var(--accent-soft); color: var(--ink-2); border: 1px solid #c9d7fb; margin: 0 0 12px; }

/* Logo para el PDF */
.logo-field { grid-column: span 2; }
.logo-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border: 1px dashed var(--line-2); border-radius: 10px; padding: 10px 12px; background: #fff; }
.logo-preview { max-height: 56px; max-width: 200px; object-fit: contain; }
@media (max-width: 640px) { .logo-field { grid-column: auto; } }

.account-danger { border-color: #f3c9c9; }
.account-danger .script { color: var(--bad); }

/* Paquetes */
.pkg-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.pkg-kpis .kpi .k-value { font-size: clamp(16px, 1.5vw, 22px); }
.pkg-combos { margin-bottom: 14px; display: grid; gap: 6px; }
.pkg-combo { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.pkg-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 240px; }
.pkg-items .prod-title { max-width: 280px; }
tr.muted-row td { opacity: .55; }
#packagesTable tfoot td { font-weight: 700; border-top: 2px solid var(--line-2); background: var(--soft); }
@media (max-width: 1200px) { .pkg-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .pkg-kpis { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Gastos del mes y utilidad neta ---------- */
.net-block { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--b-mint); }
.net-table { max-width: 560px; margin-top: 10px; }
.net-table td:first-child { color: var(--ink); }
.net-table tr.sub td { font-weight: 700; border-top: 1px solid var(--b-mint); }
.net-cta { margin-top: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--mint, #f0fbf6); border: 1px dashed var(--b-mint); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.exp-top { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.exp-top .field { margin: 0; }
.exp-cats, .exp-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; flex: 1; }
.exp-result { margin-top: 14px; }
.exp-cats > div, .exp-result > div { background: #fff; border: 1px solid var(--b-mint); border-radius: 12px; padding: 10px 12px; }
.exp-cats small, .exp-result small { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.exp-cats b, .exp-result b { display: block; font-size: 18px; margin-top: 2px; }
.exp-cats .main, .exp-result .main { border-color: var(--ink); }
.exp-result span { font-size: 12.5px; color: var(--muted); }
.exp-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.exp-form .field { margin: 0; min-width: 150px; }
.exp-form .field.grow { flex: 1; min-width: 220px; }
.exp-form .check { display: flex; gap: 6px; align-items: center; font-size: 14px; padding-bottom: 10px; }

/* ---------- Destinos de envío ---------- */
.dest-controls { flex-wrap: wrap; justify-content: flex-end; }
.dest-controls select { max-width: 260px; }
.dest-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 6px 0 16px; }
.dest-layout { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .dest-layout { grid-template-columns: 1fr; } }
.dest-bars { display: flex; flex-direction: column; gap: 8px; }
.dest-bar { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13.5px; }
.dest-bar .track { grid-column: 1 / -1; height: 8px; background: var(--b-mint); border-radius: 99px; overflow: hidden; display: flex; }
.dest-bar .track i { display: block; height: 100%; }
.dest-bar b { font-variant-numeric: tabular-nums; }
.dest-layout { grid-template-columns: 1fr; }
.dest-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 24px; }
.dest-kpis .k-value.wrap { font-size: 18px; white-space: normal; overflow-wrap: anywhere; line-height: 1.2; }

/* =====================================================================
   Rediseño de la app (dic 2026): barra lateral azul de marca, fondo gris
   claro, tarjetas blancas redondeadas y KPIs con icono.
   ===================================================================== */
:root {
  --app-bg: #f3f5fa;
  --brand: #2563eb;
  --brand-2: #1e4fd6;
  --brand-3: #1a43b8;
  --card-line: #eaedf4;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
}
body { background: var(--app-bg); }

/* Estructura: barra lateral de lado a lado + columna con encabezado */
.app-shell { grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.app-col { min-width: 0; display: flex; flex-direction: column; }
.app-col .app-main { flex: 1; }

/* ---- Barra lateral azul ---- */
.sidebar {
  top: 0; height: 100vh; padding: 20px 14px 18px; border-right: 0;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 55%, var(--brand-3) 100%);
  color: #fff; justify-content: flex-start;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.side-brand .logo-mark rect { fill: #fff; }
.side-brand .logo-mark path { stroke: var(--brand); }
.sidebar .side-nav { flex: 1; }
.sidebar .side-label { color: rgba(255,255,255,.55); margin: 18px 12px 8px; }
.sidebar .side-nav > a { color: rgba(255,255,255,.86); padding: 10px 12px; border-radius: 12px; font-weight: 500; }
.sidebar .side-nav > a:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar .side-nav > a.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 6px 18px rgba(8, 20, 70, .18); }
.sidebar .side-nav > a.active .side-pro { background: var(--brand); color: #fff; border-color: var(--brand); }
.sidebar .side-pro { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.sidebar .side-sub { border-left: 2px solid rgba(255,255,255,.22); margin: 4px 0 8px 22px; }
.sidebar .side-sub a { color: rgba(255,255,255,.72); display: flex; align-items: center; gap: 6px; }
.sidebar .side-sub a:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar .side-foot { border-top: 1px solid rgba(255,255,255,.18); margin-top: 18px; }
.sidebar .side-btn { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; }
.sidebar .side-btn svg { fill: #fff; }
.sidebar .side-btn:hover { background: rgba(255,255,255,.22); }
.sidebar .side-back { color: rgba(255,255,255,.7); }
.sidebar .side-back:hover { color: #fff; }

/* ---- Encabezado ---- */
.topbar { background: rgba(243, 245, 250, .86); border-bottom: 0; }
.app-topbar { height: 72px; padding: 0 28px; gap: 16px; }
.mobile-brand { display: none; }
.top-search { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 420px; background: #fff; border: 1px solid var(--card-line); border-radius: 999px; padding: 0 14px; height: 44px; box-shadow: 0 1px 2px rgba(16,24,40,.04); cursor: text; }
.top-search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.top-search input { border: 0; outline: 0; background: transparent; font: 500 14px var(--sans); color: var(--ink); flex: 1; min-width: 0; }
.top-search input:focus { outline: 0; }
.top-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
.top-search kbd { font: 600 11px var(--sans); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; background: var(--soft); }
.topbar-actions .badge { padding: 6px 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, #3b82f6, #6d28d9); box-shadow: 0 0 0 3px #fff, 0 2px 8px rgba(16,24,40,.12); flex: none; }
.btn { border-radius: 12px; }
.btn.small { border-radius: 10px; }

/* ---- Contenido ---- */
.app-body, .hero .wrap { max-width: 1240px; }
.app-body { padding: 8px 28px 40px; }
.page-view { padding-top: 12px; }
.card { border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card h3 { font-family: var(--sans); font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.card h2 { font-family: var(--sans); font-weight: 700; font-size: 22px; letter-spacing: -.015em; }
.app-main .display-sm { font-family: var(--sans); font-weight: 800; font-size: clamp(26px, 3vw, 32px); letter-spacing: -.025em; }
.app-main .script { font-family: var(--sans); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin-bottom: 4px; }
.card-head { align-items: center; }
.hello { margin: 0 0 4px; color: var(--muted); font-size: 14.5px; font-weight: 500; }
.dash-title { margin-bottom: 14px; }

/* Barra de periodo */
.toolbar { top: 80px; padding: 14px 18px; align-items: center; border-radius: 18px; }
.toolbar .field label { font-size: 11.5px; }
.toolbar select, .toolbar input[type="date"] { border-radius: 12px; background: var(--app-bg); border-color: transparent; font-weight: 600; }
.toolbar #pdfBtn { background: var(--ink); border-color: var(--ink); }
.toolbar #pdfBtn:hover { background: #172a52; }

/* KPIs con icono */
.kpis { gap: 16px; margin-bottom: 14px; }
.kpi { border: 1px solid var(--card-line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); position: relative; }
.kpi.main { background: #fff; border-color: var(--card-line); }
.k-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.k-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--brand); }
.k-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi .k-label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); text-transform: none; letter-spacing: 0; }
.kpi .k-value { font-size: clamp(20px, 1.9vw, 28px); font-weight: 750; letter-spacing: -.02em; margin: 0 0 6px; }
.kpi .k-prev { font-size: 12px; }
.kpi.main .k-icon { background: var(--brand); color: #fff; }
.ic-fees { background: #fff1f2; color: #e11d48; }
.ic-ship { background: #fff7ed; color: #ea580c; }
.ic-net { background: #ecfdf5; color: #059669; }
.kpi.main .ic-net { background: #059669; color: #fff; }
.ic-units { background: #f5f3ff; color: #7c3aed; }
.ic-orders { background: #eff6ff; color: #2563eb; }
.ic-ticket { background: #fefce8; color: #ca8a04; }
.ic-margin { background: #f0fdfa; color: #0d9488; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.delta.up { background: #e7f8ee; color: #15803d; }
.delta.down { background: #fdecec; color: #c53030; }
.delta.flat { background: var(--soft); color: var(--muted); }

/* Controles segmentados tipo píldora */
.seg { background: var(--app-bg); border: 0; border-radius: 999px; padding: 4px; }
.seg button { border-radius: 999px; padding: 8px 14px; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--brand); box-shadow: 0 2px 6px rgba(16,24,40,.1); }

/* Tablas más limpias */
.table th { background: #f7f8fc; border-bottom: 0; color: #7a8399; }
.table thead th:first-child { border-radius: 10px 0 0 10px; }
.table thead th:last-child { border-radius: 0 10px 10px 0; }
.table td { border-bottom: 1px solid #f0f2f7; }
.table tbody tr:hover td { background: #f8faff; }
.table tr.total td { background: #f7f8fc; border-top: 0; }
.input, select, input[type="date"] { border-radius: 12px; }

/* Tarjetas con tinte → blancas */
.card.tint-mint, .card.tint-peach, .card.tint-lilac { background: #fff; border-color: var(--card-line); }
.table-wrap.inner-mint, .table-wrap.inner { border-color: var(--card-line); }

/* Pantalla de carga de archivos */
.hero { padding: 36px 0 48px; background: transparent; }
.hero .display { font-family: var(--sans); font-weight: 800; letter-spacing: -.035em; font-size: clamp(32px, 4.6vw, 54px); line-height: 1.05; }
.hero .display em { font-style: normal; color: var(--brand); }
.dropzone { border-radius: 24px; background: #fff; border-width: 2px; box-shadow: var(--shadow); }

/* Pie */
.app-main .footer { background: transparent; border-top: 1px solid var(--card-line); }

@media (max-width: 980px) {
  .sidebar { top: 0; height: 100vh; width: 284px; z-index: 40; }
  .side-backdrop { inset: 0; z-index: 35; }
  .mobile-brand { display: inline-flex; }
  .app-topbar { padding: 0 16px; }
  .top-search { display: none; }
  .app-body { padding: 8px 16px 32px; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px; }
  .k-icon { width: 30px; height: 30px; }
  .avatar { width: 34px; height: 34px; }
  .topbar-actions #upgradeBtn { display: none; }
}

/* Tipografía: todo en sans moderna (antes serif) */
:root { --serif: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.period-label .strong { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.dialog h2 { font-weight: 800; font-size: 28px; letter-spacing: -.02em; }
.price, .plan-status .big { font-weight: 800; letter-spacing: -.03em; }
.lock-copy h4 { font-weight: 700; font-size: 20px; letter-spacing: -.015em; }
.manual-body h2 { font-weight: 700; font-size: 22px; letter-spacing: -.015em; }
.pd-title { font-weight: 700; font-size: 20px; letter-spacing: -.015em; }
.hero { border-bottom: 0; }
.dialog .script { font-family: var(--sans); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }

@media (max-width: 640px) {
  .mobile-brand .brand-name { display: none; }
  .app-topbar { gap: 10px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions #planBadge { display: none; }
  .kpi .k-value { font-size: 17px; letter-spacing: -.03em; }
  .kpi .k-label { font-size: 12.5px; line-height: 1.25; }
  .k-head { gap: 8px; align-items: flex-start; }
  .kpi .k-prev span { display: block; }
  .toolbar { position: static; }
}

/* Filtro de costos */
.costs-filter { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 14px 0 8px; }
.costs-filter .input { flex: 1; min-width: 220px; margin: 0; }
.seg-n { display: inline-block; min-width: 20px; margin-left: 4px; padding: 1px 6px; border-radius: 999px; font-size: 11px; background: #e9edf5; color: var(--ink-2); }
.seg-n.warn { background: #fdecec; color: #c53030; }
.seg-n.ok { background: #e7f8ee; color: #15803d; }

/* =====================================================================
   Panel en cuadrícula: las secciones se acomodan una al lado de otra
   para aprovechar el ancho de la pantalla.
   ===================================================================== */
.app-body { max-width: 1680px; }

/* Explicaciones plegables: botón "?" junto al título */
.help-btn { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-left: 8px; border-radius: 50%; border: 1px solid var(--line-2); background: #fff; color: var(--muted); font: 700 11.5px var(--sans); cursor: pointer; vertical-align: middle; position: relative; top: -2px; }
.help-btn:hover, .help-btn[aria-expanded="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.card.has-help:not(.show-help) > .section-help { display: none; }
.card.show-help > .section-help { background: var(--app-bg); border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; }

@media (min-width: 760px) {
  #dashboard:not([hidden]) { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
  #dashboard > * { grid-column: 1 / -1; margin: 0; min-width: 0; }
  #dashboard .grp { display: contents; }
  #dashboard .card { margin: 0; display: flex; flex-direction: column; }
  #dashboard .card > .table-wrap, #dashboard .card > .chart-box { flex: 0 0 auto; }
  #dashboard .kpis { margin: 0; }
  #dashboard .dash-title { order: 1; margin-bottom: -6px; }
  #dashboard .toolbar { order: 2; }
  #dashboard #kpis { order: 3; }
  #dashboard #estNote { order: 4; margin-top: -8px; }
  #sec-tendencia { order: 10; }
  #sec-canales { order: 11; }
  #card-account { order: 20; }
  #sec-utilidad { order: 21; }
  #sec-detalle { order: 30; }
  #sec-buscar { order: 40; }
  #sec-oportunidades { order: 41; }
  #sec-productos { order: 50; }
  #card-toprevenue { order: 51; }
  #topProfitCard { order: 52; }
  #sec-semanas { order: 60; }
  #sec-destinos { order: 70; }
  #sec-paquetes { order: 80; }
  #sec-sku { order: 90; }
  #dashboard .settings-hint { order: 99; margin-top: -6px; }

  /* Tableta: parejas de tarjetas */
  #sec-canales, #card-account, #sec-productos, #card-toprevenue { grid-column: span 6; }
  #topProfitCard { grid-column: span 12; }
}

@media (min-width: 1180px) {
  #sec-tendencia { grid-column: span 8; }
  #sec-canales { grid-column: span 4; }
  #card-account { grid-column: span 5; }
  #sec-utilidad { grid-column: span 7; }
  #sec-buscar { grid-column: span 5; }
  #sec-oportunidades { grid-column: span 7; }
  #sec-productos, #card-toprevenue, #topProfitCard { grid-column: span 4; }
  /* Sin tarjeta de utilidad por producto: dos columnas de top */
  #dashboard:has(#topProfitCard[hidden]) #sec-productos,
  #dashboard:has(#topProfitCard[hidden]) #card-toprevenue { grid-column: span 6; }
  /* Con un producto abierto, el buscador y oportunidades ocupan todo el ancho */
  #dashboard:has(#prodDetail > *) #sec-buscar,
  #dashboard:has(#prodDetail > *) #sec-oportunidades { grid-column: span 12; }

  /* Destinos: barras a la izquierda y tabla a la derecha */
  .dest-layout { grid-template-columns: minmax(260px, 1fr) 2.2fr; }
  .dest-bars { grid-template-columns: 1fr; }
  /* Las tarjetas angostas se ven mejor con tablas compactas */
  #sec-detalle .table td, #sec-detalle .table th { padding: 8px; font-size: 13px; }
  #sec-tendencia .chart-box.tall { height: 330px; }
  #sec-canales .chart-box { height: 330px; }
}

@media (min-width: 1500px) {
  #sec-semanas { grid-column: span 7; }
  #sec-paquetes { grid-column: span 5; }
  #dashboard:has(#sec-paquetes[hidden]) #sec-semanas { grid-column: span 12; }
  #sec-paquetes .pkg-kpis { grid-template-columns: repeat(2, 1fr); }
  #sec-paquetes { order: 61; }
}

/* Ajuste de la cuadrícula: parejas equilibradas y listas largas con scroll interno */
@media (min-width: 760px) {
  #sec-buscar { order: 25; grid-column: 1 / -1; }
  #sec-detalle { order: 30; }
  #sec-productos { order: 40; }
  #card-toprevenue { order: 41; }
  #topProfitCard { order: 42; }
  #sec-semanas { order: 50; }
  #sec-oportunidades { order: 51; }
  #sec-destinos { order: 60; }
  #sec-paquetes { order: 70; }
  #sec-sku { order: 80; }
  #sec-paquetes .table-wrap, #sec-destinos .table-wrap, #sec-semanas .table-wrap { max-height: 460px; overflow: auto; }
  #opportunities { max-height: 520px; overflow: auto; padding-right: 4px; }
  #sec-productos .table-wrap, #card-toprevenue .table-wrap, #topProfitCard .table-wrap { max-height: 560px; overflow: auto; }
}
@media (min-width: 1180px) {
  #card-account { grid-column: span 4; }
  #sec-utilidad { grid-column: span 8; }
  #sec-buscar, #dashboard:has(#prodDetail > *) #sec-buscar { grid-column: 1 / -1; }
  #sec-oportunidades, #dashboard:has(#prodDetail > *) #sec-oportunidades { grid-column: span 5; }
  #sec-semanas { grid-column: span 7; }
  #sec-paquetes { grid-column: 1 / -1; order: 70; }
  #dashboard:has(#sec-paquetes[hidden]) #sec-semanas { grid-column: span 7; }
}
@media (min-width: 1500px) {
  #sec-paquetes .pkg-kpis { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 760px) { #dashboard .toolbar { display: flex; flex-direction: row; align-items: center; } }
@media (min-width: 1180px) {
  #sec-oportunidades .opp { grid-template-columns: 1fr; gap: 6px; align-items: start; }
  #sec-oportunidades .opp .tag { justify-self: start; }
}
.opp { border-color: var(--card-line); }
.dest-layout { grid-template-columns: minmax(0, 1fr); }
.dest-layout > * { min-width: 0; }
@media (min-width: 1180px) { .dest-layout { grid-template-columns: minmax(240px, 1fr) minmax(0, 2.2fr); } }
@media (min-width: 1700px) { .kpis { grid-template-columns: repeat(8, minmax(0, 1fr)); } .kpi .k-value { font-size: 22px; } .kpi .k-label { font-size: 12.5px; } }

/* ---------- Reclamos y disputas ---------- */
#sec-reclamos { order: 65; }
.claims-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
@media (min-width: 1180px) { .claims-layout { grid-template-columns: minmax(260px, 1fr) minmax(0, 2.2fr); } }
.claims-layout > * { min-width: 0; }
#sec-reclamos .table-wrap { max-height: 440px; overflow: auto; }
.claim-state { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.claim-state.open { background: #fff4e5; color: #b45309; }
.claim-state.closed { background: #e7f8ee; color: #15803d; }
.claim-med { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #f1edff; color: #5b3fd1; }
.claim-split { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--line); margin: 8px 0 4px; }
.claim-split i { display: block; height: 100%; }

/* ---------- Asistente de IA ---------- */
.ai-fab { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border: 0; border-radius: 999px; font: 700 14px var(--sans); color: #fff; cursor: pointer; background: linear-gradient(135deg, #2563eb, #7c3aed); box-shadow: 0 10px 30px rgba(37, 99, 235, .35); transition: transform .15s ease; }
.ai-fab:hover { transform: translateY(-2px); }
.ai-spark { font-size: 16px; line-height: 1; }
body.ai-open .ai-fab { display: none; }
.ai-panel { position: fixed; right: 18px; bottom: 18px; top: 86px; z-index: 60; width: min(420px, calc(100vw - 32px)); display: flex; flex-direction: column; background: #fff; border: 1px solid var(--card-line); border-radius: 20px; box-shadow: 0 24px 70px rgba(16, 24, 40, .22); overflow: hidden; }
.ai-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--card-line); background: linear-gradient(135deg, #eef3ff, #f5f0ff); }
.ai-head b { font-size: 15px; }
.ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--app-bg); }
.ai-msg { display: flex; }
.ai-msg.me { justify-content: flex-end; }
.ai-bubble { max-width: 92%; padding: 10px 13px; border-radius: 16px; background: #fff; border: 1px solid var(--card-line); font-size: 14px; line-height: 1.5; }
.ai-msg.me .ai-bubble { background: var(--brand); color: #fff; border-color: var(--brand); border-bottom-right-radius: 6px; }
.ai-msg.bot .ai-bubble { border-bottom-left-radius: 6px; }
.ai-msg.err .ai-bubble { background: #fff6f6; border-color: #f3c7c7; color: #9b1c1c; }
.ai-bubble p { margin: 0 0 6px; } .ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble h4 { margin: 10px 0 4px; font-size: 14px; } .ai-bubble h4:first-child { margin-top: 0; }
.ai-bubble ul, .ai-bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.ai-bubble li { margin: 2px 0; }
.ai-typing { display: inline-flex; gap: 4px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: #a8b3c7; animation: aiDot 1s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; } .ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; background: var(--app-bg); }
.ai-chips:not(:empty) { padding-bottom: 10px; }
.ai-chip { font: 600 12.5px var(--sans); color: var(--brand); background: #fff; border: 1px solid #c9d7fb; border-radius: 999px; padding: 6px 10px; cursor: pointer; text-align: left; }
.ai-chip:hover { background: var(--accent-soft); }
.ai-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--card-line); }
.ai-form textarea { flex: 1; resize: none; font: 14px/1.4 var(--sans); min-height: 44px; max-height: 140px; }
.ai-form .btn { padding: 0 14px; }
.ai-note { margin: 0; padding: 0 14px 10px; font-size: 11.5px; color: var(--muted); }
.ai-lock, .ai-empty { margin: auto; text-align: center; padding: 20px; max-width: 320px; }
.ai-lock .ai-spark { font-size: 30px; color: #7c3aed; }
.ai-lock h4 { margin: 8px 0; font-size: 17px; }
@media (max-width: 640px) { .ai-panel { top: 70px; right: 8px; left: 8px; bottom: 8px; width: auto; } .ai-fab { right: 14px; bottom: 14px; } }
@media print { .ai-fab, .ai-panel { display: none !important; } }

/* ---------- Agencias ---------- */
.client-switch { margin: 0 4px 14px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); display: grid; gap: 6px; }
.client-switch label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: rgba(255,255,255,.7); }
.client-switch select { width: 100%; border-radius: 10px; border: 0; padding: 8px 10px; font: 600 14px var(--sans); color: var(--ink); background: #fff; }
.client-manage { font-size: 12.5px; color: rgba(255,255,255,.85); text-decoration: none; }
.client-manage:hover { color: #fff; text-decoration: underline; }
.clients-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.clients-count { font-size: 18px; }
#clientForm .input { min-width: 260px; margin: 0; }
#clientsTable tr.is-active td { background: #f5f8ff; }
.plans { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.dialog { max-width: 980px; }
.plan-col.agency { border: 2px solid #7c3aed; background: #faf7ff; }
.plan-col.agency h3 { color: #6d28d9; }
.pay-plan { display: grid; gap: 10px; margin-bottom: 14px; }
.pay-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px; background: #faf7ff; border: 1px solid #e3d8fb; border-radius: 12px; font-size: 14px; }
.pay-extra label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pay-extra input { width: 80px; margin: 0; }

/* Clientes extra (Agencias) */
.extras-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.extras-row label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.extras-row input { width: 90px; margin: 0; }
.extras-price { font-size: 14.5px; }

/* Recordatorio semanal */
.reminder-field { grid-column: 1 / -1; }
.switch-row { display: flex; align-items: flex-start; gap: 8px; font-weight: 500 !important; text-transform: none !important; letter-spacing: 0 !important; font-size: 14px !important; color: var(--ink) !important; }
.switch-row input { margin-top: 3px; }
.reminder-admin { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 12px; display: grid; gap: 8px; }

/* Resumen de clientes (Agencias) */
.agency-overview-wrap { padding-top: 8px; padding-bottom: 0; }
.ov-alert { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin: 1px 2px 1px 0; white-space: nowrap; }
.ov-alert.bad { background: #fdecec; color: #c53030; }
.ov-alert.warn { background: #fff4e5; color: #b45309; }
.ov-alert.muted { background: var(--soft); color: var(--muted); }

/* Plantilla para otros canales: tarjeta visible */
.template-card { display: flex; align-items: center; gap: 14px; max-width: 760px; margin: 18px auto 0; padding: 14px 16px; text-align: left; background: #fff; border: 1px solid #c9d7fb; border-radius: 18px; box-shadow: var(--shadow); }
.tc-icon { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--brand); }
.tc-icon svg, .template-card .btn svg, #filesSection [data-template] svg, .side-btn[data-template] svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tc-icon svg { width: 20px; height: 20px; }
.tc-text { flex: 1; display: grid; gap: 2px; font-size: 14px; color: var(--ink-2); }
.tc-text b { color: var(--ink); font-size: 15px; }
.tc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.template-card .btn, #filesSection [data-template] { display: inline-flex; align-items: center; gap: 6px; }
.side-btn[data-template] svg { fill: none; stroke: #fff; }
@media (max-width: 640px) { .template-card { flex-direction: column; align-items: flex-start; } }

/* Agencias: crear el primer cliente */
.need-client { text-align: center; padding: 40px 24px; max-width: 640px; margin: 24px auto; }
.need-client h2 { margin: 12px 0 8px; }
.need-client p { max-width: 480px; margin: 0 auto 18px; }
.nc-icon { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--brand); }
.nc-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notice-card { padding: 16px 18px; }

/* Metas y notas (Agencias) */
.small-dialog { max-width: 560px; }
.ov-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.goal-cell { min-width: 150px; display: grid; gap: 4px; }
.goal-bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.goal-bar i { display: block; height: 100%; border-radius: 999px; }
.note-form { display: grid; gap: 8px; margin: 10px 0 14px; }
.note-form textarea { margin: 0; resize: vertical; font: 14px/1.4 var(--sans); }
.notes-list { display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.note { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--card-line); border-radius: 12px; background: #fff; }
.note.is-task { border-color: #fde3b0; background: #fffaf0; }
.note.is-done { opacity: .6; }
.note.is-done .note-body > div { text-decoration: line-through; }
.note-body { display: grid; gap: 2px; font-size: 14px; }
.note-dot { color: var(--muted); line-height: 1.4; }
