@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --pink: #D62E6C; --pink-d: #B8215A; --pink-l: #FCE7EF;
  --teal: #17A596; --teal-l: #E2F5F2;
  --blue: #5E8FF0; --blue-l: #E8EFFE;
  --red: #E5352C; --red-l: #FDE7E6;
  --yellow: #F4C430; --yellow-l: #FFF6D6;
  --green: #5FB82E; --green-l: #EAF7E1;
  --purple: #6A3DE8; --purple-l: #EFEAFD;
  --ink: #1D1D22; --muted: #6B6B78; --line: #E7E4EC; --bg: #F7F6F9; --card: #FFFFFF;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,10,40,.05), 0 4px 16px rgba(20,10,40,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Outfit, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--ink); background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--pink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 700; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
code { background: #F0EEF3; padding: 1px 5px; border-radius: 5px; }

/* ── Estructura ─────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; flex: none; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; padding: 20px 18px 16px; border-bottom: 1px solid var(--line); }
.brand img { width: 148px; height: auto; max-height: 30px; object-fit: contain; }
.brand span { font-weight: 700; font-size: 12px; letter-spacing: .12em; color: #fff; background: var(--teal); padding: 3px 7px; border-radius: 6px; }
.brand:hover { text-decoration: none; }
.side nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; }
.side nav a svg { width: 19px; height: 19px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side nav a:hover { background: var(--bg); text-decoration: none; }
.side nav a.on { background: var(--pink-l); color: var(--pink-d); }
.side nav a.on svg { stroke: var(--pink); }
.side nav .count { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; }
.me { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.me strong { display: block; font-size: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: rgba(247,246,249,.9); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line); }
.topbar .search { flex: 1; max-width: 520px; }
.topbar .search input { width: 100%; background: #fff; }
.burger { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; }
.content { padding: 24px 28px 60px; max-width: 1280px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 6px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Componentes ─────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card > h2, .card-head { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack > * + * { margin-top: 16px; }

.kpi { padding: 16px 18px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--pink)); }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { text-decoration: none; border-color: #cfcad6; }
.btn.primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn.primary:hover { background: var(--pink-d); }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-l); border-color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn.ghost { border-color: transparent; background: transparent; }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 2px 4px; }
.link-btn:hover { color: var(--red); }
form.inline { display: inline; }

input, select, textarea { font: inherit; color: inherit; border: 1px solid #DAD6E0; border-radius: 10px; padding: 8px 11px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pink-l); border-color: var(--pink); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 13px; font-weight: 600; color: #3b3b45; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
label.inline { display: flex; gap: 8px; align-items: center; font-weight: 500; margin-top: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid.three .span3 { grid-column: span 3; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.help { font-size: 12px; color: var(--muted); font-weight: 400; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 11px 10px; border-bottom: 1px solid #F0EEF3; vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #FBFAFC; }
table.list .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #F0EEF3; color: #4b4b55; white-space: nowrap; }
.stage-prospecto, .status-borrador, .cstatus-prospecto { background: #F0EEF3; color: #4b4b55; }
.stage-contactado { background: var(--blue-l); color: #2F5FC4; }
.stage-reunion { background: var(--purple-l); color: var(--purple); }
.stage-cotizado, .status-enviada { background: var(--yellow-l); color: #8A6A00; }
.stage-licitacion { background: var(--teal-l); color: #0E7A6F; }
.stage-ganado, .status-aceptada, .cstatus-activo { background: var(--green-l); color: #3C7C1A; }
.stage-perdido, .status-rechazada, .status-vencida, .cstatus-inactivo { background: var(--red-l); color: #B42318; }
.type-badge { background: var(--pink-l); color: var(--pink-d); }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--green-l); color: #2F6A12; }
.flash.error { background: var(--red-l); color: #B42318; }
.flash.warn { background: var(--yellow-l); color: #7A5C00; }

.pager { display: flex; gap: 4px; justify-content: center; margin-top: 14px; }
.pager a, .pager span { padding: 5px 11px; border-radius: 8px; color: var(--ink); }
.pager a.on { background: var(--pink); color: #fff; }

dl.info { display: grid; grid-template-columns: 110px 1fr; gap: 7px 10px; margin: 0; font-size: 14px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; word-break: break-word; }

/* Pipeline */
.board { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #EFEDF2; border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 10px; }
.col-head strong { font-size: 14px; }
.col-head span { font-size: 12px; color: var(--muted); }
.deal { background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); margin-bottom: 8px; border-left: 4px solid var(--c, var(--pink)); }
.deal a.t { color: var(--ink); font-weight: 600; display: block; }
.deal .c { font-size: 13px; color: var(--muted); }
.deal .row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 13px; gap: 6px; }
.deal select { padding: 3px 6px; font-size: 12px; width: auto; border-radius: 7px; }
.bars .bar { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13.5px; }
.bars .track { background: #F0EEF3; border-radius: 99px; height: 10px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 99px; background: var(--c, var(--pink)); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 11px 0; border-bottom: 1px solid #F0EEF3; }
.timeline li:last-child { border-bottom: 0; }
.timeline .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; background: #F0EEF3; }
.timeline .meta { font-size: 12.5px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; }
.timeline li.done .body { text-decoration: line-through; color: var(--muted); }
.due { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--yellow-l); color: #7A5C00; }
.due.late { background: var(--red-l); color: #B42318; }

/* Editor de cotización */
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: 6px 5px; }
table.lines td { padding: 5px; vertical-align: top; }
table.lines input, table.lines textarea { padding: 7px 8px; font-size: 14px; }
table.lines textarea { min-height: 38px; height: 38px; }
table.lines .w-code { width: 110px; } table.lines .w-qty { width: 80px; } table.lines .w-unit { width: 70px; }
table.lines .w-price { width: 130px; } table.lines .w-disc { width: 76px; } table.lines .w-total { width: 120px; } table.lines .w-x { width: 34px; }
table.lines .line-total { padding-top: 13px; font-weight: 600; }
.totals { margin-left: auto; width: 320px; max-width: 100%; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font-size: 19px; font-weight: 700; }
.product-picker { display: flex; gap: 8px; margin: 12px 0 4px; }
.product-picker input { flex: 1; }

/* Login / instalador */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, var(--pink-l), #fff 45%, var(--teal-l)); }
.login-card { background: #fff; padding: 34px 32px 26px; border-radius: 20px; box-shadow: 0 20px 60px rgba(60,20,60,.12); width: 100%; max-width: 400px; }
.login-card.wide { max-width: 680px; }
.login-card img { width: 240px; max-width: 100%; height: auto; margin-bottom: 18px; }
.login-card h1 { font-size: 22px; margin-bottom: 18px; }
.login-card label { margin-bottom: 14px; }
.login-card fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 0 0 14px; }
.login-card legend { font-weight: 700; padding: 0 6px; }
.login-card .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.login-card .span2 { grid-column: span 2; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; font-size: 14px; }
.checks .ok { color: #2F6A12; } .checks .bad { color: #B42318; font-weight: 700; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }
.dots i:nth-child(2) { background: var(--red); } .dots i:nth-child(3) { background: var(--yellow); } .dots i:nth-child(4) { background: var(--green); }

/* ── Responsivo ─────────────────────────────── */
@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-side { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .side { position: fixed; left: -260px; z-index: 20; transition: left .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .side.open { left: 0; }
  .burger { display: block; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 50px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .form-grid .span2, .form-grid.three .span3 { grid-column: auto; }
  .hide-sm { display: none; }
  table.lines, table.lines tbody, table.lines tr, table.lines td { display: block; width: 100% !important; }
  table.lines thead { display: none; }
  table.lines tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 10px; }
}
@media (max-width: 520px) {
  .cols-4 { grid-template-columns: 1fr; }
  .login-card .grid2 { grid-template-columns: 1fr; }
  .login-card .span2 { grid-column: auto; }
  .topbar .btn.primary { display: none; }
}
@media print {
  .side, .topbar, .actions, .no-print { display: none !important; }
  body { background: #fff; }
}

/* Ajustes finos */
.filters input[type=checkbox] { min-width: 0; width: auto; }
.filters label.inline { font-weight: 500; }
.nowrap, table.list td:first-child a strong { white-space: nowrap; }
.board { grid-template-columns: repeat(5, minmax(180px, 1fr)); }
@media (max-width: 860px) {
  .product-picker { flex-wrap: wrap; }
  .product-picker input { flex: 1 1 100%; }
  table.lines td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
  table.lines tr { display: grid !important; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
  table.lines td { padding: 2px !important; }
  table.lines td[data-label="Descripción"], table.lines td[data-label="Código"] { grid-column: span 2; }
  table.lines .line-total { text-align: left; padding-top: 8px !important; }
}

/* ── v2: imágenes, buscador visual, licitaciones, calendario ── */
.thumb { width: 46px; height: 46px; border-radius: 9px; background: #F3F1F6; border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.sm { width: 40px; height: 40px; }
.thumb.lg { width: 132px; height: 132px; border-radius: 14px; }
.thumb.lg span { font-size: 12px; color: var(--muted); }
.img-field { display: flex; gap: 16px; align-items: center; }
table.lines .w-img { width: 50px; padding-top: 6px; }
.picker-box { position: relative; flex: 1; }
.picker-box input { width: 100%; }
.picker-results { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(30,10,40,.14); max-height: 380px; overflow-y: auto; padding: 6px; }
.picker-item { display: flex; gap: 12px; align-items: center; padding: 7px 9px; border-radius: 9px; cursor: pointer; }
.picker-item.on, .picker-item:hover { background: var(--pink-l); }
.pi-main { flex: 1; min-width: 0; }
.pi-main strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-main span { font-size: 12.5px; color: var(--muted); }
.pi-price { font-weight: 600; font-size: 14px; white-space: nowrap; }
.pi-price em { font-weight: 400; color: var(--muted); font-size: 12px; }
.picker-empty { padding: 14px; color: var(--muted); font-size: 14px; }

.tstatus-publicada { background: var(--blue-l); color: #2F5FC4; }
.tstatus-cerrada { background: var(--yellow-l); color: #8A6A00; }
.tstatus-adjudicada { background: var(--green-l); color: #3C7C1A; }
.tstatus-desierta, .tstatus-revocada { background: #F0EEF3; color: #4b4b55; }
.tender-code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; background: #F3F1F6; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.steps { display: flex; gap: 0; margin: 4px 0 2px; }
.steps span { flex: 1; text-align: center; font-size: 12.5px; font-weight: 600; padding: 8px 4px; background: #F0EEF3; color: var(--muted); position: relative; }
.steps span:first-child { border-radius: 10px 0 0 10px; } .steps span:last-child { border-radius: 0 10px 10px 0; }
.steps span.done { background: var(--teal-l); color: #0E7A6F; }
.steps span.now { background: var(--teal); color: #fff; }
.award-box { border: 2px dashed var(--green); background: var(--green-l); border-radius: var(--radius); padding: 16px 18px; }

.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-head h2 { min-width: 190px; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: #FBFAFC; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px; text-align: center; }
.cal .day { min-width: 0; background: #fff; min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal .day.out { background: #FAF9FB; }
.cal .day.out .dnum { color: #C3C0CB; }
.cal .day.today .dnum { background: var(--pink); color: #fff; }
.cal .dnum { font-size: 12.5px; font-weight: 600; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.cal .add { margin-left: auto; opacity: 0; font-size: 16px; color: var(--muted); line-height: 1; padding: 0 4px; }
.cal .day:hover .add { opacity: 1; }
.cal .day-top { display: flex; align-items: center; }
.ev { display: block; font-size: 12px; line-height: 1.25; padding: 3px 6px; border-radius: 6px; color: var(--ink); background: var(--c-bg, #F0EEF3); border-left: 3px solid var(--c, #9A98A6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev:hover { text-decoration: none; filter: brightness(.97); }
.ev b { font-weight: 600; }
.ev.cancel { text-decoration: line-through; opacity: .6; }
.ev-reunion_online { --c: var(--pink); --c-bg: var(--pink-l); }
.ev-reunion_presencial { --c: var(--purple); --c-bg: var(--purple-l); }
.ev-visita { --c: var(--green); --c-bg: var(--green-l); }
.ev-llamada { --c: var(--blue); --c-bg: var(--blue-l); }
.ev-licitacion { --c: var(--teal); --c-bg: var(--teal-l); }
.ev-tarea { --c: var(--yellow); --c-bg: var(--yellow-l); }
.ev-otro { --c: #9A98A6; --c-bg: #F0EEF3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.agenda li { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid #F0EEF3; align-items: start; }
.agenda li:last-child { border-bottom: 0; }
.agenda .when { text-align: center; background: #F7F6F9; border-radius: 10px; padding: 5px 0; }
.agenda .when b { display: block; font-size: 20px; line-height: 1; }
.agenda .when span { font-size: 11px; text-transform: uppercase; color: var(--muted); }
@media (max-width: 860px) {
  .cal .day { min-height: 64px; padding: 3px; }
  .cal .ev { font-size: 0; padding: 0; height: 6px; border-left-width: 0; background: var(--c); }
  .cal .dow { font-size: 10px; padding: 6px 2px; }
  .img-field { flex-direction: column; align-items: flex-start; }
  table.lines td.w-img { grid-column: span 2; }
  .steps span { font-size: 11px; }
}
.due { white-space: nowrap; }
.timeline li.auto .body { color: var(--muted); font-size: 13.5px; }
.note-form { background: #FBFAFC; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.last-contact { font-size: 12.5px; color: var(--ink); white-space: nowrap; line-height: 1.3; }
td.nowrap { white-space: nowrap; }

/* ── v7: alertas de vencimiento ── */
.exp { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.exp-soon { background: var(--yellow-l); color: #7A5C00; }
.exp-today { background: #FFE7CC; color: #9A4A00; animation: pulse 1.6s ease-in-out infinite; }
.exp-expired { background: var(--red-l); color: #B42318; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(230, 120, 0, .15); } }
tr.row-expired td { background: #FFF8F7; }
tr.row-soon td { background: #FFFCF0; }
.side nav .count.warn { background: #F08C00; }
.bell { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; margin-left: auto; }
.bell svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bell.on svg { stroke: #F08C00; animation: ring 2.4s ease-in-out infinite; transform-origin: 50% 10%; }
.bell b { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; font-size: 11px; min-width: 19px; height: 19px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px; }
.bell:hover { text-decoration: none; border-color: #cfcad6; }
@keyframes ring { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(14deg); } 80% { transform: rotate(-12deg); } 85% { transform: rotate(8deg); } 90% { transform: rotate(-4deg); } }
.topbar .search { flex: 1; }
.expiry-alert { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; border: 1px solid; }
.expiry-alert .ico { font-size: 26px; line-height: 1; }
.expiry-alert .txt { flex: 1; min-width: 220px; }
.expiry-alert .txt strong { display: block; font-size: 16px; }
.expiry-alert.soon { background: var(--yellow-l); border-color: #F4D675; color: #5E4700; }
.expiry-alert.today { background: #FFEBD6; border-color: #F5B26B; color: #7A3A00; }
.expiry-alert.expired { background: var(--red-l); border-color: #F3B1AD; color: #8F1D14; }
@media (prefers-reduced-motion: reduce) { .bell.on svg, .exp-today { animation: none; } }

/* Permisos por usuario */
fieldset.perms { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px 14px; margin: 16px 0 0; }
fieldset.perms legend { font-weight: 700; padding: 0 6px; }
label.inline.perm { align-items: flex-start; }
label.inline.perm input { margin-top: 3px; }
.badge.perm-badge { background: #E6F6F4; color: #0f766e; margin: 2px 2px 0 0; font-weight: 500; }

/* Pestañas de cotizaciones y archivo */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 14px; overflow-x: auto; }
.tabs .tab { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs .tab:hover { color: var(--ink); }
.tabs .tab.active { color: var(--pink); border-bottom-color: var(--pink); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: #F0EEF3; color: var(--muted); font-size: 12px; text-align: center; }
.tabs .tab.active .count { background: var(--pink-l); color: var(--pink); }
.badge.archived-badge { background: #ECEAF0; color: #55535F; }
.flash.info-archived { background: #ECEAF0; color: #45434F; }

/* ── v11: ventas, pagos, producción y estadísticas ── */
.kpi-link { display: block; color: inherit; }
.kpi-link:hover { text-decoration: none; border-color: #cfcad6; }
.kpi .hint a { font-weight: 600; }
.delta { font-weight: 700; }
.delta.up { color: #3C7C1A; } .delta.down { color: #B42318; }

/* Estados */
.pay-sin_pago { background: var(--red-l); color: #B42318; }
.pay-abonada { background: var(--yellow-l); color: #7A5C00; }
.pay-pagada { background: var(--green-l); color: #3C7C1A; }
.prod-espera_abono { background: #F0EEF3; color: #4b4b55; }
.prod-fabricacion { background: var(--blue-l); color: #2F5FC4; }
.prod-lista { background: var(--purple-l); color: var(--purple); }
.prod-entregada { background: var(--green-l); color: #3C7C1A; }
.dl { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.dl-ok { background: var(--teal-l); color: #0E7A6F; }
.dl-soon, .dl-today { background: var(--yellow-l); color: #7A5C00; }
.dl-late { background: var(--red-l); color: #B42318; }

/* Aceptar cotización */
.accept-box { margin-top: 12px; }
.accept-box > summary { list-style: none; cursor: pointer; }
.accept-box > summary::-webkit-details-marker { display: none; }
.accept-box[open] > summary { border-radius: 10px 10px 0 0; }
.accept-form { border: 1px solid var(--teal); border-top: 0; border-radius: 0 0 12px 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--teal-l); }
.accept-form label.inline { margin-top: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }

/* Venta: producción y pagos */
.sale-card { border-top: 4px solid var(--teal); }
.steps span { padding: 8px 6px; }
.delivery-alert { margin: 12px 0 4px; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.d-ok { background: var(--teal-l); color: #0E5E56; }
.d-soon, .d-today, .d-wait { background: var(--yellow-l); color: #5E4700; }
.d-late { background: var(--red-l); color: #8F1D14; }
dl.info.cols { grid-template-columns: 150px 1fr 150px 1fr; margin-top: 12px; }
.inline-flex { display: inline-flex; gap: 6px; align-items: center; }
.w-date { width: auto; padding: 7px 9px; }
.edit-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.edit-box > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.pay-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pay-summary div { background: #FBFAFC; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.pay-summary span { display: block; font-size: 12.5px; color: var(--muted); }
.pay-summary strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.pay-summary .ok { color: #3C7C1A; } .pay-summary .due-amt { color: #B42318; }
.pay-bar { height: 8px; background: #F0EEF3; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.pay-bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.pay-bar.sm { height: 5px; margin: 5px 0 2px; }
.load-row { display: flex; gap: 12px; flex-wrap: wrap; }
.load-cell { flex: 1 1 150px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.load-n { font-size: 22px; font-weight: 700; }

/* Gráficos */
.chart { display: grid; grid-template-columns: 64px 1fr; height: calc(var(--h, 220px) + 26px); }
.chart-y { position: relative; height: var(--h, 220px); }
.chart-y span { position: absolute; right: 8px; transform: translateY(50%); font-size: 11.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-plot { position: relative; height: var(--h, 220px); border-bottom: 1px solid #CFCAD6; }
.grid-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #ECEAF0; }
.chart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; }
.chart-col { position: relative; display: flex; align-items: flex-end; justify-content: center; height: 100%; color: inherit; outline: none; border-radius: 6px 6px 0 0; }
.chart-col:hover, .chart-col:focus-visible { background: rgba(23, 165, 150, .07); text-decoration: none; }
.chart-col .bar { display: block; width: min(70%, 44px); background: var(--teal); border-radius: 4px 4px 0 0; transition: filter .15s; }
.chart-col:hover .bar { filter: brightness(.9); }
.chart-col.sel .bar { background: var(--pink); }
.chart-col.future .bar { opacity: .35; }
.chart-col.weekend { background: repeating-linear-gradient(0deg, #FAF9FB, #FAF9FB 4px, #F4F2F6 4px, #F4F2F6 5px); }
.chart-col.today .xl { color: var(--pink); font-weight: 700; }
.chart-col .xl { position: absolute; top: calc(100% + 5px); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.chart-tip { position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: #fff; font-size: 12.5px; padding: 6px 10px; border-radius: 8px; max-width: 280px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.table-toggle { margin-top: 14px; }
.table-toggle > summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--pink); }
table.list tfoot th { border-top: 2px solid var(--line); border-bottom: 0; color: var(--ink); font-size: 13px; text-transform: none; letter-spacing: 0; }
tr.row-sel td { background: var(--pink-l); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg a { padding: 5px 11px; font-size: 13px; color: var(--muted); font-weight: 600; }
.seg a.on { background: var(--pink-l); color: var(--pink-d); }
.seg a:hover { text-decoration: none; }
.cols-side-r { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.share { display: flex; align-items: center; gap: 6px; }
.share i { display: block; height: 6px; background: var(--teal); border-radius: 99px; min-width: 2px; }
.share span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cat-bars .bar { grid-template-columns: minmax(0, 130px) 1fr 70px; }
.cat-bars .bar > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ol.rank { margin: 0; padding-left: 22px; }
ol.rank li { padding: 6px 0; border-bottom: 1px solid #F0EEF3; font-size: 14px; }
ol.rank li span { float: right; font-weight: 600; }
@media (max-width: 1100px) { .cols-side-r { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .chart { grid-template-columns: 46px 1fr; }
  .chart-y span { font-size: 10px; right: 4px; }
  .chart-col .xl { font-size: 9.5px; }
  dl.info.cols { grid-template-columns: 130px 1fr; }
  .pay-summary strong { font-size: 16px; }
}
@media (max-width: 520px) { .pay-summary { grid-template-columns: 1fr; } }
.cols-side > *, .cols-side-r > * { min-width: 0; }
@media (max-width: 860px) {
  .sale-card .steps { flex-wrap: wrap; gap: 3px; }
  .sale-card .steps span { flex: 1 1 30%; border-radius: 8px !important; }
}

/* ── v12: documentos de la venta ── */
.doc-check { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.doc-check .chk { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: #F0EEF3; color: var(--muted); }
.doc-check .chk.ok { background: var(--green-l); color: #3C7C1A; }
.doc-check .chk.part { background: var(--yellow-l); color: #7A5C00; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #F0EEF3; }
.doc-list li:last-child { border-bottom: 0; }
.doc-ico { width: 46px; height: 46px; border-radius: 9px; border: 1px solid var(--line); background: var(--pink-l); display: grid; place-items: center; overflow: hidden; }
.doc-ico span { font-size: 11px; font-weight: 700; color: var(--pink-d); letter-spacing: .03em; }
.doc-ico.img { background: #F3F1F6; }
.doc-ico img { width: 100%; height: 100%; object-fit: cover; }
.doc-ico:hover { text-decoration: none; border-color: var(--pink); }
.doc-main { min-width: 0; }
.doc-main .small a { color: inherit; text-decoration: underline; text-decoration-color: #CFCAD6; }
.doc-for { background: var(--blue-l); color: #2F5FC4; font-size: 13px; font-weight: 600; padding: 7px 10px; border-radius: 8px; margin-bottom: 10px; }
.clip { font-size: 16px; text-decoration: none; margin-right: 2px; }
.clip:hover { text-decoration: none; filter: brightness(.8); }
input[type=file] { padding: 7px; background: #fff; font-size: 13.5px; }
.docs-mini { display: inline-flex; gap: 3px; margin-top: 4px; }
.docs-mini b { font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 5px; background: #F0EEF3; color: #9A98A6; }
.docs-mini b.on { background: var(--green-l); color: #3C7C1A; }

/* v13 · Oportunidades Mercado Público */
.kw { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; margin: 1px 3px 1px 0; border-radius: 99px; background: var(--pink-l); color: var(--pink); white-space: nowrap; }
.mp-list td a strong, .mp-list td:first-child a strong { white-space: normal; }
.mp-list td { vertical-align: top; }
.mp-desc { white-space: pre-line; line-height: 1.5; }
.mp-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.mp-facts dt { color: var(--muted); }
.mp-facts dd { margin: 0; }
.busy-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.85); display: flex; align-items: center; justify-content: center; z-index: 999; font-weight: 600; font-size: 16px; text-align: center; padding: 20px; }
.sync-log { font-size: 13px; }
.sync-log td { vertical-align: top; }
.mprev-nueva { background: var(--blue-l); color: #2F5FC4; }
.mprev-interesante { background: var(--yellow-l); color: #8A6A00; }
.mprev-convertida { background: var(--green-l); color: #3C7C1A; }
.mprev-descartada, .tstatus-suspendida { background: #F0EEF3; color: #4b4b55; }
.btn .count { background: var(--red); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; }

/* v14 · Análisis de bases con IA */
.ia-wait { display: flex; gap: 18px; align-items: center; }
.spinner { width: 38px; height: 38px; flex: none; border-radius: 50%; border: 4px solid var(--pink-l); border-top-color: var(--pink); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ia-table td { vertical-align: top; }
.ia-table tr.ia-off td { opacity: .55; }
.ia-table tr.ia-off td:first-child { opacity: 1; }
.ia-opt { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; padding: 6px; border-radius: 8px; margin: 0 0 4px; cursor: pointer; }
.ia-opt:hover { background: #F7F5FA; }
.ia-opt input { margin-top: 3px; width: auto; }
.ia-opt img { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); flex: none; }
.ia-other { margin-top: 4px; font-size: 13px; padding: 6px 8px; }
.ia-obs { margin-top: 4px; color: #7A5C00; }
.ia-warnqty { color: #B42318; font-weight: 600; }
.conf { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 99px; text-transform: uppercase; letter-spacing: .02em; }
.conf-alta { background: var(--green-l); color: #3C7C1A; }
.conf-media { background: var(--yellow-l); color: #8A6A00; }
.conf-baja { background: #F0EEF3; color: #4b4b55; }
.ia-alerts { border-left: 4px solid #F08C00; }
.ia-alerts ul, .ia-req { margin: 0; padding-left: 18px; }
.ia-alerts li, .ia-req li { margin-bottom: 8px; font-size: 14px; }
.ia-list { list-style: none; margin: 0 0 12px; padding: 0; }
.ia-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* v15 · filtros de Oportunidades MP */
.mp-filters { padding: 14px 16px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.mp-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 13px; font-weight: 600; }
.chip b { font-weight: 700; color: var(--muted); font-size: 12px; }
.chip:hover { text-decoration: none; border-color: #cfcad6; }
.chip.on { background: var(--pink); border-color: var(--pink); color: #fff; }
.chip.on b { color: #fff; opacity: .85; }
.chip.st-publicada:not(.on) { border-color: #BCD0F5; }
.chip.st-cerrada:not(.on) { border-color: #F0DC9A; }
.chip.st-adjudicada:not(.on) { border-color: #B9DDA4; }
.mp-dates { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mp-dates input[type=date] { min-width: 0; width: 150px; }
.mp-quick a { font-weight: 600; }
.stype { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.stype-suministro { background: #E6F4F1; color: #0F766E; }
.stype-obra { background: #F0EEF3; color: #4b4b55; }
.awarded { margin-top: 5px; font-weight: 600; color: #3C7C1A; }

/* v16 · crear productos desde las bases */
.ia-newbtn { margin-top: 6px; }
.ia-newbtn.suggest { border-color: var(--pink); color: var(--pink); }
tr.ia-new > td { background: #FBFAFD; border-top: 0; }
.np-box { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; padding: 14px; border: 1px dashed #D6D0DE; border-radius: 12px; background: #fff; }
.np-preview { height: 220px; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; text-align: center; padding: 8px; }
.np-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.np-photo-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.np-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.np-actions .np-msg { margin-right: auto; }
.conf-nuevo { background: var(--pink-l); color: var(--pink); }
.ia-opt-new { background: #FFF6FA; }
.crop-modal { position: fixed; inset: 0; background: rgba(20, 16, 28, .55); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.crop-modal[hidden] { display: none; }
.crop-box { background: #fff; border-radius: 14px; width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.crop-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.crop-bar select, .crop-bar input { width: auto; }
.crop-pages { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.crop-stage { overflow: auto; padding: 12px; background: #EDEBF1; flex: 1; text-align: center; }
.crop-page { position: relative; display: inline-block; cursor: crosshair; user-select: none; touch-action: none; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.crop-page canvas { display: block; max-width: 100%; height: auto; }
.crop-sel { position: absolute; border: 2px solid var(--pink); background: rgba(214, 46, 108, .12); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .25); pointer-events: none; }
@media (max-width: 760px) { .np-box { grid-template-columns: 1fr; } }
.readonly-code { background: #F3F1F6; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; }

/* v19: Compra Ágil */
.castatus-publicada { background: var(--blue-l); color: #2F5FC4; }
.castatus-cerrada { background: var(--yellow-l); color: #8A6A00; }
.castatus-proveedor_seleccionado, .castatus-oc_emitida { background: var(--green-l); color: #3C7C1A; }
.castatus-desierta, .castatus-cancelada { background: #F0EEF3; color: #4b4b55; }
.carev-nueva { background: var(--blue-l); color: #2F5FC4; }
.carev-interesante { background: var(--yellow-l); color: #8A6A00; }
.carev-cotizada { background: var(--green-l); color: #3C7C1A; }
.carev-descartada { background: #F0EEF3; color: #4b4b55; }
.cares-ganada { background: var(--green-l); color: #2F6A12; }
.cares-perdida { background: var(--red-l); color: #B42318; }
.cares-no_ofertada, .cares-desierta { background: #F0EEF3; color: #4b4b55; }
tr.ca-win td { background: #F3FAEE; }
tr.ca-us td:first-child { box-shadow: inset 4px 0 0 var(--pink); }
.help-i { cursor: help; color: var(--muted); font-weight: 400; }
table.list.compact td { padding: 4px 6px; font-size: 12.5px; }
details.small summary { cursor: pointer; color: var(--pink); font-weight: 600; margin-top: 4px; }
