@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Primary Colors - Premium Indigo */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --primary-glow: rgba(99, 102, 241, 0.2);

    /* Functional Colors */
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #06b6d4;

    /* Backgrounds - Refined Light Palette */
    --bg-body: #f8fafc;
    --bg-sidebar: rgba(255, 255, 255, 0.7);
    --bg-card: rgba(255, 255, 255, 0.5);
    --bg-card-hover: rgba(255, 255, 255, 0.8);
    --bg-input: #ffffff;

    /* Text Colors - High Contrast */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Glassmorphism - Optimized for Light Mode */
    --glass-blur: 16px;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --border-color: rgba(0, 0, 0, 0.08);

    /* Radii & Effects */
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    /* Shadows - Soft depth */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.15);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* ===== MAP ===== */
#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: absolute;
    top: 16px;
    left: 16px;
    bottom: 16px;
    width: 340px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    overflow: hidden;
}

.sidebar.collapsed {
    transform: translateX(calc(-100% - 20px));
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon .icon {
    width: 20px;
    height: 20px;
    color: white;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== TABS ===== */
.tab-nav {
    display: flex;
    padding: 12px 16px 0;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-card);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-card);
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
}

.panel-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== LAYER LIST (Viewer) ===== */
.layer-list,
.admin-layer-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
}

.layer-list::-webkit-scrollbar,
.admin-layer-list::-webkit-scrollbar {
    width: 4px;
}

.layer-list::-webkit-scrollbar-thumb,
.admin-layer-list::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

/* Viewer Layer Card */
.layer-card {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    gap: 12px;
}

.layer-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.layer-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-info .name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-info .count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--text-muted);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    left: 2px;
    top: 2px;
    background: white;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(16px);
}

/* ===== ADMIN LAYER CARD ===== */
.admin-layer-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    overflow: hidden;
    transition: var(--transition);
}

.admin-layer-card:hover {
    border-color: var(--primary);
}

.admin-layer-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    gap: 10px;
    cursor: pointer;
}

.admin-layer-header .emoji {
    font-size: 1.2rem;
}

.admin-layer-header .name {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-layer-actions {
    display: flex;
    gap: 4px;
}

.admin-layer-body {
    display: none;
    padding: 0 14px 14px;
    border-top: 1px solid var(--border-color);
}

.admin-layer-body.open {
    display: block;
}

.point-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 8px;
}

.point-list-header span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.point-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    gap: 8px;
    transition: var(--transition);
}

.point-item:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-sm);
}

.point-item .point-info {
    flex: 1;
    min-width: 0;
}

.point-item .point-name {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.point-item .point-addr {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.point-item .point-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.empty-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 0.85rem;
}

.empty-msg .empty-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}

/* Checkboxes */
.point-checkbox, .layer-select-all {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
    margin-right: 2px;
}

.select-all-points {
    display: flex;
    align-items: center;
    gap: 6px;
}

.layer-bulk-delete {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.empty-msg .empty-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-glow);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-card);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-icon.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.btn-icon.edit:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.btn-icon.locate:hover {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

/* ===== SIDEBAR TOGGLE ===== */
.sidebar-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 999;
    width: 40px;
    height: 40px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.sidebar-toggle.visible {
    display: flex;
}

.sidebar-toggle:hover {
    background: var(--bg-card-hover);
}

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

/* ===== FORM ===== */
form {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 2px;
}

.color-preview {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    min-width: 260px;
    font-size: 0.85rem;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--primary);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* ===== ADD POINT INDICATOR ===== */
.add-point-indicator {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1500;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border-radius: 50px;
    box-shadow: var(--shadow-glow), var(--shadow-lg);
    font-size: 0.85rem;
    font-weight: 600;
    animation: pulse 2s infinite;
}

.add-point-indicator.active {
    display: flex;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: var(--shadow-glow), var(--shadow-lg);
    }

    50% {
        box-shadow: 0 0 30px rgba(37, 99, 235, 0.5), var(--shadow-lg);
    }
}

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-popup-content-wrapper {
    background: #1e293b;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-tip {
    background: #1e293b;
}

.leaflet-popup-content {
    margin: 12px 14px;
    line-height: 1.5;
}

.popup-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.popup-address {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.popup-note {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-style: italic;
}

.popup-coords {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    margin-top: 6px;
}

/* ===== CUSTOM MARKER ===== */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.custom-marker:hover {
    transform: rotate(-45deg) scale(1.2);
}

.custom-marker .marker-emoji {
    transform: rotate(45deg);
    font-size: 12px;
    line-height: 1;
}

/* ===== IMAGE MARKER (circular icon on map) ===== */
.image-marker {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2.5px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    transform: scale(0.6);
    transition: transform 0.2s ease;
}

.image-marker:hover {
    transform: scale(0.75);
}

.image-marker img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ===== ICON UPLOAD ===== */
.icon-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.icon-upload-area:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.icon-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.icon-upload-placeholder span {
    font-size: 0.75rem;
}

.icon-upload-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
}

.icon-upload-preview img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.2);
}

.icon-remove-btn {
    position: absolute;
    top: -4px;
    right: calc(50% - 46px);
    width: 22px !important;
    height: 22px !important;
    background: var(--danger) !important;
    color: white !important;
    border-radius: 50%;
}

/* ===== ICON SIZES ===== */
.icon {
    width: 20px;
    height: 20px;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-xs {
    width: 14px;
    height: 14px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 300px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        top: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        border-radius: 0;
    }
}

/* ===== IMPORT MODAL ===== */
.modal-lg {
    max-width: 560px;
}

.import-body {
    padding: 20px;
}

.import-instructions {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.instruction-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 8px;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: var(--radius-sm);
    gap: 8px;
}

.instruction-card strong {
    font-size: 0.72rem;
    line-height: 1.3;
}

.instruction-card p {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-select option {
    background: #1e293b;
    color: var(--text-primary);
}

/* Import Preview */
.import-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.import-preview-header span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.select-all-label input[type="checkbox"] {
    accent-color: var(--primary);
}

.import-preview-list {
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.import-preview-list::-webkit-scrollbar {
    width: 4px;
}

.import-preview-list::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.import-preview-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    transition: var(--transition);
}

.import-preview-item:hover {
    border-color: var(--primary);
}

.import-preview-item input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--primary);
}

.import-preview-item .preview-info {
    flex: 1;
    min-width: 0;
}

.import-preview-item .preview-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
    word-break: break-word;
}

.import-preview-item .preview-address {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.import-preview-item .preview-coords {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.import-preview-item .preview-status {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}

.preview-status.ok {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.preview-status.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== IMPORT EXCEL / PASTE ===== */
.import-excel-body {
    padding: 20px;
}

.import-excel-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 3px;
    border: 1px solid var(--border-color);
}

.excel-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.excel-tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.excel-tab-btn:not(.active):hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.excel-tab-content {
    display: none;
}

.excel-tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.import-excel-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.import-excel-hint i {
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 1px;
}

#excel-paste-area {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    resize: vertical;
    min-height: 120px;
    outline: none;
    transition: var(--transition);
    tab-size: 16;
    white-space: pre;
    overflow-x: auto;
}

#excel-paste-area:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Drop Zone */
.import-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 20px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    color: var(--text-muted);
}

.import-drop-zone:hover,
.import-drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.06);
    color: var(--primary);
}

.import-drop-zone.drag-over {
    border-style: solid;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
}

.import-drop-zone p {
    margin: 0;
    font-size: 0.85rem;
}

.drop-zone-sub {
    color: var(--text-muted) !important;
    font-size: 0.78rem !important;
}

.drop-zone-formats {
    font-size: 0.7rem !important;
    color: var(--text-muted) !important;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.icon-lg {
    width: 36px;
    height: 36px;
}

.selected-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: var(--radius-sm);
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--success);
    font-weight: 500;
}

.selected-file-info span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Column Mapping */
.column-mapping {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.column-mapping h4 {
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.mapping-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mapping-item label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mapping-item select {
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.78rem;
    outline: none;
    cursor: pointer;
}

.mapping-item select:focus {
    border-color: var(--primary);
}

/* Excel Preview Table */
.import-excel-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.import-excel-preview-header span {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
}

.import-excel-preview {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.import-excel-preview::-webkit-scrollbar {
    width: 4px;
}

.import-excel-preview::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.excel-preview-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.78rem;
    transition: var(--transition);
}

.excel-preview-row:last-child {
    border-bottom: none;
}

.excel-preview-row:hover {
    background: var(--bg-card-hover);
}

.excel-preview-row.invalid {
    opacity: 0.55;
    background: rgba(239, 68, 68, 0.05);
}

.excel-preview-row input[type="checkbox"] {
    accent-color: var(--primary);
    flex-shrink: 0;
}

.excel-preview-row .row-num {
    font-size: 0.68rem;
    color: var(--text-muted);
    width: 22px;
    text-align: right;
    flex-shrink: 0;
    font-family: 'Courier New', monospace;
}

.excel-preview-row .row-data {
    flex: 1;
    min-width: 0;
}

.excel-preview-row .row-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.excel-preview-row .row-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.excel-preview-row .row-status {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}

.row-status.valid {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.row-status.invalid {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* ===== LOADING OVERLAY (Firebase) ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-body);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-spinner-lg {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(148, 163, 184, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.loading-subtext {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.connection-status {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1500;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.4s ease;
}

.connection-status.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.connection-status.online .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.connection-status.offline .status-dot {
    background: var(--warning);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.connection-status.error .status-dot {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    animation: blink 1s infinite;
}

.connection-status .status-text {
    color: var(--text-secondary);
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ===== USER PROFILE (Sidebar Header) ===== */
.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    margin-top: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.user-info .icon-sm {
    color: var(--text-muted);
}

.user-email {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== AUTH SCREEN ===== */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    background: radial-gradient(circle at top left, rgba(99, 102, 241, 0.08), transparent 40%),
        radial-gradient(circle at bottom right, rgba(167, 139, 250, 0.08), transparent 40%),
        #f8fafc;
    overflow: hidden;
}

.auth-screen::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0, transparent 50%),
        radial-gradient(at 50% 0%, rgba(139, 92, 246, 0.05) 0, transparent 50%),
        radial-gradient(at 100% 0%, rgba(217, 70, 239, 0.05) 0, transparent 50%);
    filter: blur(100px);
    z-index: -1;
}

.auth-container {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    box-sizing: border-box;
    animation: authAppear 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authAppear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    position: relative;
}

.auth-header .logo-icon::after {
    content: '';
    position: absolute;
    inset: -4px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: inherit;
    opacity: 0.3;
    z-index: -1;
    filter: blur(8px);
}

.auth-header .logo-icon .icon {
    width: 32px;
    height: 32px;
}

.auth-header h2 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #4f46e5, #9333ea);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.auth-header p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.auth-tabs {
    display: flex;
    margin-bottom: 32px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.auth-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.auth-tab:not(.active):hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.02);
}

/* Beautiful Inputs */
.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon .input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition);
}

.input-with-icon input {
    padding-left: 44px !important;
}

.input-with-icon input:focus+.input-icon {
    color: var(--primary);
}

.form-group label {
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    height: 48px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    border-radius: var(--radius-md);
    font-weight: 500;
}

.form-group input:hover {
    border-color: var(--primary);
}

.auth-error {
    background: rgba(244, 63, 94, 0.1);
    color: var(--danger);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 24px;
    text-align: center;
    backdrop-filter: blur(4px);
}

.btn-auth-submit {
    width: 100%;
    margin-top: 12px;
    padding: 14px;
    height: 52px;
    font-size: 1rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-auth-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-auth-submit:active {
    transform: translateY(0);
}

/* ===== ROLE BADGES ===== */
.role-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.6;
    flex-shrink: 0;
}

.role-admin {
    background: rgba(139, 92, 246, 0.15);
    color: #7c3aed;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.role-mod {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.role-user {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(100, 116, 139, 0.2);
}

/* ===== USER PROFILE — role badge row ===== */
.user-info-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

/* ===== USER LIST (tab Users) ===== */
.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    gap: 8px;
    transition: var(--transition);
}

.user-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.user-item-self {
    border-color: rgba(99, 102, 241, 0.3);
    background: var(--primary-light);
}

.user-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.user-item-email {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.self-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.user-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}