:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1a1d23;
  --text-dim: #6b7280;
  --border: #e2e4e9;
  --accent: #4f46e5;
  --accent-dim: #eef0fe;
  --danger: #dc2626;
  --danger-dim: #fde8e8;
  --warn: #d97706;
  --warn-dim: #fef3e2;
  --good: #16a34a;
  --good-dim: #e7f7ec;
  --muy-caliente: #dc2626;
  --caliente: #ea580c;
  --tibio: #d97706;
  --frio: #2563eb;
  --radius: 12px;
  --nav-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2026;
    --surface-2: #24272e;
    --text: #eef0f4;
    --text-dim: #9aa0ab;
    --border: #2c2f37;
    --accent: #818cf8;
    --accent-dim: #2a2a4a;
    --danger: #f87171;
    --danger-dim: #3a2020;
    --warn: #fbbf24;
    --warn-dim: #3a2f14;
    --good: #4ade80;
    --good-dim: #17321f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-h) + 14px);
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar .brand { display: flex; align-items: center; gap: 8px; }
.topbar .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.topbar form { margin: 0; }
.icon-btn {
  border: none; background: transparent; color: var(--text-dim);
  font-size: 13px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

main { padding: 14px 14px 8px; max-width: 900px; margin: 0 auto; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; height: var(--nav-h);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; color: var(--text-dim);
}
.bottom-nav a.active { color: var(--accent); font-weight: 700; }
.bottom-nav svg { width: 21px; height: 21px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat .num { font-size: 24px; font-weight: 800; }
.stat .label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip.muy_caliente { background: var(--danger-dim); color: var(--muy-caliente); }
.chip.caliente { background: var(--warn-dim); color: var(--caliente); }
.chip.tibio { background: var(--warn-dim); color: var(--tibio); }
.chip.frio { background: var(--accent-dim); color: var(--frio); }
.chip.zona { background: var(--surface-2); color: var(--text-dim); }
.chip.alerta { background: var(--danger-dim); color: var(--danger); }

.list-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.list-item:last-child { border-bottom: none; }
.list-item .title { font-weight: 600; font-size: 14px; }
.list-item .sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.kanban-wrap { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; -webkit-overflow-scrolling: touch; }
.kanban-col { min-width: 250px; max-width: 250px; background: var(--surface-2); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 10px; font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }
.kanban-col-head .count { background: var(--surface); border-radius: 999px; padding: 1px 7px; font-size: 11px; }
.kanban-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; flex: 1; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; cursor: grab; touch-action: pan-y; user-select: none; }
.kanban-card.dragging { box-shadow: 0 10px 26px rgba(0,0,0,.35); opacity: .96; cursor: grabbing; }
.kanban-placeholder { border: 2px dashed var(--accent); border-radius: 10px; background: var(--accent-dim); min-height: 54px; }
.kanban-card .title { font-weight: 700; font-size: 13.5px; }
.kanban-card .meta { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.kanban-card .accion { font-size: 12px; margin-top: 6px; }
.kanban-card .dias { font-size: 11px; margin-top: 6px; font-weight: 700; }
.kanban-card .dias.rojo { color: var(--danger); }
.kanban-card .chips { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 15px; font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 10px; border: none; font-weight: 700; font-size: 14px;
  cursor: pointer; background: var(--accent); color: white; width: 100%;
}
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger-dim); color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.small { width: auto; padding: 7px 12px; font-size: 12.5px; }
.btn.wa { background: #25d366; color: white; }
.row-btns { display: flex; gap: 8px; }

.fab {
  position: fixed; bottom: calc(var(--nav-h) + 16px); right: 16px; z-index: 25;
  width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center; font-size: 28px; box-shadow: 0 6px 16px rgba(0,0,0,.25);
  border: none; cursor: pointer;
}

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px; }
.login-card h1 { text-align: center; margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 0 0 20px; }
.error-msg { background: var(--danger-dim); color: var(--danger); padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }
.info-msg { background: var(--good-dim); color: var(--good); padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }

.section-title { font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin: 22px 0 8px; }
.empty { color: var(--text-dim); font-size: 13px; padding: 14px 0; text-align: center; }
.hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.timeline-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .fecha { font-size: 11px; color: var(--text-dim); }
.timeline-item .canal { font-weight: 700; font-size: 12.5px; margin: 2px 0; text-transform: capitalize; }

.tag-etapa { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--accent-dim); color: var(--accent); font-weight: 700; }
