/* Layout: una columna para el pulgar — controles, meta diaria, ficha del lead, navegación fija.
   Estética de terminal invertida: negro de fondo, blanco para el texto y lo importante, líneas finas, etiquetas en mono.
   Siempre en oscuro, sin seguir el modo del sistema. El único color es el verde de la meta. */
:root {
  --bg: #000000;
  --fg: #fafafa;
  --muted: #8a8a8a;
  --faint: #525252;
  --line: #1f1f1f;
  --field: #0a0a0a;
  --invert: #000000;
  --green: #22c55e;

  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 6px;

  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8a8a' stroke-width='1.5' stroke-linecap='square'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body {
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }

.screen { min-height: 100dvh; display: flex; flex-direction: column; }

/* Etiqueta técnica reutilizada en todo el panel */
.field > span, .field > label, .goal-label, dialog h3 {
  font-family: var(--mono);
  font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Campos ---------- */
select, input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--field);
  font-size: 16px; /* evita el zoom de iOS */
  outline: none;
}
select {
  padding-right: 26px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  text-overflow: ellipsis;
}
select:focus, input:focus { border-color: var(--fg); }
input::placeholder { color: var(--faint); }
input[type=number]::-webkit-inner-spin-button { display: none; }

/* ---------- Login ---------- */
#login { align-items: center; justify-content: center; padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.login-box { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
.login-box h1 { margin: 0 0 16px; text-align: center; font-family: var(--mono); font-size: 14px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---------- Cabecera ---------- */
header {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-direction: column; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; gap: 10px; align-items: center; }

.title-select {
  flex: 1;
  height: 34px;
  padding-left: 0;
  border: 0;
  background-color: transparent;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.4px;
}
.icon-btn {
  flex: none; width: 34px; height: 34px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--bg); font-size: 18px; line-height: 1;
}
.sync {
  flex: none; display: flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 0;
  color: var(--muted); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
}
.sync .dot { width: 6px; height: 6px; background: var(--fg); }
.sync.loading .dot { animation: pulse 0.6s infinite alternate; }
.sync.error .dot { background: transparent; border: 1px solid var(--fg); }
@keyframes pulse { to { opacity: 0.15; } }

.controls { display: grid; grid-template-columns: 1.15fr 1.25fr 0.6fr; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; margin: 0; min-width: 0; }
#gotoRow { font-family: var(--mono); }

.demo { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }

/* ---------- Meta diaria (el único verde de la app) ---------- */
main {
  flex: 1; display: flex; flex-direction: column; gap: 12px;
  padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}
.goal {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  transition: background-color 0.4s ease, border-color 0.4s ease;
}
.goal-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.goal-label { display: flex; align-items: center; gap: 6px; }
.goal-label::before { content: ""; width: 6px; height: 6px; background: var(--green); }
.goal-count {
  margin-top: 6px;
  font-family: var(--mono); font-size: 34px; font-weight: 500; line-height: 1;
  letter-spacing: -1.5px; font-variant-numeric: tabular-nums;
}
.goal-of { margin-left: 6px; font-size: 15px; letter-spacing: 0; color: var(--faint); }
.goal-side { text-align: right; min-width: 0; }
.goal-msg { font-size: 13px; font-weight: 600; }
.goal-calls { margin-top: 3px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; color: var(--muted); }

/* Una casilla por agendada de la meta */
.goal-pips { display: grid; grid-template-columns: repeat(auto-fit, minmax(6px, 1fr)); gap: 3px; }
.goal-pips i {
  height: 10px; border-radius: 1px;
  background: var(--line);
  transition: background-color 0.3s ease;
}
.goal-pips i.on { background: var(--green); }
.goal-pips i.pop { animation: pop 0.5s ease; }
@keyframes pop { 40% { transform: scaleY(1.8); } }

.goal.bump .goal-count { animation: bump 0.45s ease; }
@keyframes bump { 40% { transform: scale(1.1); } }

.goal.complete {
  background: color-mix(in srgb, var(--green) 8%, var(--bg));
  border-color: color-mix(in srgb, var(--green) 50%, transparent);
}
.goal.complete .goal-msg, .goal.complete .goal-count { color: var(--green); }

/* ---------- Ficha del lead ---------- */
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg);
  will-change: transform;
}
main { touch-action: pan-y; }

.meta {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.card h1 {
  margin: 12px 0 0;
  font-size: 28px; font-weight: 600; letter-spacing: -0.8px; line-height: 1.1;
  text-wrap: balance; word-break: break-word;
}
.phone { font-family: var(--mono); font-size: 18px; font-variant-numeric: tabular-nums; }
.email { color: var(--muted); font-size: 13px; word-break: break-all; }

.current { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.badge {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 3px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge[data-s="none"] { color: var(--faint); }
.badge.agent { color: var(--muted); border-style: dashed; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r);
  font-weight: 500; text-decoration: none;
  background: var(--bg); color: var(--fg);
}
.btn.primary { background: var(--fg); color: var(--invert); border-color: var(--fg); }
.btn.ghost { background: transparent; }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.4; }

.btn.call {
  height: 56px; margin-top: 18px;
  background: var(--fg); color: var(--invert); border-color: var(--fg);
  font-size: 17px; font-weight: 600;
}
.btn.call svg { width: 18px; height: 18px; fill: currentColor; }

/* Estados: discretos, en una fila, tal cual se escriben en el Sheet. Solo "Llamar" destaca. */
.status-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1.6fr; gap: 6px; margin-top: 10px; }
.status-btn {
  height: 38px; padding: 0 6px;
  border-color: var(--line); background: transparent; color: var(--muted);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap;
}
.status-btn.selected { color: var(--fg); border-color: var(--fg); background: var(--field); font-weight: 600; }
.status-btn.saving { opacity: 0.5; }

.empty { color: var(--muted); text-align: center; padding: 48px 16px; line-height: 1.5; font-size: 14px; }

/* ---------- Navegación ---------- */
.nav {
  position: sticky; bottom: 0;
  display: grid; grid-template-columns: 1fr 1.3fr 1.3fr 1fr; gap: 8px;
  padding: 8px max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 8px) max(16px, env(safe-area-inset-left));
  background: var(--bg); border-top: 1px solid var(--line);
}
.nav-btn {
  height: 48px; border: 0; border-radius: var(--r); background: none;
  font-family: var(--mono); font-size: 13px; color: var(--muted);
}
.nav-btn[data-step="1"], .nav-btn[data-step="-1"] {
  border: 1px solid var(--line); color: var(--fg);
  font-family: var(--font); font-size: 24px; font-weight: 300;
}
.nav-btn:active { opacity: 0.5; }

/* ---------- Diálogo ---------- */
dialog {
  width: min(420px, calc(100vw - 32px));
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r); padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog form { display: flex; flex-direction: column; gap: 10px; }
dialog h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
dialog h3 { margin: 10px 0 0; }
.wlist { list-style: none; margin: 0; padding: 0; }
.wlist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.wlist button { background: none; border: 0; color: var(--muted); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.hint { color: var(--muted); font-size: 13px; margin: 0; word-break: break-all; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.error { color: var(--fg); font-size: 13px; margin: 0; min-height: 1em; }
.error:not(:empty)::before { content: "ERROR · "; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; }

/* ---------- Aviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 78px);
  transform: translateX(-50%) translateY(12px);
  background: var(--fg); color: var(--invert);
  padding: 10px 14px; border-radius: var(--r);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.02em;
  opacity: 0; pointer-events: none; transition: all 0.2s ease;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--bg); color: var(--fg); border: 1px solid var(--fg); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
