@font-face {
    font-family: 'Frescito';
    src: url('./assets/fonts/FrescitoBold_PERSONAL_USE_ONLY.otf') format('opentype');
    font-weight: 700;
}
@font-face {
    font-family: 'Satoshi';
    src: url('./assets/fonts/Satoshi-Regular.otf') format('opentype');
    font-weight: 400;
}
@font-face {
    font-family: 'Satoshi';
    src: url('./assets/fonts/Satoshi-Medium.otf') format('opentype');
    font-weight: 500;
}
@font-face {
    font-family: 'Satoshi';
    src: url('./assets/fonts/Satoshi-Bold.otf') format('opentype');
    font-weight: 700;
}
@font-face {
    font-family: 'Satoshi';
    src: url('./assets/fonts/Satoshi-Light.otf') format('opentype');
    font-weight: 300;
}

:root {
    --primary:      #6DB8C9;   /* --t  en metys.css  */
    --primary-dark: #4fa3b5;   /* --td en metys.css  */
    --primary-light:#e0f4f7;
    --text:         #1a1a1a;   /* --tx en metys.css  */
    --text-muted:   #6b7f7c;   /* --mu en metys.css  */
    --bg:           #f4f6f5;   /* --off en metys.css */
    --white:        #ffffff;
    --border:       #e5e9ec;
    --shadow-sm:    0 2px 8px rgba(0,0,0,.06);
    --shadow-md:    0 6px 24px rgba(0,0,0,.09);
    --shadow-lg:    0 20px 60px rgba(0,0,0,.12);
    --radius:       16px;
    --radius-sm:    10px;
    --ease:         cubic-bezier(0.16,1,0.3,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    font-family: 'Satoshi', 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── LOGIN ─────────────────────────────────────────────── */

.login-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    background: linear-gradient(160deg, #ffffff 0%, #f0f8f9 45%, #daeef1 100%);
}

.login-bg-gradient {
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 80% 20%, rgba(109,184,201,.18) 0%, transparent 70%),
        radial-gradient(ellipse 40% 40% at 10% 80%, rgba(109,184,201,.12) 0%, transparent 70%);
    pointer-events: none;
}

.login-card {
    position: relative;
    background: var(--white);
    border-radius: 24px;
    padding: 48px 40px 40px;
    width: min(440px, 92vw);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(109,184,201,.15);
    text-align: center;
    animation: loginReveal .55s var(--ease) both;
}

@keyframes loginReveal {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.login-logo {
    height: 52px;
    width: auto;
    margin-bottom: 24px;
    object-fit: contain;
}

.login-title {
    font-family: 'Frescito', sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: .95rem;
    margin-bottom: 32px;
    font-weight: 300;
}

.login-input-wrap {
    position: relative;
    margin-bottom: 14px;
}

.login-input-wrap > i {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    color: var(--primary); font-size: .95rem;
}

.login-input-wrap input {
    width: 100%;
    padding: 14px 48px 14px 42px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Satoshi', sans-serif;
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
    background: var(--white);
    color: var(--text);
    letter-spacing: .08em;
}

.login-input-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(109,184,201,.15);
}

#togglePwd {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: .9rem;
    transition: color .2s;
}
#togglePwd:hover { color: var(--primary); }

.login-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .88rem;
    text-align: left;
    margin-bottom: 14px;
    animation: shake .3s ease;
}

@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.login-btn {
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 14px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Satoshi', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .35s var(--ease), transform .35s var(--ease), box-shadow .35s var(--ease);
    box-shadow: 0 8px 28px rgba(109,184,201,.35);
    margin-top: 6px;
}

.login-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: 0 14px 40px rgba(109,184,201,.45);
}

.login-btn i { transition: transform .2s; }
.login-btn:hover i { transform: translateX(4px); }

.login-help {
    margin-top: 24px;
    font-size: .875rem;
    color: var(--text-muted);
}

.login-help a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.login-help a:hover { text-decoration: underline; }


/* ─── DASHBOARD LAYOUT ──────────────────────────────────── */

.dashboard {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.dash-topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    height: 64px;
    padding: 0 28px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.dash-topbar-left {
    display: flex; align-items: center; gap: 16px;
}

.dash-logo-link { display: flex; align-items: center; }

.dash-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.dash-divider {
    width: 1px; height: 28px;
    background: var(--border);
}

.dash-client-name {
    font-weight: 600;
    font-size: .95rem;
    color: var(--text);
}

.dash-topbar-right {
    display: flex; align-items: center; gap: 20px;
}

.dash-date {
    font-size: .875rem;
    color: var(--text-muted);
}

.dash-logout {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 16px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 50px;
    font-family: 'Satoshi', sans-serif;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s;
}

.dash-logout:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Main content */
.dash-main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Welcome bar */
.dash-welcome {
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(130deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    padding: 24px 28px;
    color: var(--white);
    box-shadow: 0 8px 32px rgba(109,184,201,.3);
}

.dash-welcome h2 {
    font-family: 'Frescito', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.dash-welcome p {
    font-size: .9rem;
    opacity: .88;
    font-weight: 300;
}

.dash-badge {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 50px;
    padding: 8px 18px;
    font-size: .875rem;
    font-weight: 600;
    white-space: nowrap;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}

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

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

.kpi-icon--blue  { background: #eff6ff; color: #3b82f6; }
.kpi-icon--teal  { background: var(--primary-light); color: var(--primary-dark); }
.kpi-icon--green { background: #f0fdf4; color: #16a34a; }
.kpi-icon--gold  { background: #fffbeb; color: #d97706; }

.kpi-data { display: flex; flex-direction: column; gap: 2px; }

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}

.kpi-label {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 16px;
}

.chart-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.chart-card--wide {
    grid-column: 1 / -1;
}

.chart-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.chart-card-header h3 {
    font-family: 'Frescito', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
}

.chart-card-header p {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 300;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.legend-item {
    display: flex; align-items: center; gap: 5px;
    font-size: .75rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

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

.chart-card--wide .chart-wrap {
    height: 280px;
}

/* Table */
.table-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.table-card-header h3 {
    font-family: 'Frescito', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 3px;
}

.table-card-header p {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 300;
}

.table-controls {
    display: flex; align-items: center; gap: 10px;
}

.dash-select {
    padding: 7px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: 'Satoshi', sans-serif;
    font-size: .875rem;
    color: var(--text);
    background: var(--white);
    cursor: pointer;
    transition: border-color .2s;
}

.dash-select:focus {
    outline: none;
    border-color: var(--primary);
}

.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.data-table thead th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.data-table tbody tr:last-child { border-bottom: none; }

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

.data-table tbody td {
    padding: 13px 16px;
    color: var(--text);
    white-space: nowrap;
}

.status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 600;
}

.status-ok      { background: #f0fdf4; color: #16a34a; }
.status-watch   { background: #fffbeb; color: #d97706; }
.status-alert   { background: #fef2f2; color: #dc2626; }

/* Recommendations */
.recom-section {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.recom-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}

.recom-card h4 {
    font-family: 'Frescito', sans-serif;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: .95rem;
}

.recom-card p {
    font-size: .855rem;
    color: var(--text-muted);
    font-weight: 300;
    line-height: 1.5;
}

/* Footer */
.dash-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    background: var(--white);
    font-size: .8rem;
    color: var(--text-muted);
}

.dash-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* ─── RESPONSIVE ────────────────────────────────────────── */

@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card--wide { grid-column: auto; }
}

@media (max-width: 640px) {
    .dash-topbar { padding: 0 16px; }
    .dash-main { padding: 20px 16px; gap: 16px; }
    .dash-welcome { flex-direction: column; align-items: flex-start; gap: 14px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi-value { font-size: 1.3rem; }
    .dash-date { display: none; }
}

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

/* ─── TABS ──────────────────────────────────────────────── */

.dash-tabs {
    display: flex;
    gap: 4px;
    background: var(--white);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    align-self: flex-start;
}

.dash-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 22px;
    border: none;
    border-radius: calc(var(--radius) - 6px);
    font-family: 'Satoshi', sans-serif;
    font-size: .9rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    cursor: pointer;
    transition: all .35s var(--ease);
    white-space: nowrap;
}

.dash-tab.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(109,184,201,.38);
    font-weight: 600;
}

.dash-tab:not(.active):hover {
    background: var(--bg);
    color: var(--text);
}

/* ─── PLANIFICADOR ──────────────────────────────────────── */

.dash-section {
    display: contents;
}

#planCamposContainer {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.campo-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow .35s var(--ease), transform .35s var(--ease);
}

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

.campo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #f8fbfc 0%, #eef7f9 100%);
    gap: 16px;
    flex-wrap: wrap;
}

.campo-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.campo-icon {
    width: 44px; height: 44px;
    background: var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.campo-nombre {
    font-family: 'Frescito', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
}

.campo-meta {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.campo-meta i {
    color: var(--primary);
    font-size: .73rem;
    margin-right: 2px;
}

.campo-stats {
    display: flex;
    gap: 20px;
    flex-shrink: 0;
}

.campo-stat {
    font-size: .875rem;
    color: var(--text-muted);
}

.campo-stat strong {
    color: var(--text);
}

/* Plan table */
.campo-table-wrap {
    overflow-x: auto;
}

.plan-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .855rem;
}

.plan-table thead th {
    background: var(--bg);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.plan-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.plan-table tbody tr:last-child { border-bottom: none; }

.plan-table tbody tr:hover { background: #f8fbfc; }

.plan-table tbody td {
    padding: 12px 14px;
    color: var(--text);
    white-space: nowrap;
    vertical-align: middle;
}

/* Cultivo badges */
.cultivo-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 50px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.cultivo-trigo    { background: #fef9c3; color: #854d0e; }
.cultivo-soja     { background: #dcfce7; color: #166534; }
.cultivo-maiz,
.cultivo-maíz     { background: #fef3c7; color: #92400e; }
.cultivo-girasol  { background: #fde68a; color: #78350f; }
.cultivo-sorgo    { background: #fce7f3; color: #9d174d; }

/* Rotación chips */
.rotacion-cell {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
}

.rotacion-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: .73rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.rotacion-trigo    { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.rotacion-soja     { background: #dcfce7; color: #166534; border-color: #86efac; }
.rotacion-maiz,
.rotacion-maíz     { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.rotacion-girasol  { background: #fde68a; color: #78350f; border-color: #f59e0b; }

.rotacion-año {
    opacity: .65;
    font-weight: 400;
    font-size: .68rem;
}

/* Fertilización cell */
.fert-cell {
    max-width: 220px;
    white-space: normal !important;
    line-height: 1.45;
    color: var(--text-muted);
}

/* Estado de planificación */
.plan-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.plan-status--planificado { background: #f1f5f9; color: #475569; }
.plan-status--sembrado    { background: #dcfce7; color: #15803d; }
.plan-status--en-curso    { background: #dbeafe; color: #1d4ed8; }
.plan-status--cosechado   { background: #f0fdf4; color: #166534; }

/* Empty state */
.plan-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.plan-empty i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 14px;
    display: block;
}

.plan-empty p {
    font-size: .95rem;
    font-weight: 300;
}

/* ─── PLANNER TOOLBAR ───────────────────────────────────── */

.plan-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.plan-toolbar-title {
    font-family: 'Frescito', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.plan-toolbar-sub {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.btn-nuevo-campo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Satoshi', sans-serif;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .35s var(--ease), transform .35s var(--ease), box-shadow .35s var(--ease);
    box-shadow: 0 4px 14px rgba(109,184,201,.3);
    white-space: nowrap;
}

.btn-nuevo-campo:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(109,184,201,.4);
}

/* ─── CAMPO CARD ACCIONES ───────────────────────────────── */

.campo-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.campo-actions {
    display: flex;
    gap: 6px;
}

.campo-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: #fafcfc;
}

.btn-nuevo-lote {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: none;
    border: 1.5px dashed var(--primary);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-family: 'Satoshi', sans-serif;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .25s var(--ease);
}

.btn-nuevo-lote:hover {
    background: var(--primary-light);
    border-style: solid;
}

/* ─── BOTONES EDITAR / ELIMINAR en filas ────────────────── */

.row-actions {
    display: flex;
    gap: 4px;
}

.btn-row-edit,
.btn-row-delete {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: .78rem;
    transition: all .2s var(--ease);
    flex-shrink: 0;
}

.btn-row-edit {
    background: #e0f4f7;
    color: var(--primary-dark);
}

.btn-row-edit:hover {
    background: var(--primary);
    color: #fff;
}

.btn-row-delete {
    background: #fef2f2;
    color: #dc2626;
}

.btn-row-delete:hover {
    background: #dc2626;
    color: #fff;
}

.table-empty-row {
    text-align: center;
    padding: 24px !important;
    color: var(--text-muted);
    font-size: .875rem;
    font-weight: 300;
}

/* ─── MODAL ─────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12,20,18,.55);
    backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn .25s var(--ease);
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-card {
    background: var(--white);
    border-radius: 20px;
    width: min(480px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 32px 80px rgba(0,0,0,.22);
    animation: modalSlideUp .3s var(--ease);
}

.modal-card--wide {
    width: min(680px, 100%);
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(28px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px 18px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 1;
    border-radius: 20px 20px 0 0;
}

.modal-header h3 {
    font-family: 'Frescito', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    width: 32px; height: 32px;
    background: var(--bg);
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: .9rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
}

.modal-close:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* ─── FORMULARIO ────────────────────────────────────────── */

.modal-form {
    padding: 22px 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group--sm {
    max-width: 120px;
}

.form-group label {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Satoshi', sans-serif;
    font-size: .9rem;
    color: var(--text);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
}

.form-group textarea {
    resize: vertical;
    min-height: 64px;
    line-height: 1.5;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(109,184,201,.15);
}

.form-section-title {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--primary-dark);
    padding: 8px 0 2px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 7px;
}

/* Rotación input rows */
.rotacion-header {
    display: grid;
    grid-template-columns: 1fr 1fr 32px;
    gap: 8px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 2px;
}

.rotacion-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr 32px;
    gap: 8px;
    align-items: center;
}

.rotacion-input-row input,
.rotacion-input-row select {
    padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: 'Satoshi', sans-serif;
    font-size: .85rem;
    color: var(--text);
    transition: border-color .2s;
    width: 100%;
}

.rotacion-input-row input:focus,
.rotacion-input-row select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-rot-remove {
    width: 32px; height: 32px;
    background: #fef2f2;
    border: none;
    border-radius: 8px;
    color: #dc2626;
    font-size: .78rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
    flex-shrink: 0;
}

.btn-rot-remove:hover { background: #fecaca; }

.btn-add-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: none;
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-family: 'Satoshi', sans-serif;
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    align-self: flex-start;
}

.btn-add-row:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Modal actions */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.btn-modal-cancel {
    padding: 10px 20px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Satoshi', sans-serif;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s;
}

.btn-modal-cancel:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.btn-modal-save {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Satoshi', sans-serif;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .35s var(--ease);
    box-shadow: 0 4px 14px rgba(109,184,201,.3);
}

.btn-modal-save:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(109,184,201,.4);
}

/* ─── RESPONSIVE planner ────────────────────────────────── */

@media (max-width: 640px) {
    .dash-tabs { align-self: stretch; }
    .dash-tab { flex: 1; justify-content: center; padding: 9px 12px; font-size: .82rem; }
    .campo-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .form-row { grid-template-columns: 1fr; }
    .form-group--sm { max-width: 100%; }
    .modal-card { border-radius: 16px; }
    .modal-form { padding: 16px 18px 22px; }
    .modal-header { padding: 18px 18px 14px; }
}

::selection { background: var(--primary); color: #fff; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

/* ── Inicio / Resumen General ─────────────────────────────── */
.inicio-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #4a9aaa 100%);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    margin-bottom: 20px;
    color: white;
}
.inicio-bienvenido {
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0 0 2px;
    color: rgba(255,255,255,0.8);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.inicio-empresa-nombre {
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0 0 8px;
    color: white;
}
.inicio-header-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: .83rem;
    opacity: .88;
}
.inicio-header-meta span { display: flex; align-items: center; gap: 6px; }

.inicio-header-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,.18);
    border: 1.5px solid rgba(255,255,255,.35);
    border-radius: 14px;
    padding: 14px 20px;
    white-space: nowrap;
    flex-shrink: 0;
}
.inicio-header-badge i { font-size: 1.4rem; opacity: .9; }
.inicio-badge-camp { font-size: 1rem; font-weight: 700; color: white; }
.inicio-badge-sub  { font-size: .72rem; opacity: .75; color: white; }
.inicio-camp-select {
    background: rgba(255,255,255,0.2);
    border: 1.5px solid rgba(255,255,255,0.4);
    border-radius: 8px;
    color: white;
    font-size: .95rem;
    font-weight: 700;
    font-family: inherit;
    padding: 4px 8px;
    cursor: pointer;
    outline: none;
    width: 100%;
}
.inicio-camp-select option { background: #2d6a7a; color: white; }

/* Establishment pills */
.inicio-estab-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.inicio-estab-pill {
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.35);
    border-radius: 20px;
    color: rgba(255,255,255,0.85);
    font-size: .82rem;
    font-weight: 600;
    font-family: inherit;
    padding: 4px 14px;
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.inicio-estab-pill:hover {
    background: rgba(255,255,255,0.28);
    color: #fff;
}
.inicio-estab-pill.active {
    background: rgba(255,255,255,0.95);
    color: var(--primary);
    border-color: transparent;
}

/* KPIs */
.inicio-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
@media (max-width: 800px) { .inicio-kpis { grid-template-columns: repeat(2, 1fr); } }

.inicio-kpi {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.inicio-kpi-icon {
    font-size: 1.3rem;
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px; flex-shrink: 0;
}
.inicio-kpi-icon--blue  { background: #dbeafe; color: #1d4ed8; }
.inicio-kpi-icon--teal  { background: #ccfbf1; color: #0d9488; }
.inicio-kpi-icon--green { background: #dcfce7; color: #16a34a; }
.inicio-kpi-icon--gold  { background: #fef9c3; color: #ca8a04; }
.inicio-kpi-data { display: flex; flex-direction: column; gap: 1px; }
.inicio-kpi-val   { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.inicio-kpi-label { font-size: .72rem; color: var(--text-muted); }

/* 2-column body */
.inicio-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 860px) {
    .inicio-body { grid-template-columns: 1fr; }
    .inicio-header { flex-direction: column; }
    .inicio-header-badge { align-self: flex-start; }
}
.inicio-col { display: flex; flex-direction: column; gap: 16px; }

/* Cards */
.inicio-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.inicio-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.inicio-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.inicio-card-title i { color: var(--primary); }
.inicio-plan-ha {
    font-size: .73rem; font-weight: 400;
    color: var(--text-muted); text-transform: none; letter-spacing: 0; margin-left: 4px;
}
.inicio-card-link {
    display: flex; align-items: center; gap: 5px;
    font-size: .76rem; font-weight: 500; color: var(--primary);
    background: none; border: none; cursor: pointer;
    padding: 4px 8px; border-radius: 6px; white-space: nowrap;
    transition: background .15s;
}
.inicio-card-link:hover { background: rgba(109,184,201,.12); }

/* MB summary */
.inicio-mb-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.inicio-mb-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 8px;
    background: var(--bg); border: 1px solid var(--border);
}
.inicio-mb-crop { font-size: .85rem; font-weight: 600; color: var(--text); flex: 1; }
.inicio-mb-sys  { font-size: .72rem; color: var(--text-muted); }
.inicio-mb-val  { font-size: .9rem; font-weight: 700; text-align: right; }
.inicio-mb-val small { font-size: .68rem; font-weight: 400; }
.inicio-mb-high { color: #15803d; }
.inicio-mb-mid  { color: #0d9488; }
.inicio-mb-low  { color: #d97706; }
.inicio-mb-neg  { color: #e11d48; }
.inicio-mb-empty {
    padding: 18px; text-align: center; color: var(--text-muted);
    font-size: .82rem; display: flex; align-items: center; justify-content: center; gap: 8px;
}

/* Suelos snapshot */
.inicio-suelos-row {
    display: flex; justify-content: space-around;
    padding: 18px 16px; gap: 8px;
}
.inicio-suelo-stat {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    flex: 1; padding: 12px 8px;
    background: var(--bg); border-radius: 10px; border: 1px solid var(--border);
}
.inicio-suelo-val   { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.inicio-suelo-label { font-size: .7rem; color: var(--text-muted); }

/* Planificador lotes */
.inicio-lotes-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.inicio-lote-row {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 7px;
    background: var(--bg); font-size: .8rem; border: 1px solid transparent;
}
.inicio-lote-row:hover { border-color: var(--border); }
.inicio-lote-name    { flex: 1; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 5px; }
.inicio-lote-name i  { color: var(--text-muted); font-size: .72rem; }
.inicio-lote-cultivo { color: var(--text-muted); font-size: .78rem; }
.inicio-lote-ha      { color: var(--text-muted); font-size: .75rem; white-space: nowrap; }

/* Recomendaciones */
.inicio-recom-list { padding: 10px 16px; display: flex; flex-direction: column; gap: 10px; }
.inicio-recom-item {
    padding: 10px 12px;
    border-left: 3px solid var(--primary);
    background: var(--bg);
    border-radius: 0 8px 8px 0;
}
.inicio-recom-titulo { font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.inicio-recom-texto  { font-size: .77rem; color: var(--text-muted); line-height: 1.45; }

/* Lote status badges (shared) */
.status-sembrado    { background: #dbeafe; color: #1d4ed8; }
.status-en-curso    { background: #dcfce7; color: #15803d; }
.status-cosechado   { background: #f3f4f6; color: #6b7280; }
.status-planificado { background: #fef9c3; color: #854d0e; }

/* ── Plan Matrix ──────────────────────────────────────── */
.plan-matrix-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 28px;
    overflow: hidden;
}
.plan-matrix-header {
    display: flex; flex-direction: column; gap: 2px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.plan-matrix-header-title {
    font-size: .88rem; font-weight: 700; color: var(--text);
    display: flex; align-items: center; gap: 7px;
}
.plan-matrix-header-title i { color: var(--primary); }
.plan-matrix-header-sub { font-size: .75rem; color: var(--text-muted); }

.plan-matrix-scroll { overflow-x: auto; }

.plan-matrix-table {
    width: 100%; border-collapse: collapse; font-size: .8rem;
}
.plan-matrix-table thead tr th {
    padding: 9px 14px; text-align: center;
    background: var(--bg); color: var(--text-muted);
    font-size: .72rem; font-weight: 700; letter-spacing: .04em;
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
.plan-matrix-th-first { text-align: left !important; min-width: 240px; }
.plan-matrix-th-cultivo { min-width: 130px; }
.plan-matrix-th-total { min-width: 90px; color: var(--text) !important; }
.plan-matrix-th-mb { min-width: 110px; color: var(--primary) !important; }

/* Campo rows */
.plan-matrix-campo td {
    padding: 10px 14px;
    background: color-mix(in srgb, var(--primary) 5%, var(--card-bg));
    border-top: 2px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
}
.plan-matrix-campo-label {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; color: var(--text); text-align: left !important;
}
.plan-matrix-campo-label i { color: var(--primary); font-size: .85rem; }
.plan-matrix-edit-btn {
    background: none; border: none; cursor: pointer; padding: 2px 4px;
    color: var(--text-muted); border-radius: 4px; font-size: .72rem;
    opacity: 0; transition: opacity .15s;
}
.plan-matrix-campo:hover .plan-matrix-edit-btn { opacity: 1; }
.plan-matrix-edit-btn:hover { color: var(--primary); background: var(--bg); }
.plan-matrix-add-lote-btn:hover { color: #16a34a; background: #dcfce7; }
.plan-matrix-campo-ha, .plan-matrix-campo-total, .plan-matrix-campo-mb {
    text-align: center; font-weight: 600; color: var(--text);
}
.plan-matrix-campo-ha--empty { color: var(--text-muted) !important; font-weight: 400 !important; }

/* Lote rows */
.plan-matrix-lote td {
    padding: 7px 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    vertical-align: middle;
}
.plan-matrix-lote:hover td { background: color-mix(in srgb, var(--primary) 3%, var(--card-bg)); }
.plan-matrix-lote-name { text-align: left !important; }
.plan-matrix-tree { color: var(--text-muted); margin-right: 4px; font-size: .9rem; }
.plan-matrix-lote-btn {
    background: none; border: none; cursor: pointer; padding: 0;
    font-size: .8rem; font-weight: 500; color: var(--text);
    text-decoration: none;
}
.plan-matrix-lote-btn:hover { color: var(--primary); text-decoration: underline; }

/* Ha cells */
.plan-matrix-ha { text-align: center; }
.plan-matrix-ha--fill {
    background: color-mix(in srgb, var(--primary) 6%, var(--card-bg));
}
.plan-matrix-ha-val { font-weight: 600; color: var(--text); display: block; }
.plan-matrix-mb-hint {
    display: block; font-size: .7rem; font-weight: 600; margin-top: 1px;
    padding: 1px 5px; border-radius: 4px;
}
.plan-matrix-ha--empty { color: var(--text-muted); font-size: .75rem; }

.plan-matrix-total-ha { text-align: center; font-weight: 600; color: var(--text-muted); }
.plan-matrix-mb { text-align: center; font-weight: 700; border-radius: 6px; }
.plan-matrix-mb--na { text-align: center; color: var(--text-muted); font-size: .75rem; }

/* Global row */
.plan-matrix-emp td {
    padding: 11px 14px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: .83rem;
    border-top: 2px solid var(--primary-dark, var(--primary));
}
.plan-matrix-emp-label { display: flex; align-items: center; gap: 8px; }
.plan-matrix-emp-ha, .plan-matrix-emp-total, .plan-matrix-emp-mb {
    text-align: center; color: rgba(255,255,255,.95);
}
.plan-matrix-emp-ha--empty { opacity: .4; }
.plan-matrix-emp-mb { font-size: .88rem; }

/* MB value colors (reuse sens palette) */
.plan-matrix-mb.pmb-neg, .plan-matrix-campo-mb.pmb-neg, .plan-matrix-mb-hint.pmb-neg { background: #fee2e2; color: #dc2626; }
.plan-matrix-mb.pmb-low, .plan-matrix-campo-mb.pmb-low, .plan-matrix-mb-hint.pmb-low { background: #fef9c3; color: #92400e; }
.plan-matrix-mb.pmb-mid, .plan-matrix-campo-mb.pmb-mid, .plan-matrix-mb-hint.pmb-mid { background: #fef3c7; color: #78350f; }
.plan-matrix-mb.pmb-ok,  .plan-matrix-campo-mb.pmb-ok,  .plan-matrix-mb-hint.pmb-ok  { background: #dcfce7; color: #15803d; }
.plan-matrix-mb.pmb-high,.plan-matrix-campo-mb.pmb-high,.plan-matrix-mb-hint.pmb-high { background: #bbf7d0; color: #166534; }

/* Detalle por campo header */
.plan-campos-title {
    margin: 8px 0 10px;
    padding: 0 2px;
}
.plan-campos-title h4 {
    font-size: .82rem; font-weight: 700; color: var(--text-muted);
    letter-spacing: .06em; text-transform: uppercase;
    display: flex; align-items: center; gap: 6px;
}
