@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@500;700&family=DM+Sans:wght@400;500;700&display=swap');

        :root {
            --forest-dark: #1A3C2E;
            --forest-mid: #2D6A4F;
            --leaf-green: #52B788;
            --mint-light: #D8F3DC;
            --cream: #F4F1E8;
            --text-dark: #1A1A1A;
            --text-mid: #4A4A4A;
            --border-light: #E0E0E0;
            --warning: #F4A261;
            --success: #06D6A0;
            --danger: #E63946;
            --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
            --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
        }

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

        body {
            font-family: 'DM Sans', sans-serif;
            color: var(--text-dark);
            background: #dfe4ec;
            min-height: 100vh;
        }

        .app-container { max-width: none; width: 100%; margin: 0 auto; padding: 10px; }

        .app-header {
            background: linear-gradient(135deg, #1b5b3c 0%, #2a7a57 100%);
            color: white;
            border-radius: 10px;
            padding: 14px 14px 10px;
            margin-bottom: 10px;
            box-shadow: 0 7px 16px rgba(24, 42, 36, 0.22);
        }

        .app-title {
            font-family: 'Crimson Pro', serif;
            font-size: 30px;
            line-height: 1.05;
            font-weight: 700;
            margin-bottom: 6px;
            letter-spacing: 0.01em;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .app-title-mark {
            width: 20px;
            height: 20px;
            border-radius: 999px;
            background: linear-gradient(135deg, #bde16d, #8abf47);
            color: #20462f;
            font-family: 'DM Sans', sans-serif;
            font-size: 12px;
            font-weight: 700;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transform: translateY(1px);
        }
        .app-subtitle { color: #d9f0e2; font-size: 12px; font-weight: 500; line-height: 1.3; }
        .glossary-bar {
            margin-top: 12px;
            border-radius: 7px;
            background: rgba(214, 239, 223, 0.16);
            border: 1px solid rgba(214, 239, 223, 0.14);
            color: #cde7d5;
            font-size: 11px;
            padding: 8px 10px;
        }

        .dashboard-selector { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }

        .dashboard-btn {
            border: 1px solid #d4d8dd;
            background: #f0f2f5;
            color: #4c5a66;
            border-radius: 8px;
            padding: 7px 12px;
            font-weight: 700;
            font-size: 12px;
            cursor: pointer;
            transition: 0.2s;
            min-height: 32px;
            box-shadow: 0 1px 4px rgba(25, 35, 50, 0.08);
        }

        .dashboard-btn:hover { border-color: #87b7a1; transform: translateY(-1px); }
        .dashboard-btn.active { background: linear-gradient(135deg, #3f9f74, #58b889); color: #fff; border-color: #3f9f74; }
        .tab-badge {
            display: inline-block;
            margin-left: 6px;
            min-width: 18px;
            padding: 1px 6px;
            border-radius: 999px;
            font-size: 11px;
            font-weight: 700;
            line-height: 1.4;
            background: var(--mint-light);
            color: var(--forest-dark);
            cursor: pointer;
        }
        .dashboard-btn.active .tab-badge { background: rgba(255, 255, 255, 0.22); color: #fff; }

        .card {
            background: #fff;
            border-radius: 10px;
            padding: 10px;
            box-shadow: 0 2px 8px rgba(25, 35, 50, 0.08);
            border: 1px solid rgba(25, 35, 50, 0.06);
            margin-bottom: 8px;
        }

        .section-title {
            font-family: 'Crimson Pro', serif;
            font-size: 20px;
            line-height: 1.1;
            margin-bottom: 8px;
            color: #eaf6ef;
            font-weight: 700;
            letter-spacing: 0.01em;
            background: linear-gradient(135deg, #1f5a3c, #2c7350);
            border: 1px solid #1f5a3c;
            border-radius: 8px;
            padding: 8px 10px;
        }
        .section-badge {
            display: inline-block;
            margin-left: 8px;
            padding: 2px 8px;
            border-radius: 999px;
            font-family: 'DM Sans', sans-serif;
            font-size: 11px;
            font-weight: 700;
            background: var(--mint-light);
            color: var(--forest-dark);
            vertical-align: middle;
            cursor: pointer;
        }
        .filter-popover { position: relative; display: inline-block; }
        .filter-popover-card {
            position: absolute;
            top: calc(100% + 6px);
            right: 0;
            z-index: 30;
            min-width: 220px;
            background: #fff;
            border: 1px solid var(--border-light);
            border-radius: 10px;
            padding: 8px;
            box-shadow: var(--shadow-md);
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }
        .filter-chip { padding: 6px 8px; font-size: 11px; }
        .muted { color: #60706a; font-size: 11px; line-height: 1.3; }
        .pagination-bar {
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }
        .pagination-actions {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }

        .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

        .form-grid,
        .form-grid-2,
        .form-grid-3 {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 6px;
            margin-bottom: 6px;
        }
        .form-grid-relaxed {
            column-gap: 12px;
            row-gap: 12px;
            align-items: start;
        }
        .form-grid-relaxed input[type="file"],
        .form-grid-relaxed textarea {
            grid-column: span 2;
        }
        .form-grid-relaxed .muted {
            grid-column: 1 / -1;
        }
        .form-grid-relaxed .auto-labeled-control {
            margin-top: 16px;
        }
        .auto-labeled-grid {
            position: relative;
        }
        .auto-labeled-control {
            margin-top: 14px;
        }
        .auto-field-label {
            position: absolute;
            font-size: 11px;
            line-height: 1.2;
            color: #6a7872;
            font-weight: 600;
            margin: 0;
            letter-spacing: 0.01em;
            pointer-events: none;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            z-index: 2;
        }

        input, select, textarea {
            width: 100%;
            border: 1px solid #d6dfda;
            border-radius: 8px;
            padding: 6px 8px;
            font-family: inherit;
            font-size: 12px;
            background: #fcfdfd;
        }

        textarea { min-height: 66px; resize: vertical; }

        .btn {
            border: none;
            border-radius: 7px;
            padding: 6px 10px;
            cursor: pointer;
            font-weight: 700;
            font-size: 11px;
            letter-spacing: 0.01em;
            min-height: 28px;
        }

        .btn-primary { background: var(--forest-mid); color: #fff; }
        .btn-secondary { background: var(--mint-light); color: var(--forest-dark); }
        .btn-warning { background: var(--warning); color: #fff; }
        .btn-danger { background: var(--danger); color: #fff; }
        .link-btn {
            margin-top: 10px;
            background: none;
            border: none;
            padding: 0;
            color: var(--forest-mid);
            text-decoration: underline;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
        }

        .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }

        .list { display: grid; gap: 10px; }

        .operator-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 12px;
            align-items: start;
        }
        .operator-span-2 {
            grid-column: 1 / -1;
        }
        .table-wrap {
            overflow-x: auto;
            border: 1px solid #dfe6e2;
            border-radius: 10px;
            background: #fff;
        }
        .portlet-shell {
            position: relative;
        }
        .portlet-toggle {
            position: absolute;
            top: 18px;
            right: 18px;
            z-index: 5;
            width: 30px;
            height: 30px;
            border-radius: 8px;
            border: 1px solid #d5ded8;
            background: #f4f8f6;
            color: #285642;
            cursor: pointer;
            font-size: 14px;
            line-height: 1;
            font-weight: 700;
        }
        .portlet-toggle:hover {
            background: #eaf4ef;
        }
        .portlet-expanded {
            position: fixed !important;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 999;
            overflow: auto;
            background: #f3f6f9;
            border-radius: 0;
            padding: 10px;
            box-shadow: 0 10px 28px rgba(13, 22, 33, 0.3);
        }
        .portlet-expanded.card {
            margin-bottom: 0;
            min-height: 100vh;
        }
        .portlet-expanded > .card {
            min-height: calc(100vh - 28px);
            margin-bottom: 0;
        }
        .map-footer {
            margin-top: 10px;
            display: grid;
            gap: 8px;
            align-items: start;
        }
        .map-footer-note {
            margin: 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
        }
        .map-footer-note .muted {
            margin: 0;
        }
        .map-controls-grid {
            display: grid;
            gap: 6px;
        }
        .map-btn-row {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 6px;
        }
        .data-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 11px;
        }
        .data-table thead th {
            text-align: left;
            background: #eef7f1;
            color: #2e5d46;
            font-weight: 700;
            padding: 6px 8px;
            border-bottom: 1px solid #d8e7de;
            white-space: nowrap;
        }
        .data-table tbody td {
            padding: 6px 8px;
            border-bottom: 1px solid #edf2ef;
            vertical-align: top;
        }
        .data-table tbody tr:last-child td {
            border-bottom: none;
        }
        .clickable-row {
            cursor: pointer;
        }
        .clickable-row:hover td {
            background: #f1f8f4;
        }
        .details-overlay {
            position: fixed;
            inset: 0;
            background: rgba(16, 27, 20, 0.46);
            z-index: 1200;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 6px;
        }
        .details-modal {
            width: min(1360px, 99vw);
            max-height: 97vh;
            overflow: auto;
            background: #fff;
            border-radius: 10px;
            border: 1px solid #d8e4dc;
            box-shadow: 0 16px 40px rgba(12, 21, 18, 0.32);
            padding: 10px;
        }
        .details-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
        }
        .details-body {
            margin-top: 6px;
        }
        .details-section {
            margin-bottom: 8px;
            border: 1px solid #e1ebe4;
            border-radius: 10px;
            padding: 8px;
            background: #fbfdfa;
        }
        .details-section-compact {
            margin-bottom: 6px;
            padding: 6px;
            border-radius: 8px;
        }
        .details-subtitle {
            font-size: 11px;
            font-weight: 700;
            color: #23543b;
            margin-bottom: 6px;
        }
        .details-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 6px 8px;
        }
        .details-field {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .details-label {
            font-size: 10px;
            color: #4a6858;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: .02em;
        }
        .details-value {
            font-size: 12px;
            color: #1d2b23;
            word-break: break-word;
            min-height: 20px;
        }
        .details-check input {
            width: 18px;
            height: 18px;
            margin-top: 2px;
        }
        .details-array {
            border-top: 1px dashed #d7e5dc;
            padding-top: 6px;
            margin-top: 6px;
        }
        .details-mini-table {
            font-size: 10px;
        }
        .details-mini-table thead th {
            padding: 4px 5px;
        }
        .details-mini-table tbody td {
            padding: 4px 5px;
            white-space: nowrap;
        }
        .details-cell-link {
            background: none;
            border: none;
            padding: 0;
            margin: 0;
            color: #2f7d57;
            font-size: 10px;
            font-weight: 700;
            text-decoration: underline;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }
        .details-cell-icon {
            width: 10px;
            height: 10px;
            border: 1px solid #2f7d57;
            border-radius: 2px;
            position: relative;
            display: inline-block;
        }
        .details-cell-icon::after {
            content: '';
            position: absolute;
            width: 4px;
            height: 4px;
            border-top: 1px solid #2f7d57;
            border-right: 1px solid #2f7d57;
            right: 1px;
            top: 1px;
        }
        .details-view-link {
            border: none;
            background: none;
            padding: 0;
            margin: 0;
            color: #2f7d57;
            font-size: 10px;
            font-weight: 700;
            text-decoration: underline;
            cursor: pointer;
        }
        .details-modal-drilldown {
            width: min(1300px, 98.5vw);
            max-height: 98vh;
        }
        .details-modal-asset {
            width: min(1400px, 99vw);
            max-height: 98vh;
        }
        .details-image-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
            gap: 6px;
        }
        .details-thumb-btn {
            border: 1px solid #d6e3db;
            border-radius: 6px;
            padding: 2px;
            background: #fff;
            cursor: pointer;
        }
        .details-thumb-img {
            width: 100%;
            height: 70px;
            object-fit: cover;
            border-radius: 4px;
            display: block;
        }
        .asset-view-wrap {
            width: 100%;
            min-height: 65vh;
            max-height: 83vh;
            overflow: auto;
            border: 1px solid #dbe6df;
            border-radius: 8px;
            background: #f7fbf8;
        }
        .asset-view-image {
            display: block;
            max-width: 100%;
            height: auto;
            margin: 0 auto;
        }
        .asset-view-frame {
            width: 100%;
            min-height: 72vh;
            border: 0;
            background: #fff;
        }
        .details-geo-table thead th,
        .details-geo-table tbody td {
            text-align: center;
        }
        .details-array-item {
            border: 1px solid #e4ece7;
            border-radius: 8px;
            padding: 6px;
            margin-bottom: 6px;
            background: #ffffff;
        }
        .details-analytics-section {
            padding: 6px;
        }
        .details-analytics-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 4px;
        }
        .details-analytics-card {
            border: 1px solid #dbe7df;
            border-radius: 7px;
            padding: 5px;
            background: #fff;
        }
        .details-analytics-title {
            font-size: 11px;
            font-weight: 700;
            color: #2a5e44;
            margin-bottom: 4px;
        }
        .details-analytics-metrics {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 3px 5px;
        }
        .details-analytics-item {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            gap: 6px;
            border-bottom: 1px dotted #e5eeea;
            padding-bottom: 2px;
        }
        .details-analytics-label {
            font-size: 10px;
            color: #557266;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .details-analytics-value {
            font-size: 11px;
            font-weight: 700;
            color: #1c3b2c;
            white-space: nowrap;
        }
        .details-modal input,
        .details-modal select,
        .details-modal textarea {
            width: 100%;
        }
        @media (max-width: 900px) {
            .details-grid {
                grid-template-columns: 1fr;
            }
            .details-analytics-grid,
            .details-analytics-metrics {
                grid-template-columns: 1fr;
            }
        }
        .details-json-view {
            margin: 0;
            border: 1px solid #dbe6df;
            background: #f9fcfa;
            border-radius: 10px;
            padding: 10px;
            font-size: 12px;
            line-height: 1.4;
            white-space: pre-wrap;
            word-break: break-word;
        }
        .details-json-editor {
            width: 100%;
            min-height: 320px;
            border: 1px solid #d6dfda;
            border-radius: 10px;
            padding: 10px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
            font-size: 12px;
            line-height: 1.45;
            background: #fbfdfc;
        }
        .op-card-primary { min-height: 0; }
        .op-card-admin { min-height: 0; }
        .op-card-secondary { min-height: 0; }
        .op-card-table { min-height: 0; }
        .op-card-metrics { min-height: 0; }
        .op-card-primary { order: 1; }
        .op-card-admin { order: 2; }
        .op-card-user-list { order: 3; }
        .op-card-farmers-list { order: 4; }
        .op-card-map { order: 4; }

        @media (min-width: 901px) and (max-width: 1200px) {
            .op-card-primary { min-height: 0; }
            .op-card-admin { min-height: 0; }
            .op-card-secondary { min-height: 0; }
            .op-card-table { min-height: 0; }
            .op-card-metrics { min-height: 0; }
        }

        .pill {
            display: inline-block;
            border-radius: 999px;
            padding: 4px 10px;
            font-size: 11px;
            font-weight: 700;
            background: var(--mint-light);
            color: var(--forest-dark);
        }

        .status-Submitted { background: #e8f0fe; color: #174ea6; }
        .status-Approved { background: #fff4e5; color: #b06000; }
        .status-Packed { background: #e9f7ff; color: #0d5a87; }
        .status-Validated { background: #e3f4ff; color: #0a5c87; }
        .status-Packing { background: #f3efff; color: #5b3fb3; }
        .status-InTransit { background: #ede7f6; color: #5e35b1; }
        .status-Dispatched { background: #ede7f6; color: #5e35b1; }
        .status-Delivered { background: #e6f4ea; color: #137333; }
        .status-Closed { background: #dff4e8; color: #0f5d3d; }
        .status-Pending { background: #fff4e5; color: #b06000; }
        .status-Published { background: #e6f4ea; color: #137333; }
        .status-Rejected { background: #fce8e6; color: #b3261e; }

        .kpi { font-size: 32px; font-family: 'Crimson Pro', serif; color: var(--forest-dark); line-height: 1; font-weight: 700; }
        .kpi-strip {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 10px;
            margin-bottom: 10px;
        }
        .kpi-card {
            background: #f3f2ee;
            border: 1px solid #e3e5e2;
            border-left: 3px solid #45be8d;
            border-radius: 12px;
            padding: 8px 10px;
            box-shadow: 0 1px 5px rgba(25, 35, 50, 0.06);
        }
        .kpi-label {
            font-size: 12px;
            color: #6c7c74;
            margin-bottom: 6px;
            font-weight: 700;
        }
        .kpi-sub {
            margin-top: 6px;
            font-size: 12px;
            color: #31ad80;
            font-weight: 700;
        }

        .card h4 {
            font-size: 14px;
            line-height: 1.2;
            color: #e7f4ed;
            margin-bottom: 6px;
            background: linear-gradient(135deg, #3a8a63, #4fa67b);
            border: 1px solid #3a8a63;
            border-radius: 8px;
            padding: 6px 8px;
        }

        .card .list > div,
        .card .list p,
        .card .row span,
        .card .row div {
            font-size: 12px;
        }

        @media (max-width: 900px) {
            .form-grid, .form-grid-2, .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        }

        @media (max-width: 600px) {
            .form-grid, .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
            .form-grid-relaxed input[type="file"],
            .form-grid-relaxed textarea {
                grid-column: span 1;
            }
        }

        @media (max-width: 900px) {
            .grid-2, .kpi-strip, .operator-grid { grid-template-columns: 1fr; }
            .operator-span-2 { grid-column: auto; }
            .op-card-primary, .op-card-admin, .op-card-secondary, .op-card-table, .op-card-metrics { min-height: 0; }
            .map-btn-row .btn { min-width: 94px; }
            .map-footer-note { justify-content: flex-start; }
        }

        /* Laptop density profile: optimize for 1366x768-like screens */
        @media (min-width: 1024px) and (max-width: 1460px), (min-width: 1024px) and (max-height: 820px) {
            .app-container { padding: 8px; }
            .app-header { padding: 10px 10px 8px; margin-bottom: 8px; }
            .app-title { font-size: 26px; margin-bottom: 4px; }
            .app-subtitle { font-size: 11px; }
            .glossary-bar { margin-top: 8px; padding: 6px 8px; font-size: 10px; }

            .dashboard-selector { gap: 5px; margin: 8px 0 6px; }
            .dashboard-btn { min-height: 26px; padding: 5px 9px; font-size: 11px; border-radius: 7px; }

            .card { padding: 8px; margin-bottom: 6px; border-radius: 8px; }
            .section-title { font-size: 18px; padding: 6px 8px; margin-bottom: 6px; border-radius: 7px; }
            .card h4 { font-size: 13px; padding: 5px 7px; margin-bottom: 4px; }

            .muted { font-size: 10px; line-height: 1.2; }
            .row { gap: 5px; }
            .btn { min-height: 24px; padding: 4px 8px; font-size: 10px; }

            .form-grid, .form-grid-2, .form-grid-3 { gap: 5px; margin-bottom: 5px; }
            input, select, textarea { padding: 5px 7px; font-size: 11px; border-radius: 7px; }
            textarea { min-height: 54px; }
            .auto-labeled-control { margin-top: 12px; }
            .auto-field-label { font-size: 10px; }

            .data-table { font-size: 10px; }
            .data-table thead th { padding: 5px 6px; }
            .data-table tbody td { padding: 5px 6px; }

            .pagination-bar { margin-top: 6px; }

            .details-overlay { padding: 4px; }
            .details-modal { width: min(1440px, 99.5vw); max-height: 98.5vh; padding: 8px; border-radius: 8px; }
            .details-head { gap: 6px; }
            .details-body { margin-top: 4px; }
            .details-section { padding: 6px; margin-bottom: 6px; border-radius: 7px; }
            .details-subtitle { font-size: 11px; margin-bottom: 4px; }
            .details-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 6px; }
            .details-label { font-size: 9px; }
            .details-value { font-size: 11px; min-height: 16px; }

            .kpi { font-size: 26px; }
            .kpi-card { padding: 6px 8px; border-radius: 8px; }
            .kpi-label, .kpi-sub { font-size: 10px; margin-bottom: 3px; }
        }

