/* 
 * Evergreen CropFlow - Modern CSS Design System
 * Aesthetic: Rich Emerald & Slate, Glassmorphism, Micro-interactions
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-deep: #042f2e;
    --primary-light: #14b8a6;
    --primary-subtle: #f0fdfa;
    --primary-border: #99f6e4;
    
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.25);

    --success: #15803d;
    --success-bg: #dcfce7;
    --success-border: #86efac;

    --warning: #b45309;
    --warning-bg: #fef3c7;
    --warning-border: #fcd34d;

    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --danger-border: #fca5a5;

    --info: #6d28d9;
    --info-bg: #ede9fe;
    --info-border: #c4b5fd;

    --bg-page: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-hover-border: #cbd5e1;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --field-bg: #f0fdf4;
    --field-border: #bbf7d0;
    --factory-bg: #eff6ff;
    --factory-border: #bfdbfe;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

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

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

/* Top Navigation Bar */
.top-navbar {
    background: #042f2e;
    background: linear-gradient(135deg, #042f2e 0%, #0f766e 100%);
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(4, 47, 46, 0.25);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.nav-container {
    max-width: 1750px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #ffffff;
    line-height: 1.1;
}

.brand-text span {
    font-size: 0.75rem;
    color: #a7f3d0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Nav Links */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
}

.nav-link {
    color: #e6fffa;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

/* Active Factory Selector Pill */
.factory-select-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    padding: 0.25rem 0.75rem;
    gap: 0.5rem;
}

.factory-select-label {
    font-size: 0.75rem;
    color: #a7f3d0;
    font-weight: 600;
    text-transform: uppercase;
}

.factory-select {
    background: transparent;
    color: #ffffff;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    outline: none;
    cursor: pointer;
}

.factory-select option {
    background: #0f172a;
    color: #ffffff;
}

/* User Profile Badge */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 0.5rem;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: #10b981;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.user-role-badge {
    font-size: 0.6875rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #6ee7b7;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(252, 165, 165, 0.3);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fecaca;
}

/* Main Container */
.main-wrapper {
    max-width: 1750px;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 3rem;
    flex: 1;
}

/* Control Bar (Date picker, search, quick filter pills) */
.control-bar {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.date-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-nav-btn {
    background: var(--bg-page);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.date-nav-btn:hover {
    background: var(--primary-subtle);
    border-color: var(--primary-border);
    color: var(--primary);
}

.date-input {
    background: var(--bg-page);
    border: 1px solid var(--card-border);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.date-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

/* Filter Chips */
.filter-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.filter-btn:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.filter-badge {
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    background: rgba(0, 0, 0, 0.08);
}

.filter-btn.active .filter-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Search Box */
.search-input-box {
    position: relative;
    min-width: 240px;
}

.search-input {
    width: 100%;
    background: var(--bg-page);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    font-size: 0.875rem;
    font-family: var(--font-body);
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.search-icon {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Stats / KPI Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

/* 8-Card Layout: Single row on desktop, 4 columns (2 rows) on tablets */
.stats-grid-8 {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 1199px) and (min-width: 680px) {
    .stats-grid-8 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.65rem;
    }
}

@media (max-width: 679px) and (min-width: 440px) {
    .stats-grid-8 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }
}

@media (max-width: 439px) {
    .stats-grid-8 {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.65rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-width: 0;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3.5px;
    height: 100%;
    background: var(--primary);
}

.stat-card.variant-field::before { background: #16a34a; }
.stat-card.variant-factory::before { background: #2563eb; }
.stat-card.variant-diff::before { background: #0891b2; }
.stat-card.variant-transfer::before { background: #7c3aed; }
.stat-card.variant-made::before { background: #059669; }
.stat-card.variant-ded::before { background: #d97706; }

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    margin-bottom: 0.35rem;
}

.stat-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-icon {
    font-size: 0.95rem;
    opacity: 0.8;
    flex-shrink: 0;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-unit {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 0.2rem;
}

.stat-sub {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-sub > span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-pill {
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.6875rem;
    flex-shrink: 0;
}

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

.pill-neg {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Crop Data Table Container */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.table-header-bar {
    padding: 1rem 1.25rem;
    background: #ffffff;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-title {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-responsive {
    overflow-x: auto;
    max-height: 65vh;
}

/* Crop Data Table */
.crop-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8125rem;
    text-align: right;
}

.crop-table th, .crop-table td {
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

.crop-table th {
    background: #f1f5f9;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    z-index: 10;
}

.crop-table th.th-field {
    background: #e8f5e9;
    color: #1b5e20;
    border-left: 2px solid #81c784;
}

.crop-table th.th-factory {
    background: #e3f2fd;
    color: #0d47a1;
    border-left: 2px solid #64b5f6;
}

.crop-table th.th-variance {
    background: #f3e8ff;
    color: #4a148c;
    border-left: 2px solid #ba68c8;
}

.crop-table td.text-left, .crop-table th.text-left {
    text-align: left;
}

.crop-table td.text-center, .crop-table th.text-center {
    text-align: center;
}

.crop-table tbody tr {
    transition: background-color 0.15s ease;
}

.crop-table tbody tr:hover {
    background-color: #f8fafc;
}

.crop-table tbody tr.row-transferred {
    background-color: #faf5ff;
}

.crop-table tbody tr.row-transferred:hover {
    background-color: #f3e8ff;
}

.crop-table tbody tr.row-pending {
    border-left: 3px solid #f59e0b;
}

.crop-table tbody tr.row-complete {
    border-left: 3px solid #10b981;
}

/* Table Totals Row */
.crop-table tfoot tr {
    background: #0f172a;
    color: #ffffff;
    font-weight: 700;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.crop-table tfoot td {
    padding: 0.75rem 0.65rem;
    border-top: 2px solid #334155;
    border-bottom: none;
    font-family: var(--font-heading);
    font-size: 0.875rem;
}

/* Status Badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.badge-status.complete {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.badge-status.complete:hover {
    background: #bbf7d0;
}

.badge-status.pending {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid var(--warning-border);
}

.badge-status.pending:hover {
    background: #fde68a;
}

/* Transfer Badge */
.badge-transfer {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid var(--info-border);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.6875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Action Buttons */
.btn-action {
    background: #f1f5f9;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-action:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.badge-status.badge-locked {
    cursor: not-allowed;
    opacity: 0.85;
}
.badge-status.badge-locked:hover {
    background: var(--success-bg) !important;
}

.btn-action-locked {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #64748b;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-action-locked:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #334155;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border: 1px solid var(--primary-dark);
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-outline:hover {
    background: var(--primary-subtle);
}

/* Excel Rows 69-89: Daily Reconciliation Card */
.reconciliation-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 2rem;
}

.reconciliation-header {
    background: linear-gradient(135deg, #042f2e 0%, #115e59 100%);
    color: #ffffff;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reconciliation-header h2 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reconciliation-header span {
    font-size: 0.8125rem;
    color: #a7f3d0;
}

.reconciliation-body {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .reconciliation-body {
        grid-template-columns: 1fr;
    }
}

.reconcile-step-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.reconcile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    background: var(--bg-page);
    border: 1px solid var(--card-border);
    font-size: 0.875rem;
}

.reconcile-row.highlight-sub {
    background: #f0fdf4;
    border-color: #86efac;
    font-weight: 600;
}

.reconcile-row.highlight-final {
    background: linear-gradient(135deg, #042f2e 0%, #0f766e 100%);
    color: #ffffff;
    border: none;
    padding: 1rem 1.25rem;
    margin-top: 0.5rem;
}

.reconcile-row.highlight-final .reconcile-val {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: #a7f3d0;
}

.reconcile-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reconcile-op {
    font-weight: 700;
    color: var(--text-muted);
    width: 20px;
    text-align: center;
}

.reconcile-val {
    font-weight: 700;
    font-family: var(--font-heading);
    font-size: 1rem;
}

/* Transferred breakdown cards */
.transfers-box {
    background: #faf5ff;
    border: 1px solid var(--info-border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.transfers-box h3 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--info);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.transfer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: #ffffff;
    border: 1px solid #e9d5ff;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
}

/* Modal Window */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

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

.modal-content {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 860px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideUp 0.25s ease-out;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: #042f2e;
    color: #ffffff;
    padding: 1.1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: var(--transition);
}

.btn-close-modal:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal-nav-btn {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.2;
}

.modal-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.45);
    transform: translateY(-1px);
}

.modal-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.route-counter-badge {
    background: rgba(255, 255, 255, 0.18);
    color: #a7f3d0;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    display: inline-block;
}

.modal-body {
    padding: 1.5rem;
}

.modal-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

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

/* Route Month-to-Date (MTD) KPI Grid */
.mtd-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

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

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

.modal-col-card {
    background: var(--bg-page);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.1rem;
}

.modal-col-card.col-field {
    background: #f0fdf4;
    border-color: #86efac;
}

.modal-col-card.col-factory {
    background: #eff6ff;
    border-color: #93c5fd;
}

.col-card-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-input {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.65rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--font-body);
    outline: none;
    transition: var(--transition);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.form-input.computed-net {
    background: #0f172a;
    color: #a7f3d0;
    font-size: 1.1rem;
    font-family: var(--font-heading);
    border-color: #334155;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: #0f172a;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    border-left: 4px solid var(--accent);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Print Styles */
@media print {
    .top-navbar, .control-bar, .btn-action, .btn-primary, .modal-overlay, .toast-container, .btn-print, .table-header-bar button {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    .main-wrapper {
        padding: 0 !important;
        max-width: 100% !important;
    }

    .crop-table {
        font-size: 9pt !important;
    }

    .crop-table th, .crop-table td {
        padding: 4px 6px !important;
        border: 1px solid #999 !important;
    }

    .reconciliation-card {
        page-break-inside: avoid;
        border: 1px solid #333 !important;
        box-shadow: none !important;
    }
}

/* ==========================================================================
   Table Column Sorting & Visibility Toggle & Route MTD Modal
   ========================================================================== */

/* Sortable Table Headers */
.crop-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.4rem !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.crop-table th.sortable:hover {
    background-color: rgba(15, 23, 42, 0.08) !important;
    color: #0f172a !important;
}

.sort-icon {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #94a3b8;
    opacity: 0.6;
    transition: all 0.15s ease;
}

.crop-table th.sortable:hover .sort-icon {
    opacity: 1;
    color: #0f766e;
}

.crop-table th.sorted-asc .sort-icon,
.crop-table th.sorted-desc .sort-icon {
    color: #0f766e;
    opacity: 1;
    font-weight: 800;
}

/* Column Visibility Dropdown */
.col-vis-container {
    position: relative;
    display: inline-block;
}

.col-vis-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
}

.col-vis-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.col-vis-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    min-width: 230px;
    max-height: 380px;
    z-index: 100;
    overflow-y: auto;
    padding: 0.4rem 0;
}

.col-vis-menu.active {
    display: block;
    animation: dropdownFadeIn 0.15s ease-out;
}

.col-vis-header {
    padding: 0.5rem 0.85rem 0.4rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.col-vis-reset {
    background: none;
    border: none;
    color: #0f766e;
    font-size: 0.6875rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.col-vis-reset:hover {
    text-decoration: underline;
}

.col-vis-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.8125rem;
    color: #334155;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease;
}

.col-vis-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.col-vis-item input[type="checkbox"] {
    cursor: pointer;
    accent-color: #0f766e;
    width: 15px;
    height: 15px;
}

/* Route Month-To-Date Link */
.route-mtd-link {
    color: #0f766e !important;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.route-mtd-link:hover {
    color: #042f2e !important;
    background: #ccfbf1;
    box-shadow: 0 1px 3px rgba(15, 118, 110, 0.15);
    transform: translateX(2px);
}

/* Sister Factory Transfers Interactive Styling */
.transfer-factory-row {
    transition: background-color 0.15s ease;
}

.transfer-factory-row:hover {
    background-color: #faf5ff !important;
}

.factory-interactive-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #581c87;
    font-weight: 700;
    transition: all 0.15s ease;
}

.transfer-factory-row:hover .factory-interactive-badge {
    color: #7c3aed;
    transform: translateX(3px);
}


