:root {
    --primary-color: #2d5016;
    --secondary-color: #1a3009;
    --accent-color: #4a7c2a;
    --forest-green: #228b22;
    --dark-forest: #0f4c0f;
    --light-forest: #6b8e23;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --border-color: #d4d4d4;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.app-header {
    background: linear-gradient(135deg, var(--forest-green), var(--dark-forest));
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.15);
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 0;
}

.logo-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.2);
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-text h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.header-text p {
    font-size: 0.875rem;
    opacity: 0.9;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    font-weight: 600;
    min-width: 110px;
}

.view-btn:hover {
    background: #fff;
}

.view-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #1d4ed8;
}

.view-btn .view-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    background-size: cover;
}

.markers-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s-6-4.35-6-10a6 6 0 1112 0c0 5.65-6 10-6 10z'/%3E%3Ccircle cx='12' cy='11' r='2.5'/%3E%3C/svg%3E");
}

.view-btn.active .markers-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s-6-4.35-6-10a6 6 0 1112 0c0 5.65-6 10-6 10z'/%3E%3Ccircle cx='12' cy='11' r='2.5'/%3E%3C/svg%3E");
}

.heatmap-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23f97316' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7' cy='7' r='3'/%3E%3Ccircle cx='17' cy='7' r='3'/%3E%3Ccircle cx='7' cy='17' r='3'/%3E%3Ccircle cx='17' cy='17' r='3'/%3E%3C/svg%3E");
}

.view-btn.active .heatmap-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7' cy='7' r='3'/%3E%3Ccircle cx='17' cy='7' r='3'/%3E%3Ccircle cx='7' cy='17' r='3'/%3E%3Ccircle cx='17' cy='17' r='3'/%3E%3C/svg%3E");
}

select, button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

select {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
}

button {
    background: var(--light-forest);
    color: white;
    font-weight: 500;
}

button:hover {
    background: var(--forest-green);
    transform: translateY(-1px);
}

.status {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status.timestamp {
    background: rgba(255, 255, 255, 0.15);
    font-size: 0.75rem;
}

.main-container {
    display: flex;
    height: calc(100vh - var(--header-height, 4.5rem));
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    width: 20rem;
    background: var(--bg-secondary);
    padding: 1.5rem;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    width: 0;
    padding: 0;
    border: none;
}

.map-container {
    flex: 1;
    position: relative;
}

#map {
    height: 100%;
    width: 100%;
}

.coordinate-controls {
    position: absolute;
    bottom: 10px;
    right: 12px;
    left: auto;
    transform: none;
    display: flex;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    align-items: center;
    backdrop-filter: blur(5px);
    flex-wrap: wrap;
    max-width: calc(100% - 24px);
    transition: all 0.3s ease;
    font-size: 0.7rem;
}

.coordinate-controls.collapsed {
    transform: translateY(calc(100% - 40px));
}

.coordinate-controls.collapsed > *:not(.toggle-coords-btn) {
    display: none;
}

.coordinate-controls.expanded {
    transform: translateY(0);
}

.toggle-coords-btn {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    cursor: pointer;
    white-space: nowrap;
    margin-left: auto;
    min-height: 24px;
}

.toggle-coords-btn:hover {
    background: rgba(0, 0, 0, 0.15);
}

.cursor-coords {
    font-size: 0.65rem;
    color: var(--text-primary);
    min-width: 140px;
    white-space: nowrap;
    padding: 0.2rem 0.3rem;
}

@media (max-width: 1024px) {
    .cursor-coords {
        min-width: 120px;
        font-size: 0.6rem;
    }
}

.btn-ghost {
    background: rgba(0,0,0,0.05);
    color: var(--text-primary);
    border: 1px solid rgba(0,0,0,0.08);
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    min-height: 24px;
}

.btn-ghost:hover {
    background: rgba(0,0,0,0.08);
}

.map-scale {
    padding: 0.2rem 0.4rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 70px;
    text-align: center;
    border: 1px solid rgba(212, 212, 212, 0.5);
    white-space: nowrap;
}

.coordinate-controls input {
    width: 100px;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.7rem;
    min-height: 24px;
}

.coordinate-controls input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.coordinate-controls button {
    padding: 0.3rem 0.6rem;
    background: var(--forest-green);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    min-height: 24px;
    white-space: nowrap;
}

.coordinate-controls button:disabled {
    opacity: 0.5;
    cursor: default;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-secondary);
}

.coordinate-controls button:hover {
    background: var(--dark-forest);
}

.district-label {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: none;
    padding: 0;
    font-size: 0.85rem !important;
}

.tehsil-label {
    background: transparent;
    border: none;
    color: #1f2937;
    font-weight: 700;
    box-shadow: none;
    padding: 0;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.9);
    font-size: 0.75rem !important;
}

/* Copyright information */
.copyright-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    z-index: 999;
    font-size: 0.75rem;
    color: var(--text-primary);
    backdrop-filter: blur(5px);
    line-height: 1.4;
    max-width: calc(50% - 20px);
}

.copyright-info div {
    margin: 0;
    padding: 0;
}

.copyright-info div:first-child {
    font-weight: 600;
    margin-bottom: 0.15rem;
}

/* Home button styling - positioned below zoom controls */
.leaflet-control-home {
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    margin-top: 10px;
}

.leaflet-control-home button {
    width: 30px;
    height: 30px;
    line-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #333;
    background: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.leaflet-control-home button:hover {
    background: #f4f4f4;
}

.leaflet-control-home button svg {
    width: 18px;
    height: 18px;
}

/* Boundary controls styling */
.leaflet-control-boundary {
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    margin-top: 10px;
    padding: 6px;
}

.leaflet-popup-pane {
    z-index: 1200;
}

.boundary-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.7rem;
}

.boundary-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: #333;
    white-space: nowrap;
}

.boundary-controls input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: 12px;
    height: 12px;
}

.boundary-controls label:hover {
    color: var(--forest-green);
}

.sidebar h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.legend-section, .stats-section, .search-section, .info-section, 
.filters-section, .export-section, .charts-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.filter-chips .chip {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #fff;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.8rem;
    box-shadow: var(--shadow-sm);
}

.filter-chips .chip.active {
    background: #2563eb;
    color: #fff;
    border-color: #1d4ed8;
}

.legend-section {
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.legend-section h2 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 0.8rem;
}

.legend-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
}

.measure-result {
    font-size: 0.65rem;
    color: var(--text-primary);
    min-width: 100px;
    text-align: center;
    padding: 0.2rem 0.3rem;
}

#measureBtn {
    background: var(--forest-green);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
    min-height: 24px;
    white-space: nowrap;
}

#measureBtn.active {
    background: #2563eb;
}

#map.measure-mode {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='10' width='18' height='4' rx='1'/%3E%3Cpath d='M7 10v4M11 10v4M15 10v4'/%3E%3Cpath d='M3 8h3M3 16h3M18 8h3M18 16h3'/%3E%3C/svg%3E") 12 12, crosshair;
}

/* Helper to hide elements */
.hidden {
    display: none !important;
}

.stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid;
}

.total { border-left-color: var(--forest-green); }
.valid { border-left-color: #228b22; }
.expired-cte { border-left-color: #eab308; }
.expired-cto { border-left-color: #f97316; }
.without-consent { border-left-color: #6b7280; }
.refused { border-left-color: #b91c1c; }

.stat-label { font-size: 0.875rem; color: var(--text-secondary); }
.stat-value { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }

.search-section input, .filters-section input, .filters-section select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
    margin-bottom: 0.5rem;
}

.search-section input:focus, .filters-section input:focus, .filters-section select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-group {
    margin-bottom: 1rem;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-clear {
    width: 100%;
    padding: 0.75rem;
    background: #f3f4f6;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.btn-clear:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.export-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-export {
    width: 100%;
    padding: 0.75rem;
    background: var(--forest-green);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-export:hover {
    background: var(--dark-forest);
    transform: translateY(-1px);
}

.chart-container {
    height: 200px;
    margin-bottom: 1rem;
    position: relative;
}

.chart-container:last-child {
    margin-bottom: 0;
}

#kilnInfo {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Buffer tool cursor */
#map.buffer-mode {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='6'/%3E%3Cline x1='12' y1='2' x2='12' y2='6'/%3E%3Cline x1='12' y1='18' x2='12' y2='22'/%3E%3Cline x1='2' y1='12' x2='6' y2='12'/%3E%3Cline x1='18' y1='12' x2='22' y2='12'/%3E%3C/svg%3E") 12 12, crosshair;
}

/* Ensure buffer/measure cursor also appears when hovering markers/clusters */
#map.buffer-mode .leaflet-marker-icon,
#map.buffer-mode .leaflet-interactive,
#map.buffer-mode .marker-cluster,
#map.measure-mode .leaflet-marker-icon,
#map.measure-mode .leaflet-interactive,
#map.measure-mode .marker-cluster {
    cursor: inherit !important;
}

/* In buffer mode, let clicks on kiln/cluster icons fall through to the map */
#map.buffer-mode .leaflet-marker-icon,
#map.buffer-mode .marker-cluster {
    pointer-events: none;
}

/* Centered buffer popup */
.buffer-distance-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.96);
    border-radius: 0.9rem;
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-md);
    z-index: 1101;
    min-width: 260px;
    max-width: 380px;
    font-size: 0.75rem;
}

.buffer-distance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.buffer-distance-title {
    font-weight: 600;
    color: var(--text-primary);
}

.buffer-distance-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    cursor: pointer;
}

.buffer-distance-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.buffer-distance-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.buffer-distance-message {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.buffer-distance-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.buffer-distance-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.buffer-distance-input-wrap input {
    padding: 0.4rem 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    width: 100%;
}

.buffer-distance-input-wrap input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.buffer-distance-apply {
    padding: 0.4rem 0.7rem;
    border-radius: 0.5rem;
    border: none;
    background: var(--forest-green);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.buffer-distance-apply:hover {
    background: var(--dark-forest);
}

.buffer-distance-error {
    min-height: 0.9rem;
    font-size: 0.7rem;
    color: #b91c1c;
}

/* Sidebar toggle button */
.sidebar-toggle {
    position: fixed;
    top: 5.5rem;
    left: 1rem;
    z-index: 999;
    background: var(--forest-green);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: var(--dark-forest);
    transform: scale(1.1);
}

.sidebar-toggle.active {
    left: calc(20rem + 1rem);
}

/* Tablet and smaller laptop screens */
@media (max-width: 1366px) {
    .coordinate-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        max-width: 220px;
        bottom: 60px;
        padding: 0.35rem 0.4rem;
        font-size: 0.65rem;
    }

    .coordinate-controls > * {
        width: 100%;
    }

    .coordinate-controls input {
        width: 100% !important;
        font-size: 0.65rem;
        padding: 0.25rem 0.35rem;
    }

    .coordinate-controls button {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }

    .cursor-coords {
        font-size: 0.6rem;
        min-width: 100%;
    }

    .map-scale {
        font-size: 0.6rem;
        padding: 0.15rem 0.3rem;
    }

    .copyright-info {
        bottom: 10px;
        max-width: calc(100% - 240px);
    }
}

/* Small laptop screens (15 inch and similar) */
@media (max-width: 1280px) {
    .coordinate-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem;
        max-width: 200px;
        bottom: 70px;
        right: 10px;
        padding: 0.3rem 0.4rem;
        font-size: 0.6rem;
    }

    .coordinate-controls > * {
        width: 100%;
    }

    .coordinate-controls input {
        width: 100% !important;
        font-size: 0.6rem;
        padding: 0.25rem 0.3rem;
        min-height: 22px;
    }

    .coordinate-controls button {
        font-size: 0.6rem;
        padding: 0.25rem 0.4rem;
        min-height: 22px;
    }

    .cursor-coords {
        font-size: 0.55rem;
        min-width: 100%;
        padding: 0.15rem 0.25rem;
    }

    .map-scale {
        font-size: 0.55rem;
        padding: 0.15rem 0.3rem;
        min-width: 60px;
    }

    .measure-result {
        font-size: 0.55rem;
    }

    .toggle-coords-btn {
        font-size: 0.6rem;
        padding: 0.2rem 0.3rem;
        min-height: 22px;
    }

    .copyright-info {
        bottom: 10px;
        left: 10px;
        max-width: calc(100% - 220px);
        font-size: 0.65rem;
        padding: 0.35rem 0.5rem;
    }
}

/* Tablet screens */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 4.5rem;
        height: calc(100vh - 4.5rem);
        z-index: 998;
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar-toggle {
        display: flex;
    }

    .main-container {
        height: calc(100vh - 4.5rem);
    }

    .map-container {
        width: 100%;
    }

    .coordinate-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem;
        max-width: 180px;
        bottom: 80px;
        right: 10px;
        padding: 0.3rem 0.35rem;
        font-size: 0.6rem;
    }

    .coordinate-controls > * {
        width: 100%;
    }

    .coordinate-controls input {
        font-size: 0.6rem;
        padding: 0.25rem 0.3rem;
        min-height: 22px;
    }

    .coordinate-controls button {
        font-size: 0.6rem;
        padding: 0.25rem 0.4rem;
        min-height: 22px;
    }

    .cursor-coords {
        font-size: 0.55rem;
        min-width: 100%;
    }

    .map-scale {
        font-size: 0.55rem;
        padding: 0.15rem 0.3rem;
    }

    .toggle-coords-btn {
        font-size: 0.6rem;
        padding: 0.2rem 0.3rem;
        min-height: 22px;
    }

    .copyright-info {
        bottom: 10px;
        left: 10px;
        max-width: calc(100% - 200px);
        font-size: 0.6rem;
        padding: 0.3rem 0.4rem;
    }
}

/* Mobile screens */
@media (max-width: 768px) {
    .app-header { 
        flex-direction: column; 
        gap: 1rem; 
        padding: 1rem; 
        height: auto;
    }

    .header-left {
        width: 100%;
        justify-content: center;
    }

    .header-right { 
        flex-wrap: wrap; 
        justify-content: center; 
        width: 100%;
        gap: 0.5rem;
    }

    .view-toggle {
        width: 100%;
        justify-content: center;
    }

    .view-btn {
        flex: 1;
        min-width: auto;
    }

    .main-container { 
        height: calc(100vh - 8rem);
        flex-direction: column; 
    }

    .sidebar { 
        width: 280px;
        height: calc(100vh - 8rem);
        top: 8rem;
    }

    .map-container { 
        min-height: 60vh; 
    }

    #map { 
        min-height: 60vh; 
    }

    .coordinate-controls { 
        flex-direction: column;
        width: calc(100% - 2rem);
        max-width: none;
        left: 1rem;
        right: 1rem;
        bottom: 100px;
        gap: 0.3rem;
        padding: 0.35rem 0.4rem;
        font-size: 0.6rem;
    }

    .coordinate-controls input { 
        width: 100% !important; 
        font-size: 0.6rem;
        padding: 0.25rem 0.35rem;
        min-height: 24px;
    }

    .coordinate-controls button {
        font-size: 0.6rem;
        padding: 0.3rem 0.5rem;
        min-height: 24px;
    }

    .copyright-info {
        bottom: 10px;
        left: 1rem;
        right: 1rem;
        max-width: none;
        width: calc(100% - 2rem);
        font-size: 0.6rem;
        padding: 0.35rem 0.5rem;
    }

    .chart-container { 
        height: 150px; 
    }

    .cursor-coords {
        min-width: 100%;
        font-size: 0.55rem;
        padding: 0.2rem 0.3rem;
    }

    .map-scale {
        font-size: 0.55rem;
        padding: 0.15rem 0.3rem;
        min-width: auto;
    }

    .measure-result {
        font-size: 0.55rem;
    }

    .toggle-coords-btn {
        font-size: 0.6rem;
        padding: 0.2rem 0.35rem;
        min-height: 24px;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {
    .app-header {
        padding: 0.75rem;
    }

    .header-text h1 {
        font-size: 1rem;
    }

    .header-text p {
        font-size: 0.75rem;
    }

    .sidebar {
        width: 100%;
    }

    .coordinate-controls {
        bottom: 110px;
        padding: 0.3rem 0.35rem;
        gap: 0.25rem;
        font-size: 0.55rem;
    }

    .coordinate-controls input {
        font-size: 0.55rem;
        padding: 0.2rem 0.3rem;
        min-height: 22px;
    }

    .coordinate-controls button {
        font-size: 0.55rem;
        padding: 0.25rem 0.4rem;
        min-height: 22px;
    }

    .cursor-coords {
        font-size: 0.5rem;
        padding: 0.15rem 0.25rem;
    }

    .map-scale {
        font-size: 0.5rem;
        padding: 0.15rem 0.25rem;
    }

    .measure-result {
        font-size: 0.5rem;
    }

    .toggle-coords-btn {
        font-size: 0.55rem;
        padding: 0.2rem 0.3rem;
        min-height: 22px;
    }

    .copyright-info {
        bottom: 5px;
        left: 0.5rem;
        right: 0.5rem;
        width: calc(100% - 1rem);
        font-size: 0.55rem;
        padding: 0.25rem 0.4rem;
    }

    .sidebar-toggle {
        top: 4.5rem;
        width: 36px;
        height: 36px;
    }
}