/* Estilos específicos de la vista: dashboard */
/* Incluye también: historial de Ventas (vt-*) y Recibo (rc-*), con reglas de impresión. */

:root {
  /* Gráfico: una sola serie en latón; "hoy" en latón profundo (validado: ΔE 24 normal y CVD).
     El latón claro queda < 3:1 sobre la tarjeta → alivio: etiquetas directas, tooltip y vista de tabla. */
  --chart-bar: var(--brass-2);
  --chart-bar-hover: #b6873a;
  --chart-hoy: #7a5418;
  --chart-hoy-hover: #8e6420;
  --chart-grid: #efe5d4;
  --chart-axis: var(--line-2);
}

/* ═════════════════════════ Inicio ═════════════════════════ */
.db-kpis { margin-bottom: 18px; }
.db-kpis .kpi { min-height: 132px; }
.db-kpi-ico { position: absolute; top: 18px; right: 18px; width: 24px; height: 24px; color: var(--brass); opacity: .75; }
.db-kpi-ico svg { width: 100%; height: 100%; }
.kpi-accent .db-kpi-ico { color: var(--brass-2); opacity: 1; z-index: 1; }
.db-kpis .kpi-foot strong { color: inherit; font-weight: 700; }
.db-kpis .kpi-label { padding-right: 34px; }
.db-inline-ico { width: 14px; height: 14px; vertical-align: -2px; color: var(--sage); }
.db-delta { font-weight: 700; white-space: nowrap; }
.db-delta.up { color: var(--sage); }
.db-delta.down { color: var(--oxblood); }
.db-delta.flat { color: var(--ink-2); }

.db-duo { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.db-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.db-duo > .card, .db-trio > .card { min-width: 0; }
.db-duo .card-header h3, .db-trio .card-header h3, .vt-tabla-card .card-header h3 { font-size: 1.15rem; }
.db-duo .card-header .muted.small, .db-trio .card-header .muted.small { margin-top: 2px; }
.db-head-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brass-soft); color: var(--brass); flex: none; }
.db-head-ico svg { width: 17px; height: 17px; }

/* ── Gráfico de barras ── */
.db-chart { position: relative; }
.db-chart [data-svg] { width: 100%; min-height: 340px; }
.db-svg { display: block; width: 100%; height: auto; overflow: visible; }
.db-svg text { font-family: var(--font-body); font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.db-svg .db-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.db-svg .db-base { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.db-svg .db-xtick { font-weight: 600; letter-spacing: .02em; }
.db-svg .db-xday { fill: var(--ink-2); font-size: 12px; }
.db-svg .db-val { fill: var(--ink-2); font-size: 11.5px; font-weight: 700; }
.db-bar { cursor: default; outline: none; }
.db-bar .db-hit { fill: transparent; transition: fill .15s; }
.db-bar .db-mark { fill: var(--chart-bar); transition: fill .15s; }
.db-bar.is-hoy .db-mark { fill: var(--chart-hoy); }
.db-bar.is-hoy .db-xtick, .db-bar.is-hoy .db-xday { fill: var(--ink); font-weight: 700; }
.db-bar.is-hoy .db-val { fill: var(--ink); }
.db-bar.is-activa .db-hit { fill: rgba(201, 154, 75, .09); }
.db-bar.is-activa .db-mark { fill: var(--chart-bar-hover); }
.db-bar.is-hoy.is-activa .db-mark { fill: var(--chart-hoy-hover); }
.db-bar:focus-visible .db-hit { stroke: var(--brass); stroke-width: 1.5; }
.db-svg.animar .db-mark { transform-box: fill-box; transform-origin: 50% 100%; animation: db-crece .7s var(--ease) both; animation-delay: var(--d, 0ms); }
.db-svg.animar .db-val { animation: fade .4s ease .55s both; }
@keyframes db-crece { from { transform: scaleY(0); } }

.db-tip {
  position: absolute; z-index: 2; pointer-events: none; transform: translate(-50%, calc(-100% - 12px));
  background: var(--ink); color: #f8efe0; border-radius: 10px; padding: 8px 12px; white-space: nowrap;
  box-shadow: 0 12px 28px -14px rgba(0, 0, 0, .6); display: flex; flex-direction: column; gap: 1px; line-height: 1.25;
}
.db-tip[hidden] { display: none; }
.db-tip strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.db-tip span { font-size: .78rem; color: #c4b6a0; }
.db-tip::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; background: var(--ink); transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.db-tabla { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.db-tabla .table td, .db-tabla .table th { padding: 8px 12px; }
.db-tabla .table th { position: sticky; top: 0; background: #f6eee0; }
.db-tr-hoy td { font-weight: 700; }

/* ── Ranking de fragancias ── */
.db-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.db-rank li { display: flex; gap: 14px; align-items: flex-start; }
.db-rank .grow { display: flex; flex-direction: column; gap: 6px; }
.db-rank-n { width: 26px; flex: none; font-size: 1.5rem; line-height: 1; font-style: italic; color: var(--brass); text-align: center; padding-top: 1px; }
.db-rank li:first-child .db-rank-n { color: var(--ink); }
.db-rank-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-rank .money { font-size: .9rem; }

/* ── Listas (últimas ventas, alertas) ── */
.db-list { list-style: none; margin: 0 -10px; padding: 0; display: flex; flex-direction: column; }
.db-list > li + li { border-top: 1px solid var(--line); }
.db-item-title { display: block; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-list .muted.small { display: block; }
.db-alerta { display: flex; align-items: center; gap: 12px; padding: 11px 10px; }
.db-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--paper-2); color: var(--ink-2); }
.db-ico svg { width: 17px; height: 17px; }
.db-ico-fragancia { background: var(--c-fragancia-soft); color: var(--c-fragancia); }
.db-ico-frasco { background: var(--c-frasco-soft); color: var(--c-frasco); }
.db-ico-tercero { background: var(--c-tercero-soft); color: var(--c-tercero); }
.db-mas { padding: 10px 0 0; }

.db-venta {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 10px; text-align: left;
  border: 0; background: transparent; border-radius: 10px; cursor: pointer; font: inherit; color: inherit;
  transition: background .15s;
}
.db-venta:hover { background: rgba(243, 230, 204, .45); }
.db-venta:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }
.db-venta .grow { display: flex; flex-direction: column; }
.db-venta-num { flex: none; min-width: 52px; font-size: 1.02rem; color: var(--brass); font-style: italic; }
.db-venta-total { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.db-venta.is-void { color: var(--muted); }
.db-venta.is-void .db-venta-num { color: var(--muted); }
.db-venta.is-void .strike { text-decoration: line-through; }

/* ── Métodos de pago ── */
.db-metodos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.db-metodos li { display: flex; flex-direction: column; gap: 6px; }
.db-metodos .row-between > span:last-child { white-space: nowrap; }
.db-metodos .bar { height: 6px; }

.db-duo .empty, .db-trio .empty { padding: 26px 12px; }

/* ═════════════════════════ Ventas (historial) ═════════════════════════ */
.vt-filtros { padding: 16px 18px; margin-bottom: 18px; }
.vt-filtros .toolbar { margin-bottom: 12px; }
.vt-filtros .toolbar:last-child { margin-bottom: 0; }
.vt-rangos { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.vt-rangos button { white-space: nowrap; }
.vt-fechas { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.vt-fechas .input { width: 158px; height: 40px; }
.vt-filtros .search { min-width: 220px; }
.vt-filtros .search .input, .vt-metodo { height: 40px; }
.vt-metodo { width: auto; min-width: 190px; }
.vt-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .88rem; color: var(--ink-2); cursor: pointer; user-select: none; white-space: nowrap; padding: 0 4px; }
.vt-check input { width: 17px; height: 17px; accent-color: var(--brass); margin: 0; cursor: pointer; }

.vt-resultados { gap: 18px; }
.vt-resumen { display: grid; grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr)); padding: 0; }
.vt-res-cell { padding: 18px 20px; min-width: 0; }
.vt-res-cell + .vt-res-cell { border-left: 1px solid var(--line); }
.vt-res-cell .kpi-label { font-size: .7rem; }
.vt-res-valor { font-family: var(--font-display); font-size: 1.45rem; line-height: 1.15; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vt-res-main { background: linear-gradient(150deg, #241d16 0%, #15110d 100%); color: var(--side-ink); border-radius: calc(var(--radius) - 1px) 0 0 calc(var(--radius) - 1px); }
.vt-res-main .kpi-label, .vt-res-main .muted { color: #a39581; }
.vt-res-main .vt-res-valor { color: #f6e9d2; font-size: 1.7rem; }

.vt-tabla-card .card-header { padding-bottom: 14px; margin-bottom: 0; }
.vt-tabla .vt-row { cursor: pointer; }
.vt-tabla .vt-row:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }
.vt-num { font-size: 1.02rem; font-style: italic; color: var(--brass); white-space: nowrap; }
.vt-tabla tr.is-void .vt-num { color: var(--muted); }
.vt-tabla td { white-space: nowrap; }
.vt-detalle { white-space: normal !important; min-width: 220px; max-width: 360px; }
.vt-detalle .cell-title { font-weight: 500; }
.vt-tabla tr.is-void td:last-child { opacity: 1; }
.vt-mas { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 14px; border-top: 1px solid var(--line); }

/* ═════════════════════════ Recibo ═════════════════════════ */
.modal-recibo .modal-foot .rc-btn-anular { margin-right: auto; }
.rc .receipt-head { padding-bottom: 14px; }
.rc-brand { font-size: 1.6rem !important; line-height: 1.1; }
.rc .receipt-head .eyebrow { margin-top: 4px; letter-spacing: .28em; font-size: .64rem; }
.rc-num { margin-top: 10px; font-weight: 700; font-size: .95rem; letter-spacing: .02em; }
.rc-meta { margin: 0; padding: 10px 0; border-bottom: 1px dashed var(--line-2); display: flex; flex-direction: column; gap: 3px; font-size: .86rem; }
.rc-meta > div { display: flex; justify-content: space-between; gap: 12px; }
.rc-meta dt { color: var(--muted); }
.rc-meta dd { margin: 0; text-align: right; font-weight: 600; }
.rc-item { flex-direction: column; gap: 4px; }
.rc-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.rc-row > div { min-width: 0; }
.rc-name { font-weight: 600; }
.rc-sub { font-size: .78rem; color: var(--muted); }
.rc-nested { font-size: .84rem; color: var(--ink-2); padding-left: 2px; }
.rc-gift { color: var(--sage); font-weight: 700; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.rc .receipt-total { border-bottom: 1px solid var(--ink); padding-bottom: 14px; }
.rc-anulada .strike { text-decoration: line-through; color: var(--muted); }
.rc-note { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.rc-note p { margin: 3px 0 0; font-size: .88rem; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.rc-gifts { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 9px 12px; border-radius: 10px; background: var(--sage-soft); color: var(--sage); font-size: .86rem; }
.rc-gifts svg { width: 17px; height: 17px; flex: none; }
.rc-foot { text-align: center; margin-top: 18px; font-family: var(--font-display); font-style: italic; font-size: 1.05rem; color: var(--ink-2); }
.rc-void { margin-bottom: 14px; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--oxblood); background: var(--oxblood-soft); color: var(--oxblood); text-align: center; font-size: .84rem; }
.rc-void-title { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; letter-spacing: .16em; font-size: .95rem; }
.rc-void-title svg { width: 18px; height: 18px; }
.rc-void-motivo { margin-top: 2px; font-weight: 600; overflow-wrap: anywhere; }

/* ═════════════════════════ Responsive ═════════════════════════ */
@media (max-width: 1100px) {
  .db-duo { grid-template-columns: minmax(0, 1fr); }
  .db-trio { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .db-trio > :first-child { grid-column: 1 / -1; }
  .vt-resumen { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vt-res-main { grid-column: 1 / -1; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
  .vt-res-cell + .vt-res-cell { border-left: 0; }
  .vt-res-cell:nth-child(n + 2) { border-top: 1px solid var(--line); }
  .vt-res-cell:nth-child(3), .vt-res-cell:nth-child(4) { border-left: 1px solid var(--line); }
  .vt-res-cell:nth-child(5) { grid-column: span 3; border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .db-trio { grid-template-columns: minmax(0, 1fr); }
  .db-kpis .kpi { min-height: 0; }
  .page-header .page-actions { width: 100%; }
  .page-header .page-actions .btn { flex: 1; }
  .vt-fechas { margin-left: 0; width: 100%; }
  .vt-fechas .input { flex: 1; width: auto; min-width: 0; }
  .vt-filtros .search { min-width: 0; flex-basis: 100%; }
  .vt-metodo { flex: 1; min-width: 0; }
  .vt-resumen { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vt-res-cell { padding: 14px 16px; }
  .vt-res-cell:nth-child(3), .vt-res-cell:nth-child(4) { border-left: 0; }
  .vt-res-cell:nth-child(odd):not(.vt-res-main) { border-left: 1px solid var(--line); }
  .vt-res-cell:nth-child(5) { grid-column: auto; }
  .vt-res-valor { font-size: 1.2rem; }
  .vt-res-main .vt-res-valor { font-size: 1.5rem; }
  .vt-col-metodo { display: none; }
  .vt-tabla-card .card-header { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .db-kpi-ico { display: none; }
  .db-kpis .kpi-label { padding-right: 0; }
  .db-chart-card .card-header { flex-wrap: wrap; }
}

/* ═════════════════════════ Impresión del recibo ═════════════════════════ */
@media print {
  #print-root .receipt { max-width: 78mm; margin: 0 auto; color: #000; font-size: 10.5pt; }
  #print-root .receipt * { color: #000 !important; background: transparent !important; box-shadow: none !important; }
  #print-root .receipt-head, #print-root .rc-meta, #print-root .receipt-line, #print-root .rc-note { border-color: #000 !important; }
  #print-root .receipt .eyebrow, #print-root .rc-sub, #print-root .rc-meta dt { color: #333 !important; }
  #print-root .rc .receipt-total { border-bottom-color: #000; }
  #print-root .rc-void { border: 2px solid #000 !important; }
  #print-root .rc-gifts { border: 1px dashed #000; padding: 6px 8px; }
  #print-root .rc-gift { font-style: italic; }
  #print-root .receipt-line, #print-root .rc-item { break-inside: avoid; page-break-inside: avoid; }
}
