@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 { height: 34px; max-width: 150px; 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 { height: 46px; 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; }
}
