/* =========================================================
   MediFlow ERP
   Tema SaaS Responsive
   Bootstrap 5.3 + estilos propios
   ========================================================= */

:root {
  --mf-navy: #0b2545;
  --mf-navy-2: #13315c;
  --mf-blue: #1e5f9c;
  --mf-teal: #14b8a6;
  --mf-teal-2: #0d9488;
  --mf-bg: #f4f6fa;
  --mf-border: #e6eaf0;
  --mf-text: #1f2937;
  --mf-muted: #6b7280;

  --mf-sidebar-w: 272px;
  --mf-topbar-h: 68px;

  --bs-primary: #1e5f9c;
  --bs-primary-rgb: 30, 95, 156;
  --bs-link-color: #1e5f9c;
  --bs-link-hover-color: #0b2545;
  --bs-body-bg: #f4f6fa;
  --bs-body-color: #1f2937;
  --bs-font-sans-serif: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =========================================================
   BASE
   ========================================================= */

html,
body {
  min-height: 100%;
}

html {
  font-size: 16px;
}

body {
  background: var(--mf-bg);
  color: var(--mf-text);
  font-size: 1rem;
  line-height: 1.45;
  overflow-x: hidden;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.btn {
  font-size: .92rem;
  font-weight: 500;
}

.btn-sm {
  font-size: .84rem;
}

.btn-primary {
  --bs-btn-bg: #1e5f9c;
  --bs-btn-border-color: #1e5f9c;
  --bs-btn-hover-bg: #174b7c;
  --bs-btn-hover-border-color: #174b7c;
  --bs-btn-active-bg: #133e66;
  --bs-btn-active-border-color: #133e66;
}

.btn-outline-primary {
  --bs-btn-color: #1e5f9c;
  --bs-btn-border-color: #1e5f9c;
  --bs-btn-hover-bg: #1e5f9c;
  --bs-btn-hover-border-color: #1e5f9c;
  --bs-btn-active-bg: #1e5f9c;
  --bs-btn-active-border-color: #1e5f9c;
}

.btn-teal {
  --bs-btn-bg: #14b8a6;
  --bs-btn-border-color: #14b8a6;
  --bs-btn-color: #fff;
  --bs-btn-hover-bg: #0d9488;
  --bs-btn-hover-border-color: #0d9488;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #0f766e;
  --bs-btn-active-color: #fff;
}

.text-navy {
  color: var(--mf-navy) !important;
}

.text-teal {
  color: var(--mf-teal) !important;
}

.bg-navy {
  background: var(--mf-navy) !important;
}

.bg-teal {
  background: var(--mf-teal) !important;
}

.bg-soft-primary {
  background: rgba(30, 95, 156, .10) !important;
}

.bg-soft-teal {
  background: rgba(20, 184, 166, .12) !important;
}

.bg-soft-warning {
  background: rgba(245, 158, 11, .14) !important;
}

.bg-soft-danger {
  background: rgba(220, 53, 69, .12) !important;
}

.bg-soft-success {
  background: rgba(25, 135, 84, .12) !important;
}

.bg-soft-info {
  background: rgba(13, 202, 240, .14) !important;
}

.bg-soft-dark {
  background: rgba(33, 37, 41, .10) !important;
}

.bg-soft-secondary {
  background: rgba(108, 117, 125, .12) !important;
}

/* =========================================================
   FORMULARIOS
   ========================================================= */

.form-control,
.form-select {
  min-height: 40px;
  font-size: .94rem;
}

.form-control-sm,
.form-select-sm {
  min-height: 34px;
  font-size: .86rem;
}

.form-control:focus,
.form-select:focus {
  border-color: #7fb0dd;
  box-shadow: 0 0 0 .2rem rgba(30, 95, 156, .18);
}

.form-label {
  font-weight: 600;
  font-size: .90rem;
  color: #374151;
  margin-bottom: .35rem;
}

.form-text {
  font-size: .82rem;
}

.required::after {
  content: " *";
  color: #dc3545;
}

/* =========================================================
   CARDS
   ========================================================= */

.card {
  border: 1px solid var(--mf-border);
  border-radius: .8rem;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--mf-border);
  font-weight: 600;
  padding: .95rem 1.15rem;
  border-radius: .8rem .8rem 0 0 !important;
}

.card-title {
  font-weight: 700;
  color: var(--mf-navy);
}

.badge {
  font-weight: 600;
  letter-spacing: .01em;
}

.status-badge {
  font-size: .78rem;
  padding: .38em .72em;
}

/* =========================================================
   TABLAS
   ========================================================= */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  --bs-table-hover-bg: #f6f9fc;
  font-size: .94rem;
  margin-bottom: 0;
}

.table thead th {
  background: #f8fafc;
  color: #4b5563;
  font-size: .80rem;
  text-transform: uppercase;
  letter-spacing: .045em;
  font-weight: 700;
  border-bottom: 1px solid var(--mf-border);
  white-space: nowrap;
  padding-top: .75rem;
  padding-bottom: .75rem;
}

.table tbody td {
  padding-top: .68rem;
  padding-bottom: .68rem;
}

.table thead th a.sort-link {
  color: inherit;
}

.table thead th a.sort-link:hover {
  color: var(--mf-blue);
  text-decoration: none;
}

.table td {
  vertical-align: middle;
}

.table-actions {
  white-space: nowrap;
  text-align: right;
}

.table-actions .btn {
  padding: .28rem .5rem;
  font-size: .84rem;
}

.table-actions form {
  display: inline-block;
}

.pagination {
  --bs-pagination-color: #1e5f9c;
  --bs-pagination-active-bg: #1e5f9c;
  --bs-pagination-active-border-color: #1e5f9c;
  --bs-pagination-font-size: .9rem;
}

/* =========================================================
   COMPONENTES GENERALES
   ========================================================= */

.dropdown-menu {
  border: 1px solid var(--mf-border);
  box-shadow: 0 10px 30px rgba(11, 37, 69, .12);
  border-radius: .65rem;
  font-size: .94rem;
}

.dropdown-item {
  padding: .5rem 1rem;
}

.dropdown-item.active,
.dropdown-item:active {
  background: var(--mf-blue);
}

.modal-content {
  border-radius: .85rem;
  border: 0;
}

.modal-header {
  border-bottom: 1px solid var(--mf-border);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--mf-blue), var(--mf-teal));
  font-size: .9rem;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-lg {
  width: 68px;
  height: 68px;
  font-size: 1.35rem;
}

.avatar-xl {
  width: 92px;
  height: 92px;
  font-size: 1.9rem;
}

.icon-circle {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.icon-circle.sm {
  width: 36px;
  height: 36px;
  font-size: 1rem;
  border-radius: 9px;
}

.fw-600 {
  font-weight: 600;
}

.fs-7 {
  font-size: .84rem;
}

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cursor-pointer {
  cursor: pointer;
}

/* =========================================================
   LAYOUT PRINCIPAL
   ========================================================= */

.mf-wrapper {
  min-height: 100vh;
}

.mf-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--mf-sidebar-w);
  background: linear-gradient(180deg, var(--mf-navy) 0%, #0e2b52 100%);
  color: #cfd8e6;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.mf-brand {
  height: var(--mf-topbar-h);
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.mf-brand img {
  height: 44px;
  max-width: 180px;
}

.mf-tenant {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.mf-tenant .name {
  color: #fff;
  font-weight: 600;
  font-size: .96rem;
  line-height: 1.25;
}

.mf-tenant .plan {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #8fb3d9;
}

.mf-nav {
  flex: 1;
  overflow-y: auto;
  padding: .65rem 0 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.mf-nav-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #8aa2c1;
  padding: 1rem 1.3rem .4rem;
  font-weight: 700;
}

.mf-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .63rem 1.15rem .63rem 1.3rem;
  color: #cfd8e6;
  font-size: .95rem;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}

.mf-nav a i {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  opacity: .95;
}

.mf-nav a:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
  text-decoration: none;
}

.mf-nav a.active {
  background: rgba(20, 184, 166, .16);
  color: #fff;
  border-left-color: var(--mf-teal);
  font-weight: 600;
}

.mf-nav a .badge {
  margin-left: auto;
}

.mf-sidebar-footer {
  padding: .85rem 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: .78rem;
  color: #8fb3d9;
}

.mf-main {
  margin-left: var(--mf-sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .25s ease;
}

.mf-topbar {
  height: var(--mf-topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--mf-border);
  display: flex;
  align-items: center;
  padding: 0 1.4rem;
  gap: .8rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.mf-topbar .btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: #4b5563;
  font-size: 1.2rem;
  position: relative;
}

.mf-topbar .btn-icon:hover {
  background: #f1f4f8;
  color: var(--mf-navy);
}

.mf-topbar .btn-icon .count {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #dc3545;
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.mf-search {
  position: relative;
  flex: 1;
  max-width: 580px;
}

.mf-search .form-control {
  padding-left: 2.55rem;
  background: #f4f6fa;
  border-color: transparent;
  border-radius: 10px;
}

.mf-search .form-control:focus {
  background: #fff;
  border-color: #7fb0dd;
}

.mf-search .bi-search {
  position: absolute;
  left: .95rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  z-index: 2;
}

.mf-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--mf-border);
  border-radius: .7rem;
  box-shadow: 0 16px 40px rgba(11, 37, 69, .15);
  max-height: 70vh;
  overflow-y: auto;
  display: none;
  z-index: 1050;
}

.mf-search-results.show {
  display: block;
}

.mf-search-results .group {
  padding: .55rem 1rem .25rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #6b7280;
  font-weight: 700;
  background: #f8fafc;
}

.mf-search-results a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem 1rem;
  color: var(--mf-text);
}

.mf-search-results a:hover,
.mf-search-results a.focus {
  background: #eef4fb;
  text-decoration: none;
}

.mf-search-results a i {
  color: var(--mf-blue);
}

.mf-search-results .sub {
  font-size: .82rem;
  color: #6b7280;
}

.mf-content {
  padding: 1.5rem 1.6rem 2rem;
  flex: 1;
  width: 100%;
}

.mf-footer {
  padding: .85rem 1.6rem;
  font-size: .82rem;
  color: #6b7280;
  border-top: 1px solid var(--mf-border);
  background: #fff;
}

.mf-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 69, .45);
  z-index: 1035;
}

/* =========================================================
   PAGE HEADER
   ========================================================= */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  margin-bottom: 1.35rem;
}

.page-header h1 {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--mf-navy);
  margin: 0;
}

.page-header .breadcrumb {
  margin: 0;
  font-size: .84rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

/* =========================================================
   NOTIFICACIONES
   ========================================================= */

.notif-list {
  max-height: 420px;
  overflow-y: auto;
  width: 380px;
  max-width: 92vw;
}

.notif-item {
  display: flex;
  gap: .7rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--mf-border);
  color: var(--mf-text);
}

.notif-item:hover {
  background: #f6f9fc;
  text-decoration: none;
}

.notif-item.unread {
  background: #f0f7ff;
}

.notif-item .t {
  font-weight: 600;
  font-size: .92rem;
}

.notif-item .m {
  font-size: .84rem;
  color: #4b5563;
}

.notif-item .d {
  font-size: .76rem;
  color: #9ca3af;
}

.user-menu .dropdown-toggle::after {
  display: none;
}

/* =========================================================
   KPI
   ========================================================= */

.kpi-card {
  border-radius: .85rem;
  border: 1px solid var(--mf-border);
  background: #fff;
  padding: 1.15rem 1.2rem;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.kpi-card .label {
  font-size: .80rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6b7280;
  font-weight: 700;
}

.kpi-card .value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--mf-navy);
  line-height: 1.15;
  margin-top: .3rem;
}

.kpi-card .sub {
  font-size: .82rem;
  color: #6b7280;
  margin-top: .3rem;
}

.kpi-card .icon-circle {
  position: absolute;
  right: 1rem;
  top: 1rem;
}

.kpi-card.accent-primary {
  border-top: 3px solid var(--mf-blue);
}

.kpi-card.accent-teal {
  border-top: 3px solid var(--mf-teal);
}

.kpi-card.accent-warning {
  border-top: 3px solid #f59e0b;
}

.kpi-card.accent-danger {
  border-top: 3px solid #dc3545;
}

.kpi-card.accent-success {
  border-top: 3px solid #198754;
}

.kpi-card.accent-info {
  border-top: 3px solid #0dcaf0;
}

.kpi-card.accent-dark {
  border-top: 3px solid #374151;
}

.delta {
  font-size: .80rem;
  font-weight: 700;
}

.delta.up {
  color: #198754;
}

.delta.down {
  color: #dc3545;
}

/* =========================================================
   GRÁFICOS
   ========================================================= */

.chart-box {
  position: relative;
  height: 320px;
  min-width: 0;
}

.chart-box.sm {
  height: 250px;
}

.chart-box.lg {
  height: 390px;
}

.chart-box canvas {
  max-width: 100% !important;
}

.list-compact .list-group-item {
  padding: .68rem .95rem;
  font-size: .92rem;
}

/* =========================================================
   LOGIN / AUTH
   ========================================================= */

.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 10% 10%, rgba(20, 184, 166, .25), transparent 60%),
    radial-gradient(900px 500px at 90% 90%, rgba(30, 95, 156, .35), transparent 60%),
    var(--mf-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-x: hidden;
}

.auth-body .container-fluid {
  max-width: 1380px;
}

.auth-body .row {
  min-height: calc(100vh - 4rem);
}

.auth-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 1.15rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  padding: 2.5rem 2.4rem;
}

.auth-card .brand {
  text-align: center;
  margin-bottom: 1.6rem;
}

.auth-card .brand img {
  height: 66px;
  max-width: 100%;
}

.auth-card h1 {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--mf-navy);
  text-align: center;
}

.auth-card p {
  font-size: .98rem;
}

.auth-side {
  color: #dbe7f5;
  max-width: 540px;
}

.auth-side h2 {
  color: #fff;
  font-weight: 800;
  font-size: 2.4rem;
  line-height: 1.18;
}

.auth-side p {
  font-size: 1.08rem;
  line-height: 1.6;
}

.auth-side li {
  margin-bottom: .7rem;
  font-size: 1.02rem;
}

.demo-box {
  background: #f0f7ff;
  border: 1px dashed #b7d3ee;
  border-radius: .65rem;
  padding: .85rem 1rem;
  font-size: .88rem;
  line-height: 1.55;
}

/* =========================================================
   ERRORES
   ========================================================= */

.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.error-page .code {
  font-size: 6rem;
  font-weight: 900;
  color: var(--mf-blue);
  line-height: 1;
}

/* =========================================================
   TIMELINE / HISTORIA CLÍNICA
   ========================================================= */

.timeline {
  position: relative;
  padding-left: 1.6rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: #dbe3ee;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.1rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.6rem;
  top: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--mf-blue);
}

.timeline-item.teal::before {
  border-color: var(--mf-teal);
}

.timeline-item .when {
  font-size: .82rem;
  color: #6b7280;
  font-weight: 600;
}

.vitals-grid .v {
  background: #f8fafc;
  border: 1px solid var(--mf-border);
  border-radius: .6rem;
  padding: .65rem .75rem;
}

.vitals-grid .v .k {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6b7280;
  font-weight: 700;
}

.vitals-grid .v .n {
  font-weight: 700;
  color: var(--mf-navy);
  font-size: 1.05rem;
}

.alert-clinical {
  border-left: 4px solid #dc3545;
  background: #fff5f5;
}

.tab-pane .table {
  margin-bottom: 0;
}

.nav-tabs .nav-link,
.nav-pills .nav-link {
  color: #4b5563;
  font-weight: 600;
  font-size: .92rem;
}

.nav-tabs .nav-link.active {
  color: var(--mf-blue);
  border-bottom-color: #fff;
}

.nav-pills .nav-link.active {
  background: var(--mf-blue);
}

/* =========================================================
   AGENDA
   ========================================================= */

.cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  align-items: center;
  justify-content: space-between;
}

.cal-grid {
  display: grid;
  grid-template-columns: 74px repeat(var(--cols, 7), minmax(0, 1fr));
  border: 1px solid var(--mf-border);
  border-radius: .7rem;
  overflow: hidden;
  background: #fff;
  min-width: 900px;
}

.cal-grid .cal-head {
  background: #f8fafc;
  font-weight: 700;
  font-size: .84rem;
  text-align: center;
  padding: .65rem .3rem;
  border-bottom: 1px solid var(--mf-border);
  border-left: 1px solid var(--mf-border);
  color: #374151;
}

.cal-grid .cal-head.today {
  color: var(--mf-blue);
  background: #eef4fb;
}

.cal-grid .cal-time {
  font-size: .78rem;
  color: #6b7280;
  text-align: right;
  padding: .4rem .5rem;
  border-top: 1px solid var(--mf-border);
  background: #fcfdfe;
}

.cal-grid .cal-cell {
  border-top: 1px solid var(--mf-border);
  border-left: 1px solid var(--mf-border);
  min-height: 52px;
  padding: 3px;
  position: relative;
}

.cal-grid .cal-cell:hover {
  background: #f6f9fc;
}

.cal-grid .cal-cell a.slot-add {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.cal-grid .cal-cell:hover a.slot-add {
  opacity: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mf-blue);
  font-size: 1rem;
  text-decoration: none;
}

.cal-grid .cal-cell.closed {
  background:
    repeating-linear-gradient(
      45deg,
      #fafbfc,
      #fafbfc 6px,
      #f2f4f7 6px,
      #f2f4f7 12px
    );
}

.appt-chip {
  display: block;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: .78rem;
  line-height: 1.28;
  margin-bottom: 2px;
  color: #fff;
  text-decoration: none;
  border-left: 3px solid rgba(0, 0, 0, .25);
  overflow: hidden;
}

.appt-chip:hover {
  filter: brightness(.95);
  color: #fff;
  text-decoration: none;
}

.appt-chip .who {
  font-weight: 700;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appt-chip.st-scheduled {
  background: #1e5f9c;
}

.appt-chip.st-confirmed {
  background: #0891b2;
}

.appt-chip.st-waiting {
  background: #d97706;
}

.appt-chip.st-attended {
  background: #198754;
}

.appt-chip.st-cancelled {
  background: #9ca3af;
  text-decoration: line-through;
}

.appt-chip.st-no_show {
  background: #374151;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  min-width: 840px;
}

.month-grid .dow {
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  padding: .35rem 0;
}

.month-grid .day {
  background: #fff;
  border: 1px solid var(--mf-border);
  border-radius: .5rem;
  min-height: 110px;
  padding: .4rem;
  font-size: .82rem;
}

.month-grid .day.other {
  background: #fafbfc;
  opacity: .6;
}

.month-grid .day.today {
  border-color: var(--mf-blue);
  box-shadow: inset 0 0 0 1px var(--mf-blue);
}

.month-grid .day .n {
  font-weight: 700;
  color: #374151;
  display: flex;
  justify-content: space-between;
}

.month-grid .day .n a {
  color: var(--mf-blue);
}

.month-grid .day .more {
  color: var(--mf-blue);
  font-size: .76rem;
  font-weight: 600;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.busy-slots .chip {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: .8rem;
  margin: 2px;
}

/* =========================================================
   KANBAN / CRM
   ========================================================= */

.kanban {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}

.kanban-col {
  flex: 0 0 300px;
  background: #eef1f6;
  border-radius: .8rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 260px);
}

.kanban-col .kh {
  padding: .8rem .95rem;
  font-weight: 700;
  font-size: .92rem;
  color: var(--mf-navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 4px solid var(--stage, #1e5f9c);
  border-radius: .8rem .8rem 0 0;
}

.kanban-col .kh .cnt {
  background: #fff;
  border-radius: 999px;
  font-size: .78rem;
  padding: .12rem .55rem;
  color: #374151;
}

.kanban-col .kv {
  font-size: .78rem;
  color: #6b7280;
  padding: 0 .95rem .55rem;
}

.kanban-list {
  padding: .45rem .65rem .65rem;
  overflow-y: auto;
  min-height: 60px;
  flex: 1;
}

.kanban-list.drag-over {
  background: rgba(20, 184, 166, .12);
  border-radius: .5rem;
  outline: 2px dashed var(--mf-teal);
}

.kanban-card {
  background: #fff;
  border: 1px solid var(--mf-border);
  border-radius: .6rem;
  padding: .7rem .75rem;
  margin-bottom: .55rem;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  font-size: .9rem;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: .5;
}

.kanban-card .kn {
  font-weight: 700;
  color: var(--mf-navy);
  display: flex;
  justify-content: space-between;
  gap: .3rem;
}

.kanban-card .kn a {
  color: inherit;
}

.kanban-card .ki {
  color: #6b7280;
  font-size: .8rem;
}

.kanban-card .kf {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .45rem;
  font-size: .78rem;
}

.kanban-card .due.late {
  color: #dc3545;
  font-weight: 700;
}

.funnel-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: #e5e7eb;
}

.funnel-bar span {
  display: block;
  height: 100%;
}

.st-new {
  --stage: #1e5f9c;
}

.st-contacted {
  --stage: #0891b2;
}

.st-interested {
  --stage: #f59e0b;
}

.st-scheduled {
  --stage: #8b5cf6;
}

.st-converted {
  --stage: #198754;
}

.st-lost {
  --stage: #dc3545;
}

.bg-stage-new {
  background: #1e5f9c;
}

.bg-stage-contacted {
  background: #0891b2;
}

.bg-stage-interested {
  background: #f59e0b;
}

.bg-stage-scheduled {
  background: #8b5cf6;
}

.bg-stage-converted {
  background: #198754;
}

.bg-stage-lost {
  background: #dc3545;
}

/* =========================================================
   FORMULARIOS DINÁMICOS
   ========================================================= */

.repeater-table td {
  padding: .35rem;
  vertical-align: top;
}

.repeater-table .form-control,
.repeater-table .form-select {
  font-size: .9rem;
  padding: .38rem .55rem;
}

.totals-box {
  background: #f8fafc;
  border: 1px solid var(--mf-border);
  border-radius: .7rem;
  padding: 1.1rem 1.25rem;
}

.totals-box .row + .row {
  margin-top: .3rem;
}

.totals-box .grand {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--mf-navy);
}

.perm-matrix th,
.perm-matrix td {
  text-align: center;
  vertical-align: middle;
}

.perm-matrix td:first-child,
.perm-matrix th:first-child {
  text-align: left;
}

.perm-matrix .form-check-input {
  margin: 0;
  cursor: pointer;
}

/* =========================================================
   FILTROS
   ========================================================= */

.filter-bar {
  background: #fff;
  border: 1px solid var(--mf-border);
  border-radius: .75rem;
  padding: 1rem 1.05rem;
  margin-bottom: 1rem;
}

.filter-bar .form-control,
.filter-bar .form-select {
  font-size: .92rem;
}

/* =========================================================
   REPORTES
   ========================================================= */

.report-tile {
  display: block;
  background: #fff;
  border: 1px solid var(--mf-border);
  border-radius: .8rem;
  padding: 1.15rem 1.2rem;
  height: 100%;
  color: var(--mf-text);
  transition: transform .15s, box-shadow .15s;
}

.report-tile:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(11, 37, 69, .1);
  color: var(--mf-text);
}

.report-tile .icon-circle {
  margin-bottom: .7rem;
}

.report-tile h6 {
  font-weight: 700;
  color: var(--mf-navy);
  margin: 0 0 .3rem;
  font-size: 1rem;
}

.report-tile p {
  font-size: .88rem;
  color: #6b7280;
  margin: 0;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: #fff;
  border: 1px solid var(--mf-border);
  border-radius: 999px;
  padding: .3rem .75rem;
  font-size: .84rem;
  font-weight: 600;
}

/* =========================================================
   DOCUMENTOS / OTROS
   ========================================================= */

.doc-tile {
  display: flex;
  align-items: center;
  gap: .75rem;
  border: 1px solid var(--mf-border);
  border-radius: .6rem;
  padding: .7rem .85rem;
  background: #fff;
}

.doc-tile .ext {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: #eef4fb;
  color: var(--mf-blue);
}

.signature-preview {
  max-height: 70px;
}

.print-only {
  display: none;
}

.toast-container {
  z-index: 1090;
}

.progress-thin {
  height: 6px;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #6b7280;
}

.empty-state i {
  font-size: 2.6rem;
  color: #cbd5e1;
  display: block;
  margin-bottom: .5rem;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: .7rem;
  padding: 1.25rem;
  text-align: center;
  color: #6b7280;
  background: #fafbfc;
}

.dropzone:hover {
  border-color: var(--mf-blue);
  background: #f4f9ff;
}

.setting-section {
  border-bottom: 1px dashed var(--mf-border);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.projection-table td,
.projection-table th {
  text-align: right;
}

.projection-table td:first-child,
.projection-table th:first-child {
  text-align: left;
}

.sc-conservative {
  color: #b45309;
}

.sc-expected {
  color: #1e5f9c;
}

.sc-optimistic {
  color: #0f766e;
}

mark {
  background: #fff3bf;
  padding: 0 .1em;
}

.w-120 {
  width: 120px;
}

.w-160 {
  width: 160px;
}

.w-90 {
  width: 90px;
}

.w-70 {
  width: 70px;
}

/* =========================================================
   LAPTOP / TABLET
   ========================================================= */

@media (max-width: 1199.98px) {
  :root {
    --mf-sidebar-w: 250px;
  }

  .mf-content {
    padding: 1.25rem;
  }

  .chart-box {
    height: 290px;
  }

  .chart-box.sm {
    height: 230px;
  }

  .chart-box.lg {
    height: 340px;
  }

  .auth-card {
    max-width: 480px;
    padding: 2.1rem 1.9rem;
  }

  .auth-side h2 {
    font-size: 2rem;
  }
}

/* =========================================================
   TABLET / MENÚ MÓVIL
   ========================================================= */

@media (max-width: 991.98px) {
  :root {
    --mf-sidebar-w: 280px;
  }

  .mf-sidebar {
    transform: translateX(-100%);
    box-shadow: 8px 0 30px rgba(11, 37, 69, .20);
  }

  body.sidebar-open .mf-sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .mf-overlay {
    display: block;
  }

  .mf-main {
    margin-left: 0;
  }

  .mf-content {
    padding: 1rem;
  }

  .mf-search {
    max-width: none;
  }

  .page-header h1 {
    font-size: 1.4rem;
  }

  .chart-box {
    height: 280px;
  }

  .chart-box.lg {
    height: 320px;
  }

  .kanban-col {
    flex-basis: 280px;
  }

  .auth-body {
    padding: 1.25rem;
  }

  .auth-body .row {
    min-height: calc(100vh - 2.5rem);
  }
}

/* =========================================================
   MÓVIL
   ========================================================= */

@media (max-width: 575.98px) {
  html {
    font-size: 15px;
  }

  .mf-topbar {
    padding: 0 .65rem;
    gap: .35rem;
  }

  .mf-content {
    padding: .8rem;
  }

  .mf-footer {
    padding: .8rem;
  }

  .page-header {
    align-items: flex-start;
    margin-bottom: 1rem;
  }

  .page-header > div:first-child {
    width: 100%;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn,
  .page-actions .dropdown {
    flex: 1 1 auto;
  }

  .page-actions .btn {
    white-space: nowrap;
  }

  .card-header {
    padding: .8rem;
  }

  .card-body {
    padding: .85rem;
  }

  .kpi-card {
    padding: 1rem;
  }

  .kpi-card .value {
    font-size: 1.45rem;
  }

  .auth-body {
    padding: .7rem;
    align-items: flex-start;
  }

  .auth-body .container-fluid {
    padding: 0;
  }

  .auth-body .row {
    min-height: 0;
    margin: 0;
    padding: .7rem 0;
  }

  .auth-card {
    max-width: none;
    padding: 1.5rem 1.15rem;
    border-radius: .9rem;
  }

  .auth-card .brand {
    margin-bottom: 1.1rem;
  }

  .auth-card .brand img {
    height: 54px;
  }

  .auth-card h1 {
    font-size: 1.35rem;
  }

  .demo-box {
    font-size: .82rem;
  }

  .notif-list {
    width: 94vw;
  }

  .chart-box,
  .chart-box.sm,
  .chart-box.lg {
    height: 260px;
  }

  .table {
    font-size: .86rem;
  }

  .table thead th {
    font-size: .74rem;
  }

  .cal-toolbar {
    align-items: stretch;
  }

  .cal-toolbar > * {
    max-width: 100%;
  }

  .month-grid,
  .cal-grid {
    overflow-x: visible;
  }

  .kanban-col {
    flex-basis: 265px;
  }

  .error-page .code {
    font-size: 4.5rem;
  }
}

/* =========================================================
   DESKTOP NORMAL
   ========================================================= */

@media (min-width: 992px) {
  body.sidebar-collapsed .mf-sidebar {
    transform: translateX(-100%);
  }

  body.sidebar-collapsed .mf-main {
    margin-left: 0;
  }
}

/* =========================================================
   PANTALLAS GRANDES 1600+
   Escalado real para monitores grandes
   ========================================================= */

@media (min-width: 1600px) {
  html {
    font-size: 17px;
  }

  :root {
    --mf-sidebar-w: 286px;
    --mf-topbar-h: 72px;
  }

  .mf-content {
    padding: 1.65rem 1.75rem 2.2rem;
  }

  .mf-search {
    max-width: 640px;
  }

  .chart-box {
    height: 340px;
  }

  .chart-box.sm {
    height: 270px;
  }

  .chart-box.lg {
    height: 410px;
  }

  .auth-body .container-fluid {
    max-width: 1500px;
  }

  .auth-card {
    max-width: 560px;
  }

  .auth-side {
    max-width: 600px;
  }

  .auth-side h2 {
    font-size: 2.55rem;
  }
}

/* =========================================================
   QHD / 2K / ULTRAWIDE
   ========================================================= */

@media (min-width: 2200px) {
  html {
    font-size: 18px;
  }

  :root {
    --mf-sidebar-w: 300px;
    --mf-topbar-h: 76px;
  }

  .mf-content {
    padding: 1.8rem 2rem 2.4rem;
  }

  .mf-search {
    max-width: 720px;
  }

  .chart-box {
    height: 360px;
  }

  .chart-box.sm {
    height: 290px;
  }

  .chart-box.lg {
    height: 430px;
  }

  .auth-body .container-fluid {
    max-width: 1660px;
  }

  .auth-card {
    max-width: 590px;
    padding: 2.8rem 2.6rem;
  }

  .auth-side {
    max-width: 650px;
  }

  .auth-side h2 {
    font-size: 2.7rem;
  }
}

/* =========================================================
   4K / PANTALLAS MUY GRANDES
   ========================================================= */

@media (min-width: 3000px) {
  html {
    font-size: 20px;
  }

  :root {
    --mf-sidebar-w: 330px;
    --mf-topbar-h: 82px;
  }

  .mf-content {
    padding: 2rem 2.2rem 2.6rem;
  }

  .mf-search {
    max-width: 820px;
  }

  .mf-brand img {
    height: 50px;
  }

  .chart-box {
    height: 390px;
  }

  .chart-box.sm {
    height: 315px;
  }

  .chart-box.lg {
    height: 470px;
  }

  .auth-body .container-fluid {
    max-width: 1900px;
  }

  .auth-card {
    max-width: 640px;
    padding: 3rem;
  }

  .auth-side {
    max-width: 720px;
  }

  .auth-side h2 {
    font-size: 3rem;
  }
}

/* =========================================================
   IMPRESIÓN
   ========================================================= */

@media print {
  html {
    font-size: 16px !important;
  }

  .no-print,
  .mf-sidebar,
  .mf-topbar,
  .mf-footer,
  .page-actions,
  .filter-bar,
  .btn,
  .pagination {
    display: none !important;
  }

  .mf-main {
    margin: 0 !important;
  }

  .mf-content {
    padding: 0 !important;
  }

  .print-only {
    display: block;
  }

  body {
    background: #fff;
    font-size: 12px;
  }

  .card {
    border: 0;
    box-shadow: none;
  }
}
