/* Oveja DAG · tema y componentes propios. Se carga DESPUÉS de styles.css (la base heredada de Fatari) y manda
   sobre ella. Lenguaje de GIRMO Valle Blanco: Archivo + IBM Plex Mono, fondo #E9EDED, tinta #0F1618, azul de
   marca #2563EB para todo lo activo, superficies con radio 12 px y sombra suave, sin fondos negros.
   El color se reserva para estados y para el semáforo. Detalle en docs/diseno.md. */
:root {
    color-scheme: light;
    --bg: #E9EDED; --card: #FFFFFF; --soft: #F3F6F6; --line: #D9DFE0; --line-fuerte: #B4BEC1;
    --ink: #0F1618; --muted: #5B6770; --muted-2: #8A959C;
    --brand: #2563EB; --brand-ink: #FFFFFF; --brand-soft: #E6EEFD; --brand-2: #1D4ED8;
    --acento: #B45309; --acento-soft: #FDF1DC; --acento-ink: #7A3A06;
    --pos: #15803D; --pos-soft: #DFF3E6; --warn: #B7791F; --warn-soft: #FBF0D0; --neg: #C2410C; --neg-soft: #FBE4D8; --info: #2E6FA7; --info-soft: #E1EDF7;
    --sombra: 0 1px 2px rgba(15, 22, 24, .05), 0 4px 14px rgba(15, 22, 24, .06);
    --r: 12px; --r-chico: 8px;
}
:root[data-tema="oscuro"] {
    color-scheme: dark;
    --bg: #161B26; --card: #1E2533; --soft: #252D3D; --line: #323C4F; --line-fuerte: #4A566C;
    --ink: #E6EAF0; --muted: #A3AEC0; --muted-2: #76829A;
    --brand: #6B9BF5; --brand-ink: #0F1524; --brand-soft: #24324F; --brand-2: #8FB4F8;
    --acento: #E0A458; --acento-soft: #3A2C17; --acento-ink: #F3CF9C;
    --pos: #5CC98A; --pos-soft: #183326; --warn: #E5B94E; --warn-soft: #3A3014; --neg: #F28B66; --neg-soft: #40221A; --info: #7FB3E0; --info-soft: #1B2E42;
    --sombra: 0 1px 2px rgba(0, 0, 0, .35);
}

/* ── Radios y superficies ────────────────────────────────────────────── */
.card, .modal, .menu-mas .hoja { border-radius: var(--r); }
.menu-mas .hoja { border-radius: var(--r) var(--r) 0 0; border-top: 0; }
.btn, .campo input, .campo select, .campo textarea, .input, .icono-btn, .segmento, .stepper, .aviso-inline, .toast { border-radius: var(--r-chico); }
.segmento, .stepper { overflow: hidden; }
.chip, .estado { border-radius: 999px; }
.nav-item { border-radius: var(--r-chico); border-left: 0; }
.nav-item.activo { background: var(--brand-soft); color: var(--brand-2); }
.nav-inferior .nav-item { border-radius: 0; }
.nav-inferior .nav-item.activo { color: var(--brand); border-top-color: var(--brand); }
.nav-inferior .nav-item.destacado .ico { color: var(--brand); }
.login-wrap { background: linear-gradient(180deg, var(--brand-soft) 0, var(--bg) 45%); }
.brand .ao, .sidebar .marca b .ao, .topbar .marca-movil .ao { color: var(--brand); }
.badge { background: var(--neg); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline-color: var(--brand); }
.campo input, .campo select, .campo textarea { font-size: 16px; }   /* 16 px: iOS no hace zoom al enfocar */
.tabla-wrap { border-radius: var(--r); }
.aviso.nuevo { background: var(--brand-soft); border-left-color: var(--brand); }
.vista-cab { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.volver { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 4px 0; color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.sec { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 4px; }
.sec .rotulo { font-size: 11px; }

/* ── Estados de la nota ──────────────────────────────────────────────── */
.estado.por_evaluar { color: var(--acento-ink); background: var(--acento-soft); }
.estado.aprobada { color: var(--brand-2); background: var(--brand-soft); }
.estado.facturada { color: var(--info); background: var(--info-soft); }
.estado.despachada { color: var(--info); background: var(--info-soft); }
.estado.entregada { color: var(--pos); background: var(--pos-soft); }
.estado.rechazada, .estado.anulada { color: var(--neg); background: var(--neg-soft); }

/* ── Semáforo (lo único que el vendedor ve del margen) ───────────────── */
.luz { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 8px; border-radius: 999px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; font-weight: 600; white-space: nowrap; }
.luz::before { content: ''; width: 11px; height: 11px; border-radius: 50%; background: currentColor; }
.luz.verde { color: var(--pos); background: var(--pos-soft); }
.luz.amarillo { color: var(--warn); background: var(--warn-soft); }
.luz.rojo { color: var(--neg); background: var(--neg-soft); }
.luz.neutro { color: var(--muted); background: var(--soft); }
.luz.grande { font-size: 12px; padding: 7px 14px 7px 11px; }
.luz.grande::before { width: 14px; height: 14px; }

/* ── Indicadores ─────────────────────────────────────────────────────── */
.kpis.seis { grid-template-columns: repeat(3, 1fr); }
.kpis.cuatro { grid-template-columns: repeat(4, 1fr); }
.kpi { border-radius: var(--r); border-top: 0; position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-fuerte); }
.kpi.k-venta::before { background: var(--brand); } .kpi.k-margen::before { background: var(--pos); } .kpi.k-cli::before { background: var(--info); }
.kpi.k-alerta::before { background: var(--acento); } .kpi.k-neg::before { background: var(--neg); }
.kpi.clic { cursor: pointer; } .kpi.clic:hover { border-color: var(--brand); }
.kpi .n small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
@media (max-width: 820px) { .kpis.seis, .kpis.cuatro { grid-template-columns: 1fr 1fr; } .kpi .n { font-size: 21px; } }

/* Venta diaria: columnas de un solo eje, sin librerías */
.dias { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 16px; }
.dias .d { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; position: relative; }
.dias .d i { display: block; width: 100%; max-width: 26px; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; }
.dias .d.hoy i { background: var(--brand-2); outline: 2px solid var(--brand-soft); }
.dias .d.cero i { background: var(--line); }
.dias .d span { font-family: var(--mono); font-size: 9px; color: var(--muted-2); }
.dias .d b { position: absolute; top: -14px; font-family: var(--mono); font-size: 9px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.dias .prom { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--muted-2); pointer-events: none; }
.dias-wrap { position: relative; }

/* ── Ruta: comunas y clientes ────────────────────────────────────────── */
.fila-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 13px 14px; cursor: pointer; align-items: center; text-align: left; width: 100%; color: inherit; font: inherit; }
.fila-card:hover { border-color: var(--brand); }
.fila-card .t { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-card .d { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-card .lado { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.fila-card .barra { grid-column: 1 / -1; border-radius: 4px; overflow: hidden; height: 6px; border: 0; background: var(--line); }
.fila-card .barra > i { background: var(--brand); }
.fila-card.lista .barra > i { background: var(--pos); }
.fila-card.hecho { background: var(--soft); }
.tam { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; font-family: var(--mono); font-size: 11px; font-weight: 600; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.tam.A { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); } .tam.B { background: var(--brand-soft); color: var(--brand-2); border-color: var(--brand-soft); }
.tam.pri { background: var(--acento-soft); color: var(--acento-ink); border-color: var(--acento-soft); }
.buscador { position: sticky; top: 57px; z-index: 15; background: var(--bg); padding: 6px 0; margin: -6px 0; }
.buscador input { width: 100%; padding: 12px 14px; border: 1px solid var(--line-fuerte); border-radius: var(--r); background: var(--card); font-size: 16px; min-height: 48px; }
.buscador input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line-fuerte); background: var(--card); color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; cursor: pointer; min-height: 36px; }
.chips button.activo { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* Ficha del cliente y visita */
.ficha-dir { padding: 14px 16px; background: var(--brand-soft); border-radius: var(--r); display: flex; flex-direction: column; gap: 4px; }
.ficha-dir .dir { font-size: 18px; font-weight: 700; line-height: 1.2; }
.botones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.botones.dos { grid-template-columns: 1fr 1fr; }
.botones .btn { min-height: 48px; }
.btn.elegido { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.elegido.no { background: var(--neg); border-color: var(--neg); }
.resultado-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.resultado-grid .btn { min-height: 52px; white-space: normal; text-align: center; line-height: 1.2; }
.resultado-grid .btn.ancho { grid-column: 1 / -1; }

/* ── Pedido rápido ───────────────────────────────────────────────────── */
.prod { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; padding: 12px 14px; align-items: center; border-bottom: 1px solid var(--line); }
.prod:last-child { border-bottom: 0; }
.prod.en-pedido { background: var(--brand-soft); }
.prod .nom { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.prod .cod { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.prod .precios { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pre { display: inline-flex; flex-direction: column; padding: 4px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-variant-numeric: tabular-nums; line-height: 1.15; }
.pre small { font-family: var(--mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pre b { font-size: 14px; }
.pre.activo { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.pre.activo small { color: var(--brand-2); }
.prod .stepper button { width: 44px; min-height: 44px; font-size: 22px; }
.prod .stepper input { width: 52px; min-height: 44px; background: var(--card); }
.btn-mas { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); font-size: 24px; line-height: 1; cursor: pointer; }
.prod .ajuste { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.prod .ajuste .precio-wrap input { width: 120px; min-height: 40px; padding: 8px 10px 8px 22px; border: 1px solid var(--line-fuerte); border-radius: var(--r-chico); background: var(--card); font-size: 16px; }
.prod .ajuste .precio-wrap input.bajo { border-color: var(--warn); background: var(--warn-soft); }
.prod .ajuste .precio-wrap input.muy-bajo { border-color: var(--neg); background: var(--neg-soft); }
.barra-accion { border-radius: var(--r) var(--r) 0 0; box-shadow: 0 -6px 20px rgba(15, 22, 24, .08); flex-wrap: wrap; }
.barra-accion .tot { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.barra-accion .tot b { font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.barra-accion .tot span { font-size: 12px; color: var(--muted); }
.barra-accion .aviso-eval { flex-basis: 100%; font-size: 12.5px; }
.cliente-elegido { border-radius: var(--r); background: var(--card); border-color: var(--line); }
.cliente-pick .resultados { border-radius: var(--r); }

/* ── Evaluación (director) ───────────────────────────────────────────── */
.eval { padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--acento); background: var(--acento-soft); display: flex; flex-direction: column; gap: 10px; }
.eval .cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.eval .cifras .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.margen-barra { height: 10px; border-radius: 5px; background: var(--line); position: relative; }
.margen-barra > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--pos); }
.margen-barra > i.amarillo { background: var(--warn); } .margen-barra > i.rojo { background: var(--neg); }
.margen-barra > .meta { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
td.bajo { color: var(--warn); font-weight: 600; } td.muy-bajo { color: var(--neg); font-weight: 600; }
.pasos { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.pasos span.hecho { color: var(--pos); } .pasos span.actual { color: var(--ink); font-weight: 600; }
.pasos i { width: 14px; height: 1px; background: var(--line-fuerte); }

/* ── Catálogo y cartera (director) ───────────────────────────────────── */
.celda-input { width: 84px; padding: 6px 8px; border: 1px solid var(--line-fuerte); border-radius: 6px; background: var(--card); text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.celda-input.chica { width: 58px; }
textarea.pegar { width: 100%; min-height: 150px; padding: 12px; border: 1px dashed var(--line-fuerte); border-radius: var(--r); background: var(--card); font-family: var(--mono); font-size: 12px; white-space: pre; overflow: auto; }
.comunas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; max-height: 60vh; overflow: auto; padding: 2px; }
.comuna-op { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-chico); background: var(--card); cursor: pointer; font-size: 13.5px; }
.comuna-op.sel { border-color: var(--brand); background: var(--brand-soft); }
.comuna-op input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.comuna-op .d { font-size: 11.5px; color: var(--muted); }
tr.error td { background: var(--neg-soft); }
tr.inactivo td { opacity: .5; }

/* ── Ajustes finos ───────────────────────────────────────────────────── */
a.btn { text-decoration: none; }
.tabla td.num, .tabla th.num { white-space: nowrap; }
.kpi .sub { line-height: 1.3; }
.calle-cab { margin-top: 10px; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.calle-cab .rotulo:first-child { color: var(--ink); font-weight: 600; font-size: 11.5px; }
