/* ═══════════════════════════════════════════════════════════════
   Finca Montesur — Estilos principales
   Paleta: verde campo + tierra + blanco limpio
   ═══════════════════════════════════════════════════════════════ */

:root {
  --fm-verde:        #2d6a4f;
  --fm-verde-claro:  #52b788;
  --fm-verde-bg:     #d8f3dc;
  --fm-tierra:       #8b5e3c;
  --fm-tierra-claro: #c9956c;
  --fm-gris:         #495057;
  --fm-gris-claro:   #f8f9fa;
  --fm-borde:        #dee2e6;
  --fm-alerta:       #e76f51;
  --fm-sombra:       0 2px 8px rgba(0,0,0,.08);
  --fm-radio:        10px;
}

/* ── Base ─────────────────────────────────────────────────────── */
body {
  background: #f4f6f4;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: #2b2d2e;
  font-size: 15px;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  width: 240px;
  height: 100vh;
  background: var(--fm-verde);
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform .25s ease;
}

#sidebar .sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

#sidebar .sidebar-brand h5 {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: .3px;
}

#sidebar .sidebar-brand small {
  color: rgba(255,255,255,.55);
  font-size: .78rem;
}

#sidebar .nav-section {
  padding: .5rem 1rem .2rem;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  margin-top: .5rem;
}

#sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1.25rem;
  color: rgba(255,255,255,.82);
  font-size: .875rem;
  border-radius: 0;
  transition: background .15s, color .15s;
  text-decoration: none;
}

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

#sidebar .nav-link .nav-icon {
  width: 18px;
  text-align: center;
  opacity: .75;
}

#sidebar .nav-link.active .nav-icon { opacity: 1; }

#sidebar .badge-alerta {
  margin-left: auto;
  background: var(--fm-alerta);
  color: #fff;
  font-size: .68rem;
  padding: .2em .5em;
  border-radius: 20px;
}

/* ── Layout principal ─────────────────────────────────────────── */
#main-content {
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--fm-borde);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .page-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--fm-gris);
  margin: 0;
}

.topbar .topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-body {
  padding: 1.5rem;
  flex: 1;
}

/* ── Tarjetas KPI ─────────────────────────────────────────────── */
.kpi-card {
  background: #fff;
  border-radius: var(--fm-radio);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--fm-sombra);
  border-left: 4px solid var(--fm-verde-claro);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.kpi-card.kpi-rojo  { border-left-color: var(--fm-alerta); }
.kpi-card.kpi-tierra { border-left-color: var(--fm-tierra-claro); }
.kpi-card.kpi-gris  { border-left-color: #adb5bd; }

.kpi-card .kpi-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.kpi-card .kpi-valor {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--fm-verde);
  line-height: 1;
}

.kpi-card.kpi-rojo .kpi-valor   { color: var(--fm-alerta); }
.kpi-card.kpi-tierra .kpi-valor { color: var(--fm-tierra); }

.kpi-card .kpi-label {
  font-size: .8rem;
  color: #6c757d;
  margin-top: .15rem;
}

/* ── Tarjeta estándar ─────────────────────────────────────────── */
.fm-card {
  background: #fff;
  border-radius: var(--fm-radio);
  box-shadow: var(--fm-sombra);
  border: 1px solid var(--fm-borde);
  overflow: hidden;
}

.fm-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--fm-borde);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
}

.fm-card-header h6 {
  font-weight: 600;
  font-size: .9rem;
  margin: 0;
  color: var(--fm-gris);
}

.fm-card-body { padding: 1.25rem; }

/* ── Tablas ───────────────────────────────────────────────────── */
.fm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.fm-table thead th {
  background: var(--fm-gris-claro);
  color: #495057;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: .65rem 1rem;
  border-bottom: 2px solid var(--fm-borde);
  white-space: nowrap;
}

.fm-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background .12s;
}

.fm-table tbody tr:hover { background: #f8fffe; }

.fm-table tbody td {
  padding: .65rem 1rem;
  vertical-align: middle;
  color: #2b2d2e;
}

.fm-table .col-acciones { width: 130px; text-align: right; }

/* ── Badges de estado ─────────────────────────────────────────── */
.badge-estado {
  display: inline-block;
  padding: .25em .65em;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}

.badge-activo    { background: var(--fm-verde-bg); color: var(--fm-verde); }
.badge-vendido   { background: #fff3cd; color: #856404; }
.badge-muerto    { background: #f8d7da; color: #842029; }
.badge-pendiente { background: #fff3cd; color: #856404; }
.badge-atendida  { background: var(--fm-verde-bg); color: var(--fm-verde); }
.badge-vencida   { background: #f8d7da; color: #842029; }
.badge-rentable  { background: var(--fm-verde-bg); color: var(--fm-verde); }
.badge-perdida   { background: #f8d7da; color: #842029; }

/* ── Filtros ──────────────────────────────────────────────────── */
.filtros-bar {
  background: #fff;
  border: 1px solid var(--fm-borde);
  border-radius: var(--fm-radio);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}

.filtros-bar .form-label {
  font-size: .78rem;
  font-weight: 600;
  color: #6c757d;
  margin-bottom: .25rem;
}

.filtros-bar .form-control,
.filtros-bar .form-select {
  font-size: .875rem;
  border-radius: 6px;
}

/* ── Botones ──────────────────────────────────────────────────── */
.btn-fm-primary {
  background: var(--fm-verde);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .45rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.btn-fm-primary:hover { background: #1e4d38; color: #fff; }

.btn-fm-danger {
  background: var(--fm-alerta);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .45rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s;
}

.btn-fm-danger:hover { background: #c1440e; color: #fff; }

.btn-sm-icon {
  padding: .25rem .5rem;
  font-size: .8rem;
  border-radius: 5px;
  border: 1px solid var(--fm-borde);
  background: #fff;
  color: var(--fm-gris);
  transition: all .12s;
  text-decoration: none;
}

.btn-sm-icon:hover { background: var(--fm-gris-claro); color: #000; }

/* ── Formularios ──────────────────────────────────────────────── */
.fm-form-card {
  background: #fff;
  border-radius: var(--fm-radio);
  box-shadow: var(--fm-sombra);
  padding: 2rem;
  max-width: 860px;
}

.fm-form-card .form-label {
  font-weight: 500;
  font-size: .875rem;
  color: var(--fm-gris);
}

/* ── Alertas ──────────────────────────────────────────────────── */
.alerta-banner {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
}

/* ── Gráficas ─────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 280px;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #main-content {
    margin-left: 0;
  }

  .kpi-card .kpi-valor { font-size: 1.3rem; }
  .page-body { padding: 1rem; }
}

/* ── Tablas responsive para movil ─────────────────────── */
.fm-card-body.p-0 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.fm-table {
    min-width: 600px;
}

@media (max-width: 768px) {
    .fm-table {
        font-size: .8rem;
    }
    .fm-table th, .fm-table td {
        padding: .4rem .5rem;
        white-space: nowrap;
    }
    .filtros-bar form {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .filtros-bar .form-control,
    .filtros-bar .form-select {
        width: 100% !important;
    }
    .btn-fm-primary, .btn-sm {
        width: 100%;
        text-align: center;
        margin-bottom: .25rem;
    }
}

/* Tablas responsive para movil */
.fm-card-body.p-0 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.fm-table {
    min-width: 600px;
}
@media (max-width: 768px) {
    .fm-table {
        font-size: .8rem;
    }
    .fm-table th, .fm-table td {
        padding: .4rem .5rem;
        white-space: nowrap;
    }
    .filtros-bar form {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .filtros-bar .form-control,
    .filtros-bar .form-select {
        width: 100% !important;
    }
}

/* Fix scroll horizontal tablas movil */
.fm-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.fm-table {
    min-width: 650px;
    width: 100%;
}
