/* ════════════════════════════════════════════════════════════
   Kukuri · CRM — PIEL "SALA BLANCA"
   Papel cálido + tinta obsidiana. Misma polaridad clara que kukuri.io
   (remap R26 · SALA BLANCA, jul-2026). Acromático total salvo los
   badges de estado (--ok / --warn / --alert). Números en JetBrains Mono,
   protagonistas. Sello 括 como firma discreta.
   Sin dependencias externas, sin CDN, sin internet (salvo tel:).
   ════════════════════════════════════════════════════════════ */

/* ── Fuentes locales (woff2 reales copiadas de la web) ── */
@font-face {
  font-family: "Inter Tight";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/inter-tight-400-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter Tight";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/inter-tight-500-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter Tight";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/inter-tight-700-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/jetbrains-mono-400-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/jetbrains-mono-500-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/jetbrains-mono-700-latin.woff2") format("woff2");
}

:root {
  /* Paleta Sala Blanca (literal del brief / DS kukuri.io). */
  --papel:       #F5F3EE;   /* fondo madre */
  --papel-hondo: #ECE9E1;   /* banda de contraste suave */
  --surface:     #FFFFFF;   /* tarjetas / superficie */
  --tinta:       #1B1A17;   /* texto primario */
  --tinta-pura:  #111009;   /* LA SEÑAL: números, acentos, foco */
  --humo:        #8B8781;   /* secundario / anotaciones / ejes */
  --muted:       #7F7C74;   /* texto atenuado */

  --hairline:    rgba(27, 26, 23, 0.12);
  --hairline-2:  rgba(27, 26, 23, 0.08);   /* bordes de glass */

  /* Glass papel. */
  --glass-bg:     rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.80);
  --glass-border: rgba(27, 26, 23, 0.08);

  /* Color SOLO en los badges de estado, con máxima moderación. */
  --ok:    #1f8f5e;   /* verde   */
  --warn:  #b07410;   /* ámbar   */
  --alert: #c34234;   /* terracota */

  /* Sombras suaves multicapa (nada de glow). */
  --shadow-sm:
    0 1px 1px rgba(27, 26, 23, 0.04),
    0 2px 6px rgba(27, 26, 23, 0.05),
    0 0 0 0.5px rgba(27, 26, 23, 0.03);
  --shadow-md:
    0 1px 1px rgba(27, 26, 23, 0.05),
    0 4px 12px rgba(27, 26, 23, 0.06),
    0 12px 28px rgba(27, 26, 23, 0.08),
    0 0 0 0.5px rgba(27, 26, 23, 0.03);
  --shadow-lg:
    0 2px 4px rgba(27, 26, 23, 0.06),
    0 8px 20px rgba(27, 26, 23, 0.09),
    0 24px 48px rgba(27, 26, 23, 0.12),
    0 0 0 0.5px rgba(27, 26, 23, 0.04);

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Radios del DS. */
  --r-ctl: 11px;   /* controles / botones */
  --r-card: 16px;  /* tarjetas */
  --r-big: 22px;   /* contenedores grandes */
}

* { box-sizing: border-box; }

html { background: var(--papel); }
html, body {
  margin: 0; padding: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--tinta); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--humo); }

/* Todo lo numérico / técnico vive en mono. */
.mono, .num, .phone, .rating { font-family: var(--mono); }

/* Kicker / etiqueta mono en mayúsculas (protagonista, como en la web). */
.kicker {
  font-family: var(--mono); font-weight: 500;
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}

/* ══ Barra superior (glass papel) ══ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 11px 20px;
  background: color-mix(in srgb, var(--papel) 88%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--hairline);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: .1px; color: var(--tinta);
}
.brand small { color: var(--muted); font-weight: 400; }
.seal {
  font-family: var(--mono);
  display: inline-grid; place-items: center;
  width: 27px; height: 27px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--tinta); background: var(--surface);
  font-size: 14px; box-shadow: var(--shadow-sm);
}
.topbar .spacer { flex: 1; }
.topbar nav a { color: var(--muted); margin-left: 16px; font-size: 14px; }
.topbar nav a.active, .topbar nav a:hover { color: var(--tinta); text-decoration: none; }
.who { color: var(--muted); font-size: 13px; }
.who b { color: var(--tinta); font-weight: 500; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.wrap-narrow { max-width: 440px; margin: 9vh auto; padding: 24px; }

/* ══ Filtros ══ */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.filters .full { grid-column: 1 / -1; }
.toggles {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  padding-top: 12px; margin-top: 4px;
  border-top: 1px solid var(--hairline);
}
.toggles label { display: flex; align-items: center; gap: 7px; color: var(--tinta); font-size: 13px; cursor: pointer; }
.toggles .count { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 12.5px; }

label.field {
  display: flex; flex-direction: column; gap: 5px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}

input, select, textarea {
  font-family: var(--sans);
  font-size: 14px; letter-spacing: normal; text-transform: none;
  color: var(--tinta);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-ctl);
  padding: 9px 11px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--tinta-pura);
  box-shadow: 0 0 0 3px rgba(17, 16, 9, 0.08);
}
select { cursor: pointer; }
input[type=checkbox] { width: auto; accent-color: var(--tinta-pura); }
input[type=date] { font-family: var(--mono); }

/* ══ Botones ══ */
.btn {
  font-family: var(--sans);
  font-size: 14px; font-weight: 500;
  color: #faf8f4;
  background: var(--tinta);
  border: 1px solid var(--tinta);
  border-radius: var(--r-ctl);
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .14s ease, transform .05s ease;
}
.btn:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn.ghost {
  background: var(--surface); color: var(--tinta); border-color: var(--hairline);
  box-shadow: none;
}
.btn.ghost:hover { border-color: rgba(27, 26, 23, 0.32); box-shadow: var(--shadow-sm); }
.btn.small { padding: 6px 11px; font-size: 13px; }
/* El botón LLAMAR es el gesto físico: mono, verde de acción, contenido. */
.btn.call {
  background: var(--ok); border-color: var(--ok); color: #ffffff;
  font-family: var(--mono); font-weight: 500; letter-spacing: 0.02em;
}
.btn.call:hover { background: #1b7d52; border-color: #1b7d52; }
.btn.danger { background: var(--surface); color: var(--alert); border-color: rgba(195, 66, 52, 0.4); box-shadow: none; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ══ Fichas de lead ══ */
.leads { display: flex; flex-direction: column; gap: 12px; }
.lead {
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 15px 17px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 20px;
  align-items: start;
  box-shadow: var(--shadow-sm);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.lead:hover { border-color: rgba(27, 26, 23, 0.22); box-shadow: var(--shadow-md); }
.lead .info h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--tinta); letter-spacing: -0.01em; }
.lead .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.lead .meta .sector { color: var(--tinta); }
.lead .addr { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.lead .nums {
  font-family: var(--mono); color: var(--tinta); font-size: 13px;
  margin-top: 6px; display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline;
}
.lead .nums .rating { color: var(--tinta-pura); font-weight: 500; }
.lead .nums .muted { color: var(--muted); font-family: var(--sans); font-size: 12px; }
.lead .nums a { text-decoration: underline; text-decoration-color: var(--hairline); text-underline-offset: 3px; }
.lead .phone { font-family: var(--mono); font-size: 15px; color: var(--tinta-pura); font-weight: 500; }

.lead .actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 200px; }
.lead .actions .call { font-size: 15px; padding: 11px 16px; }
.lead .actions .row { display: flex; gap: 8px; }
.lead .actions .row .btn { flex: 1; }

/* ══ Badge / pill de estado — ÚNICO punto de color ══ */
.pill {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--hairline); color: var(--muted);
  background: var(--surface);
  white-space: nowrap; letter-spacing: 0.01em;
}
.pill[data-s="pendiente"]       { color: var(--muted); }
.pill[data-s="no_contesta"]     { color: var(--tinta); border-color: var(--hairline); }
.pill[data-s="ilocalizable"]    { color: var(--muted); }
.pill[data-s="volver_a_llamar"] { color: var(--warn);  border-color: rgba(176, 116, 16, 0.35); background: rgba(176, 116, 16, 0.06); }
.pill[data-s="interesado"]      { color: var(--ok);    border-color: rgba(31, 143, 94, 0.35);  background: rgba(31, 143, 94, 0.06); }
.pill[data-s="cita"]            { color: #fff; background: var(--ok); border-color: var(--ok); }
.pill[data-s="no_interesado"]   { color: var(--alert); border-color: rgba(195, 66, 52, 0.3); }
.pill[data-s="no_valido"]       { color: var(--muted); border-color: var(--hairline); text-decoration: line-through; }

/* ══ Registro inline (expandible dentro de la ficha) ══ */
.register {
  grid-column: 1 / -1;
  border-top: 1px solid var(--hairline);
  padding-top: 14px; margin-top: 4px;
  display: none;
  gap: 12px;
  grid-template-columns: 190px 1fr 160px auto;
  align-items: end;
}
.register.open { display: grid; }
.register textarea { min-height: 40px; resize: vertical; }
.register .date-wrap { display: none; }
.register .date-wrap.show { display: flex; }

/* ══ Histórico ══ */
.hist {
  grid-column: 1/-1; border-top: 1px solid var(--hairline);
  margin-top: 10px; padding-top: 10px; display: none;
}
.hist.open { display: block; }
.hist ul { list-style: none; margin: 0; padding: 0; }
.hist li { font-size: 12.5px; color: var(--tinta); padding: 6px 0; border-bottom: 1px solid var(--hairline-2); }
.hist li:last-child { border-bottom: none; }
.hist li .when { font-family: var(--mono); color: var(--muted); font-size: 11.5px; }
.hist li .agent { color: var(--tinta); }
.hist li .muted { color: var(--muted); }
.hist .empty { color: var(--muted); font-size: 12.5px; }

/* ══ Paginación ══ */
.pager {
  display: flex; justify-content: center; align-items: center; gap: 12px;
  margin: 22px 0 4px; color: var(--tinta); font-family: var(--mono); font-size: 13px;
}
.pager a { padding: 7px 13px; border: 0.5px solid var(--hairline); border-radius: var(--r-ctl); color: var(--tinta); background: var(--surface); box-shadow: var(--shadow-sm); }
.pager a:hover { border-color: rgba(27, 26, 23, 0.32); text-decoration: none; box-shadow: var(--shadow-md); }
.pager .disabled { opacity: .35; pointer-events: none; }
.pager span:not(.disabled) { color: var(--muted); }

/* ══ Stats / admin ══ */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 17px;
  box-shadow: var(--shadow-sm);
}
.card .k {
  color: var(--muted); font-family: var(--mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
}
.card .v { font-family: var(--mono); font-size: 30px; font-weight: 500; color: var(--tinta-pura); margin-top: 6px; line-height: 1; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; font-family: var(--mono); }

table.data {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-radius: var(--r-card);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
table.data th, table.data td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--hairline-2); font-size: 14px; }
table.data th {
  color: var(--muted); font-family: var(--mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 500;
  background: var(--papel-hondo);
}
table.data td.num, table.data th.num { font-family: var(--mono); text-align: right; }
table.data td .mono { color: var(--tinta); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: rgba(27, 26, 23, 0.015); }

.bar { display: inline-block; width: calc(100% - 46px); height: 7px; background: var(--papel-hondo); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.bar > span { display: block; height: 100%; background: var(--tinta); }

.section-title {
  font-family: var(--mono); font-weight: 500;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  margin: 30px 0 12px; color: var(--muted);
}
.section-title:first-of-type { margin-top: 6px; }

/* ══ Flash ══ */
.flash { padding: 11px 15px; border-radius: var(--r-ctl); margin-bottom: 16px; font-size: 14px; border: 0.5px solid var(--hairline); background: var(--surface); box-shadow: var(--shadow-sm); }
.flash.ok  { color: var(--ok);    border-color: rgba(31, 143, 94, 0.3); }
.flash.err { color: var(--alert); border-color: rgba(195, 66, 52, 0.3); }

/* ══ Login ══ */
.login-card {
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-radius: var(--r-big);
  padding: 30px 28px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 21px; font-weight: 700; margin: 0 0 6px; display: flex; align-items: center; gap: 11px; letter-spacing: -0.01em; }
.login-card p.tag { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card label.field { margin-bottom: 15px; }
.login-card .btn { width: 100%; margin-top: 8px; padding: 11px; }

.muted { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ══ Toast ══ */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--tinta); color: #faf8f4; padding: 11px 20px;
  border-radius: var(--r-ctl); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
#toast.err { background: var(--alert); }

/* ══ Responsive — uso intensivo, móvil impecable ══ */
@media (max-width: 760px) {
  .wrap { padding: 14px 12px 48px; }
  .lead { grid-template-columns: 1fr; }
  .lead .actions { min-width: 0; }
  .register { grid-template-columns: 1fr 1fr; }
  .register textarea, .register .status-wrap, .register .save-wrap { grid-column: 1 / -1; }
  .register .save-wrap .btn { width: 100%; }
  .topbar { padding: 9px 13px; gap: 10px; }
  .topbar nav a { margin-left: 12px; }
  .who { display: none; }
  table.data { display: block; overflow-x: auto; white-space: nowrap; }
}
