:root {
  --brand: #2166f3;
  --brand-dark: #1747ad;
  --brand-soft: #e8f0ff;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee9;
  --surface: #ffffff;
  --page: #f4f7fb;
  --sidebar: #0f172a;
  --sidebar-soft: #1e293b;
}

body {
  background: var(--page);
  color: var(--ink);
}

.app-body {
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.crm-sidebar {
  width: 280px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .98), rgba(22, 34, 58, .97)),
    radial-gradient(circle at top, rgba(33, 102, 243, .35), transparent 40%);
  color: #fff;
  padding: 24px 18px;
}

.crm-sidebar-shell {
  width: 100%;
}

.crm-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.crm-brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), #64a2ff);
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 18px 30px rgba(33, 102, 243, .28);
}

.crm-nav-section {
  color: rgba(255, 255, 255, .65);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 12px;
}

.crm-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, .78);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  font-weight: 500;
}

.crm-nav .nav-link.active,
.crm-nav .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .09);
}

.app-main {
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px 28px 0;
}

.topbar-title {
  font-size: 1.5rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  line-height: 1.15;
}

.user-pill-name {
  font-weight: 600;
}

.user-pill-role {
  color: var(--muted);
  font-size: .84rem;
  text-transform: capitalize;
}

.app-content {
  padding: 28px;
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(33, 102, 243, .94), rgba(23, 32, 51, .88)),
    url("https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 430px);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 24px 70px rgba(9, 24, 51, .22);
}

.eyebrow {
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: .78rem;
}

.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(23, 32, 51, .05);
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 2.1rem;
  line-height: 1;
}

.badge-soft {
  border-radius: 999px;
  padding: 6px 10px;
  background: #eaf2ff;
  color: #174ea6;
  font-weight: 600;
}

.timeline-item {
  border-left: 3px solid var(--brand);
  padding-left: 14px;
  margin-bottom: 14px;
}

.btn,
.form-control,
.form-select,
.modal-content,
.alert {
  border-radius: 12px;
}

table.dataTable td {
  vertical-align: middle;
}

.contact-phone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.icon-action img {
  width: 18px;
  height: 18px;
  display: block;
}

.stack-list {
  display: grid;
  gap: 8px;
}

.stack-row {
  display: grid;
  grid-template-columns: minmax(90px, 120px) 1fr auto;
  gap: 12px;
  align-items: center;
}

.stack-label {
  font-weight: 600;
}

.stack-bar {
  height: 10px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
}

.stack-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #7fb2ff);
}

#eventsCalendar {
  min-height: 760px;
}

.fc {
  --fc-border-color: var(--line);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: #f8fafc;
  --fc-list-event-hover-bg-color: #eef4ff;
  --fc-today-bg-color: rgba(33, 102, 243, .08);
  --fc-button-bg-color: var(--brand);
  --fc-button-border-color: var(--brand);
  --fc-button-hover-bg-color: var(--brand-dark);
  --fc-button-hover-border-color: var(--brand-dark);
  --fc-button-active-bg-color: var(--brand-dark);
  --fc-button-active-border-color: var(--brand-dark);
}

.fc .fc-toolbar-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.fc .fc-button {
  border-radius: 10px;
  box-shadow: none !important;
}

.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number,
.fc .fc-list-day-text,
.fc .fc-list-day-side-text {
  color: var(--ink);
  text-decoration: none;
}

.fc .fc-event {
  border-radius: 10px;
  padding: 2px 4px;
  box-shadow: 0 6px 14px rgba(23, 32, 51, .12);
}

.fc .fc-event-title {
  font-weight: 600;
}

.fc .fc-list-event-dot {
  border-color: var(--brand);
}

@media (max-width: 768px) {
  #eventsCalendar {
    min-height: 640px;
  }

  .fc .fc-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .fc .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
  }
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.kanban-column {
  background: linear-gradient(180deg, #f9fbff, #f1f5fb);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  min-height: 240px;
}

.kanban-column-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.kanban-column-header h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}

.kanban-column-header span {
  color: var(--muted);
  font-size: .85rem;
}

.kanban-items {
  display: grid;
  gap: 12px;
}

.kanban-card {
  background: #fff;
  border: 1px solid rgba(33, 102, 243, .12);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 18px rgba(15, 23, 42, .06);
}

.kanban-card.ganada {
  border-color: rgba(34, 197, 94, .35);
}

.kanban-card.perdida {
  border-color: rgba(239, 68, 68, .35);
}

.kanban-card-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.kanban-empty {
  color: var(--muted);
  font-size: .92rem;
  padding: 18px 8px;
  text-align: center;
}

.offcanvas .crm-sidebar-shell {
  color: var(--ink);
}

.offcanvas .crm-nav-section {
  color: var(--muted);
}

.offcanvas .crm-nav .nav-link {
  color: var(--ink);
}

.offcanvas .crm-nav .nav-link.active,
.offcanvas .crm-nav .nav-link:hover {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

@media (max-width: 576px) {
  .login-panel {
    padding: 24px;
  }
}

@media (max-width: 991.98px) {
  .topbar,
  .app-content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    padding-top: 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .user-pill {
    flex: 1;
  }
}
