/* ============================================
   GIS SiPS - Modern GIS Dashboard
   Inspired by PlainGIS Timber UI
   ============================================ */

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #2d6a4f;
    --color-primary-light: #52b788;
    --color-primary-lighter: #95d5b2;
    --color-primary-dark: #1b4332;
    --color-accent: #e9c46a;
    --color-danger: #e63946;
    --color-bg: #f0f7f4;
    --color-surface: #ffffff;
    --color-text: #1b1b1b;
    --color-text-secondary: #6b7280;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.15);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        sans-serif;
    --navbar-height: 52px;
}

body {
    font-family: var(--font);
    height: 100vh;
    overflow: hidden;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === NAVBAR === */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 2000;
    box-shadow: var(--shadow-sm);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.3px;
}

.nav-title-accent {
    color: var(--color-primary);
}

.nav-separator {
    width: 1px;
    height: 24px;
    background: var(--color-border);
}

.nav-subtitle {
    font-size: 13px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Label Blok */
.blok-label {
    background: transparent;
    border: none;
    box-shadow: none;
    color: #000000;
    font-weight: 700;
    /* Ukuran font dinamis berdasarkan zoom level */
    font-size: calc(var(--map-zoom, 15) * 0.8px);
    text-shadow: 
        -1.5px -1.5px 0 #fff,  
         1.5px -1.5px 0 #fff,
        -1.5px  1.5px 0 #fff,
         1.5px  1.5px 0 #fff,
         0px 0px 3px rgba(255,255,255,0.8);
    white-space: nowrap;
    text-align: center;
    pointer-events: none;
    z-index: 1000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: font-size 0.15s ease-out, opacity 0.15s ease-out;
}

/* Sembunyikan label saat zoom level terlalu jauh (low zoom) agar tidak tabrakan/menumpuk */
.map-zoom-low .blok-label {
    display: none !important;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: var(--transition);
}

.nav-btn:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

.nav-btn .material-symbols-rounded {
    font-size: 22px;
}

/* === MAIN CONTENT === */
#main-content {
    position: relative;
    height: calc(100vh - var(--navbar-height));
    margin-top: var(--navbar-height);
}

/* === MAP === */
#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* === LEFT TOOLBAR === */
#left-toolbar {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 6px;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
}

.toolbar-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: var(--transition);
    position: relative;
}

.toolbar-btn:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

.toolbar-btn.active {
    background: var(--color-primary);
    color: white;
}

.toolbar-btn .material-symbols-rounded {
    font-size: 22px;
}

/* === TOOLBAR PANELS (Layer/Basemap) === */
.toolbar-panel {
    position: absolute;
    top: 16px;
    left: 72px;
    z-index: 1100;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 220px;
    max-width: 280px;
    overflow: hidden;
    animation: panelSlideIn 0.2s ease-out;
    pointer-events: auto;
}

.toolbar-panel.hidden {
    display: none;
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toolbar-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.toolbar-panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.panel-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: var(--transition);
}

.panel-close:hover {
    background: #fee2e2;
    color: var(--color-danger);
}

.panel-close .material-symbols-rounded {
    font-size: 18px;
}

.toolbar-panel-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Basemap Options */
.basemap-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px;
}

.basemap-option {
    cursor: pointer;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid transparent;
    transition: var(--transition);
    text-align: center;
}

.basemap-option:hover {
    border-color: var(--color-primary-light);
}

.basemap-option.active {
    border-color: var(--color-primary);
}

.basemap-preview {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-sm);
}

.basemap-option span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary);
    padding: 6px 0;
}

.basemap-option.active span {
    color: var(--color-primary);
}

/* Layer List */
.layer-list {
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.layer-empty {
    font-size: 12px;
    color: var(--color-text-secondary);
    text-align: center;
    padding: 20px 12px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--color-text);
}

.layer-item:hover {
    background: var(--color-bg);
}

.layer-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: #d1d5db;
    border-radius: 10px;
    transition: var(--transition);
    flex-shrink: 0;
}

.layer-toggle.on {
    background: var(--color-primary);
}

.layer-toggle::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.layer-toggle.on::after {
    left: 18px;
}

.layer-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Layer list scrollbar */
.layer-list::-webkit-scrollbar {
    width: 4px;
}

.layer-list::-webkit-scrollbar-track {
    background: transparent;
}

.layer-list::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

/* === RIGHT SIDEBAR (Filter & Data Panel) === */
#sidebar {
    position: absolute;
    top: 16px;
    left: 72px;
    bottom: 90px;
    width: 360px;
    z-index: 1100;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sidebarSlideIn 0.3s ease-out;
    transition: var(--transition);
    pointer-events: auto;
}

#sidebar.sidebar-hidden {
    display: none;
}

@keyframes sidebarSlideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.sidebar-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.sidebar-subtitle {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

/* === FILTER CARDS === */
.filter-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    overflow: hidden;
    transition: var(--transition);
}

.filter-card:hover {
    border-color: var(--color-border);
}

.filter-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-card-header:hover {
    background: var(--color-bg);
}

.filter-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.filter-card-icon {
    font-size: 18px;
    color: var(--color-primary);
}

.filter-arrow {
    font-size: 18px;
    color: var(--color-text-secondary);
    transition: transform 0.3s ease;
}

.filter-arrow.collapsed {
    transform: rotate(180deg);
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: var(--color-primary);
    color: white;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
}

.filter-card-body {
    padding: 0 14px 14px;
    transition: all 0.3s ease;
    max-height: 600px;
    overflow: hidden;
    opacity: 1;
}

.filter-card-body.collapsed {
    padding: 0 14px;
    max-height: 0;
    opacity: 0;
}

.legend-body {
    padding-top: 0 !important;
}

/* === FORM ELEMENTS === */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-surface);
    transition: var(--transition);
    appearance: auto;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* === BUTTONS === */
.btn-load {
    width: 100%;
    padding: 11px 16px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    font-family: var(--font);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
}

.btn-load .material-symbols-rounded {
    font-size: 18px;
}

.btn-load:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(45, 106, 79, 0.3);
}

.btn-load:active:not(:disabled) {
    transform: translateY(0);
}

.btn-load:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-reset {
    width: 100%;
    padding: 9px 14px;
    background: transparent;
    color: var(--color-danger);
    border: 1.5px solid var(--color-danger);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 12px;
    font-family: var(--font);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-reset .material-symbols-rounded {
    font-size: 16px;
}

.btn-reset:hover {
    background: var(--color-danger);
    color: white;
    transform: translateY(-1px);
}

/* === LEGEND === */
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

/* === DATA LIST === */
.data-list-section {
    margin-top: 6px;
}

.data-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
}

.data-list-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.data-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    background: var(--color-bg);
    color: var(--color-primary);
    padding: 0 8px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
}

/* TPH Items */
.tph-item {
    padding: 12px 14px;
    margin: 0 6px 6px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    background: var(--color-surface);
}

.tph-item:hover {
    background: var(--color-bg);
    border-color: var(--color-primary-lighter);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.tph-item.active {
    background: #f0fdf4;
    border-color: var(--color-primary-light);
    box-shadow: 0 2px 8px rgba(45, 106, 79, 0.15);
}

.tph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.tph-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
}

.tph-badge {
    background: var(--color-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.tph-details {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.tph-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--color-text-secondary);
}

.tph-output {
    display: inline-block;
    margin-top: 6px;
    font-weight: 700;
    font-size: 13px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
}

/* === STATS BOX === */
.stats-box {
    position: absolute;
    bottom: 46px;
    right: 16px;
    z-index: 1100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.stats-date-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-align: center;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--color-border);
    margin-bottom: 2px;
}
.stats-date-header:empty {
    display: none;
}

.stats-chips-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.stats-chip {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-chip-icon {
    color: var(--color-primary);
    font-size: 20px;
}

.stats-chip-content {
    display: flex;
    flex-direction: column;
}

.stats-chip-label {
    font-size: 10px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.stats-chip-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.stats-divider {
    width: 1px;
    height: 30px;
    background: var(--color-border);
}

.stats-status-breakdown {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stats-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.stats-status-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.stats-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.stats-status-values {
    font-weight: 700;
    color: var(--color-text);
}

/* === LOADING === */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: var(--color-text-secondary);
    font-size: 13px;
}

.spinner {
    border: 3px solid var(--color-border);
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Popup Image */
.popup-image-container {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(
        135deg,
        var(--color-primary) 0%,
        var(--color-primary-light) 100%
    );
}

.popup-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.popup-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
    z-index: 5;
}

.popup-header {
    font-size: 17px;
    font-weight: 700;
    color: white;
    margin: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
}

.popup-header .data-counter {
    font-size: 14px;
    color: var(--color-primary-lighter);
    font-weight: 600;
}

.popup-subheader {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.popup-body {
    padding: 16px;
    max-height: 380px;
    overflow-y: auto;
}

.popup-body::-webkit-scrollbar {
    width: 4px;
}

.popup-body::-webkit-scrollbar-track {
    background: transparent;
}

.popup-body::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

/* Popup Stats Grid */
.popup-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.popup-stat-card {
    background: var(--color-bg);
    padding: 10px;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--color-border-light);
    transition: var(--transition);
}

.popup-stat-card:hover {
    border-color: var(--color-primary-lighter);
    transform: translateY(-1px);
}

.popup-stat-icon {
    font-size: 20px;
    margin-bottom: 4px;
}
.popup-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}
.popup-stat-label {
    font-size: 9px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 2px;
}

/* Popup Section */
.popup-section {
    margin-bottom: 16px;
}

.popup-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1.5px solid var(--color-border-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

.popup-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.popup-info-grid.compact {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.popup-info-item {
    background: var(--color-bg);
    padding: 10px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
    transition: var(--transition);
}

.popup-info-grid.compact .popup-info-item {
    padding: 6px;
    border-left-width: 2px;
}

.popup-info-item:hover {
    background: var(--color-border-light);
    transform: translateY(-1px);
}

.popup-info-label {
    font-size: 10px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 3px;
    font-weight: 600;
}

.popup-info-grid.compact .popup-info-label {
    font-size: 8.5px;
    margin-bottom: 1px;
    letter-spacing: 0.2px;
}

.popup-info-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.popup-info-grid.compact .popup-info-value {
    font-size: 11px;
}

/* Popup No Image */
.popup-no-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(
        135deg,
        var(--color-primary) 0%,
        var(--color-primary-light) 100%
    );
    color: white;
}

.popup-no-image span {
    font-size: 56px;
    margin-bottom: 8px;
    opacity: 0.8;
}

.popup-no-image-text {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.85;
}

/* === COMPACT INFO POPUP (For Blok, Jalan, TPH, Ancak) === */
.info-compact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    padding: 14px 16px;
}
.info-compact-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.info-compact-label {
    font-size: 9px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.info-compact-value {
    font-size: 12px;
    font-weight: 800;
    color: #1e293b;
    text-align: right;
}

/* Compact Popup Header */
.info-compact-header {
    background: rgba(0, 0, 0, 0.05);
    padding: 8px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.info-compact-title {
    font-size: 10px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Popup Compact Table */
.popup-compact-table {
    display: grid;
    grid-template-columns: max-content auto max-content auto;
    gap: 6px 12px;
    background: var(--color-bg);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    align-items: center;
}
.popup-compact-table .label {
    color: var(--color-text-secondary);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}
.popup-compact-table .value {
    color: var(--color-text);
    font-size: 12px;
    font-weight: 700;
    text-align: right;
}

/* Popup Info List */
.popup-info-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.popup-info-list .row {
    display: grid;
    grid-template-columns: 80px 10px auto;
    align-items: baseline;
}

.popup-info-list .label {
    font-weight: 500;
    color: var(--color-text-secondary);
}

.popup-info-list .sep {
    text-align: center;
    color: #9ca3af;
}

.popup-info-list .value {
    color: var(--color-text);
    font-weight: 600;
    white-space: nowrap;
}

/* === SLIDESHOW STYLES === */
.popup-slideshow-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.popup-image-slideshow {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: #111;
}

.popup-slide-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    pointer-events: none;
}

.popup-slide-image.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
}

.popup-slide-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.popup-slide-image .popup-no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: #2a2a2a;
    color: #888;
    gap: 8px;
    font-size: 13px;
}

.popup-slide-image .popup-no-image.active {
    display: flex;
}

.popup-data-slideshow {
    position: relative;
    width: 100%;
    min-height: 180px;
    background: white;
    overflow: hidden;
}

.popup-data-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    opacity: 0;
    transform: translateX(16px);
    transition: all 0.4s ease-in-out;
    pointer-events: none;
    padding: 16px;
    box-sizing: border-box;
}

.popup-data-slide.active {
    position: relative;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    animation: fadeInSlide 0.4s ease-out;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slideshow Navigation */
.slideshow-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.45);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
    backdrop-filter: blur(4px);
}

.slideshow-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.05);
}

.slideshow-btn.prev {
    left: 8px;
}
.slideshow-btn.next {
    right: 8px;
}

.slideshow-counter {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    padding: 4px 10px;
    border-radius: 18px;
    font-size: 11px;
    font-weight: 600;
    z-index: 10;
    backdrop-filter: blur(4px);
}

.slideshow-counter .current-slide {
    color: var(--color-primary-lighter);
    font-size: 13px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    #sidebar {
        width: calc(100% - 32px);
        right: 16px;
        left: 16px;
        bottom: 80px;
    }

    .stats-box {
        left: 16px;
        right: 16px;
        bottom: 12px;
        justify-content: center;
    }

    .popup-image-slideshow {
        height: 180px;
    }

    .slideshow-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .popup-info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .nav-subtitle,
    .nav-separator {
        display: none;
    }

    #sidebar {
        width: calc(100% - 16px);
        right: 8px;
        left: 8px;
    }
}

/* === PRINT === */
@media print {
    .slideshow-btn,
    .slideshow-counter {
        display: none !important;
    }
    .popup-slide-image,
    .popup-no-image {
        opacity: 1 !important;
        position: relative !important;
    }
    .popup-data-slide {
        opacity: 1 !important;
        position: relative !important;
        transform: none !important;
    }
}

/* === ACCESSIBILITY === */
.slideshow-btn:focus {
    outline: 3px solid var(--color-primary-lighter);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .popup-slide-image,
    .popup-no-image,
    .popup-data-slide,
    .slideshow-btn {
        transition: none;
    }
}

/* Hidden utility classes */
.toolbar-panel.hidden {
    display: none;
}

#sidebar.sidebar-hidden {
    display: none;
}

#statsBox.stats-hidden {
    display: none;
}

/* === LIGHTBOX MODAL === */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#lightboxImage {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    background: #000;
}

.lightbox-caption {
    color: white;
    margin-top: 15px;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.lightbox-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-btn.prev {
    left: 20px;
}

.lightbox-btn.next {
    right: 20px;
}

/* === AI DETECTION BUTTON === */
.ai-detect-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 15;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.ai-detect-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-detect-btn:hover {
    transform: scale(1.12);
    box-shadow:
        0 4px 16px rgba(102, 126, 234, 0.45),
        0 0 0 2px rgba(102, 126, 234, 0.3);
}

.ai-detect-btn:hover::before {
    opacity: 1;
}

.ai-detect-btn:active {
    transform: scale(1);
}

.ai-detect-btn .ai-icon-default {
    font-size: 20px;
    color: #667eea;
    position: relative;
    z-index: 1;
    transition: color 0.3s ease;
    font-variation-settings: "FILL" 1;
}

.ai-detect-btn:hover .ai-icon-default {
    color: #fff;
}

/* AI Spinner (loading state) */
.ai-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(102, 126, 234, 0.25);
    border-top: 2.5px solid #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: relative;
    z-index: 1;
}

.ai-detect-btn.loading {
    pointer-events: none;
    background: rgba(255, 255, 255, 0.95);
    animation: ai-pulse 1.5s ease-in-out infinite;
}

.ai-detect-btn.loading .ai-icon-default {
    display: none;
}

.ai-detect-btn.loading .ai-spinner {
    display: block;
}

.ai-detect-btn.loading::before {
    opacity: 0;
}

@keyframes ai-pulse {
    0%,
    100% {
        box-shadow:
            0 2px 10px rgba(102, 126, 234, 0.3),
            0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow:
            0 2px 10px rgba(102, 126, 234, 0.3),
            0 0 0 8px rgba(102, 126, 234, 0);
    }
}

/* AI Detection Result Badge */
.ai-detect-result {
    position: absolute;
    top: 10px;
    left: 54px;
    z-index: 15;
    display: flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 6px 14px 6px 10px;
    border-radius: 20px;
    color: white;
    font-weight: 700;
    box-shadow:
        0 4px 14px rgba(102, 126, 234, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
}

.ai-detect-result.ai-animate-in {
    animation: aiResultSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes aiResultSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-10px) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.ai-result-icon {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    font-variation-settings: "FILL" 1;
}

.ai-result-count {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.ai-result-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ai-result-clear-btn {
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    pointer-events: auto; /* Agar bisa diklik meskipun badge-nya overlay */
}

.ai-result-clear-btn:hover {
    color: #ff8080;
    transform: scale(1.1);
}

.ai-result-clear-btn .material-symbols-rounded {
    font-size: 18px;
}

/* Lightbox Specific AI Styles */
.lightbox-ai-btn {
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
}

.lightbox-ai-btn .ai-icon-default {
    font-size: 24px;
}

.lightbox-ai-result {
    top: 20px;
    left: 75px;
    height: 44px;
    padding: 0 18px 0 12px;
}

.lightbox-ai-result .ai-result-count {
    font-size: 18px;
}

/* ============================================
   DASHBOARD STYLES
   ============================================ */

/* Nav Tabs */
.nav-tabs {
    display: flex;
    align-items: center;
    gap: 3px;
    background: var(--color-bg);
    padding: 3px;
    border-radius: var(--radius-md);
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-family: var(--font);
    transition: var(--transition);
    white-space: nowrap;
}
.nav-tab .material-symbols-rounded {
    font-size: 17px;
}
.nav-tab:hover {
    background: var(--color-surface);
    color: var(--color-text);
}
.nav-tab.active {
    background: var(--color-surface);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

/* Dashboard View */
#dashboard-view {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    background: var(--color-bg);
    padding: 20px 24px;
    z-index: 500;
}
#dashboard-view::-webkit-scrollbar {
    width: 6px;
}
#dashboard-view::-webkit-scrollbar-track {
    background: transparent;
}
#dashboard-view::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

/* Filter Topbar */
.db-topbar {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
}
.db-filter-group {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.db-filter-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.db-filter-item label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.db-filter-item select,
.db-filter-item input[type="date"] {
    padding: 8px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-surface);
    transition: var(--transition);
    min-width: 140px;
}
.db-filter-item select:focus,
.db-filter-item input[type="date"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}
.db-load-btn {
    height: 37px;
    padding: 0 16px;
}

/* KPI Grid */
.db-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
.db-kpi-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.db-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.db-kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.db-kpi-card.green::before {
    background: linear-gradient(90deg, #2d6a4f, #52b788);
}
.db-kpi-card.blue::before {
    background: linear-gradient(90deg, #1d4ed8, #60a5fa);
}
.db-kpi-card.purple::before {
    background: linear-gradient(90deg, #6d28d9, #a78bfa);
}
.db-kpi-card.yellow::before {
    background: linear-gradient(90deg, #b45309, #fcd34d);
}
.db-kpi-card.red::before {
    background: linear-gradient(90deg, #b91c1c, #fca5a5);
}

.db-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.db-kpi-icon .material-symbols-rounded {
    font-size: 22px;
}
.db-kpi-card.green .db-kpi-icon {
    background: #f0fdf4;
    color: var(--color-primary);
}
.db-kpi-card.blue .db-kpi-icon {
    background: #eff6ff;
    color: #3b82f6;
}
.db-kpi-card.purple.db-kpi-icon {
    background: #f5f3ff;
    color: #7c3aed;
}
.db-kpi-card.purple .db-kpi-icon {
    background: #f5f3ff;
    color: #7c3aed;
}
.db-kpi-card.yellow .db-kpi-icon {
    background: #fffbeb;
    color: #d97706;
}
.db-kpi-card.red .db-kpi-icon {
    background: #fef2f2;
    color: #dc2626;
}

.db-kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1;
    margin-bottom: 5px;
    letter-spacing: -1px;
}
.db-kpi-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* Charts */
.db-charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.db-charts-row-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}
.db-chart-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
}
.db-chart-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.db-chart-title .material-symbols-rounded {
    font-size: 18px;
    color: var(--color-primary);
}
.db-chart-canvas-wrapper {
    position: relative;
    height: 230px;
}

/* Table Card */
.db-table-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    overflow: hidden;
    margin-bottom: 24px;
}
.db-table-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.db-table-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
}
.db-table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.db-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.db-search-icon {
    position: absolute;
    left: 10px;
    font-size: 17px;
    color: var(--color-text-secondary);
    pointer-events: none;
}
.db-search-input {
    padding: 7px 12px 7px 34px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-surface);
    width: 260px;
    transition: var(--transition);
}
.db-search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}
.db-btn-export {
    padding: 7px 14px;
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
    white-space: nowrap;
}
.db-btn-export .material-symbols-rounded {
    font-size: 16px;
}
.db-btn-export:hover {
    background: var(--color-primary);
    color: white;
}

.db-table-container {
    overflow-x: auto;
}
.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.db-table thead th {
    padding: 10px 14px;
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: var(--transition);
}
.db-table thead th:hover {
    background: #e8f0ed;
    color: var(--color-primary);
}
.db-table thead th.sort-asc::after {
    content: " ↑";
    color: var(--color-primary);
}
.db-table thead th.sort-desc::after {
    content: " ↓";
    color: var(--color-primary);
}

.db-table tbody tr {
    border-bottom: 1px solid var(--color-border-light);
    transition: background 0.15s;
}
.db-table tbody tr:last-child {
    border-bottom: none;
}
.db-table tbody tr:hover {
    background: #f8fdfb;
}
.db-table tbody td {
    padding: 11px 14px;
    color: var(--color-text);
    white-space: nowrap;
}

/* Status badges */
.db-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.db-status-badge.selesai {
    background: #f0fdf4;
    color: #2d6a4f;
}
.db-status-badge.selisih {
    background: #fffbeb;
    color: #b45309;
}
.db-status-badge.belum {
    background: #fef2f2;
    color: #b91c1c;
}

/* Pagination */
.db-table-pagination {
    padding: 12px 20px;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.db-pagination-info {
    font-size: 12px;
    color: var(--color-text-secondary);
}
.db-pagination-btns {
    display: flex;
    gap: 4px;
    align-items: center;
}
.db-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    color: var(--color-text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.db-page-btn:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.db-page-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}
.db-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Dashboard loading */
.db-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    gap: 12px;
    color: var(--color-text-secondary);
    font-size: 13px;
}

/* Responsive */
@media (max-width: 1280px) {
    .db-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 1024px) {
    .db-charts-row {
        grid-template-columns: 1fr;
    }
    .db-charts-row-equal {
        grid-template-columns: 1fr;
    }
    .db-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 640px) {
    #dashboard-view {
        padding: 12px;
    }
    .db-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .db-search-input {
        width: 160px;
    }
}

/* ============================================
   DASHBOARD DETAIL MODAL — REDESIGNED
   ============================================ */

/* ══ New Card Field styles ══ */
.dm-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.dm-field-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-text-secondary);
}
.dm-field-value {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
    word-break: break-word;
}
.dm-field-value.mono {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    letter-spacing: 0.5px;
    color: var(--color-primary-dark);
}
.dm-field-value.big {
    font-size: 22px;
    font-weight: 800;
    color: var(--color-primary-dark);
    letter-spacing: -0.5px;
}

/* ══ Section Card ══ */
.dm-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: 12px;
    overflow: hidden;
}
.dm-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border-light);
}
.dm-card-header .material-symbols-rounded {
    font-size: 16px;
    color: var(--color-primary);
}
.dm-card-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-secondary);
}
.dm-card-body {
    padding: 14px;
    display: grid;
    gap: 12px 16px;
}
.dm-card-body.col2 { grid-template-columns: repeat(2, 1fr); }
.dm-card-body.col3 { grid-template-columns: repeat(3, 1fr); }
.dm-card-body.col4 { grid-template-columns: repeat(4, 1fr); }

/* ══ Harvest Quality Card ══ */
.dm-quality-grid {
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.dm-quality-item {
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    padding: 10px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.dm-quality-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-border);
    border-radius: 2px 2px 0 0;
}
.dm-quality-item:hover {
    background: #f0fdf4;
    border-color: var(--color-primary-lighter);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45,106,79,0.08);
}
.dm-quality-item:hover::before {
    background: var(--color-primary);
}
/* OUTPUT - spans 2 cols, highlighted */
.dm-quality-item.output-item {
    grid-column: span 2;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: #86efac;
    padding: 12px 14px;
}
.dm-quality-item.output-item::before {
    background: var(--color-primary);
    height: 3px;
}
.dm-quality-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}
.dm-quality-value {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1;
}
.dm-quality-item.output-item .dm-quality-label {
    font-size: 10px;
    color: var(--color-primary);
}
.dm-quality-item.output-item .dm-quality-value {
    font-size: 28px;
    color: var(--color-primary-dark);
    letter-spacing: -1px;
}
/* Color coding */
.dm-quality-item.warn-item::before { background: #f59e0b; }
.dm-quality-item.warn-item:hover { background: #fffbeb; border-color: #fcd34d; }
.dm-quality-item.danger-item::before { background: #ef4444; }
.dm-quality-item.danger-item:hover { background: #fef2f2; border-color: #fca5a5; }

/* ══ Legacy dm-sec-hdr / dm-row kept for compatibility ══ */
.dm-sec-hdr, .dm-row, .dm-lbl, .dm-val, .dm-big { display: none; }

.detail-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: detailFadeIn 0.18s ease;
}

@keyframes detailFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.detail-modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 1100px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255,255,255,0.05);
    animation: detailSlideUp 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes detailSlideUp {
    from {
        transform: translateY(32px) scale(0.98);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Header */
.detail-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
    background: linear-gradient(to right, #f8fffe, var(--color-surface));
}

.detail-modal-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--color-text);
    font-family: "Courier New", monospace;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-modal-close {
    width: 34px;
    height: 34px;
    border: none;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: var(--transition);
    flex-shrink: 0;
}
.detail-modal-close:hover {
    background: #fee2e2;
    color: var(--color-danger);
}
.detail-modal-close .material-symbols-rounded {
    font-size: 20px;
}

/* Body: NEW vertical layout — photo banner + scrollable info */
.detail-modal-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Photo panel — horizontal banner strip */
.detail-photo-panel {
    border-bottom: 1px solid #1e293b;
    display: flex;
    flex-direction: row;
    background: #0f172a;
    height: 180px;
    flex-shrink: 0;
    overflow: hidden;
}

.detail-photo-wrapper {
    width: 240px;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    border-right: 1px solid #1e293b;
}

.detail-photo-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}
.detail-photo-wrapper:hover img {
    transform: scale(1.04);
}

.detail-photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #475569;
    padding: 16px;
    text-align: center;
    width: 100%;
    height: 100%;
}
.detail-photo-placeholder .material-symbols-rounded {
    font-size: 40px;
    opacity: 0.4;
}
.detail-photo-placeholder p {
    font-size: 11px;
    opacity: 0.6;
}

.detail-photo-zoom-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 10px;
    padding: 3px 9px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    white-space: nowrap;
}
.detail-photo-zoom-hint .material-symbols-rounded {
    font-size: 13px;
}

/* Photo summary panel beside image */
.detail-photo-caption {
    flex: 1;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.5;
}
.detail-photo-caption strong {
    color: #e2e8f0;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* Info panel */
.detail-info-panel {
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}
.detail-info-panel::-webkit-scrollbar {
    width: 4px;
}
.detail-info-panel::-webkit-scrollbar-track {
    background: transparent;
}
.detail-info-panel::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

/* Sections */
.detail-section-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding-bottom: 6px;
    border-bottom: 1.5px solid var(--color-border-light);
}
.detail-section-title .material-symbols-rounded {
    font-size: 15px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.detail-grid.col3 {
    grid-template-columns: repeat(3, 1fr);
}

.detail-item {
    background: var(--color-bg);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-border);
    transition: var(--transition);
}
.detail-item:hover {
    background: var(--color-border-light);
}
.detail-item.hl {
    border-left-color: var(--color-primary);
}
.detail-item.warn {
    border-left-color: var(--color-accent);
}
.detail-item.bad {
    border-left-color: var(--color-danger);
}

.detail-item-label {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}
.detail-item-value {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text);
    word-break: break-word;
    line-height: 1.3;
}
.detail-item-value.mono {
    font-family: "Courier New", monospace;
    font-size: 12px;
    letter-spacing: 0.3px;
}
.detail-item-value.big {
    font-size: 16px;
    color: var(--color-primary-dark);
}

/* Compact Detail Table */
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 5px;
}
.detail-table th, .detail-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}
.detail-table th {
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}
.detail-table tr:last-child td {
    border-bottom: none;
}
.detail-table td {
    color: var(--color-text);
    font-weight: 600;
}
.detail-table td.label-cell {
    color: var(--color-text-secondary);
    font-weight: 500;
    width: 40%;
}
.detail-table .val-warn { color: var(--color-accent) !important; }
.detail-table .val-bad { color: var(--color-danger) !important; }

/* Make table rows look clickable */
.db-table tbody tr {
    cursor: pointer;
}
.db-table tbody tr:hover td:first-child {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Lightbox for detail photo */
.detail-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: detailFadeIn 0.15s ease;
}
.detail-lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
    cursor: default;
}
.detail-lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.detail-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}
.detail-lightbox-close .material-symbols-rounded {
    font-size: 22px;
}

/* Responsive */
@media (max-width: 820px) {
    .detail-modal-overlay {
        padding: 12px;
    }
    .detail-photo-panel {
        height: 140px;
    }
    .detail-photo-wrapper {
        width: 160px;
    }
    .dm-quality-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .dm-quality-item.output-item {
        grid-column: span 2;
    }
    .dm-card-body.col3 { grid-template-columns: repeat(2, 1fr); }
    .dm-card-body.col4 { grid-template-columns: repeat(2, 1fr); }
}

/* ===== POPUP Z-INDEX FIX ===== */

/* Popup data panen (custom-popup) harus di atas segalanya */
.maplibregl-popup.custom-popup {
    z-index: 999 !important;
}

/* Popup layer biasa (blok, jalan, TPH, ancak) */
.maplibregl-popup:not(.custom-popup) {
    z-index: 500 !important;
}

/* Marker panen di atas layer polygon tapi di bawah popup */
.maplibregl-marker {
    z-index: 100 !important;
}

/* Pastikan canvas peta di layer paling bawah */
.maplibregl-canvas-container {
    z-index: 1 !important;
}

/* ===== POPUP PANEN REDESIGN ===== */
.maplibregl-popup.custom-popup .maplibregl-popup-content {
    padding: 0 !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18) !important;
    width: 320px !important;
    max-width: 320px !important;
}

.maplibregl-popup.custom-popup .maplibregl-popup-tip {
    display: block !important;
    fill: #ffffff !important;
}

.maplibregl-popup.custom-popup .maplibregl-popup-close-button {
    display: none !important;
}

.maplibregl-popup.info-compact-wrapper {
    z-index: 600 !important;
}

.maplibregl-popup.info-compact-wrapper .maplibregl-popup-content {
    padding: 0 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    background: #f1f7f5 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12) !important;
    min-width: 260px !important;
    max-width: 320px !important;
}

.maplibregl-popup.info-compact-wrapper .maplibregl-popup-tip {
    fill: #f1f7f5 !important;
}

.maplibregl-popup.info-compact-wrapper .maplibregl-popup-close-button {
    background-color: white !important;
    color: #1b1b1b !important;
    border-radius: 50% !important;
    width: 24px !important;
    height: 24px !important;
    line-height: 24px !important;
    text-align: center !important;
    top: 6px !important;
    right: 6px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18) !important;
    padding: 0 !important;
}

.maplibregl-popup.info-compact-wrapper .maplibregl-popup-close-button:hover {
    background-color: #f8fafc !important;
    transform: scale(1.05) !important;
}

/* Tombol X custom */
.popup-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    z-index: 10;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    line-height: 1;
}

.popup-close-btn:hover {
    background: #f0f0f0;
}

/* Wrapper utama */
.popup-slideshow-wrapper {
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}

/* Area gambar */
.popup-image-slideshow {
    position: relative;
    width: 100%;
    height: 170px;
    background: #1a1a1a;
    overflow: hidden;
}

.popup-slide-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    pointer-events: none;
}

.popup-slide-image.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
}

.popup-slide-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.popup-slide-image .popup-no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: #2a2a2a;
    color: #888;
    gap: 8px;
    font-size: 13px;
}

.popup-slide-image .popup-no-image.active {
    display: flex;
}

.popup-no-image.active {
    display: flex !important;
}

/* Overlay teks di atas gambar */
.popup-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.62));
}

.popup-header {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.popup-subheader {
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    margin-top: 2px;
}

.data-counter {
    color: #4CAF50;
    font-weight: 600;
}

/* Tombol navigasi slideshow */
.slideshow-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    padding: 0;
}

.slideshow-btn.prev { left: 10px; }
.slideshow-btn.next { right: 10px; }

.slideshow-counter {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 5px 11px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
}

/* Area data */
.popup-data-slideshow {
    padding: 0;
}

.popup-data-slide {
    display: none;
    padding: 10px 12px 12px;
}

.popup-data-slide.active {
    display: block;
}

.popup-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.popup-doc-title {
    font-size: 11px;
    font-weight: 600;
    color: #222;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f2f2f2;
    font-family: monospace;
}

/* Tabel data 2 kolom */
.popup-compact-table {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    align-items: start;
}

.popup-compact-table .col {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.popup-compact-table .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
    line-height: 1.15;
    min-height: 18px;
    font-size: 11px;
}

.popup-compact-table .col:first-child .row {
    padding-right: 10px;
}

.popup-compact-table .label {
    color: #777;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.popup-compact-table .value {
    font-weight: 700;
    color: #181818;
    font-size: 11px;
}

.popup-compact-table .value.highlight {
    color: #27AE60;
    font-size: 12px;
}

/* Status icon */
.status-icon-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Override tombol close MapLibre jadi bulat seperti screenshot */
.maplibregl-popup.custom-popup .maplibregl-popup-close-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.95) !important;
    color: #333 !important;
    font-size: 18px !important;
    font-weight: bold !important;
    top: 8px !important;
    right: 8px !important;
    border: none !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2) !important;
    z-index: 10 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.maplibregl-popup.custom-popup .maplibregl-popup-close-button:hover {
    background: #f0f0f0 !important;
}

/* === CUSTOM MAP ATTRIBUTION === */
.maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(4px);
    border-radius: 6px !important;
    padding: 4px 10px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.maplibregl-ctrl-attrib-inner {
    font-size: 11px;
    font-weight: 500;
    color: #444;
    white-space: nowrap;
}
