:root {
    --color-primary: #2d8659;
    --color-primary-dark: #1a5c3a;
    --color-primary-light: #4db380;
    --color-hover-bg: #e8f4e8;
    --color-accent-bg: #f0faf5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    user-select: none;
    -webkit-user-select: none;
}
/* Re-enable selection only where needed */
input, textarea, .selectable {
    user-select: text;
    -webkit-user-select: text;
}

.header {
    background: linear-gradient(to right, var(--color-primary-dark), #2d7a50);
    color: white;
    padding: 0.8rem 1.4rem;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    gap: 20px;
    position: relative;
    min-height: 60px;
    overflow: visible;
    flex-shrink: 0;
}

.header-menu-wrapper {
    position: relative;
    margin-left: 0;
    z-index: 1000;
}
.header-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 10px;
    margin: -4px -9px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    border-radius: 4px;
    transition: background 0.2s;
}
.header-menu-btn:hover {
    background: rgba(255,255,255,0.15);
}
.header-menu-btn span {
    display: block;
    width: 5px;
    height: 5px;
    background: white;
    border-radius: 50%;
}
.header-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    min-width: 180px;
    overflow: hidden;
}
.header-menu-dropdown.open {
    display: block;
}
.header-menu-user {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}
.header-menu-user-icon {
    font-size: 18px;
}
.header-menu-divider {
    height: 1px;
    background: #e5e5e5;
}
.header-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #000;
    transition: background 0.15s;
}
.header-menu-item:hover {
    background: #f5f5f5;
}
.header-menu-item-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.header-logo {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    height: 55px;
    width: 90px;
    max-width: 120px;
    border-radius: 7%;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
    flex-shrink: 0;
}

.header-content {
    flex: 1;
}

.header h1 {
    font-size: clamp(16px, 2vw, 25px);
    margin-bottom: 3px;
    user-select: none;
    cursor: default;
    line-height: 1.2;
}

.header p {
    font-size: 12px;
    opacity: 0.9;
    user-select: none;
    cursor: default;
}

.view-toggle {
    display: flex;
    gap: 1.2rem;
    margin-left: auto;
    align-items: center;
    flex-shrink: 0;
}

.control-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
}

.control-btn:hover {
    background: rgba(255,255,255,0.3);
}

.toggle-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    user-select: none;
    -webkit-user-select: none;
    white-space: nowrap;
}

.toggle-btn:hover {
    background: rgba(255,255,255,0.3);
}

.toggle-btn.active {
    background: white;
    color: var(--color-primary);
}

.container {
    position: relative;
    flex: 1;
    min-height: 0;
}

.stats-panel {
    width: 272px;
    background: white;
    overflow-y: hidden;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 500;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    display: flex;
    flex-direction: column;
}

.stats-panel::-webkit-scrollbar {
    width: 13px;
}

.stats-panel::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.stats-panel::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 5px;
    cursor: grab;
}

.stats-panel::-webkit-scrollbar-thumb:hover {
    background: #999;
    cursor: grab;
}

.stats-panel.scrollbar-grabbing,
.stats-panel.scrollbar-grabbing * {
    cursor: grabbing !important;
}

.stats-panel input,
.stats-panel textarea {
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
}

.stats-panel.collapsed {
    transform: translateX(-100%);
}

.panel-toggle-btn {
    position: absolute;
    top: 8px;
    left: 272px;
    z-index: 501;
    width: 14px;
    height: 36px;
    background: white;
    border: none;
    border-radius: 0 6px 6px 0;
    box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.38);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #555;
    transition: left 0.3s ease;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
}

.panel-toggle-btn:hover {
    background: var(--color-primary);
    color: white;
}

.map-panel {
    width: 100%;
    height: 100%;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background: #4a5a4a;
}

.leaflet-container {
    background: #4a5a4a !important;
}

.leaflet-control-attribution {
    display: none !important;
}

.leaflet-bottom.leaflet-right {
    display: none !important;
}

.leaflet-control-zoom {
    display: none !important;
}

.leaflet-top.leaflet-left {
    display: none !important;
}

.leaflet-tile-container {
    will-change: transform;
}
.leaflet-tile-container img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.leaflet-tile {
    border: none !important;
    outline: none !important;
    transform: scale(1.002);
    backface-visibility: hidden;
    will-change: transform, opacity;
}

.stat-card {
    margin: 20px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stat-card h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 8px;
    text-align: center;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    cursor: pointer;
}

.stat-item:hover {
    background: var(--color-hover-bg);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-unit-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin: 4px 0 8px 0;
    background: #fafafa;
}

.stat-unit-list .unit-search {
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    font-size: 12px;
    outline: none;
    background: white;
    position: sticky;
    top: 0;
    z-index: 1;
}

.stat-unit-list .unit-row {
    padding: 5px 10px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.1s;
}

.stat-unit-list .unit-row:hover {
    background: var(--color-hover-bg);
}

.stat-unit-list .unit-row:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: 500;
}

.stat-value {
    font-weight: bold;
    color: var(--color-primary);
}

.total-fleet-bar {
    padding: 8px 20px;
    margin: 10px 0 0 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
    flex-shrink: 0;
}

.total-fleet-bar span {
    font-weight: bold;
    color: var(--color-primary);
    font-size: 16px;
}

.search-dropdown {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--color-primary);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.search-dropdown.visible {
    display: block;
}

.search-dropdown-item {
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-dropdown-item:hover {
    background: var(--color-hover-bg);
}

.search-dropdown-item .item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.search-dropdown-item .item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.search-dropdown-item .item-detail {
    color: #999;
    font-size: 10px;
    flex-shrink: 0;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    margin: 20px;
    border-radius: 8px;
    border-left: 4px solid #c62828;
}

.legend {
    background: transparent;
    padding: 5px 5px;
    margin-top: 0.5rem;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.legend-items {
    display: flex;
    justify-content: space-evenly;
    width: 100%;
}

.legend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-bottom: 4px;
    border: 2px solid #333;
}

/* Cluster styling - uniform blue */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(27, 141, 255, 0.6) !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: rgba(27, 141, 255, 0.8) !important;
    color: white !important;
    font-weight: bold !important;
}


/* Marker label styling */
.leaflet-tooltip.marker-label {
    font-family: sans-serif;
    background: rgba(0, 0, 0, 0.704);
    border: none;
    box-shadow: none;
    font-size: 12px;
    font-weight: bold;
    color: #ffffff;
    text-align: center;
    padding: 3px 5px;
    white-space: nowrap;
    line-height: 1;
    margin: 0;
}

.leaflet-tooltip.marker-label::before {
    display: none !important;
}

.leaflet-tooltip-bottom::before {
    display: none !important;
}

.leaflet-tooltip,
.leaflet-popup-content {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.leaflet-popup-content {
    margin: 8px 10px;
    line-height: 1.7;
    font-size: 13px;
}
.leaflet-popup-content a:hover {
    color: #004080;
    text-decoration: underline !important;
}
.leaflet-popup-content a.gallery-link:hover {
    text-decoration: none !important;
}
.leaflet-popup-content a.gallery-link:hover .gallery-text {
    text-decoration: underline;
}

.search-filter-section {
    margin: 0;
    padding: 15px;
    background: white;
    border-radius: 0;
    border: none;
    box-shadow: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.search-filter-section h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--color-primary);
    text-align: center;
}

.search-box {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.3s;
    -webkit-user-select: none;
    user-select: none;
}

.search-box:focus {
    outline: none;
    border-color: var(--color-primary);
    -webkit-user-select: text;
    user-select: text;
}

.filter-row {
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-evenly;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-item label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.filter-item select {
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    background: white;
    -webkit-user-select: none;
    user-select: none;
}

.filter-item select:hover,
.filter-item select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.clear-filters-btn {
    margin-top: 8px;
    margin-bottom: 10px;
    width: 100%;
    padding: 8px;
    background: #e0e0e0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    flex-shrink: 0;
}

.clear-filters-btn:hover {
    background: #e0e0e0;
    color: #000;
}

.movement-alerts {
    display: none;
    margin: 15px 20px;
    padding: 15px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    border-radius: 10px;
    border: 2px solid #ff5252;
    box-shadow: 0 4px 12px rgba(255,82,82,0.3);
}

.movement-alerts.visible {
    display: block;
}

.movement-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    color: white;
}

.movement-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.movement-count {
    background: white;
    color: #ff5252;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
}

.movement-list {
    max-height: 400px;
    overflow-y: auto;
}

.movement-item {
    background: white;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid #ff5252;
}

.movement-item:last-child {
    margin-bottom: 0;
}

.movement-unit-name {
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 6px;
    font-size: 14px;
}

.movement-detail {
    font-size: 12px;
    color: #4a5568;
    margin: 4px 0;
}

.movement-distance {
    color: #ff5252;
    font-weight: 600;
}

.movement-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.movement-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.movement-btn-default {
    background: #48bb78;
    color: white;
}

.movement-btn-default:hover {
    background: #38a169;
}

.movement-btn-dismiss {
    background: #e2e8f0;
    color: #4a5568;
}

.movement-btn-dismiss:hover {
    background: #cbd5e0;
}

.no-movements {
    color: white;
    text-align: center;
    padding: 20px;
    font-size: 14px;
    opacity: 0.9;
}

/* Analytics styles */
.analytics-container {
    display: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 20px 0;
    background: #f9f9f9;
    min-height: 0;
}

.analytics-container.active {
    display: block;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.summary-card {
    background: white;
    padding: 8px 14px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.summary-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.summary-card-title {
    font-size: 14px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
}

.summary-card-icon {
    font-size: 24px;
}

.summary-card-value {
    font-size: 36px;
    font-weight: bold;
    color: var(--color-primary);
    line-height: 1;
}

.summary-card-label {
    display: none;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(500px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 10px;
}

.chart-container {
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
}

.chart-canvas {
    position: relative;
    height: 300px;
}

.filter-section {
    background: white;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 12px;
}

.filter-header {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.filter-controls {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 0.8fr 0.6fr 1.6fr auto;
    gap: 10px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.filter-label {
    font-size: 14px;
    font-weight: 600;
    color: #666;
}

.filter-select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.filter-controls .custom-select-btn {
    border-radius: 8px;
    font-size: 14px;
    padding: 8px 28px 8px 12px;
}

.filter-controls .custom-select-dropdown {
    border-radius: 0 0 8px 8px;
}

.filter-btn {
    background: #e0e0e0;
    color: #666;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    align-self: flex-end;
}

.filter-btn:hover {
    background: #d0d0d0;
    color: #000;
}

.filtered-results {
    background: white;
    padding: 15px 0 20px 0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.results-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
}

.results-count {
    font-size: 18px;
    font-weight: bold;
    color: var(--color-primary);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.sticky-header {
    display: table;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: white;
}
.sticky-header > div {
    display: table-cell;
    padding: 8px 10px;
    text-align: center;
    font-weight: 600;
    color: #000;
    border-bottom: 2px solid #d0d0d0;
    border-right: 1px solid #e0e0e0;
}
.sticky-header > div:first-child {
    border-left: 1px solid #e0e0e0;
}

.results-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #e8e8e8;
    border-right: 1px solid #e8e8e8;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    word-break: break-word;
}
.results-table td:first-child {
    border-left: 1px solid #e8e8e8;
}
.results-table td.selectable {
    user-select: text;
    -webkit-user-select: text;
}
.results-table td.unit-name-cell {
    cursor: pointer;
    position: relative;
}
.results-table td.unit-name-cell:hover {
    color: white;
    background: var(--color-primary);
}
.results-table td:nth-child(8) {
    font-size: 13.5px;
}
.results-table td.qty-cell.editable {
    cursor: pointer;
    position: relative;
}
.qty-lock {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    opacity: 0;
    pointer-events: none;
    line-height: 1;
    transition: opacity 0.15s;
}
.results-table tr:hover .qty-lock {
    opacity: 0.6;
}
.qty-cell.qty-unlocked .qty-lock {
    opacity: 0.9;
}
.qty-cell.qty-editing .qty-lock {
    opacity: 0;
}
.qty-edit-input {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 0 4px;
    border: 1px solid var(--color-primary);
    border-radius: 3px;
    font-size: inherit;
    line-height: inherit;
    outline: none;
    margin: -1px 0;
}
.photo-limit-text {
    text-align: center;
    color: #999;
    font-size: 13px;
    margin-top: 8px;
}

.results-table tr:hover {
    background: #f0f0f0;
}

.results-table tr:last-child td {
    border-bottom: 1px solid #e8e8e8;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: #222;
}

.type-solar {
    background: #fff3cd;
}

.type-transformer {
    background: #f8d7da;
}

.type-minigrid {
    background: #d4edda;
}

.analytics-search-box {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

.analytics-search-box:focus {
    border-color: var(--color-primary);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.pagination button:hover {
    background: #f0f0f0;
}

.pagination button.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.upload-photos-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 0;
    width: 62px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    box-sizing: border-box;
}
.upload-photos-btn .photo-camera-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    position: relative;
    top: -1px;
}
.upload-photos-btn .photo-count-badge {
    font-weight: 400;
    font-size: 12px;
    line-height: 1;
    min-width: 20px;
    text-align: center;
}
.upload-photos-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.version-info {
    text-align: center;
    padding: 10px 0;
    color: #ccc;
    font-size: 10px;
}

/* Login Screen Styles */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 50%, var(--color-primary-light) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.login-container.hidden {
    display: none;
}

.login-box {
    background: white;
    padding: 40px 25px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 435px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 20px;
    color: var(--color-primary);
    margin-bottom: 10px;
}

.login-header p {
    font-size: 14px;
    color: #666;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.remember-device {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

.remember-device input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.login-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.login-btn:hover {
    background: var(--color-primary-dark);
}

.login-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.login-error {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    display: none;
}

.login-error.show {
    display: block;
}

.app-container {
    display: none;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-container.visible {
    display: flex;
}

/* Cluster list panel */
.cluster-list-panel {
    position: absolute;
    width: auto;
    min-width: 180px;
    max-width: 300px;
    max-height: 400px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.cluster-list-panel.visible {
    display: flex;
}

.cluster-list-header {
    padding: 10px 14px;
    background: var(--color-primary);
    color: white;
    font-weight: bold;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cluster-list-header .close-btn {
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.8;
}

.cluster-list-header .close-btn:hover {
    opacity: 1;
}

.cluster-list-body {
    overflow-y: auto;
    max-height: 350px;
}

.cluster-list-item {
    padding: 8px 14px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    transition: background 0.15s;
}

.cluster-list-item:hover {
    background: var(--color-hover-bg);
}

.cluster-list-item .unit-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cluster-list-item .unit-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cluster-list-item .unit-type {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    color: #000;
    flex-shrink: 0;
}

/* Custom searchable dropdown */
.custom-select-wrap {
    position: relative;
}

.custom-select-btn {
    width: 100%;
    padding: 8px 28px 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    background: white;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

.custom-select-btn::after {
    content: '\25BC';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #999;
    pointer-events: none;
}

.custom-select-btn:hover,
.custom-select-btn.open {
    border-color: var(--color-primary);
}

.custom-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--color-primary);
    border-top: none;
    border-radius: 0 0 6px 6px;
    z-index: 100;
    max-height: 200px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    flex-direction: column;
}

.custom-select-dropdown.open {
    display: flex;
}

.custom-select-dropdown input {
    padding: 6px 10px;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    font-size: 12px;
    outline: none;
    flex-shrink: 0;
}

.custom-select-options {
    overflow-y: auto;
    max-height: 160px;
}

.custom-select-option {
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
}

.custom-select-option:hover {
    background: var(--color-hover-bg);
}

.custom-select-option.selected {
    background: var(--color-hover-bg);
    font-weight: 600;
}

/* Vendor dropdown opens upward */
#vendorSelectDropdown {
    top: auto;
    bottom: 100%;
    border: 2px solid var(--color-primary);
    border-bottom: none;
    border-top: 2px solid var(--color-primary);
    border-radius: 6px 6px 0 0;
}

#vendorSelectBtn.open {
    border-radius: 0 0 6px 6px;
}

/* Sessions Panel */
.sessions-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10001;
    justify-content: center;
    align-items: center;
}
.sessions-overlay.open {
    display: flex;
}
.sessions-panel {
    background: white;
    border-radius: 12px;
    width: 90vw;
    max-width: 780px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    overflow: hidden;
}
.sessions-header {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.sessions-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.sessions-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
}
.sessions-close-btn:hover {
    opacity: 1;
}
.sessions-tabs {
    display: flex;
    border-bottom: 2px solid #e5e5e5;
    flex-shrink: 0;
}
.sessions-tab {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.sessions-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}
.sessions-tab:hover:not(.active) {
    color: #333;
}
.sessions-filters {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
    align-items: flex-end;
}
.sessions-filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.sessions-filter-group label {
    font-size: 11px;
    color: #888;
    font-weight: 500;
}
.sessions-filter-group select,
.sessions-filter-group input {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 12px;
    background: white;
}
.sessions-filter-btn {
    padding: 5px 14px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    align-self: flex-end;
}
.sessions-filter-btn:hover {
    background: var(--color-primary-dark);
}
.sessions-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.sessions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.sessions-table th {
    background: #f8f8f8;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    z-index: 1;
}
.sessions-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
    vertical-align: top;
}
.sessions-table tr:hover td {
    background: #fafafa;
}
.sessions-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 500;
}
.sessions-badge.active {
    background: #e6f4ea;
    color: #1a7f37;
}
.sessions-badge.expired {
    background: #f0f0f0;
    color: #888;
}
.sessions-badge.action-login {
    background: #e6f4ea;
    color: #1a7f37;
}
.sessions-badge.action-logout {
    background: #fff3e0;
    color: #e65100;
}
.sessions-badge.action-login_failed {
    background: #ffebee;
    color: #c62828;
}
.sessions-badge.action-photo_upload {
    background: #e3f2fd;
    color: #1565c0;
}
.sessions-badge.action-photo_delete {
    background: #fce4ec;
    color: #c62828;
}
.sessions-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    font-size: 12px;
    color: #666;
}
.sessions-pagination button {
    padding: 4px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 12px;
}
.sessions-pagination button:hover:not(:disabled) {
    background: #f5f5f5;
}
.sessions-pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}
.sessions-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 13px;
}
.sessions-detail-cell {
    font-size: 11px;
    color: #888;
}

/* ─── Photo Management Modal ─────────────────── */
.photos-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10002;
    justify-content: center;
    align-items: center;
}
.photos-overlay.open {
    display: flex;
}
.photos-panel {
    background: white;
    border-radius: 12px;
    width: 94vw;
    max-width: 920px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    overflow: hidden;
}
.photos-header {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}
.photos-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.photos-close-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 4px 16px;
    line-height: 1;
    opacity: 1;
    transition: transform 0.2s;
}
.photos-close-btn:hover {
    transform: translateY(-50%) scale(1.15);
}
.photos-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
    gap: 10px;
    margin-bottom: 12px;
}
.photo-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #fafafa;
    cursor: pointer;
}
.photo-card img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    display: block;
    background: #f0f0f0;
}
.photo-card-info {
    padding: 6px 8px;
    font-size: 12px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.photo-card-delete {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(220,53,69,0.85);
    border: none;
    border-top-left-radius: 8px;
    border-bottom-right-radius: 6px;
    color: white;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 8px;
    line-height: 1.2;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}
.photo-card:hover .photo-card-delete {
    opacity: 1;
}
.photo-card.draggable-card {
    cursor: grab;
}
.photo-card.draggable-card:active {
    cursor: grabbing;
}
.photo-card.dragging {
    opacity: 0.4;
    border: 2px dashed var(--color-primary);
}
.photo-card.drag-over-card {
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 8px rgba(45,134,89,0.3);
}
.photos-upload-area {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 28px 20px;
    text-align: center;
    color: #999;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 1;
}
.photos-upload-area:hover {
    border-color: var(--color-primary);
    background: var(--color-accent-bg);
}
.photos-upload-area.drag-over {
    border-color: var(--color-primary);
    background: #e0f5ec;
}
.photos-count {
    font-size: 14px;
    color: #333;
    margin-bottom: 12px;
    text-align: center;
    font-weight: 500;
}
.photos-grid:has(.photos-empty) {
    display: flex;
    flex: 1;
}
.photos-empty {
    text-align: center;
    color: #333;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    white-space: nowrap;
}
.photos-uploading {
    padding: 16px;
    background: var(--color-accent-bg);
    border-radius: 8px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--color-primary);
    text-align: center;
}
.photos-uploading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: photos-spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}
@keyframes photos-spin {
    to { transform: rotate(360deg); }
}
/* ─── Custom Confirm Dialog ──────────────────── */
.confirm-overlay {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 10010;
    justify-content: center;
    align-items: center;
}
.confirm-box {
    background: white;
    border-radius: 12px;
    padding: 28px 32px 20px;
    max-width: 520px;
    width: auto;
    min-width: 280px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    text-align: center;
}
.confirm-box p {
    font-size: 15px;
    color: #333;
    margin: 0 0 20px;
    word-break: break-word;
}
.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.confirm-btn {
    padding: 8px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}
.confirm-btn.yes {
    background: #dc3545;
    color: white;
}
.confirm-btn.yes:hover {
    background: #c82333;
}
.confirm-btn.no {
    background: #e9ecef;
    color: #333;
}
.confirm-btn.no:hover {
    background: #d3d7db;
}
/* ─── Unit Context Menu ──────────────────────── */
.unit-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    z-index: 10005;
    padding: 4px 0;
    width: auto;
}
.unit-context-menu-item {
    padding: 8px 16px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
    white-space: nowrap;
}
.unit-context-menu-item:hover {
    background: var(--color-accent-bg);
}

/* ─── Gallery Lightbox (view-only) ───────────── */
.gallery-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    z-index: 10003;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}
.gallery-overlay.open {
    display: flex;
}
.gallery-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(255,255,255,0.18);
    border: none;
    color: white;
    font-size: 28px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    user-select: none;
}
.gallery-close:hover {
    background: rgba(255,255,255,0.35);
}
.gallery-counter {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.9);
    font-size: 20px;
    font-weight: 600;
    z-index: 20;
    letter-spacing: 1px;
    pointer-events: none;
}
.gallery-main-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 60px 0 8px;
    position: relative;
    min-height: 0;
}
.gallery-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
    padding: 0 70px;
    min-height: 0;
}
.gallery-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
}
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.18);
    border: none;
    color: white;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 15;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    padding: 0;
}
.gallery-nav:hover {
    background: rgba(255,255,255,0.35);
}
.gallery-nav.prev { left: 18px; }
.gallery-nav.next { right: 18px; }
.gallery-caption {
    color: rgba(255,255,255,0.9);
    font-size: 16px;
    text-align: center;
    padding: 6px 20px;
    max-width: 700px;
    margin: 0 auto;
    flex-shrink: 0;
    pointer-events: none;
}
.gallery-fullscreen-btn {
    position: absolute;
    top: 24px;
    right: 100px;
    background: rgba(255,255,255,0.18);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 20;
}
.gallery-fullscreen-btn:hover {
    background: rgba(255,255,255,0.35);
}
.gallery-delete-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    background: rgba(220,53,69,0.7);
    border: none;
    color: white;
    height: 48px;
    border-radius: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    z-index: 20;
}
.gallery-delete-btn:hover {
    background: rgba(220,53,69,0.9);
}
/* Thumbnail strip */
.gallery-thumbs {
    display: flex;
    gap: 8px;
    padding: 10px 20px 16px;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    flex-shrink: 0;
}
.gallery-thumb {
    width: 72px;
    height: 72px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    transition: opacity 0.2s, border-color 0.2s;
    flex-shrink: 0;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-thumb:hover {
    opacity: 0.8;
}
.gallery-thumb.active {
    border-color: var(--color-primary);
    border-width: 4px;
    opacity: 1;
}
.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
/* Empty state */
.gallery-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.gallery-empty p {
    color: rgba(255,255,255,0.6);
    font-size: 18px;
    margin: 0;
}
.gallery-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Fullscreen tweaks */
.gallery-overlay:fullscreen .gallery-thumbs,
.gallery-overlay:-webkit-full-screen .gallery-thumbs {
    display: none;
}
.gallery-overlay:fullscreen .gallery-delete-btn,
.gallery-overlay:-webkit-full-screen .gallery-delete-btn {
    display: none;
}
.gallery-overlay:fullscreen .gallery-main-area,
.gallery-overlay:-webkit-full-screen .gallery-main-area {
    padding-bottom: 8px;
}
.gallery-overlay:fullscreen .gallery-caption,
.gallery-overlay:-webkit-full-screen .gallery-caption {
    padding-bottom: 16px;
}
