/* xamz/web/styles.css
   Design system de XAMZ. Los tokens y las primitivas salen del prototipo
   validado (../demo/marketing-ventas.html); los componentes de cada vista se
   portan a medida que se construyen las vistas.
   Fucsia pitahaya como acento (hereda del color de producto de la wiki). */

:root {
  --ground:   #f7f5f4;
  --surface:  #ffffff;
  --surface-2:#f0edeb;
  --ink:      #23201f;
  --muted:    #6f6763;
  --faint:    #9a918c;
  --line:     #e6e1de;
  --line-2:   #d8d2ce;
  --accent:   #b8327f;
  --accent-ink:#ffffff;
  --accent-wash:#f7e6f1;
  --ok:   #3f7d54; --ok-wash:  #e4efe6;
  --warn: #a06f16; --warn-wash:#f5ebd8;
  --crit: #b23b3b; --crit-wash:#f4e2e0;
  --shadow: 0 1px 2px rgba(30,20,25,.06), 0 8px 24px -12px rgba(30,20,25,.18);
  --radius: 10px;
  --font-display: "Bricolage Grotesque", Georgia, serif;
  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:#171315; --surface:#211c1f; --surface-2:#2b2429;
    --ink:#ece7e6; --muted:#a89f9c; --faint:#7c726f;
    --line:#362e32; --line-2:#453a40;
    --accent:#e070b0; --accent-ink:#241016; --accent-wash:#3a2130;
    --ok:#6bb387; --ok-wash:#22322a; --warn:#d7a648; --warn-wash:#352c1d;
    --crit:#e5776f; --crit-wash:#38241f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 34px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --ground:#171315; --surface:#211c1f; --surface-2:#2b2429;
  --ink:#ece7e6; --muted:#a89f9c; --faint:#7c726f;
  --line:#362e32; --line-2:#453a40;
  --accent:#e070b0; --accent-ink:#241016; --accent-wash:#3a2130;
  --ok:#6bb387; --ok-wash:#22322a; --warn:#d7a648; --warn-wash:#352c1d;
  --crit:#e5776f; --crit-wash:#38241f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 34px -14px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font-ui); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- shell ---- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding: 6px 8px 16px; }
.brand b { font-family: var(--font-display); font-size: 20px; letter-spacing: .02em; }
.brand span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }
.nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-weight: 500; text-decoration: none;
}
.nav-link .ct { margin-left: auto; font-size: 12px; color: var(--faint); }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.side-foot { margin-top: auto; padding: 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 26px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.view { padding: 26px; max-width: 1180px; }
.view-head { margin-bottom: 18px; }
.view-head h1 { font-size: 23px; }
.view-head p { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }

/* ---- primitivas ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2);
  font-size: 12.5px; font-weight: 500;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.chip.is-crit { background: var(--crit-wash); border-color: color-mix(in srgb, var(--crit) 30%, transparent); color: var(--crit); }
.chip.is-crit .dot { background: var(--crit); }
.chip.is-warn { background: var(--warn-wash); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.chip.is-warn .dot { background: var(--warn); }
.chip.is-ok { background: var(--ok-wash); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.chip.is-ok .dot { background: var(--ok); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-2); }
.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: 9px 15px; border-radius: 8px; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--accent-ink); background: var(--accent); }

.state { padding: 40px 26px; color: var(--muted); text-align: center; }
.state code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}

/* =====================================================================
   Componentes de vista (portados del prototipo demo/marketing-ventas.html)
   ===================================================================== */

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip b { font-variant-numeric: tabular-nums; }

.pill.st-NUEVO        { background: var(--accent-wash); color: var(--accent); border-color: transparent; }
.pill.st-CONTACTADO   { background: var(--surface-2); color: var(--ink); }
.pill.st-SEGUIMIENTO  { background: var(--warn-wash); color: var(--warn); border-color: transparent; }
.pill.st-CITA         { background: #e7eef6; color: #3a628c; border-color: transparent; }
.pill.st-SOCIO        { background: var(--ok-wash); color: var(--ok); border-color: transparent; }
.pill.st-PERDIDO      { background: var(--surface-2); color: var(--faint); }
:root[data-theme="dark"] .pill.st-CITA,
:root:not([data-theme="light"]) .pill.st-CITA { background: #26313d; color: #9fc0e0; }

.tag {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  padding: 2px 7px; border-radius: 6px; background: var(--surface-2);
  color: var(--muted); border: 1px solid var(--line-2);
}
.who-mini { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }

/* ---- bandeja ---- */
.stack { display: flex; flex-direction: column; }
.inbox-row {
  display: grid; grid-template-columns: 4px 130px 1fr 96px 150px 100px;
  align-items: center; gap: 14px;
  padding: 13px 16px 13px 0; border-bottom: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left;
}
.inbox-row:last-child { border-bottom: 0; }
.inbox-row:hover { background: var(--surface-2); }
.inbox-row .sem { align-self: stretch; border-radius: 3px; background: var(--ok); min-height: 34px; }
.inbox-row.sem-crit .sem { background: var(--crit); }
.inbox-row.sem-warn .sem { background: var(--warn); }
.inbox-link { display: contents; text-decoration: none; color: inherit; }
.inbox-when { font-size: 12.5px; }
.inbox-when b { display: block; font-weight: 600; }
.inbox-when.crit b { color: var(--crit); }
.inbox-when.warn b { color: var(--warn); }
.inbox-when span { color: var(--faint); }
.inbox-who { min-width: 0; }
.inbox-who b { font-weight: 600; }
.inbox-who span { color: var(--muted); display: block; font-size: 12.5px; }
.inbox-actions { display: flex; gap: 5px; justify-self: end; }
.mini-act {
  width: 27px; height: 27px; padding: 0; border-radius: 7px; line-height: 1;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--muted);
  font-size: 13px; display: grid; place-items: center;
}
.mini-act:hover { background: var(--surface-2); color: var(--ink); }
.mini-act.ok:hover { border-color: var(--ok); color: var(--ok); }
.mini-act.crit:hover { border-color: var(--crit); color: var(--crit); }
.mini-act:disabled { opacity: .4; }

/* ---- leads ---- */
.tablewrap { overflow-x: auto; border-radius: var(--radius); }
table.leads { width: 100%; border-collapse: collapse; min-width: 720px; background: var(--surface); }
table.leads th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600;
  padding: 11px 14px; border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
table.leads td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.leads tr:last-child td { border-bottom: 0; }
table.leads tbody tr:hover td { background: var(--surface-2); }
.lead-name { font-weight: 600; }
.lead-name a { color: inherit; text-decoration: none; }
.lead-name a:hover { text-decoration: underline; text-underline-offset: 2px; }
.lead-name .code { font-family: var(--font-mono); font-size: 11px; color: var(--faint); font-weight: 400; }
.stale { color: var(--crit); font-weight: 600; }
.reassign {
  font: inherit; font-size: 12.5px; padding: 5px 8px;
  border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink);
}
.rowlock { font-size: 12px; color: var(--faint); }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 0 0 14px; flex-wrap: wrap; }
.toolbtn {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
}
.toolbtn.accent { border-color: var(--accent); color: var(--accent); }
.toolbtn:hover { background: var(--surface-2); }
.toolbar .hint { font-size: 12px; color: var(--faint); }

/* ---- tablero ---- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-h { padding: 15px 18px 0; }
.card-h h3 { font-size: 15px; }
.card-h p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.card-b { padding: 16px 18px 18px; }
.funnel { display: flex; flex-direction: column; gap: 11px; }
.fbar-label { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.fbar-label b { font-variant-numeric: tabular-nums; }
.fbar-track { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.fbar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.fbar.mut .fbar-fill { background: var(--line-2); }
.callout { margin-top: 14px; padding: 11px 13px; border-radius: 8px; background: var(--accent-wash); color: var(--accent); font-size: 12.5px; font-weight: 500; }
.callout.warn { background: var(--warn-wash); color: var(--warn); }
.adbars { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding-top: 6px; }
.adbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.adbar .col { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 3px; }
.adbar.nodata .col { background: repeating-linear-gradient(45deg, var(--line-2), var(--line-2) 4px, transparent 4px, transparent 8px); border: 1px dashed var(--line-2); }
.adbar small { font-size: 10.5px; color: var(--muted); }
.adbar .v { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.adbar.nodata .v { color: var(--warn); font-weight: 600; }
table.mini { width: 100%; border-collapse: collapse; }
table.mini th, table.mini td { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 12.5px; text-align: right; }
table.mini th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini td.num { font-variant-numeric: tabular-nums; }
table.mini tr.me td { background: var(--accent-wash); }

/* ---- ficha (lead) ---- */
.ficha-head { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.ficha-head h2 { font-size: 19px; }
.ficha-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.ficha-body { padding: 16px 20px 22px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; margin-bottom: 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.tl { position: relative; padding-left: 20px; }
.tl::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line-2); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ""; position: absolute; left: -18px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl-item.cita::before { border-color: var(--warn); }
.tl-item .t { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tl-item .h { font-weight: 600; font-size: 13px; margin: 1px 0; }
.tl-item .d { font-size: 12.5px; color: var(--muted); }
.oppbox { border: 1px solid var(--line-2); border-radius: 9px; padding: 13px; margin-bottom: 18px; }
.oppbox .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.etapa { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--accent); }
.btn-wide { width: 100%; margin-top: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 8px; }
.section-head h3 { font-size: 14px; margin: 0; }
.contacto-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.contacto-form select, .contacto-form input { flex: 1 1 140px; }
.contacto-form textarea { flex: 1 1 100%; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--ground); color: var(--ink); resize: vertical; min-height: 52px; }

/* ---- modal (cerrar venta / importar) ---- */
.modal-scrim { position: fixed; inset: 0; background: rgba(20,12,16,.5); display: none; place-items: center; z-index: 50; padding: 20px; }
.modal-scrim.open { display: grid; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 96vw); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.modal-head h2 { font-size: 18px; }
.modal-head span { color: var(--muted); font-size: 12.5px; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 16px; }
.fieldset { border: 1px solid var(--line-2); border-radius: 10px; padding: 13px; }
.fieldset legend { padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.frow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.frow:last-child { margin-bottom: 0; }
.frow label { font-size: 12.5px; color: var(--muted); min-width: 92px; }
input[type="number"], input[type="text"], input[type="email"], input[type="date"], input[type="password"], select {
  font: inherit; font-size: 13px; padding: 7px 9px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--ground); color: var(--ink);
}
.mini-add { font-size: 12px; padding: 4px 9px; border-radius: 6px; border: 1px dashed var(--line-2); background: transparent; color: var(--muted); }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.checkline .ic { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: #fff; background: var(--crit); flex: none; }
.checkline.good .ic { background: var(--ok); }
.semaforo { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); font-weight: 700; font-family: var(--font-display); }
.semaforo .lamp { width: 14px; height: 14px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 20%, transparent); }
.semaforo.listo { color: var(--ok); }
.semaforo.revisar { color: var(--crit); }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ---- importar leads: selector de archivo + detalle fila a fila ---- */
.filepick {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px; border-radius: 8px; border: 1px dashed var(--line-2);
  background: var(--ground); cursor: pointer;
}
.filepick:hover { border-color: var(--accent); }
.filepick-btn {
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--accent); color: var(--accent); background: var(--surface);
}
.filepick-name { font-family: var(--font-mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.filepick-name.set { color: var(--ink); }
.imp-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 4px; }
.imp-hint b { color: var(--ink); }
#impResult { font-size: 12.5px; color: var(--muted); min-height: 18px; }
#impResult b { color: var(--ink); }
.imp-detalle { border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.imp-detalle-h { padding: 8px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.imp-detalle-list { max-height: 160px; overflow-y: auto; }
.imp-detalle-row {
  display: grid; grid-template-columns: 44px 1fr 110px 1fr; gap: 8px;
  padding: 6px 12px; font-size: 12px; border-top: 1px solid var(--line);
  align-items: baseline;
}
.imp-detalle-row span:last-child { color: var(--muted); }
.imp-detalle-more { padding: 6px 12px; font-size: 11.5px; color: var(--faint); border-top: 1px solid var(--line); }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--ground);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .22s; z-index: 60; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
