:root {
  --bg: #eaf5fc;
  --card: #ffffff;
  --ink: #1a1d23;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #0f172a;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); font-size: 0.9rem; }

.screen { min-height: 100vh; }

#login-view {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #0a2e2e 0%, #06181c 55%, #040f12 100%);
}

#bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.login-card {
  position: relative;
  z-index: 1;
  max-width: 380px;
  width: 90%;
  margin: 0 auto;
  background: rgba(10, 30, 32, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(45, 212, 191, 0.25);
  padding: 2.2rem;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(45, 212, 191, 0.08);
  color: #e6fbf8;
}
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; color: #fff; }
.login-card .muted { color: #7fd8cf; }
.login-card form input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: #e6fbf8;
}
.login-card form input:focus {
  outline: none;
  border-color: #2dd4bf;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2);
}
.login-card button {
  width: 100%;
  background: linear-gradient(135deg, #14b8a6, #0891b2);
  box-shadow: 0 4px 16px rgba(20, 184, 166, 0.35);
}
.login-card button:hover { filter: brightness(1.08); }

form label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.9rem 0 0.3rem; }
form input, form select, form textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}
form textarea { resize: vertical; }
form .checkbox { display: flex; align-items: center; gap: 0.5rem; }
form .checkbox input { width: auto; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  margin-top: 1rem;
}
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; margin: 0; }
button.danger { background: var(--red); }

a.button {
  display: inline-block;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--accent);
  color: #fff;
  padding: 0.8rem 1.5rem;
}
.brand { font-weight: 700; }
#tabs { display: flex; gap: 0.3rem; flex: 1; }
.tab {
  background: transparent;
  color: #cbd5e1;
  margin: 0;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-weight: 500;
}
.tab.active { background: rgba(255,255,255,0.15); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 0.8rem; }
.topbar-right .ghost { color: #fff; border-color: rgba(255,255,255,0.3); margin: 0; }

#app-view { position: relative; overflow: hidden; }

.clouds {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.cloud {
  position: absolute;
  background: #8ecae6;
  border-radius: 100px;
  opacity: 0.85;
  filter: blur(0.5px);
}
.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 100px;
}
.cloud-1 { width: 260px; height: 90px; top: 4%; left: -40px; }
.cloud-1::before { width: 140px; height: 140px; top: -70px; left: 30px; border-radius: 50%; }
.cloud-1::after { width: 110px; height: 110px; top: -50px; left: 140px; border-radius: 50%; }

.cloud-2 { width: 320px; height: 110px; top: 20%; right: -60px; opacity: 0.75; }
.cloud-2::before { width: 160px; height: 160px; top: -80px; left: 40px; border-radius: 50%; }
.cloud-2::after { width: 130px; height: 130px; top: -60px; right: 30px; border-radius: 50%; }

.cloud-3 { width: 220px; height: 80px; bottom: 6%; left: 8%; opacity: 0.7; }
.cloud-3::before { width: 120px; height: 120px; top: -60px; left: 20px; border-radius: 50%; }
.cloud-3::after { width: 90px; height: 90px; top: -40px; left: 110px; border-radius: 50%; }

.cloud-4 { width: 200px; height: 70px; bottom: 30%; right: 5%; opacity: 0.65; }
.cloud-4::before { width: 100px; height: 100px; top: -50px; left: 15px; border-radius: 50%; }
.cloud-4::after { width: 80px; height: 80px; top: -35px; left: 95px; border-radius: 50%; }

header.topbar, main { position: relative; z-index: 1; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card h2 { margin-top: 0; font-size: 1.15rem; }

.card.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.35);
  padding: 0.9rem 1.2rem;
}

.card-list { display: flex; flex-direction: column; gap: 0.8rem; }
.list-item {
  background: var(--card);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.list-item .meta { font-size: 0.85rem; color: var(--muted); margin-top: 0.2rem; }
.list-item .actions { display: flex; gap: 0.5rem; }

.stats-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat {
  background: var(--card);
  border-radius: 10px;
  padding: 1rem 1.4rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  min-width: 130px;
}
.stat strong { display: block; font-size: 1.6rem; }
.stat span { font-size: 0.8rem; color: var(--muted); }
.stat.apto strong { color: var(--green); }
.stat.descartado strong { color: var(--red); }

.results-actions { margin-bottom: 1.5rem; }

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 1rem;
  align-items: start;
  overflow-x: auto;
}
.kanban-column {
  background: rgba(127,127,127,0.06);
  border-radius: 12px;
  padding: 0.8rem;
  min-height: 200px;
}
.kanban-column h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0.2rem 0.3rem 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.col-del-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.kanban-column:hover .col-del-btn { opacity: 1; }
.col-del-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }
.kanban-cards { display: flex; flex-direction: column; gap: 0.6rem; min-height: 60px; max-height: calc(100vh - 260px); overflow-y: auto; padding-right: 2px; }
.kanban-cards.drag-over { background: rgba(45, 212, 191, 0.1); border-radius: 8px; }

.kanban-card {
  background: var(--card);
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: grab;
  border: 1px solid var(--border);
}
.kanban-card.dragging { opacity: 0.4; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.3rem; }
.card-top strong { font-size: 0.92rem; flex: 1; }

.card-del-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  margin: 0;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.kanban-card:hover .card-del-btn { opacity: 1; }
.card-del-btn:hover { background: var(--red); color: #fff; }
.kanban-card .meta { font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0 0.2rem; }
.kanban-card .date { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.4rem; }

.kanban-toolbar { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.kanban-toolbar label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.kanban-toolbar select { padding: 0.4rem 0.6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--ink); font-size: 0.85rem; }

.kanban-search-wrap { flex: 1; min-width: 200px; }
#kanban-search {
  width: 100%;
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 0.55rem center;
  color: var(--ink);
  font-size: 0.85rem;
  margin-top: 0;
}
#kanban-search:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.kanban-card .snippet {
  font-size: 0.82rem;
  color: var(--ink);
  white-space: pre-wrap;
  height: 6.2em;
  overflow-y: scroll;
  padding-right: 6px;
  margin-bottom: 0.25rem;
  cursor: auto;
  user-select: text;
}
.card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}
.card-status-select {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  padding: 0.2rem 0.4rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.card-footer a { font-size: 0.72rem; white-space: nowrap; }
.hubspot-badge { font-size: 0.7rem; color: #f97316; font-weight: 600; white-space: nowrap; }
.hubspot-error { font-size: 0.72rem; color: #dc2626; margin-top: 0.3rem; width: 100%; }
.kanban-card .snippet::-webkit-scrollbar { width: 10px; }
.kanban-card .snippet::-webkit-scrollbar-track { background: rgba(127,127,127,0.12); border-radius: 6px; }
.kanban-card .snippet::-webkit-scrollbar-thumb { background: rgba(45, 212, 191, 0.55); border-radius: 6px; }
.kanban-card .snippet::-webkit-scrollbar-button { display: block; height: 12px; background: rgba(45, 212, 191, 0.35); }
.kanban-card .snippet { scrollbar-width: thin; scrollbar-color: rgba(45, 212, 191, 0.55) rgba(127,127,127,0.12); }
.kanban-card a { font-size: 0.78rem; }
.hubspot-badge { margin-top: 0.4rem; font-size: 0.72rem; font-weight: 600; color: var(--green); }

.table-wrap { overflow-x: auto; background: var(--card); border-radius: 10px; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #fafafa; font-size: 0.75rem; text-transform: uppercase; color: var(--muted); }
td a { color: var(--accent); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --ink: #e5e7eb;
    --muted: #9aa3af;
    --border: #2a2e37;
    --accent: #2563eb;
  }
  th { background: #1d212b; }
  a.button { color: #08110a; }
  .cloud { background: #2f6690; opacity: 0.45; }
}
