/* ─── CropTracker — Estilos globales ────────────────────────────────────────── */
:root {
  --ct-green:       #2d6a4f;
  --ct-green-light: #40916c;
  --ct-green-pale:  #d8f3dc;
  --ct-accent:      #52b788;
  --ct-sidebar-w:   250px;
  --ct-navbar-h:    58px;
  --ct-bottombar-h: 60px;
}

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

/* ── Sidebar (escritorio) ────────────────────────────────────────────────────── */
.ct-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--ct-sidebar-w);
  height: 100vh;
  background: var(--ct-green);
  z-index: 1000;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

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

.ct-sidebar .brand-title {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .5px;
}

.ct-sidebar .brand-subtitle {
  color: rgba(255,255,255,.6);
  font-size: .75rem;
}

.ct-sidebar .nav-link {
  color: rgba(255,255,255,.8);
  padding: .6rem 1rem;
  border-radius: 8px;
  margin: 2px 8px;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .88rem;
  transition: background .15s, color .15s;
}

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

.ct-sidebar .nav-link i {
  width: 18px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

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

.ct-sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.15);
}

/* ── Navbar (escritorio) ─────────────────────────────────────────────────────── */
.ct-navbar {
  position: fixed;
  top: 0;
  left: var(--ct-sidebar-w);
  right: 0;
  height: var(--ct-navbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 900;
}

.ct-main {
  margin-left: var(--ct-sidebar-w);
  margin-top: var(--ct-navbar-h);
  padding: 1.5rem;
  min-height: calc(100vh - var(--ct-navbar-h));
}

/* ── Bottom navbar (móvil) ───────────────────────────────────────────────────── */
.ct-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--ct-bottombar-h);
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  z-index: 1000;
}

.ct-bottom-nav .btn-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  text-decoration: none;
  font-size: .65rem;
  gap: 3px;
  border: none;
  background: none;
}

.ct-bottom-nav .btn-nav i {
  font-size: 1.25rem;
}

.ct-bottom-nav .btn-nav.active {
  color: var(--ct-green);
}

/* ── Main móvil ──────────────────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .ct-sidebar, .ct-navbar { display: none !important; }
  .ct-main {
    margin-left: 0;
    margin-top: 0;
    padding: 1rem;
    padding-bottom: calc(var(--ct-bottombar-h) + 1rem);
  }
  .ct-mobile-header {
    position: sticky;
    top: 0;
    background: var(--ct-green);
    color: #fff;
    z-index: 900;
    padding: .75rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
  }
  .ct-mobile-header h1 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
  }
}

@media (min-width: 768px) {
  .ct-bottom-nav,
  .ct-mobile-header { display: none !important; }
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.ct-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.ct-kpi-card {
  border-radius: 12px;
  padding: 1.25rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.ct-kpi-card .kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.ct-kpi-card .kpi-label {
  font-size: .8rem;
  opacity: .85;
  margin-top: .25rem;
}

.ct-kpi-card .kpi-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  opacity: .25;
}

/* ── Botones ─────────────────────────────────────────────────────────────────── */
.btn-ct-primary {
  background: var(--ct-green);
  border-color: var(--ct-green);
  color: #fff;
}
.btn-ct-primary:hover {
  background: var(--ct-green-light);
  border-color: var(--ct-green-light);
  color: #fff;
}

/* ── Tablas ──────────────────────────────────────────────────────────────────── */
.table-ct th {
  background: #f9fafb;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #6b7280;
  border-bottom: 2px solid #e5e7eb;
}

.table-ct td {
  vertical-align: middle;
  font-size: .9rem;
}

/* ── Badges de categoría ─────────────────────────────────────────────────────── */
.badge-insumo      { background: #dbeafe; color: #1e40af; }
.badge-mano_obra   { background: #fce7f3; color: #9d174d; }
.badge-maquinaria  { background: #fef3c7; color: #92400e; }
.badge-transporte  { background: #e0e7ff; color: #3730a3; }
.badge-otro        { background: #f3f4f6; color: #374151; }

.badge-fungicida   { background: #fee2e2; color: #991b1b; }
.badge-fertilizante{ background: #dcfce7; color: #166534; }
.badge-herbicida   { background: #fef9c3; color: #713f12; }
.badge-insecticida { background: #fce7f3; color: #9d174d; }
.badge-riego       { background: #dbeafe; color: #1e40af; }

/* ── Login ───────────────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--ct-green) 0%, var(--ct-green-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-logo {
  width: 56px;
  height: 56px;
  background: var(--ct-green-pale);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--ct-green);
  margin: 0 auto 1rem;
}

/* ── Formularios ─────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  font-size: 16px; /* evita zoom en iOS */
  border-radius: 8px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--ct-accent);
  box-shadow: 0 0 0 .2rem rgba(82,183,136,.25);
}

/* ── Spinner overlay ─────────────────────────────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#loading-overlay.active { display: flex; }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.ct-toast-container {
  position: fixed;
  bottom: 80px;
  right: 1rem;
  z-index: 9000;
}
@media (min-width: 768px) {
  .ct-toast-container { bottom: 1.5rem; }
}

/* ── Utilidades ──────────────────────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.text-ct-green  { color: var(--ct-green) !important; }
.bg-ct-green    { background: var(--ct-green) !important; }

/* ── Tabla responsive en móvil ───────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .table-responsive-stack td,
  .table-responsive-stack th { display: block; }
  .table-responsive-stack thead { display: none; }
  .table-responsive-stack tr {
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: .75rem;
    padding: .5rem;
    background: #fff;
  }
  .table-responsive-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .75rem;
    color: #6b7280;
    display: block;
    text-transform: uppercase;
    letter-spacing: .5px;
  }
}
