/**
 * Agricultura Verde - Estilos principales
 * CSS responsive sin frameworks
 */

/* ================================
   Variables y Reset
   ================================ */
:root {
    --primary: #27ae60;
    --primary-dark: #1e8449;
    --primary-light: #58d68d;
    --secondary: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;

    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;

    --white: #ffffff;
    --black: #000000;

    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-size-base: 16px;
    --line-height: 1.5;

    --border-radius: 12px;
    --border-radius-lg: 16px;
    --border-radius-sm: 6px;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 280px;
    --header-height: 70px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    line-height: var(--line-height);
    color: var(--gray-800);
    background: var(--gray-100);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ================================
   Layout Principal
   ================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-logo i {
    font-size: 1.5rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.nav-item:hover,
.nav-item.active {
    background: var(--gray-100);
    color: var(--primary);
    padding-left: 2rem;
}

.nav-item.active {
    border-right: 3px solid var(--primary);
    font-weight: 600;
}

.nav-section {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 0.5px;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.main-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 2rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
}

.breadcrumb {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin: 0 0 1rem;
}

.breadcrumb ul {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.breadcrumb li {
    margin: 0;
    padding: 0;
}

.breadcrumb li+li::before {
    content: "›";
    color: var(--gray-400);
    margin-right: 0.5rem;
}

.breadcrumb a {
    color: var(--gray-600);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.breadcrumb li.active {
    color: var(--gray-900);
    font-weight: 600;
}

.breadcrumb-separator {
    color: var(--gray-400);
}

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

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    line-height: 1.2;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-600);
}

.main-body {
    padding: 2rem;
}

/* Extras del dashboard (header/sidebar/footer) */
.sidebar-logo img {
    width: 32px;
    height: 32px;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius);
}

.sidebar-close:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.user-plan {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.plan-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--gray-200);
    color: var(--gray-700);
}

.plan-badge.plan-pro {
    background: var(--primary);
    color: var(--white);
}

.plan-badge.plan-admin {
    background: var(--gray-800);
    color: var(--white);
}

.topbar-search form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-search .form-control {
    width: 280px;
}

.dropdown-toggle {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-700);
    padding: 0.5rem;
    border-radius: var(--border-radius);
}

.dropdown-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.dropdown-toggle:active {
    transform: translateY(1px);
}

.notification-badge {
    position: absolute;
    top: 0.15rem;
    right: 0.15rem;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: var(--white);
    font-size: 0.6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.dropdown-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.dropdown-header a {
    font-size: 0.8125rem;
    color: var(--primary);
}

.notifications-list {
    padding: 0.5rem 0;
}

.no-notifications {
    margin: 0;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.dashboard-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 1rem 2rem;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.modal-backdrop {
    display: none;
}

.modal-sm {
    max-width: 420px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.loading-spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    color: var(--gray-700);
}

/* ================================
   Componentes: Botones
   ================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-600);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

/* ================================
   Componentes: Cards
   ================================ */
.card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.card-header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--gray-800);
}

.card-body {
    padding: 2rem;
}

.card-danger {
    border: 1px solid var(--danger);
}

.card-danger .card-header {
    background: #fdf2f2;
    color: var(--danger);
}

/* ================================
   Componentes: Formularios
   ================================ */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15);
}

.form-control::placeholder {
    color: var(--gray-400);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

.col-md-2 {
    flex: 0 0 16.666%;
    max-width: 16.666%;
    min-width: auto;
}

.col-md-4 {
    flex: 0 0 33.333%;
    max-width: 33.333%;
    min-width: auto;
}

.col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
    min-width: auto;
}

.col-md-8 {
    flex: 0 0 66.666%;
    max-width: 66.666%;
    min-width: auto;
}

.col-md-10 {
    flex: 0 0 83.333%;
    max-width: 83.333%;
    min-width: auto;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
    margin-top: 1.5rem;
}

.form-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--gray-100);
    border-radius: var(--border-radius);
}

.form-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--gray-700);
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ================================
   Componentes: Alertas
   ================================ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ================================
   Componentes: Tablas
   ================================ */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--gray-100);
}

.table-compact th,
.table-compact td {
    padding: 0.625rem 0.75rem;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* ================================
   Componentes: Badges
   ================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50px;
}

.badge-primary {
    background: var(--primary);
    color: var(--white);
}

.badge-secondary {
    background: var(--gray-500);
    color: var(--white);
}

.badge-success {
    background: var(--success);
    color: var(--white);
}

.badge-warning {
    background: var(--warning);
    color: var(--white);
}

.badge-danger {
    background: var(--danger);
    color: var(--white);
}

/* ================================
   Componentes: Stats
   ================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2rem;
    margin-bottom: 2.5rem;
}

/* ================================
   Componentes: Dashboard Grid
   ================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    align-items: start;
}

.dashboard-main {
    min-width: 0;
    /* Prevent grid blowout */
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--white);
}

.stat-icon.bg-green {
    background: var(--success);
}

.stat-icon.bg-blue {
    background: var(--secondary);
}

.stat-icon.bg-orange {
    background: var(--warning);
}

.stat-icon.bg-purple {
    background: #9b59b6;
}

.stat-content {
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.stat-detail {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ================================
   Componentes: Grid Layout
   ================================ */
.grid {
    display: grid;
    gap: 2rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ================================
   Componentes: Empty State
   ================================ */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-large {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.empty-state-large .empty-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--gray-400);
}

.empty-state-large h2 {
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state-large p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* ================================
   Page Header
   ================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-header p {
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
}

/* ================================
   Progress Bar
   ================================ */
.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 50px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 50px;
    transition: width 0.5s ease;
}

.progress-fill.bg-gradient {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.progress-bar-lg {
    height: 12px;
}

.progress-bar-sm {
    height: 4px;
}

.progress-section {
    margin: 1rem 0;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.progress-title {
    font-weight: 500;
}

.progress-value {
    font-weight: 600;
    color: var(--primary);
}

/* ================================
   Filters Bar
   ================================ */
.filters-bar {
    background: var(--white);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.filters-form {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.875rem;
    color: var(--gray-600);
    white-space: nowrap;
}

.filter-group .form-control {
    min-width: 180px;
}

/* ================================
   Status Badges
   ================================ */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50px;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-progress {
    background: #d1ecf1;
    color: #0c5460;
}

.status-done {
    background: #d4edda;
    color: #155724;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

/* ================================
   Dropdown
   ================================ */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 0.5rem 0;
    z-index: 1000;
    display: none;
}

.dropdown:hover .dropdown-menu,
.dropdown.show .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--gray-700);
    font-size: 0.875rem;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 0.5rem 0;
}

.dropdown-form {
    margin: 0;
}

/* ================================
   Modal
   ================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ================================
   Tareas
   ================================ */
.tareas-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tarea-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.tarea-item:hover {
    background: var(--gray-200);
}

.tarea-item.estado-completada {
    opacity: 0.7;
}

.tarea-item.estado-completada .tarea-content h4 {
    text-decoration: line-through;
}

.tarea-checkbox input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.tarea-content {
    flex: 1;
}

.tarea-content h4 {
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.tarea-content h4 a {
    color: var(--gray-800);
}

.tarea-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.tarea-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.tarea-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--gray-300);
}

.tarea-card.estado-pendiente {
    border-left-color: var(--warning);
}

.tarea-card.estado-en_curso {
    border-left-color: var(--info);
}

.tarea-card.estado-completada {
    border-left-color: var(--success);
    opacity: 0.8;
}

.tarea-card-icon {
    font-size: 1.5rem;
}

.tarea-card-content {
    flex: 1;
}

.tarea-card-content h4 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.tarea-card-content h4 a {
    color: var(--gray-800);
}

.tarea-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ================================
   Productos Repeater
   ================================ */
.producto-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding: 1rem;
    background: var(--white);
    border-radius: var(--border-radius);
}

.producto-fields {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    flex-wrap: wrap;
}

.producto-fields input {
    flex: 1;
    min-width: 120px;
}

.producto-fields input:first-child {
    flex: 2;
}

/* ================================
   Actividades Grid
   ================================ */
.actividades-predefinidas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.actividad-predefinida-option {
    cursor: pointer;
}

.actividad-predefinida-option input {
    display: none;
}

.actividad-predefinida-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    transition: var(--transition);
    text-align: center;
}

.actividad-predefinida-option input:checked+.actividad-predefinida-card {
    border-color: var(--primary);
    background: rgba(39, 174, 96, 0.05);
}

.actividad-predefinida-card:hover {
    border-color: var(--primary-light);
}

.ap-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.ap-nombre {
    font-weight: 600;
    font-size: 0.875rem;
}

.ap-desc {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* ================================
   Tipo Selector
   ================================ */
.tipo-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tipo-option {
    flex: 1;
    cursor: pointer;
}

.tipo-option input {
    display: none;
}

.tipo-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    transition: var(--transition);
    text-align: center;
}

.tipo-option input:checked+.tipo-card {
    border-color: var(--primary);
    background: rgba(39, 174, 96, 0.05);
}

.tipo-card i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.tipo-card strong {
    display: block;
    margin-bottom: 0.25rem;
}

.tipo-card small {
    color: var(--gray-500);
}

/* ================================
   Admin Quick Actions
   ================================ */
.admin-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.quick-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    text-align: center;
    color: var(--gray-700);
}

.quick-action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    color: var(--primary);
}

.quick-action-card i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

/* ================================
   Activity Log
   ================================ */
.activity-log {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.activity-content {
    flex: 1;
    font-size: 0.875rem;
}

.activity-content strong {
    color: var(--gray-800);
}

.activity-content small {
    color: var(--gray-500);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ================================
   Sugerencias IA
   ================================ */
.sugerencias-container {
    margin-bottom: 2rem;
}

.sugerencias-container h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sugerencias-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sugerencia-card {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--gray-300);
}

.sugerencia-card.tipo-alerta {
    border-left-color: var(--warning);
    background: #fffcf0;
}

.sugerencia-card.tipo-sugerencia {
    border-left-color: var(--info);
}

.sugerencia-card.tipo-info {
    border-left-color: var(--gray-400);
}

.sugerencia-card.tipo-exito {
    border-left-color: var(--success);
    background: #f0fff4;
}

.sugerencia-icon {
    font-size: 1.5rem;
}

.sugerencia-content {
    flex: 1;
}

.sugerencia-content h4 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.sugerencia-content p {
    color: var(--gray-600);
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
}

/* ================================
   Public Pages
   ================================ */
.public-header {
    background: var(--white);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.public-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.public-body {
    padding-top: 80px;
}

.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 6rem 2rem;
    text-align: center;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    padding: 4rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.feature-card {
    text-align: center;
    padding: 2rem;
}

.feature-card i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--gray-600);
}

.public-footer {
    background: var(--gray-800);
    color: var(--white);
    padding: 3rem 2rem;
    text-align: center;
}

/* ================================
   Auth Pages
   ================================ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4rem;
    flex-wrap: wrap;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.auth-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    position: relative;
    z-index: 1;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--gray-500);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* Auth form (inputs con iconos) */
.auth-form {
    width: 100%;
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
    width: 100%;
    padding: 0.75rem 0.875rem;
    font-size: 0.95rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    background: var(--white);
    transition: var(--transition);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15);
}

.input-icon {
    position: relative;
    width: 100%;
}

.input-icon>i:first-child {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    pointer-events: none;
}

.input-icon input {
    padding-left: 3.8rem;
    padding-right: 2.6rem;
}

.toggle-password {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0.4rem;
}

.toggle-password:hover {
    color: var(--primary);
}

.form-options {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray-700);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.forgot-link {
    color: var(--primary);
    font-weight: 500;
    white-space: nowrap;
}

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

/* Auth side panel (lista de beneficios) */
.auth-side {
    width: 100%;
    max-width: 520px;
    color: var(--white);
    padding: 2rem;
}

.auth-side-content h2 {
    font-size: 1.75rem;
    line-height: 1.2;
    margin-bottom: 1.25rem;
    color: var(--white);
}

.features-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.features-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.features-list li:last-child {
    border-bottom: 0;
}

.features-list li i {
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

@media (max-width: 992px) {
    .auth-container {
        gap: 2rem;
        justify-content: center;
    }

    .auth-side {
        display: none;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 1.75rem;
    }

    .form-options {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ================================
   Upgrade Prompt
   ================================ */
.upgrade-prompt {
    max-width: 500px;
    margin: 4rem auto;
    text-align: center;
    padding: 3rem;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
}

.upgrade-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--white);
}

.upgrade-prompt h2 {
    margin-bottom: 0.5rem;
}

.upgrade-prompt p {
    color: var(--gray-600);
    margin-bottom: 1.5rem;
}

.feature-list {
    list-style: none;
    text-align: left;
    margin-bottom: 2rem;
}

.feature-list li {
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feature-list li i {
    color: var(--success);
}

/* ================================
   Info Card
   ================================ */
.info-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: #e8f4fd;
    border-radius: var(--border-radius);
    color: #1a5276;
    margin-bottom: 1.5rem;
}

.info-card i {
    font-size: 1.25rem;
}

/* ================================
   Charts
   ================================ */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.bg-warning {
    background: var(--warning);
}

.bg-info {
    background: var(--info);
}

.bg-success {
    background: var(--success);
}

/* ================================
   Ranking
   ================================ */
.ranking-list {
    display: flex;
    flex-direction: column;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.ranking-pos {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.ranking-item:first-child .ranking-pos {
    background: #ffd700;
    color: #8b6914;
}

.ranking-icon {
    font-size: 1.25rem;
}

.ranking-name {
    flex: 1;
}

.ranking-value {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* ================================
   User Cell (Admin)
   ================================ */
.user-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.row-disabled {
    opacity: 0.5;
}

/* ================================
   Utilities
   ================================ */
.text-muted {
    color: var(--gray-500);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

.text-info {
    color: var(--info);
}

.text-xl {
    font-size: 1.5rem;
}

.emoji-input {
    font-size: 1.5rem;
}

/* ================================
   Module: Parcelas
   ================================ */
.parcelas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.parcela-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.parcela-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-4px);
}

.parcela-card-header {
    padding: 1.25rem 1.5rem;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.parcela-card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

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

.parcela-details {
    list-style: none;
    margin: 0 0 1.5rem 0;
    padding: 0;
}

.parcela-details li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    color: var(--gray-700);
    font-size: 0.95rem;
}

.parcela-details li i {
    color: var(--primary);
    width: 20px;
    text-align: center;
}

.parcela-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: #e8f5e9;
    color: #27ae60;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tag-more {
    background: var(--gray-200);
    color: var(--gray-600);
}

.parcela-card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: var(--white);
}

.parcela-card-add {
    border: 2px dashed var(--gray-300);
    background: transparent;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    min-height: 300px;
    text-align: center;
    color: var(--gray-500);
    text-decoration: none;
    box-shadow: none;
}

.parcela-card-add:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(39, 174, 96, 0.05);
    transform: translateY(-2px);
    box-shadow: none;
}

.add-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ================================
   Module: Campañas
   ================================ */
.campanas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.campana-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.campana-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-4px);
}

.campana-card-header {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(to right, var(--gray-800), #2c3e50);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.campana-year-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.campana-year-badge .year {
    font-size: 1.25rem;
    font-weight: 700;
}

.campana-parcela {
    font-size: 0.875rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.campana-nombre {
    margin: 0 0 1.5rem 0;
    font-size: 1.1rem;
}

.campana-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    background: var(--gray-100);
    padding: 1rem;
    border-radius: var(--border-radius);
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
}

.campana-card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ================================
   Module: Actividades
   ================================ */
.actividades-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.group-header {
    grid-column: 1 / -1;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-200);
    color: var(--gray-700);
}

.group-header h3 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.year-badge {
    background: var(--gray-200);
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.8rem;
    color: var(--gray-700);
}

.actividad-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.actividad-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-3px);
}

.actividad-card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.actividad-card-content h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.actividad-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.actividad-card-actions {
    margin-top: auto;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ================================
   Module: Tareas List Full
   ================================ */
.tareas-list-full {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stats-mini {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.stat-mini {
    flex: 1;
    background: var(--white);
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    transition: var(--transition);
    border: 1px solid transparent;
}

.stat-mini:hover,
.stat-mini.active {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.stat-mini-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-mini-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* ================================
   Estilos Formulario Productos (Base)
   ================================ */
.producto-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.producto-fields {
    display: flex;
    flex: 1;
    gap: 0.5rem;
}

.producto-fields input {
    width: 100%;
}

.producto-row .btn-danger {
    margin-top: 0;
}

/* ================================
   Responsive - Modules
   ================================ */
@media (max-width: 768px) {

    .parcelas-grid,
    .campanas-grid,
    .actividades-grid {
        grid-template-columns: 1fr;
    }

    .parcela-card-footer,
    .campana-card-footer {
        flex-direction: column;
    }

    .parcela-card-footer .btn,
    .campana-card-footer .btn {
        width: 100%;
    }
}

@media (max-width: 1024px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .app-layout {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Ocultar nombre de usuario en móvil para evitar desbordamiento */
    .user-name,
    .user-role,
    .user-avatar+.fa-chevron-down {
        display: none;
    }

    .user-menu {
        padding: 0.5rem;
    }

    .main-content {
        flex: 1;
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .main-body {
        padding: 0.5rem;
        /* Reducir padding en móvil para ganar espacio */
    }

    /* Arreglo Buscador Header */
    .header-left {
        flex: 1;
        /* Permitir que ocupe espacio disponible */
        min-width: 0;
        /* Permitir shrink */
    }

    .topbar-search {
        flex: 1;
        margin-left: 0.5rem;
    }

    .topbar-search .form-control {
        width: 100%;
        min-width: 80px;
        /* Ancho mínimo usable */
    }

    .dashboard-footer {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
    }

    .page-header-actions {
        width: 100%;
    }

    .page-header-actions .btn {
        width: 100%;
    }

    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group .form-control {
        min-width: 100%;
    }

    .form-row {
        flex-direction: column;
    }

    .col-md-2,
    .col-md-4,
    .col-md-6,
    .col-md-8,
    .col-md-10 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .card-body {
        padding: 1.25rem;
    }

    .nav-item:hover,
    .nav-item.active {
        padding-left: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tipo-selector {
        flex-direction: column;
    }

    /* Arreglo Formulario Productos en Móvil */
    .producto-row {
        flex-direction: column;
        background: var(--gray-100);
        padding: 1rem;
        border-radius: var(--border-radius);
        margin-bottom: 1rem;
        gap: 0.75rem;
    }

    .producto-fields {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .producto-fields input {
        min-width: 100%;
        margin-bottom: 0;
        /* Controlado por gap */
    }

    .producto-row .btn-danger {
        width: 100%;
        /* Botón eliminar ancho completo para fácil pulsación */
        margin-top: 0.25rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero p {
        font-size: 1rem;
    }
}

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

    .btn {
        width: 100%;
    }

    .btn-group {
        flex-direction: column;
    }

    .tarea-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .tarea-card-meta {
        flex-wrap: wrap;
    }
}

/* ================================
   Dashboard Mejorado - Nuevos Estilos
   ================================ */

/* Panel de Alertas */
.alerts-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    background: var(--white);
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
}

.alert-item.alert-warning {
    border-left-color: var(--warning);
    background: #fffbf0;
}

.alert-item.alert-warning i {
    color: var(--warning);
}

.alert-item.alert-info {
    border-left-color: var(--info);
    background: #f0f9ff;
}

.alert-item.alert-info i {
    color: var(--info);
}

.alert-item.alert-danger {
    border-left-color: var(--danger);
    background: #fef2f2;
}

.alert-item.alert-danger i {
    color: var(--danger);
}

.alert-item span {
    flex: 1;
    font-size: 0.875rem;
}

.alert-action {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.alert-action:hover {
    background: var(--primary);
    color: var(--white);
}

/* KPIs Grid Mejorado */
.kpis-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.kpi-primary .kpi-icon {
    background: rgba(39, 174, 96, 0.15);
    color: var(--primary);
}

.kpi-info .kpi-icon {
    background: rgba(52, 152, 219, 0.15);
    color: var(--info);
}

.kpi-warning .kpi-icon {
    background: rgba(243, 156, 18, 0.15);
    color: var(--warning);
}

.kpi-success .kpi-icon {
    background: rgba(39, 174, 96, 0.15);
    color: var(--success);
}

.kpi-cost .kpi-icon {
    background: rgba(155, 89, 182, 0.15);
    color: #9b59b6;
}

.kpi-dark .kpi-icon {
    background: rgba(52, 73, 94, 0.15);
    color: var(--gray-700);
}

.kpi-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.8125rem;
    color: var(--gray-600);
    margin-top: 0.125rem;
}

.kpi-label small {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.kpi-detail {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* Dashboard Grid 3 columnas */
.dashboard-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.dashboard-column {
    display: flex;
    flex-direction: column;
}

/* Card destacada */
.card-highlight {
    border: 2px solid var(--primary);
    background: linear-gradient(to bottom, rgba(39, 174, 96, 0.02), var(--white));
}

.card-highlight .card-header {
    border-bottom-color: rgba(39, 174, 96, 0.2);
}

/* Timeline de tareas */
.tasks-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--gray-200);
    transition: var(--transition);
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-item:hover {
    background: var(--gray-100);
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: var(--border-radius);
}

.timeline-item.active {
    background: rgba(52, 152, 219, 0.08);
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: var(--border-radius);
}

.timeline-item.overdue {
    background: rgba(231, 76, 60, 0.06);
}

.timeline-marker {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--gray-600);
    flex-shrink: 0;
}

.timeline-item.active .timeline-marker {
    background: var(--info);
    color: var(--white);
}

.timeline-item.overdue .timeline-marker {
    background: var(--danger);
    color: var(--white);
}

.timeline-content {
    flex: 1;
    min-width: 0;
}

.timeline-content h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-content .task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.timeline-content .task-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.task-date.overdue {
    color: var(--danger);
    font-weight: 600;
}

.timeline-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    transition: var(--transition);
}

.timeline-action:hover {
    background: var(--primary);
    color: var(--white);
}

/* Ranking List (Top actividades) */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.ranking-item:hover {
    background: var(--gray-200);
}

.ranking-position {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gray-300);
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.ranking-item:first-child .ranking-position {
    background: linear-gradient(135deg, #ffd700, #ffb347);
    color: var(--white);
}

.ranking-item:nth-child(2) .ranking-position {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
    color: var(--white);
}

.ranking-item:nth-child(3) .ranking-position {
    background: linear-gradient(135deg, #cd7f32, #b87333);
    color: var(--white);
}

.ranking-icon {
    font-size: 1.25rem;
}

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-info strong {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-800);
}

.ranking-info small {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.ranking-value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
}

/* Cost Bars */
.cost-bars {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.cost-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cost-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cost-bar-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
}

.cost-bar-value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
}

.cost-bar-track {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.cost-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.cost-bar-detail {
    color: var(--gray-500);
    font-size: 0.75rem;
}

/* Recent List */
.recent-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recent-list li {
    border-bottom: 1px solid var(--gray-200);
}

.recent-list li:last-child {
    border-bottom: none;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
}

.recent-info strong {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-800);
}

.recent-info small {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.recent-cost {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--success);
    background: rgba(39, 174, 96, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
}

/* Responsive para dashboard mejorado */
@media (max-width: 1400px) {
    .kpis-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .dashboard-grid-3 {
        grid-template-columns: 1fr 1fr;
    }

    .dashboard-sidebar {
        grid-column: span 2;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    .dashboard-sidebar .card {
        margin-bottom: 0;
    }
}

@media (max-width: 992px) {
    .kpis-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid-3 {
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar {
        grid-column: span 1;
        display: flex;
        flex-direction: column;
    }

    .dashboard-sidebar .card {
        margin-bottom: 2rem;
    }
}

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

    .kpi-card {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.25rem;
    }

    .alerts-panel {
        gap: 0.375rem;
    }

    .alert-item {
        padding: 0.625rem 0.75rem;
    }

    .timeline-item:hover,
    .timeline-item.active {
        margin: 0 -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* =========================================================================
   CRITICAL MOBILE FIXES - ULTIMATE
   Estas reglas sobrescriben TODO lo anterior para asegurar la vista móvil.
   ========================================================================= */
@media (max-width: 900px) {

    /* 1. Resetear margen izquierdo del contenido */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding-top: 0 !important;
    }

    /* 2. Forzar layout sin desbordamiento */
    html,
    body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .app-layout {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* 3. Ajuste Header y Buscador */
    .header-left {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .topbar-search {
        display: block !important;
        flex: 1;
        min-width: 0;
    }

    .topbar-search form {
        display: flex;
        width: 100%;
        gap: 0.25rem;
    }

    .topbar-search .form-control {
        width: 100% !important;
        min-width: 0 !important;
        font-size: 0.875rem;
        padding: 0.5rem;
    }

    .topbar-search .btn {
        padding: 0.25rem 0.5rem;
    }

    .user-name,
    .user-role,
    .user-avatar+.fa-chevron-down {
        display: none !important;
    }

    .user-menu {
        padding: 0 !important;
        background: transparent !important;
    }

    .notifications {
        margin-right: 0.25rem;
    }

    /* 4. Arreglar inputs de productos */
    .producto-row {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .producto-fields {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .producto-fields input {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .dashboard-grid,
    .stats-grid,
    .kpis-grid {
        grid-template-columns: 1fr !important;
    }

    .col-md-2,
    .col-md-4,
    .col-md-6,
    .col-md-8,
    .col-md-10 {
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
}

/* =========================================================================
   IA SUGGESTIONS STYLES
   ========================================================================= */
.ai-loading-container {
    text-align: center;
    padding: 2rem;
    display: none;
}

.ai-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(39, 174, 96, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.ai-result-content {
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--gray-800);
}

.ai-result-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.btn-ai-generate {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(37, 117, 252, 0.3);
}

.btn-ai-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 117, 252, 0.4);
    color: white;
}