* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f4f6f2;
  margin: 0;
}

a {
  color: inherit;
}

/* --- Páginas de autenticación (login / registro) --- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1b5e20, #66bb6a);
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  padding: 2.5rem 2rem;
  text-align: center;
  animation: auth-card-in 0.45s ease both;
}

@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-icon {
  font-size: 2.6rem;
  line-height: 1;
  margin-bottom: 0.5rem;
  color: #2e7d32;
}

.auth-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  color: #1b5e20;
}

.auth-subtitle {
  margin: 0 0 1.5rem;
  color: #6b7280;
  font-size: 0.9rem;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-card input,
.auth-card select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d7dcd6;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fafbfa;
  color: #222;
}

.auth-card select {
  color: #555;
}

.auth-card input::placeholder {
  color: #9aa19a;
}

.auth-card input:focus,
.auth-card select:focus {
  outline: none;
  border-color: #2e7d32;
  background: white;
}

.auth-card button {
  width: 100%;
  padding: 0.8rem;
  margin-top: 0.3rem;
  background: #2e7d32;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-card button:hover {
  background: #256428;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(46, 125, 50, 0.35);
}

.auth-card button:active {
  transform: translateY(0);
  box-shadow: none;
}

.auth-message {
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
}

.auth-message--error {
  background: #fdecea;
  color: #c62828;
}

.auth-message--success {
  background: #e8f5e9;
  color: #2e7d32;
}

.auth-message--success a {
  color: #1b5e20;
  font-weight: 600;
}

.auth-link {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: #6b7280;
}

.auth-link a {
  color: #2e7d32;
  font-weight: 600;
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* --- Login: layout dividido con panel decorativo --- */

.login-page {
  min-height: 100vh;
  display: flex;
}

.login-hero {
  position: relative;
  flex: 1.1;
  overflow: hidden;
  background: linear-gradient(150deg, #12401a, #2e7d32 55%, #66bb6a);
  display: flex;
  align-items: center;
  padding: 3rem;
}

.login-hero-content {
  position: relative;
  z-index: 2;
  max-width: 460px;
  color: #ffffff;
}

.login-hero-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
  color: #e7f2e1;
}

.login-hero-brand i {
  font-size: 1.4rem;
  color: #a5d6a7;
}

.login-hero h1 {
  font-size: 2.3rem;
  line-height: 1.2;
  margin: 0 0 1rem;
}

.login-hero p {
  color: #d7e7d1;
  font-size: 1.02rem;
  line-height: 1.6;
  margin: 0 0 2.2rem;
  max-width: 380px;
}

.login-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.login-features li {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-weight: 600;
  color: #f1f7ee;
}

.login-feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.login-hero-icon {
  position: absolute;
  color: rgba(255, 255, 255, 0.14);
  font-size: 3.2rem;
  pointer-events: none;
  z-index: 1;
}

.login-float {
  animation: login-float 7s ease-in-out infinite;
}

.login-float--1 { top: 12%; left: 18%; font-size: 2.6rem; animation-delay: 0s; }
.login-float--2 { top: 68%; left: 10%; font-size: 4rem; animation-delay: 1.2s; }
.login-float--3 { top: 20%; left: 78%; font-size: 3.4rem; animation-delay: 2.1s; }
.login-float--4 { top: 75%; left: 72%; font-size: 3rem; animation-delay: 0.6s; }
.login-float--5 { top: 45%; left: 48%; font-size: 6rem; opacity: 0.5; animation-delay: 1.7s; }

@keyframes login-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-18px) rotate(6deg); }
}

.login-panel {
  flex: 1;
  min-width: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #f4f6f2;
}

.input-icon-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-group i {
  position: absolute;
  left: 1rem;
  color: #9aa19a;
  font-size: 0.95rem;
  pointer-events: none;
}

.input-icon-group input {
  padding-left: 2.6rem !important;
}

@media (max-width: 860px) {
  .login-hero {
    display: none;
  }
}

/* --- Panel administrativo (sidebar + contenido) --- */

/* El sidebar queda fijo a la altura de la ventana; solo se desplaza el
   contenido de la derecha, que deja libre el ancho del sidebar. */
:root {
  --sidebar-ancho: 240px;
}

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

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20; /* sobre el contenido, bajo los modales (50) */
  width: var(--sidebar-ancho);
  height: 100vh;
  box-sizing: border-box;
  background: linear-gradient(180deg, #16290f, #1f3517);
  color: #c7d6bf;
  padding: 1.6rem 1.1rem;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2rem;
  padding: 0 0.4rem;
  flex-shrink: 0;
}

.sidebar-brand i {
  color: #8bc34a;
  font-size: 1.3rem;
}

/* Si el menú no cabe (pantallas bajas), se desplaza solo él: la marca
   arriba y el bloque del usuario abajo siempre quedan visibles. */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden; /* el desplazamiento al pasar el mouse no crea scroll horizontal */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  color: #b9c9b2;
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sidebar-nav a i {
  width: 1.2rem;
  text-align: center;
  font-size: 1.05rem;
  transition: transform 0.2s ease;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  transform: translateX(3px);
}

.sidebar-nav a:hover i {
  transform: scale(1.1);
}

.sidebar-nav a.active {
  background: #2e7d32;
  color: #ffffff;
  font-weight: 600;
}

.sidebar-nav a.active:hover {
  transform: none;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
  margin-top: 1rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #e5ece0 !important;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.4rem !important;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff !important;
  transform: translateX(3px);
}

.sidebar-user.active {
  background: #2e7d32;
  color: #ffffff !important;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.sidebar-avatar-fallback {
  font-size: 1.9rem;
  line-height: 1;
  color: #8bc34a;
  flex-shrink: 0;
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.4rem;
  color: #b9c9b2;
  text-decoration: none;
}

.sidebar-footer a:hover {
  color: #ffffff;
}

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-ancho);
  padding: 2rem 2.5rem;
}

.page-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-topbar h2 {
  margin: 0;
  font-size: 1.4rem;
  color: #1b2e14;
}

.page-subtitle {
  margin: 0.25rem 0 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.finca-select {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #d7dcd6;
  background: white;
  font-family: inherit;
  font-size: 0.9rem;
  color: #333;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: #2e7d32;
  color: #ffffff;
}

.btn-primary:hover {
  background: #256428;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(46, 125, 50, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-primary:disabled {
  background: #a5b5a0;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: #eceee9;
  color: #444;
}

.btn-secondary:hover {
  background: #e0e2dc;
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* --- Tarjetas de estadísticas --- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

.stat-card .stat-icon {
  font-size: 1.3rem;
  opacity: 0.9;
  transition: transform 0.25s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.15) rotate(-4deg);
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  opacity: 0.9;
}

.stat-card--green { background: linear-gradient(135deg, #2e7d32, #43a047); }
.stat-card--amber { background: linear-gradient(135deg, #d9962c, #e6a23c); }
.stat-card--teal  { background: linear-gradient(135deg, #12786f, #26a69a); }
.stat-card--red   { background: linear-gradient(135deg, #c0392b, #e05a4a); }

/* --- Panel oscuro (gráfica) --- */

.panel-dark {
  background: #1f2a19;
  color: #f1f3ee;
  border-radius: 14px;
  padding: 1.5rem 1.6rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}

.panel-dark:hover {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.panel-dark h3 {
  margin: 0 0 1.2rem;
  font-size: 1rem;
  font-weight: 600;
}

.panel-empty {
  color: #a9b6a0;
  font-size: 0.9rem;
  margin: 0;
}

/* --- Tablas de datos --- */

.data-table-wrap {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
}

/* Redondeamos las esquinas de las celdas de punta en vez de recortar
   el contenedor con overflow:hidden, porque eso también recortaba
   (invisible) el menú desplegable de acciones al abrirse. */
.data-table thead tr:first-child th:first-child { border-top-left-radius: 14px; }
.data-table thead tr:first-child th:last-child { border-top-right-radius: 14px; }
.data-table tbody tr:last-child td:first-child { border-bottom-left-radius: 14px; }
.data-table tbody tr:last-child td:last-child { border-bottom-right-radius: 14px; }

.data-table th {
  background: #eef1ea;
  color: #6b7280;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.9rem 1.1rem;
  text-align: left;
}

.data-table td {
  padding: 1rem 1.1rem;
  border-top: 1px solid #eceee9;
  font-size: 0.95rem;
  color: #2b2f28;
  box-shadow: inset 0 0 0 rgba(46, 125, 50, 0);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.data-table td:first-child {
  transition: background 0.15s ease, box-shadow 0.15s ease, padding-left 0.15s ease;
}

.data-table tbody tr:hover td {
  background: #fafbf8;
}

.data-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 #2e7d32;
  padding-left: 1.4rem;
}

.data-table-empty {
  text-align: center;
  color: #8a9184;
  padding: 2rem 1rem !important;
}

.data-table-link a {
  color: #2e7d32;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.data-table-link a:hover {
  text-decoration: underline;
}

/* --- Badges de estado --- */

.badge {
  display: inline-block;
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge--warning { background: #fdf1dc; color: #b7791f; }
.badge--success { background: #e6f4ea; color: #2e7d32; }
.badge--danger  { background: #fdeceb; color: #c0392b; }
.badge--neutral { background: #ececec; color: #6b7280; }

/* --- Menú de acciones por fila --- */

.row-actions {
  position: relative;
  text-align: right;
  width: 2.5rem;
}

.menu-trigger {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: #6b7280;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s ease, transform 0.15s ease;
}

.menu-trigger:hover {
  background: #eceee9;
  transform: scale(1.1);
}

.menu-dropdown {
  display: none;
  position: absolute;
  right: 0.5rem;
  top: 100%;
  background: #20261b;
  border-radius: 10px;
  padding: 0.4rem;
  min-width: 160px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  z-index: 10;
  text-align: left;
}

.row-actions.open .menu-dropdown {
  display: block;
  animation: menu-drop-in 0.15s ease both;
}

@keyframes menu-drop-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-dropdown a,
.menu-dropdown .menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  color: #e5e5e5;
  text-decoration: none;
  font-size: 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s ease, transform 0.15s ease;
}

.menu-dropdown a:hover,
.menu-dropdown .menu-item:hover {
  transform: translateX(2px);
}

.menu-dropdown a:hover,
.menu-dropdown .menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu-dropdown a.danger,
.menu-dropdown .menu-item.danger {
  color: #ff6b6b;
}

.menu-dropdown form {
  margin: 0;
}

/* --- Modal --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 12, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: 16px;
  padding: 1.8rem;
  width: 100%;
  max-width: 380px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: modal-in 0.2s ease both;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-box--wide {
  max-width: 460px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-group-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #1b2e14;
}

.checklist {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #d7dcd6;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: #333;
  cursor: pointer;
}

.checklist-item input {
  width: auto;
  margin: 0;
}

.modal-box h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.2rem;
  color: #1b2e14;
  font-size: 1.05rem;
}

.modal-box form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.modal-box input {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #d7dcd6;
  font-family: inherit;
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

/* --- Vinculación de sensores --- */

.section-title {
  margin: 1.8rem 0 0.9rem;
  font-size: 1.05rem;
  color: #1b2e14;
}

.token-banner {
  background: #1f2a19;
  color: #f1f3ee;
  border-radius: 14px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.token-banner-head {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.token-banner-head i {
  font-size: 1.4rem;
  color: #8bc34a;
  margin-top: 0.15rem;
}

.token-banner-head p {
  margin: 0.2rem 0 0;
  color: #b7c2ae;
  font-size: 0.85rem;
}

.token-value {
  display: block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  word-break: break-all;
  color: #ffffff;
  margin-bottom: 0.9rem;
}

.token-hint {
  margin: 0;
  font-size: 0.82rem;
  color: #b7c2ae;
  line-height: 1.6;
}

.token-hint code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: #d7e4cd;
}

.modal-hint {
  margin: 0;
  font-size: 0.82rem;
  color: #6b7280;
}

/* Campo de formulario con etiqueta visible arriba y ayuda opcional abajo */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #1b2e14;
}

.form-field-hint {
  margin: 0;
  font-size: 0.76rem;
  color: #6b7280;
  line-height: 1.4;
}

.modal-box select {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #d7dcd6;
  font-family: inherit;
  font-size: 0.9rem;
  background: white;
  color: #333;
}

.modal-box input:focus,
.modal-box select:focus {
  outline: none;
  border-color: #2e7d32;
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12);
}

.link-danger {
  background: none;
  border: none;
  color: #c0392b;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* --- Configuración --- */

.config-panel {
  padding: 0.5rem 0;
}

.config-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-top: 1px solid #eceee9;
  transition: background 0.15s ease;
}

.config-row:first-child {
  border-top: none;
}

.config-row:hover {
  background: #fafbf8;
}

.config-row i {
  font-size: 1.3rem;
  color: #2e7d32;
  transition: transform 0.2s ease;
}

.config-row:hover i {
  transform: scale(1.15);
}

.config-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a9184;
}

.config-value {
  font-size: 1rem;
  color: #2b2f28;
  font-weight: 600;
}

.config-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
  margin-top: 1.8rem;
  align-items: start;
}

.config-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 1.5rem 1.6rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.config-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.config-card .section-title {
  margin: 0 0 1.1rem;
}

.modal-actions--start {
  justify-content: flex-start;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 0.5rem;
}

.profile-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e5e7eb;
  transition: transform 0.2s ease;
}

.profile-avatar-preview:hover {
  transform: scale(1.05);
}

.profile-avatar-fallback {
  font-size: 72px;
  line-height: 1;
  color: #c3cbc0;
}

.profile-avatar-btn {
  display: inline-flex;
  cursor: pointer;
  margin-bottom: 0.4rem;
}

.profile-form input[type="email"],
.profile-form input[type="password"],
.profile-form input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #d7dcd6;
  font-family: inherit;
  font-size: 0.9rem;
  background: #fafbfa;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.profile-form input:focus {
  outline: none;
  border-color: #2e7d32;
  background: white;
}

/* --- Lecturas en vivo --- */

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.live-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #43a047;
  box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.6);
  animation: live-pulse 1.8s ease-out infinite;
}

.live-dot--pausado {
  background: #9ca3af;
  animation: none;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(67, 160, 71, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67, 160, 71, 0); }
}

.live-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.live-grid .panel-dark {
  display: flex;
  flex-direction: column;
}

.live-chart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 200px;
  text-align: center;
}

.live-chart-empty i {
  font-size: 2rem;
  color: #8bc34a;
  opacity: 0.7;
}

.live-chart-wrap {
  position: relative;
  height: 300px;
}

.live-alerts {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 1.3rem 1.3rem 0.6rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.live-alerts h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  font-size: 1rem;
  color: #1b2e14;
}

.live-alerts h3 i {
  color: #e6a23c;
}

.live-alerts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: 330px;
}

.live-alerts-list li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.65rem 0;
  border-top: 1px solid #eceee9;
}

.live-alerts-list li:first-child {
  border-top: none;
  padding-top: 0;
}

.live-alerts-list .live-alerts-empty {
  color: #8a9184;
  font-size: 0.88rem;
}

.live-alert-meta {
  font-size: 0.84rem;
  color: #2b2f28;
}

.live-alert-meta span {
  display: block;
  color: #8a9184;
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.cell-sub {
  font-size: 0.78rem;
  color: #8a9184;
  margin-top: 0.15rem;
}

.valor {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
}

.valor--ok { background: #e6f4ea; color: #2e7d32; }
.valor--alerta { background: #fdeceb; color: #c0392b; }

.live-legend {
  margin: 0.8rem 0 0;
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.9;
}

@media (max-width: 1100px) {
  .live-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Inventario de cultivos --- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.filter-bar .form-field {
  min-width: 180px;
}

.filter-clear {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2e7d32;
  text-decoration: none;
}

.filter-clear:hover {
  text-decoration: underline;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.form-row .form-field {
  min-width: 0;
}

.form-row input,
.form-row select {
  width: 100%;
}

@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.modal-box textarea {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #d7dcd6;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.modal-box textarea:focus {
  outline: none;
  border-color: #2e7d32;
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12);
}

.badge--info { background: #e0f2f1; color: #12786f; }

.cell-sub--alerta {
  color: #c0392b;
  font-weight: 600;
}

.stat-card--olive { background: linear-gradient(135deg, #558b2f, #7cb342); }

.stat-card--link {
  text-decoration: none;
}

/* --- Programación de riego --- */

.stat-card--blue { background: linear-gradient(135deg, #1565c0, #42a5f5); }

.section-title--first {
  margin-top: 0;
}

.text-alerta {
  color: #c0392b;
}

.riego-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.riego-card {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.riego-card--activo {
  border-color: #42a5f5;
  box-shadow: 0 4px 16px rgba(21, 101, 192, 0.15);
}

.riego-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}

.riego-estado {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #ececec;
  color: #6b7280;
  white-space: nowrap;
}

.riego-estado--activo {
  background: #e3f2fd;
  color: #1565c0;
}

.riego-estado--activo i {
  animation: riego-gota 1.4s ease-in-out infinite;
}

@keyframes riego-gota {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(2px); opacity: 0.6; }
}

.riego-dato {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.86rem;
  color: #6b7280;
}

.riego-dato strong {
  color: #2b2f28;
  text-align: right;
}

.riego-dato strong.text-alerta {
  color: #c0392b;
}

.riego-dato small {
  color: #8a9184;
  font-weight: 400;
  margin-left: 0.2rem;
}

.riego-accion {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.riego-minutos {
  width: 72px;
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #d7dcd6;
  font-family: inherit;
  font-size: 0.9rem;
}

.riego-min-label {
  font-size: 0.85rem;
  color: #6b7280;
  margin-right: auto;
}

.riego-accion .btn-secondary {
  width: 100%;
  justify-content: center;
}

.btn-danger-soft {
  color: #c0392b;
}

.riego-switch {
  border-top: 1px solid #eceee9;
  padding-top: 0.7rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1b2e14;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #cfd5cc;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: #2e7d32;
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.25);
}

.riego-switch .form-field-hint {
  margin-top: 0.3rem;
}

.riego-proxima {
  font-size: 0.82rem;
  color: #6b7280;
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.riego-proxima strong {
  color: #2b2f28;
}

.dias-chips {
  display: flex;
  gap: 0.2rem;
}

.dia-chip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  background: #f0f2ee;
  color: #b0b6ab;
}

.dia-chip--on {
  background: #e6f4ea;
  color: #2e7d32;
}

.dias-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.dia-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.dia-toggle span {
  display: inline-block;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #d7dcd6;
  font-size: 0.82rem;
  color: #4b5563;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.dia-toggle input:checked + span {
  background: #2e7d32;
  border-color: #2e7d32;
  color: #ffffff;
}

.dia-toggle input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.25);
}

.dias-atajos {
  display: flex;
  gap: 0.9rem;
  margin-top: 0.15rem;
}

.link-atajo {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: #2e7d32;
  cursor: pointer;
}

.link-atajo:hover {
  text-decoration: underline;
}

/* --- Alertas --- */

.menu-badge {
  margin-left: auto;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e6a23c;
  color: #1f2a19;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-badge--alta {
  background: #e05a4a;
  color: #ffffff;
}

.sev {
  display: inline-block;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sev--alta { background: #fdeceb; color: #c0392b; box-shadow: inset 3px 0 0 #c0392b; }
.sev--media { background: #fdf1dc; color: #b7791f; box-shadow: inset 3px 0 0 #e6a23c; }
.sev--info { background: #e3f2fd; color: #1565c0; box-shadow: inset 3px 0 0 #42a5f5; }

.fila-apagada td {
  opacity: 0.6;
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.stat-desglose {
  display: flex;
  gap: 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.1rem;
}

.sev-punto--alta { color: #ffd2cc; }
.sev-punto--media { color: #fff3c4; }
.sev-punto--info { color: #d6ecff; }

/* --- Clima (dashboard) --- */

.clima-panel {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.5rem;
}

.clima-panel h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  font-size: 1rem;
  color: #1b2e14;
}

.clima-panel h3 i { color: #e6a23c; }

.clima-cuerpo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
}

.clima-ahora {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 230px;
}

.clima-icono {
  font-size: 2.6rem;
  color: #e6a23c;
}

.clima-temp {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1b2e14;
  line-height: 1;
}

.clima-cond {
  font-size: 0.9rem;
  color: #4b5563;
  margin: 0.2rem 0;
}

.clima-pronostico {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

.clima-hora {
  flex: 1;
  min-width: 70px;
  background: #f4f6f2;
  border-radius: 10px;
  padding: 0.55rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: #6b7280;
}

.clima-hora i { font-size: 1.2rem; color: #2e7d32; }
.clima-hora strong { color: #1b2e14; font-size: 0.95rem; }
.clima-hora small { color: #1565c0; font-weight: 600; }

.clima-hora--evento {
  background: #fdf1dc;
}

.clima-nota {
  margin: 0.9rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  color: #4b5563;
}

.panel-empty-claro {
  margin: 0;
  color: #8a9184;
  font-size: 0.9rem;
}

/* --- Respaldos --- */

.stat-card--slate { background: linear-gradient(135deg, #37474f, #607d8b); }

.stat-value--texto {
  font-size: 1.05rem;
}

.aviso-seguridad {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  background: #fdf8ec;
  border: 1px solid #f1dfb4;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.2rem;
  font-size: 0.85rem;
  color: #6b5320;
}

.aviso-seguridad i {
  font-size: 1.3rem;
  color: #b7791f;
}

.aviso-seguridad p {
  margin: 0;
  line-height: 1.5;
}

.nombre-respaldo {
  font-size: 0.82rem;
  background: #f4f6f2;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  color: #2b2f28;
  white-space: nowrap;
}

.acciones-respaldo {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.acciones-respaldo form {
  margin: 0;
}

.acciones-respaldo a {
  text-decoration: none;
}

.exportar-panel {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 1.1rem 1.3rem 0.9rem;
}

.exportar-panel .filter-bar {
  margin-bottom: 0.6rem;
}

.btn-peligro {
  background: #c0392b;
}

.btn-peligro:hover:not(:disabled) {
  background: #a93226;
}

/* --- Accesibilidad: respeta la preferencia de movimiento reducido --- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- Mostrar u ocultar contraseña (public/js/ver-password.js) --- */
/* Selectores con .password-campo para ganarle a .auth-card button y .input-icon-group i */

.password-campo {
  position: relative;
  display: block;
  flex: 1;
  width: 100%;
}

.password-campo input {
  padding-right: 2.8rem !important;
}

.password-campo button.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  width: auto;
  margin: 0;
  padding: 0.35rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  box-shadow: none;
  color: #6b7280;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.password-campo button.password-toggle:hover,
.password-campo button.password-toggle:focus-visible {
  background: #eef2ed;
  color: #2e7d32;
  transform: translateY(-50%);
  box-shadow: none;
  outline: none;
}

.password-campo .password-toggle i {
  position: static;
  color: inherit;
  pointer-events: none;
}
