/* Rolleadas CDE · panel */
:root {
  color-scheme: light;
  --bg: #f4f3f8;
  --surface: #ffffff;
  --surface2: #f8f7fc;
  --line: #e6e4ef;
  --line2: #d6d3e3;
  --text: #16142b;
  --text2: #54516b;
  --muted: #8a87a0;
  --brand: #e3197f;
  --brand-soft: #fde7f2;
  --accent: #2a78d6;
  --accent-soft: #e5effb;
  --bar: #2a78d6;
  --ok: #138a4f; --ok-soft: #e1f5ea;
  --warn: #b26b00; --warn-soft: #fdf1dc;
  --bad: #c62f45; --bad-soft: #fde6ea;
  --wa: #1faa55;
  --shadow: 0 1px 2px rgba(20, 16, 50, .06), 0 8px 24px -12px rgba(20, 16, 50, .18);
  --r: 14px;
  --display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --body: "Manrope", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0b16; --surface: #16142a; --surface2: #1c1a33; --line: #2a2745; --line2: #3a3659;
    --text: #f3f1ff; --text2: #c4c0dc; --muted: #8f8aad; --brand: #ff4fa3; --brand-soft: #3a1630;
    --accent: #3987e5; --accent-soft: #1b2a45; --bar: #3987e5;
    --ok: #3ccf82; --ok-soft: #13301f; --warn: #f0b24a; --warn-soft: #33260e; --bad: #ff6b81; --bad-soft: #3a1520;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -14px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0b16; --surface: #16142a; --surface2: #1c1a33; --line: #2a2745; --line2: #3a3659;
  --text: #f3f1ff; --text2: #c4c0dc; --muted: #8f8aad; --brand: #ff4fa3; --brand-soft: #3a1630;
  --accent: #3987e5; --accent-soft: #1b2a45; --bar: #3987e5;
  --ok: #3ccf82; --ok-soft: #13301f; --warn: #f0b24a; --warn-soft: #33260e; --bad: #ff6b81; --bad-soft: #3a1520;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -14px rgba(0, 0, 0, .7);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 500 14.5px/1.5 var(--body); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* acceso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(60% 50% at 20% 10%, rgba(227, 25, 127, .18), transparent), radial-gradient(50% 50% at 90% 90%, rgba(42, 120, 214, .16), transparent), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 30px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font: 800 1.35rem/1.2 var(--display); margin: 0; }
.logo { display: flex; align-items: center; gap: 10px; font: 800 1rem/1 var(--display); }
.logo svg { width: 34px; height: 34px; }
.logo small { display: block; font: 800 .62rem/1 var(--body); letter-spacing: .3em; color: var(--brand); margin-top: 4px; }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 4px 10px 18px; }
.nav-a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text2); text-decoration: none; font-weight: 700; }
.nav-a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-a:hover { background: var(--surface2); color: var(--text); }
.nav-a.on { background: var(--brand-soft); color: var(--brand); }
.nav-a .cnt { margin-left: auto; font-size: .72rem; background: var(--brand); color: #fff; border-radius: 99px; padding: 1px 7px; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-weight: 800; font-size: .85rem; flex-shrink: 0; }
.me b { display: block; line-height: 1.2; font-size: .9rem; }
.me span { font-size: .75rem; color: var(--muted); text-transform: capitalize; }
.main { padding: 26px 30px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font: 800 1.45rem/1.2 var(--display); margin: 0; }
.topbar .sp { flex: 1; }
.btn.burger { display: none; }

/* botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface2); }
.btn svg { width: 16px; height: 16px; }
.btn-p { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-p:hover { background: var(--brand); filter: brightness(1.08); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa); filter: brightness(1.06); }
.btn-d { color: var(--bad); border-color: var(--bad-soft); }
.btn-d:hover { background: var(--bad-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: .82rem; border-radius: 8px; }
.btn-ico { width: 38px; padding: 0; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 14px; height: 36px; font-weight: 700; cursor: pointer; color: var(--text2); }
.seg button.on { background: var(--text); color: var(--surface); }

/* formularios */
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 700; font-size: .8rem; color: var(--text2); }
.field input, .field select, .field textarea, .in { width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--line2); background: var(--surface); padding: 0 12px; font-weight: 600; font-size: .9rem; color: var(--text); outline: none; }
.field textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint { font-weight: 600; color: var(--muted); font-size: .75rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line2); transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.err { color: var(--bad); font-weight: 700; font-size: .86rem; min-height: 1.2em; margin: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters .in { width: auto; min-width: 150px; }
.filters .search { min-width: 240px; flex: 1; max-width: 380px; }

/* tarjetas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font: 800 .98rem/1.3 var(--body); margin: 0 0 4px; }
.card .sub { color: var(--muted); font-size: .8rem; margin: 0 0 14px; }
.cards { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.kpi span { color: var(--text2); font-weight: 700; font-size: .8rem; }
.kpi b { font: 800 1.7rem/1.15 var(--display); letter-spacing: -.01em; }
.kpi small { color: var(--muted); font-weight: 600; font-size: .78rem; }
.kpi small .up { color: var(--ok); font-weight: 800; }
.row-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.row-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* gráficos (una serie, un tono) */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .ax { fill: var(--muted); font-size: 11px; font-family: var(--body); font-weight: 600; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g.b:hover .bar { filter: brightness(1.15); }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hb { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.hb-l { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; font-size: .85rem; }
.hb-l img { width: 30px; height: 30px; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--line); flex-shrink: 0; }
.hb-l span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-v { font-weight: 800; font-size: .85rem; color: var(--text); font-variant-numeric: tabular-nums; }
.hb-t { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.hb-f { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.empty { padding: 30px 14px; text-align: center; color: var(--muted); font-weight: 600; }
.tip { position: fixed; z-index: 300; pointer-events: none; background: var(--text); color: var(--surface); padding: 7px 10px; border-radius: 8px; font-size: .8rem; font-weight: 700; box-shadow: var(--shadow); opacity: 0; transition: opacity .1s; white-space: nowrap; }
.tip.show { opacity: 1; }

/* tablas */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface2); }
td b { font-weight: 800; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--muted); font-weight: 700; font-size: .85rem; }

/* etiquetas */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 800; background: var(--surface2); color: var(--text2); border: 1px solid var(--line); white-space: nowrap; }
.tag.st-nuevo { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.tag.st-contactado { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.st-cotizado { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.st-vendido, .tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.st-perdido, .tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.pchip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 2px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--line); font-size: .75rem; font-weight: 700; max-width: 240px; }
.pchip img { width: 22px; height: 22px; border-radius: 50%; object-fit: contain; background: #fff; }
.pchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 200px; transition: background .15s; }
.col.over { background: var(--accent-soft); border-color: var(--accent); }
.col-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-weight: 800; text-transform: capitalize; }
.kc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kc:active { cursor: grabbing; }
.kc.dragging { opacity: .45; }
.kc b { display: block; font-size: .9rem; }
.kc .muted { font-size: .76rem; }
.kc .chips { margin-top: 7px; }

/* drawer y modal */
.overlay { position: fixed; inset: 0; z-index: 200; background: rgba(10, 8, 24, .45); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; z-index: 201; width: min(620px, 100%); background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; animation: slide .28s cubic-bezier(.2, .7, .2, 1); display: flex; flex-direction: column; }
@keyframes slide { from { transform: translateX(100%); } }
.dr-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 20px; display: flex; gap: 12px; align-items: center; }
.dr-head h2 { margin: 0; font: 800 1.1rem/1.2 var(--display); }
.dr-body { padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.modal { position: fixed; z-index: 201; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 24px)); max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 14px; animation: pop .22s cubic-bezier(.2, .7, .2, 1); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
.modal h2 { margin: 0; font: 800 1.1rem/1.2 var(--display); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.x { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line2); background: var(--surface); cursor: pointer; font-size: 1.3rem; line-height: 1; color: var(--text2); flex-shrink: 0; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl { display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.tl-i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface2); border: 1px solid var(--line); font-size: .85rem; }
.tl-b { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: .86rem; white-space: pre-wrap; word-break: break-word; }
.tl-b small { display: block; color: var(--muted); font-weight: 700; font-size: .74rem; margin-bottom: 2px; white-space: normal; }
.it { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.it img { width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 8px; }
.it b { display: block; font-size: .88rem; line-height: 1.25; }
.it small { color: var(--muted); font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .88rem; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; font-weight: 700; }
.sec-t { font: 800 .78rem/1 var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 0 -4px; }
.tpl-btns { display: flex; flex-wrap: wrap; gap: 6px; }

/* sorteo */
.rgrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.rn { aspect-ratio: 1.3; border-radius: 9px; border: 1px solid var(--line2); background: var(--surface); font-weight: 800; font-size: .85rem; cursor: pointer; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.rn.reservado { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.rn.pagado { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.rn.win { background: var(--brand); border-color: var(--brand); color: #fff; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; font-weight: 700; color: var(--text2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--line2); }
.draw-num { font: 800 clamp(3.5rem, 12vw, 6rem)/1 var(--display); text-align: center; letter-spacing: .04em; font-variant-numeric: tabular-nums; background: linear-gradient(120deg, var(--brand), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; padding: 10px 0; }

/* productos */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.pc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.pc.off { opacity: .5; }
.pc-img { aspect-ratio: 1.3; background: #fff; position: relative; }
.pc-img img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.pc-img .tag { position: absolute; left: 8px; top: 8px; }
.pc-b { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.pc-b b { font-size: .86rem; line-height: 1.25; }
.pc-stats { display: flex; gap: 10px; font-size: .75rem; color: var(--muted); font-weight: 700; }
.pc-tg { display: flex; justify-content: space-between; margin-top: auto; font-size: .78rem; }

/* demanda */
.dm { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; }
.dm img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 10px; border: 1px solid var(--line); }
.dm-t { font-weight: 800; }
.dm-n { text-align: right; }
.dm-n b { font: 800 1.3rem/1 var(--display); display: block; }
.sz { display: inline-flex; align-items: baseline; gap: 3px; padding: 3px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: .78rem; }
.sz small { font-weight: 700; opacity: .8; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 400; background: var(--text); color: var(--surface); padding: 12px 18px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); transition: .25s; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .row-2, .row-3, .row-eq { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 150; left: 0; width: 260px; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .btn.burger { display: inline-flex; }
  .main { padding: 18px 16px 60px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .rgrid { grid-template-columns: repeat(6, 1fr); }
  .filters .search { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
