/* ─── Animations ─────────────────────────────────────────── */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ─── Base ───────────────────────────────────────────────── */

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    color: #292524;
    background-color: #fafaf9;
    margin: 0;
}

/* ─── Main Layout ────────────────────────────────────────── */

.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

/* ─── Filter Bar ─────────────────────────────────────────── */

.filter-bar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(24px);
    border-bottom: 1px solid #f5f5f4;
    flex-shrink: 0;
    z-index: 40;
}

.filter-row {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .filter-row {
        padding: 8px 20px;
        flex-direction: row;
        align-items: center;
    }
}

/* ─── Location Group ─────────────────────────────────────── */

.location-group {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    flex-shrink: 0;
    padding-bottom: 4px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.location-group::-webkit-scrollbar {
    display: none;
}

@media (min-width: 768px) {
    .location-group {
        padding-bottom: 0;
    }
}

.location-pill {
    display: flex;
    align-items: center;
    height: 34px;
    background: white;
    border-radius: 9999px;
    padding: 0 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(231, 229, 228, 0.8);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.location-pill>*+* {
    border-left: 1px solid #f5f5f4;
}

.location-icon {
    display: flex;
    align-items: center;
    padding: 0 10px;
    flex-shrink: 0;
    background: rgba(250, 250, 249, 0.5);
    height: 100%;
}

.location-marker-icon {
    color: #10b981;
    font-size: 12px;
}

.location-select {
    padding: 4px 8px;
    font-size: 15px;
    background: transparent;
    border: none;
    outline: none;
    font-weight: 700;
    color: #57534e;
    -webkit-appearance: none;
    appearance: none;
    transition: color 200ms;
}

.region-select {
    width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.select-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 150px;
}

.province-select,
.district-select {
    padding: 4px 20px 4px 10px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.province-select:hover,
.district-select:hover {
    color: #059669;
}

.province-select:focus,
.district-select:focus {
    background: #fafaf9;
}

.district-select:disabled {
    opacity: 0.4;
}

.select-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 9px;
    color: black;
}

/* ─── Buttons ────────────────────────────────────────────── */

.back-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 9999px;
    background: #f5f5f4;
    color: #57534e;
    border: 1px solid rgba(231, 229, 228, 0.5);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 200ms;
}

.back-btn:hover {
    background: #e7e5e4;
}

.back-btn-icon {
    font-size: 10px;
}

.reset-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9999px;
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid rgba(254, 226, 226, 0.5);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background-color 200ms;
}

.reset-btn:hover {
    background: #fee2e2;
}

/* ─── Crop Filters ───────────────────────────────────────── */

.crop-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    width: 100%;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.crop-filters::-webkit-scrollbar {
    display: none;
}

@media (min-width: 768px) {
    .crop-filters {
        padding-bottom: 0;
        width: auto;
        justify-content: flex-end;
    }
}

/* ─── Layout Grid ────────────────────────────────────────── */

.layout-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

@media (min-width: 768px) {
    .layout-grid {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
    }
}

/* ─── Map Section ────────────────────────────────────────── */

.map-section {
    height: 45vh;
    position: relative;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .map-section {
        height: 100%;
        grid-column: span 6;
    }
}

.map-view {
    position: absolute;
    inset: 0;
    z-index: 0;
}

/* ─── Radius Panel ───────────────────────────────────────── */

.radius-wrapper {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
}

@media (min-width: 768px) {
    .radius-wrapper {
        width: auto;
    }
}

.radius-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    min-width: 280px;
}

.rad-minimize-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f4;
    border: none;
    border-left: 1px solid #e7e5e4;
    border-bottom: 1px solid #e7e5e4;
    color: #57534e;
    cursor: pointer;
    transition: all 200ms;
    z-index: 10;
}

.rad-minimize-btn:hover {
    background: #e7e5e4;
}

.rad-minimize-icon {
    font-size: 11px;
    transition: transform 300ms;
}

.radius-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    flex-shrink: 0;
    padding-right: 48px;
}

.radius-icon-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.radius-icon-bg {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: rgba(16, 185, 129, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.radius-crosshairs {
    color: #059669;
    font-size: 11px;
}

.radius-label {
    font-size: 12px;
    font-weight: 600;
    color: #78716c;
    white-space: nowrap;
}

/* ─── Toggle ─────────────────────────────────────────────── */

.toggle-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.toggle-track {
    width: 32px;
    height: 18px;
    background: #e7e5e4;
    border-radius: 9999px;
    position: relative;
    transition: background-color 200ms;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 200ms;
}

.toggle-input:checked+.toggle-track {
    background: #10b981;
}

.toggle-input:focus+.toggle-track {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.toggle-input:checked+.toggle-track::after {
    transform: translateX(14px);
}

/* ─── Radius Controls ────────────────────────────────────── */

.rad-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    transition: all 300ms;
    width: 100%;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: white;
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid #e7e5e4;
    box-sizing: border-box;
}

.rad-slider {
    width: 100%;
    accent-color: #10b981;
    height: 6px;
    cursor: pointer;
}

.rad-val {
    font-size: 13px;
    font-weight: 700;
    color: #059669;
    width: 48px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.coord-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.coord-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: space-between;
    background: rgba(250, 250, 249, 0.5);
    padding: 4px 8px;
    border-radius: 6px;
}

.coord-label {
    font-size: 11px;
    font-weight: 700;
    color: #a8a29e;
}

.coord-input {
    width: 96px;
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid #e7e5e4;
    border-radius: 4px;
    font-weight: 600;
    color: #44403c;
    background: white;
    outline: none;
    transition: all 200ms;
    text-align: center;
    box-sizing: border-box;
}

.coord-input:focus {
    border-color: #34d399;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

/* ─── Floating Panels ────────────────────────────────────── */

.view-mode-panel {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
}

.metric-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
}

.floating-panel {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 2px 2px 2px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.panel-label {
    font-size: 14px;
}

.panel-select {
    font-size: 12px;
    font-weight: 700;
    color: #57534e;
    background: white;
    border-radius: 10px;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 8px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.metric-img {
    width: 20px;
    height: 20px;
}

.metric-label-text {
    font-size: 12px;
    font-weight: 600;
    color: #57534e;
}

.metric-btn {
    position: relative;
    font-size: 12px;
    font-weight: 700;
    color: #57534e;
    background: white;
    border-radius: 10px;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 8px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric-chevron {
    font-size: 9px;
    opacity: 0.4;
}

.metric-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid #f5f5f4;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 50;
    min-width: 210px;
    padding: 6px 0;
    overflow: hidden;
}

.metric-opt {
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #57534e;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 200ms, color 200ms;
}

.metric-opt:hover {
    background: #ecfdf5;
    color: #047857;
}

.metric-opt-icon {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.orange-bg {
    background: #fff7ed;
}

.orange-icon {
    color: #fb923c;
    font-size: 11px;
}

.green-bg {
    background: #f0fdf4;
}

.green-icon {
    color: #4ade80;
    font-size: 11px;
}

/* ─── Loading Overlay ────────────────────────────────────── */

.map-loading {
    position: absolute;
    inset: 0;
    z-index: 999;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 300ms;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    border: 3px solid #e7e5e4;
    border-top-color: #10b981;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

.loading-text {
    font-size: 12px;
    font-weight: 700;
    color: #78716c;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ─── No Results ─────────────────────────────────────────── */

.no-results-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.no-results-icon {
    font-size: 36px;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.no-results-text {
    color: #64748b;
    font-weight: 700;
    margin: 0;
}

/* ─── Right Panel ────────────────────────────────────────── */

.right-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: rgba(248, 250, 252, 0.5);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (min-width: 768px) {
    .right-panel {
        grid-column: span 6;
        height: 100%;
        padding: 24px;
        gap: 24px;
    }
}

/* ─── Summary Section ────────────────────────────────────── */

.summary-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ─── Summary Card ───────────────────────────────────────── */

.summary-card {
    background: linear-gradient(to bottom right, #1c1917, #292524, #1c1917);
    padding: 20px;
    border-radius: 24px;
    border: 1px solid rgba(68, 64, 60, 0.5);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
    transition: all 300ms;
}

.summary-card:hover {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border-color: #57534e;
}

@media (min-width: 768px) {
    .summary-card {
        padding: 20px;
    }
}

.summary-glow {
    position: absolute;
    top: 0;
    right: 0;
    width: 256px;
    height: 256px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 9999px;
    filter: blur(60px);
    transform: translateY(-50%) translateX(33%);
    pointer-events: none;
    transition: all 500ms;
}

.summary-card:hover .summary-glow {
    background: rgba(16, 185, 129, 0.15);
}

.summary-bg-icon {
    position: absolute;
    right: -15px;
    bottom: -20px;
    opacity: 0.03;
    pointer-events: none;
    transition: all 700ms;
    z-index: 0;
    color: white;
}

.summary-bg-icon i {
    font-size: 141px;
}

.summary-card:hover .summary-bg-icon {
    transform: scale(1.1) rotate(-6deg);
    opacity: 0.05;
}

.summary-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    position: relative;
    z-index: 10;
    width: 100%;
}

@media (min-width: 768px) {
    .summary-content {
        flex-direction: row;
        align-items: flex-end;
    }
}

.summary-left {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.summary-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.sum-header {
    font-size: 12px;
    font-weight: 900;
    color: #34d399;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.summary-total-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.sum-total {
    font-size: 36px;
    font-weight: 900;
    color: white;
    letter-spacing: -0.025em;
}

@media (min-width: 768px) {
    .sum-total {
        font-size: 48px;
    }
}

.summary-unit {
    font-size: 14px;
    font-weight: 700;
    color: #78716c;
}

.summary-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

@media (min-width: 768px) {
    .summary-right {
        flex-direction: column;
        align-items: flex-end;
        padding-left: 8px;
        gap: 0;
    }
}

.view-level-label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

@media (min-width: 768px) {
    .view-level-label {
        justify-content: flex-end;
        margin-bottom: 10px;
        width: 100%;
    }
}

.filter-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(12, 10, 9, 0.4);
    border: 1px solid rgba(68, 64, 60, 0.5);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    padding: 6px 14px;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
}

.filter-stat-text {
    font-size: 11px;
    color: #78716c;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.025em;
}

/* ─── Crop Grid ──────────────────────────────────────────── */

.crop-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

@media (min-width: 768px) {
    .crop-grid {
        grid-template-columns: repeat(auto-fit, minmax(65px, 1fr));
    }
}

.crop-card {
    background: white;
    padding: 12px 6px;
    border-radius: 12px;
    border: 1px solid #e7e5e4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    min-width: 0;
    transition: all 200ms;
    box-sizing: border-box;
}

.crop-card:hover {
    border-color: #a7f3d0;
}

.crop-img {
    width: 20px;
    height: 20px;
    margin-bottom: 6px;
    opacity: 0.9;
}

.crop-icon {
    font-size: 18px;
    margin-bottom: 6px;
    opacity: 0.9;
}

.crop-label {
    font-size: 9px;
    font-weight: 700;
    color: #78716c;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
    text-align: center;
    min-height: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.25;
}

@media (min-width: 1536px) {
    .crop-label {
        font-size: 11px;
    }
}

.crop-label-th {
    font-size: 12px;
    line-height: 1.3;
}

.crop-value-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    justify-content: center;
}

.crop-value {
    font-size: 18px;
    font-weight: 800;
    color: #44403c;
    white-space: nowrap;
}

.crop-unit {
    font-size: 10px;
    font-weight: 700;
    color: #a8a29e;
    white-space: nowrap;
}

/* ─── Chart Section ──────────────────────────────────────── */

.chart-section {
    background: white;
    border-radius: 16px;
    border: 1px solid #e7e5e4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 16px;
    transition: box-shadow 200ms;
}

.chart-section:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

@media (min-width: 768px) {
    .chart-section {
        padding: 24px;
    }
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.chart-title {
    font-size: 14px;
    font-weight: 800;
    color: #292524;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.chart-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bar-chart-count {
    font-size: 11px;
    font-weight: 700;
    color: #a8a29e;
    text-transform: uppercase;
}

.chart-icon-bg {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #ecfdf5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-icon {
    color: #10b981;
}

/* ─── Pager ──────────────────────────────────────────────── */

.bar-chart-pager {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pager-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #a8a29e;
    padding: 6px 12px;
    border-radius: 8px;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 200ms;
}

.pager-btn:hover {
    color: #059669;
    background: #ecfdf5;
}

.pager-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.pager-icon {
    font-size: 10px;
}

.bar-page-info {
    font-size: 11px;
    font-weight: 900;
    color: #78716c;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Leaflet Popup ──────────────────────────────────────── */

.leaflet-popup-content-wrapper {
    border-radius: 20px !important;
    box-shadow: 0 12px 32px rgba(12, 25, 12, 0.2) !important;
    padding: 0 !important;
    overflow: hidden;
    pointer-events: none !important;
}

.leaflet-popup-tip-container {
    pointer-events: none !important;
}

.leaflet-popup {
    pointer-events: none !important;
}

.leaflet-popup-content {
    margin: 0 !important;
}

/* ─── Map Labels ─────────────────────────────────────────── */

.marker-label-center {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: white;
    font-weight: 800;
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    font-size: 13px;
    pointer-events: none !important;
}

.marker-label-tambon {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: white;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    font-size: 9px;
    pointer-events: none !important;
}

/* ─── Popup Content ──────────────────────────────────────── */

.popup-inner {
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-width: 260px;
    padding: 16px;
    border-top: 5px solid #059669;
}

/* ─── Controls ───────────────────────────────────────────── */

.leaflet-bottom.leaflet-left .leaflet-control-zoom {
    margin-bottom: 90px;
}

/* ─── Scrollbar ──────────────────────────────────────────── */

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ─── Flipped Popup ──────────────────────────────────────── */

.popup-flipped {
    bottom: auto !important;
    top: 0 !important;
    margin-bottom: 0 !important;
    margin-top: 20px !important;
}

.popup-flipped .leaflet-popup-tip-container {
    top: 0;
    margin-top: -20px;
    transform: scaleY(-1);
}

.popup-flipped .leaflet-popup-tip {
    background: #059669;
}

/* ─── Legend ──────────────────────────────────────────────── */

#legend-box {
    background: white;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.legend-title {
    font-weight: 800;
    color: #334155;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.legend-title-th {
    font-size: 12px;
}

.legend-title-en {
    font-size: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.legend-label {
    color: #64748b;
    font-weight: 700;
}

/* ─── Chart Tooltip ───────────────────────────────────────── */

.chart-tooltip {
    background: #1c1917;
    border-radius: 10px;
    color: white;
    opacity: 1;
    pointer-events: none;
    position: absolute;
    transition: opacity .1s ease;
    z-index: 999;
    padding: 10px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    min-width: 200px;
}

.chart-tooltip table {
    margin: 0;
    width: 100%;
    border-spacing: 0;
}

.tooltip-title-cell {
    text-align: left;
    font-size: 15px;
    font-weight: 700;
    padding-bottom: 6px;
    border-bottom: 1px solid #3f3f46;
}

.tooltip-main-td-label {
    padding: 4px 0 2px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 13px;
}

.tooltip-main-td-value {
    padding: 4px 0 2px 0;
    text-align: right;
    font-weight: 700;
    white-space: nowrap;
    font-size: 13px;
}

.tooltip-swatch {
    width: 20px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    margin-top: 2px;
    flex-shrink: 0;
}

.tooltip-detail-td-name {
    padding: 2px 0 2px 16px;
    color: #a8a29e;
    font-size: 13px;
}

.tooltip-detail-td-value {
    padding: 2px 0 2px 10px;
    text-align: right;
    color: #a8a29e;
    font-size: 13px;
    white-space: nowrap;
}

/* ─── Map Popup ───────────────────────────────────────────── */

.popup-inner {
    padding: 0;
}

.popup-header-section {
    padding: 14px 16px 10px;
    border-bottom: 2px solid #e2e8f0;
}

.popup-header-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.popup-metric-title-row {
    display: flex;
    justify-content: flex-start;
}

.popup-metric-title {
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.popup-location-row {
    display: flex;
    align-items: stretch;
    width: 100%;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 8px;
}

.popup-location-cell {
    text-align: center;
    flex: 1;
}

.popup-location-divider {
    width: 1px;
    background: rgba(0, 0, 0, 0.05);
}

.popup-location-cell-label {
    font-size: 11px;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.popup-location-cell-value {
    font-weight: 700;
    font-size: 12px;
    color: #1e293b;
    line-height: 1.2;
    word-break: break-word;
}

.popup-region-title {
    font-weight: 800;
    font-size: 16px;
    color: #0f172a;
}

.popup-donut-section {
    padding: 12px 16px;
}

.popup-stats-section {
    padding: 12px 16px;
    border-top-width: 1px;
    border-top-style: solid;
    border-radius: 0 0 20px 20px;
}

.popup-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.popup-stat-row+.popup-stat-row {
    margin-top: 4px;
}

.popup-stat-label {
    font-size: 11px;
    font-weight: 700;
    word-break: break-word;
    flex: 1;
    padding-right: 8px;
}

.popup-stat-value {
    font-size: 15px;
    font-weight: 800;
    text-align: right;
    flex-shrink: 0;
    word-break: break-word;
}

/* ─── Donut Chart ─────────────────────────────────────────── */

.donut-container {
    position: relative;
    width: 240px;
    height: 160px;
    margin: 16px auto 4px;
}

.donut-ring {
    position: absolute;
    border-radius: 50%;
}

.donut-center {
    position: absolute;
    border-radius: 50%;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
}

.donut-total {
    font-size: 20px;
    font-weight: 800;
    color: #334155;
    line-height: 1;
    letter-spacing: -0.5px;
}

.donut-total-label {
    font-size: 9px;
    font-weight: 700;
    color: #94a3b8;
    margin-top: 2px;
}

.donut-label {
    position: absolute;
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    width: max-content;
    z-index: 10;
    pointer-events: none;
}

.donut-label-name {
    font-weight: 800;
    font-size: 9px;
}

.donut-label-pct {
    font-size: 8px;
    font-weight: 700;
    color: #64748b;
    margin-top: 1px;
}

.donut-label-count {
    font-weight: 600;
    font-size: 7px;
    color: #94a3b8;
}

/* ─── Utility Classes (used by JS — must come last) ──────── */

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.opacity-30 {
    opacity: 0.3;
}

.pointer-events-none {
    pointer-events: none;
}

.opacity-50 {
    opacity: 0.5;
}

.rounded-xl {
    border-radius: 0.75rem;
}

.rounded-tr-xl {
    border-top-right-radius: 0.75rem;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
}

@media (min-width: 768px) {
    .md\:flex {
        display: flex !important;
    }

    .md\:block {
        display: block !important;
    }
}