:root {
  --col-cards-over: rgba(255,255,255,0.04);
}
body[data-theme="light"] {
  --col-cards-over: rgba(0,0,0,0.05);
}

body {
  font-family: 'Montserrat', sans-serif;
  background: var(--bg);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}

/* ── CANVAS BG ── */
#bg-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; opacity: 0.22;
  transition: opacity .3s;
}
body[data-theme="light"] #bg-canvas { opacity: 0.06; }

#bg-veil {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(10,10,12,0.6) 0%, transparent 60%),
    radial-gradient(ellipse at 0% 50%, rgba(10,10,12,0.4) 0%, transparent 40%),
    radial-gradient(ellipse at 100% 50%, rgba(10,10,12,0.4) 0%, transparent 40%);
  pointer-events: none; transition: background .3s;
}
body[data-theme="light"] #bg-veil {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(240,240,245,0.7) 0%, transparent 60%),
    radial-gradient(ellipse at 0% 50%, rgba(240,240,245,0.5) 0%, transparent 40%),
    radial-gradient(ellipse at 100% 50%, rgba(240,240,245,0.5) 0%, transparent 40%);
}

/* ── MAIN WRAP ── */
.wrap {
  position: relative; z-index: 1;
  padding: 0 32px 80px;
}

/* ── TOPBAR ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand a {
  color: var(--muted2); text-decoration: none;
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  transition: color .2s;
}
.topbar-brand a:hover { color: var(--white); }
.topbar-sep { color: var(--muted2); font-size: 12px; }
.topbar-title {
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gold);
}
.topbar-right { display: flex; gap: 10px; align-items: center; }

.btn-sm {
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-family: inherit;
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-sm:hover { border-color: var(--border-hover); color: var(--white); }

.btn-theme {
  background: none; border: 1px solid var(--border);
  font-size: 15px; width: 34px; height: 34px;
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .2s;
}
.btn-theme:hover { border-color: var(--border-hover); }

.btn-primary {
  background: var(--gold); color: #000;
  border: none; font-size: 13px; font-weight: 700;
  font-family: inherit; padding: 8px 18px;
  border-radius: 8px; cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover { background: var(--gold-light); }

/* ── PAGE HEADER ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-header-left {}
.page-eyebrow {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted2); margin-bottom: 8px;
}
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 700; color: var(--white);
}

/* ── FILTER BAR ── */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 24px;
}
.filter-select {
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px;
  font-size: 13px; color: var(--white); font-family: inherit;
  outline: none; cursor: pointer;
  transition: border-color .2s, background .3s, color .3s;
  appearance: none;
  padding-right: 28px;
  background-image: 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='M0 0l5 6 5-6z' fill='%23777'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.filter-select:focus { border-color: rgba(184,151,90,0.5); }
.filter-select option { background: var(--opt-bg); }

.btn-clear {
  background: none; border: 1px solid var(--border);
  color: var(--muted2); font-size: 12px; font-family: inherit;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  transition: border-color .2s, color .2s;
  display: none;
}
.btn-clear.visible { display: inline-flex; align-items: center; gap: 6px; }
.btn-clear:hover { border-color: var(--border-hover); color: var(--white); }

.count-badge {
  font-size: 12px; font-weight: 600;
  color: var(--muted2);
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-left: auto;
}

/* ── KANBAN WRAP ── */
.kanban-wrap {
  overflow-x: auto;
  margin: 0 -32px;
  padding: 0 32px 4px;
}
.kanban-wrap::-webkit-scrollbar { height: 6px; }
.kanban-wrap::-webkit-scrollbar-track { background: transparent; }
.kanban-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.kanban-wrap::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

.kanban {
  display: flex; gap: 12px;
  min-width: max-content;
  padding-bottom: 20px;
  align-items: flex-start;
}

/* ── COLUMN ── */
.kanban-col {
  width: 256px; flex-shrink: 0;
  display: flex; flex-direction: column;
}

.col-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 14px;
  border-left: 4px solid transparent;
  border-radius: 8px 8px 0 0;
  margin-bottom: 6px;
}

.col-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.col-dot-prospecto    { background: #6c8eff; }
.col-dot-conversacion { background: #f5c518; }
.col-dot-propuesta    { background: #fb8c00; }
.col-dot-negociacion  { background: #e55a2b; }
.col-dot-ganado       { background: #4caf88; }
.col-dot-live         { background: #3ecfcf; }
.col-dot-pausado      { background: #b8975a; }
.col-dot-perdido      { background: #666666; }

.col-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--white); flex: 1;
}

.col-count {
  font-size: 11px; font-weight: 600;
  color: var(--muted2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 8px;
  min-width: 22px; text-align: center;
}

.col-cards {
  flex: 1;
  display: flex; flex-direction: column; gap: 8px;
  padding: 6px;
  min-height: 100px;
  border-radius: 10px;
  border: 1px dashed transparent;
  transition: background .15s, border-color .15s;
}
.col-cards.drag-over {
  background: var(--col-cards-over);
  border-color: var(--border-hover);
}

/* ── NEGOCIO CARD ── */
.neg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
  cursor: pointer;
  transition: border-color .2s, background .2s, opacity .15s, transform .15s;
  position: relative;
  user-select: none;
}
.neg-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.neg-card.dragging { opacity: 0.45; transform: scale(0.98); }

.card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 8px; gap: 6px;
}
.card-cliente {
  font-size: 14px; font-weight: 700;
  color: var(--white); line-height: 1.3;
  flex: 1;
}
.card-flag { font-size: 16px; flex-shrink: 0; line-height: 1; margin-top: 1px; }

.card-badges {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.card-badge {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 5px;
  line-height: 1.4;
}
.card-badge-prod-connect  { background: #b8975a; color: #000; }
.card-badge-prod-copiloto { background: #6c8eff; color: #fff; }
.card-badge-prod-dimo     { background: #e92f31; color: #fff; }
.card-badge-prod-wicar    { background: #fb5f00; color: #fff; }
.card-badge-resp {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.card-valor {
  font-size: 12px; color: var(--muted);
  margin-bottom: 6px;
}

/* ── KPI BAR ── */
.kpi-bar {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.kpi-card {
  flex: 1; min-width: 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
}
.kpi-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted2); margin-bottom: 8px;
}
.kpi-value {
  font-size: 22px; font-weight: 800;
  color: var(--white); line-height: 1;
}
.kpi-green { color: var(--green); }
.kpi-amber { color: var(--gold); }
.kpi-tasa-date {
  font-size: 10px; color: var(--muted2); margin-top: 4px; letter-spacing: 0.02em;
}
.card-clp {
  font-size: 11px; color: var(--accent-teal);
  margin-top: 1px; letter-spacing: 0.01em;
}

.card-next {
  border-top: 1px solid var(--border);
  margin-top: 8px; padding-top: 8px;
  font-size: 11px; color: var(--muted2); line-height: 1.5;
}
.card-next-date { font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.card-next-paso { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── EMPTY COL ── */
.col-empty {
  font-size: 12px; color: var(--muted2);
  text-align: center; padding: 20px 8px;
  opacity: 0.5;
}

/* ── MODAL ── */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: var(--overlay-bg); backdrop-filter: blur(16px);
  align-items: center; justify-content: center; padding: 20px;
}
.overlay.visible { display: flex; }

.modal {
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 40px;
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  position: relative;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: modalIn .22s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: translateY(12px) scale(0.97); }
  to   { opacity:1; transform: none; }
}
.modal-close {
  position: absolute; top: 14px; right: 18px;
  background: none; border: none; cursor: pointer;
  color: var(--muted2); font-size: 18px; transition: color .15s;
}
.modal-close:hover { color: var(--white); }
.modal-title {
  font-size: 18px; font-weight: 700;
  color: var(--white); margin-bottom: 24px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted2); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 13px;
  font-size: 14px; color: var(--white); font-family: inherit;
  outline: none; transition: border-color .2s, background .3s, color .3s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(184,151,90,0.5);
}
.field input::placeholder, .field textarea::placeholder {
  color: var(--muted2); opacity: 0.7;
}
.field select option { background: var(--opt-bg); }
.field textarea { resize: vertical; min-height: 72px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-footer {
  margin-top: 24px; display: flex; gap: 10px; align-items: center;
}
.btn-save {
  flex: 1; background: var(--gold); color: #000;
  border: none; border-radius: 8px; padding: 12px;
  font-size: 14px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: background .2s;
}
.btn-save:hover { background: var(--gold-light); }
.btn-cancel {
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-size: 14px; font-family: inherit;
  padding: 12px 20px; border-radius: 8px; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-cancel:hover { border-color: var(--border-hover); color: var(--white); }
.btn-delete {
  background: none; border: 1px solid rgba(233,47,49,0.4);
  color: var(--red); font-size: 13px; font-family: inherit;
  padding: 12px 16px; border-radius: 8px; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.btn-delete:hover { background: rgba(233,47,49,0.1); border-color: rgba(233,47,49,0.7); }
.is-hidden.is-hidden { display: none; }

/* ── LOADING / TOAST ── */
.loading-msg {
  text-align: center; padding: 60px 20px;
  color: var(--muted2); font-size: 13px;
}

.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #000;
  font-size: 13px; font-weight: 700;
  padding: 10px 24px; border-radius: 10px;
  z-index: 9999; opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ── HERRAMIENTAS ── */
.tools-section {
  margin-bottom: 24px;
}
.tools-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted2);
  margin-bottom: 10px;
}
.tools-row {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.tool-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  transition: border-color .2s, background .2s, transform .15s;
  cursor: pointer;
  min-width: 220px;
}
.tool-card:hover {
  border-color: rgba(184,151,90,0.45);
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.tool-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: rgba(62,207,207,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.tool-info { flex: 1; min-width: 0; }
.tool-name {
  font-size: 13px; font-weight: 700;
  color: var(--white); line-height: 1.2;
}
.tool-desc {
  font-size: 11px; color: var(--muted2);
  margin-top: 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.tool-arrow {
  font-size: 12px; color: var(--muted2);
  flex-shrink: 0; transition: color .2s;
}
.tool-card:hover .tool-arrow { color: var(--accent-teal); }

@media (max-width: 600px) {
  .wrap { padding: 0 16px 60px; }
  .kanban-wrap { margin: 0 -16px; padding: 0 16px 4px; }
  .modal { padding: 28px 20px; }
  .field-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .tool-card { min-width: 100%; }
}

/* ── MAIN TABS ── */
.main-tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.main-tab-btn {
  padding: 10px 22px; background: transparent;
  border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted); font-family: 'Montserrat', sans-serif;
  font-size: 13px; font-weight: 700; letter-spacing: 0.03em;
  cursor: pointer; transition: color .2s, border-color .2s;
}
.main-tab-btn.active  { color: var(--white); border-bottom-color: var(--gold); }
.main-tab-btn:hover:not(.active) { color: var(--white); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── ANALYTICS ── */
.analytics-controls {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 28px; flex-wrap: wrap;
}
.analytics-ctrl-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted2);
}
.range-btns { display: flex; gap: 4px; }
.range-btn {
  padding: 6px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-family: 'Montserrat', sans-serif;
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: all .2s;
}
.range-btn.active { background: var(--gold); border-color: var(--gold); color: #0a0a0c; }
.range-btn:hover:not(.active) { border-color: var(--border-hover); color: var(--white); }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding-bottom: 60px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
}
.chart-card-wide { grid-column: 1 / -1; }
.chart-hdr {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 20px; gap: 12px;
}
.chart-title {
  font-size: 13px; font-weight: 800;
  color: var(--white); letter-spacing: 0.02em;
}
.chart-subtitle { font-size: 11px; color: var(--muted2); margin-top: 3px; }
.toggle-btns { display: flex; gap: 4px; flex-shrink: 0; }
.funnel-toggle {
  padding: 5px 11px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 7px;
  color: var(--muted); font-family: 'Montserrat', sans-serif;
  font-size: 11px; font-weight: 700; cursor: pointer; transition: all .15s;
}
.funnel-toggle.active {
  background: var(--surface-hover); border-color: var(--border-hover);
  color: var(--white);
}
.chart-loading {
  text-align: center; padding: 40px; color: var(--muted2); font-size: 12px;
}
@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card-wide { grid-column: 1; }
}
