:root {
  /* Paleta oficial Screaming Color Group (extraída del logo) */
  --brand-navy: #0e203c;
  --brand-crimson: #991b1f;
  --brand-coral: #dc5258;
  --brand-sky: #93c9d6;
  --brand-teal: #297b85;

  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e5eaf2;
  --text: #0e203c;
  --muted: #64748b;
  --primary: #991b1f;
  --primary-hover: #dc5258;
  --accent: #297b85;
  --success: #0f766e;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(14, 32, 60, 0.06);
  --shadow-md: 0 8px 24px rgba(14, 32, 60, 0.08);
  --shadow-lg: 0 24px 60px rgba(14, 32, 60, 0.18);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .kanban-col-title, .kpi-value {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  letter-spacing: -0.015em;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.accent { color: var(--brand-crimson); }

/* CINTA SUPERIOR MULTICOLOR (LOS 5 COLORES DEL LOGO) */
.brand-ribbon {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 100;
  background: linear-gradient(
    90deg,
    var(--brand-crimson) 0%,
    var(--brand-coral) 26%,
    var(--brand-sky) 56%,
    var(--brand-teal) 80%,
    var(--brand-navy) 100%
  );
}

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(circle at 12% 18%, rgba(153, 27, 31, 0.09), transparent 40%),
    radial-gradient(circle at 88% 20%, rgba(147, 201, 214, 0.28), transparent 42%),
    radial-gradient(circle at 75% 88%, rgba(41, 123, 133, 0.12), transparent 40%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 32px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  text-align: center;
  margin-bottom: 24px;
}
.lang-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.btn-lang {
  background: #f1f5f9;
  color: var(--brand-navy);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-lang:hover {
  border-color: var(--brand-teal);
  background: #eef6f8;
  color: var(--brand-teal);
}
.login-logo {
  max-width: 245px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 10px;
}
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.demo-users { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

/* LAYOUT */
.app-shell { display: flex; min-height: 100vh; padding-top: 4px; }
.sidebar {
  width: 256px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
}
.sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  width: 185px;
  max-width: 100%;
  height: auto;
  display: block;
}
.brand-sub {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-teal);
}
.nav-list { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; flex: 1; }
.nav-item {
  background: transparent;
  border: none;
  color: #334155;
  text-align: left;
  padding: 11px 13px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 13.8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.nav-item:hover { background: #f1f5f9; color: var(--brand-navy); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(153, 27, 31, 0.1), rgba(220, 82, 88, 0.08));
  color: var(--brand-crimson);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand-crimson);
}
.pill {
  background: #fef3c7;
  color: #b45309;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11.5px;
}
.sidebar-footer { padding-top: 14px; border-top: 1px solid var(--border); }
.user-card {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #f8fafc, #eef6f8);
  border: 1px solid #dbe9ee;
  border-radius: 10px;
}
.user-name { font-weight: 700; font-size: 13.5px; color: var(--brand-navy); }
.user-role { font-size: 11.5px; font-weight: 600; color: var(--brand-teal); }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  padding: 16px 26px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}
.topbar h2 { margin: 0; font-size: 20px; color: var(--brand-navy); }
.topbar p { margin: 2px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.tab-panel { display: none; padding: 22px 26px; flex: 1; overflow: auto; }
.tab-panel.active { display: block; }

/* INPUTS & BUTTONS */
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #475569; }
input, select, textarea {
  background: #ffffff;
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(41, 123, 133, 0.14);
}
.search-input { width: 240px; }
.select-input { padding: 9px 11px; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.15s;
}
.btn:hover { opacity: 0.94; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-full { width: 100%; }
.btn-lg { padding: 12px 18px; font-size: 14.5px; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-crimson), var(--brand-coral));
  box-shadow: 0 4px 12px rgba(153, 27, 31, 0.22);
}
.btn-accent {
  background: linear-gradient(135deg, var(--brand-navy), var(--brand-teal));
  box-shadow: 0 4px 12px rgba(14, 32, 60, 0.2);
}
.btn-success {
  background: linear-gradient(135deg, #0f766e, #10b981);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}
.btn-warning { background: linear-gradient(135deg, #d97706, #f59e0b); color: #ffffff; }
.btn-ghost { background: #ffffff; color: var(--brand-navy); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--panel-2); border-color: #cbd5e1; }
.btn-danger-ghost { background: #fff5f5; color: var(--danger); border: 1.5px solid #fecaca; }
.btn-chip {
  background: var(--panel-2);
  border: 1.5px solid var(--border);
  color: var(--brand-navy);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-chip:hover { border-color: var(--brand-crimson); background: #fff1f2; color: var(--brand-crimson); }
.icon-btn { background: transparent; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 8px; }

/* KANBAN */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(265px, 1fr));
  gap: 15px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 18px;
}
.kanban-col {
  background: #edf1f7;
  border: 1px solid #dfe6f0;
  border-top: 4px solid var(--brand-navy);
  border-radius: var(--radius);
  padding: 13px;
  min-height: 520px;
}
.kanban-col[data-stage="nuevo_lead"] { border-top-color: var(--brand-sky); }
.kanban-col[data-stage="recopilando_specs"] { border-top-color: var(--brand-teal); }
.kanban-col[data-stage="en_cotizacion"] { border-top-color: #f59e0b; }
.kanban-col[data-stage="cotizacion_lista"] { border-top-color: var(--brand-coral); }
.kanban-col[data-stage="cotizacion_enviada"] { border-top-color: var(--brand-crimson); }
.kanban-col[data-stage="ganado_pm"] { border-top-color: #10b981; }

.kanban-col.drag-over { border-color: var(--brand-crimson); background: #fff1f2; }
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(14, 32, 60, 0.08);
}
.kanban-col-title { font-weight: 800; font-size: 13.2px; color: var(--brand-navy); }
.kanban-count {
  background: #ffffff;
  color: var(--brand-navy);
  font-weight: 800;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.kanban-cards { display: flex; flex-direction: column; gap: 10px; }
.lead-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.lead-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-teal);
  box-shadow: var(--shadow-md);
}
.lead-card-title { font-weight: 800; font-size: 14.5px; margin-bottom: 2px; color: var(--brand-navy); }
.lead-card-company { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
}
.badge-web { background: rgba(147, 201, 214, 0.28); color: #0e4a5a; }
.badge-ferias { background: rgba(14, 32, 60, 0.1); color: var(--brand-navy); }
.badge-ads { background: rgba(41, 123, 133, 0.15); color: #1d5d65; }
.badge-ig { background: rgba(220, 82, 88, 0.15); color: var(--brand-crimson); }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-pm { background: #d1fae5; color: #047857; }
.badge-contact { background: #e0f2fe; color: #0369a1; }
.lead-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

/* DASHBOARD */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 15px; margin-bottom: 22px; }
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand-teal);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.kpi-card:nth-child(1) { border-top-color: var(--brand-sky); }
.kpi-card:nth-child(2) { border-top-color: #f59e0b; }
.kpi-card:nth-child(3) { border-top-color: #10b981; }
.kpi-card:nth-child(4) { border-top-color: var(--brand-coral); }
.kpi-card:nth-child(5) { border-top-color: var(--brand-navy); }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 32px; font-weight: 800; color: var(--brand-navy); }

.dashboard-split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.panel-card h3 { margin: 0 0 6px; font-size: 16.5px; color: var(--brand-navy); }
.alerts-list, .source-stats, .status-list, .pm-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.alert-item {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.alert-item.high { background: #fef2f2; border-color: #fecaca; border-left-color: var(--brand-crimson); }
.source-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 10px;
}

/* TABLES */
.table-wrap { overflow-x: auto; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--brand-navy); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; background: #f8fafc; }
tr:hover td { background: #f8fbfd; }

/* INTEGRATIONS */
.integrations-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.full-span { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 140px; }
.code-block {
  background: var(--brand-navy);
  border-radius: 10px;
  padding: 15px;
  overflow-x: auto;
  font-size: 12.5px;
  color: #e2e8f0;
  margin: 10px 0 0;
}

/* MODALS */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(14, 32, 60, 0.52); backdrop-filter: blur(3px); }
.modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  max-height: 93vh;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-xl { max-width: 1100px; }
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #ffffff, #f8fbfc);
}
.modal-header h3 { margin: 0; font-size: 18.5px; color: var(--brand-navy); }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 10px; }

/* STEPPER & GUIDED NEXT ACTION */
.stepper-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.step-pill {
  text-align: center;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 700;
  background: #f1f5f9;
  color: #64748b;
  border: 1.5px solid transparent;
  cursor: pointer;
}
.step-pill.done { background: rgba(41, 123, 133, 0.14); color: var(--brand-teal); }
.step-pill.current {
  background: rgba(153, 27, 31, 0.1);
  color: var(--brand-crimson);
  border-color: var(--brand-crimson);
}
.step-pill.step-readonly { cursor: default; }

.next-step-banner {
  background: linear-gradient(135deg, rgba(147, 201, 214, 0.18), rgba(220, 82, 88, 0.08));
  border: 1.5px solid rgba(41, 123, 133, 0.25);
  border-radius: 13px;
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.next-step-text strong { display: block; font-size: 14.5px; color: var(--brand-navy); }
.next-step-text span { font-size: 12.5px; color: #475569; }
.next-step-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; }
.detail-sidebar { display: flex; flex-direction: column; gap: 14px; }
.action-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.action-box h4 { margin: 0; font-size: 14px; color: var(--brand-navy); }
.more-fields {
  grid-column: 1 / -1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.more-fields summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--brand-navy); }
.more-fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }

.quick-contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.quick-contact-btn {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brand-navy);
  cursor: pointer;
  text-align: left;
  transition: all 0.14s;
}
.quick-contact-btn:hover { border-color: var(--brand-crimson); background: #fff1f2; color: var(--brand-crimson); }

.assign-pm-row { display: flex; gap: 8px; }
.assign-pm-row select { flex: 1; }
.ai-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-controls select { flex: 1; min-width: 110px; }
.ai-output {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
}
.note-form { display: flex; gap: 6px; }
.note-form input { flex: 1; }
.notes-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.note-item { background: #ffffff; padding: 10px 12px; border-radius: 9px; font-size: 13px; border: 1px solid var(--border); }
.note-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.action-bar-save { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.alert-inline { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; padding: 9px 11px; border-radius: 9px; font-size: 13px; }
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 90;
  background: var(--brand-navy);
  color: #fff;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}

.activity-badge { margin-right: 6px; }
.file-upload-form { display: flex; flex-direction: column; gap: 8px; }
.file-row { display: flex; gap: 6px; align-items: center; }
.file-row input[type="file"] { flex: 1; padding: 6px; font-size: 12.5px; min-width: 0; background: #fff; }
.files-list { display: flex; flex-direction: column; gap: 8px; max-height: 190px; overflow-y: auto; }
.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
}
.file-item-info { min-width: 0; flex: 1; }
.file-link { color: var(--brand-teal); font-weight: 700; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-link:hover { text-decoration: underline; }
.file-item-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* SWEETALERT2 CUSTOM FORM */
.swal-form-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-top: 6px;
}
.swal-form-stack label {
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.swal-form-stack input,
.swal-form-stack textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid #cbd5e1;
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
}
.swal2-popup {
  border-radius: 18px !important;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif !important;
}

@media (max-width: 960px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .dashboard-split, .integrations-grid, .detail-layout, .stepper-bar { grid-template-columns: 1fr; }
}
