/* ═══════════════════════════════════════════════════════
   Radio Cell Manager — Dark Theme
   ═══════════════════════════════════════════════════════ */

:root {
    --bg-base: #0a0e1a;
    --bg-surface: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --bg-input: rgba(15, 23, 42, 0.8);
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);
    --border-focus: rgba(0, 212, 255, 0.5);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary: #00d4ff;
    --primary-glow: rgba(0, 212, 255, 0.15);
    --secondary: #7c3aed;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --nav-hover: rgba(255, 255, 255, 0.05);
    --sidebar-w: 220px;
    --header-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --mono: 'Consolas', 'Cascadia Code', 'SF Mono', 'Courier New', monospace;
}

[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: rgba(241, 245, 249, 0.95);
    --bg-input: #ffffff;
    --border: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(0, 0, 0, 0.18);
    --border-focus: rgba(2, 132, 199, 0.5);
    --text: #1e293b;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    --primary: #0284c7;
    --primary-glow: rgba(2, 132, 199, 0.12);
    --secondary: #7c3aed;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
    --nav-hover: rgba(255, 255, 255, 0.05);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.15);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--primary); color: var(--bg-base); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }


/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0f172a 0%, #0a0e1a 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width var(--transition);
}

.sidebar-logo {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 24px; }
.logo-text {
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.nav-btn:hover {
    background: var(--nav-hover);
    color: var(--text);
}
.nav-btn.active {
    background: var(--primary-glow);
    color: var(--primary);
}
.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--nav-hover);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--border-hover); color: var(--text); }
.theme-toggle-icon { font-size: 14px; line-height: 1; }
.theme-toggle-track {
    margin-left: auto;
    width: 30px; height: 16px;
    border-radius: 8px;
    background: var(--text-dim);
    position: relative;
    transition: background var(--transition);
}
.theme-toggle-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--transition);
}
[data-theme="light"] .theme-toggle-track { background: var(--primary); }
[data-theme="light"] .theme-toggle-track::after { transform: translateX(14px); }

/* ── Light mode: variables ── */
[data-theme="light"] {
    --table-header-bg: #1e293b;
    --row-hover: rgba(0,0,0,0.04);
    --row-even: rgba(0,0,0,0.025);
}

/* ── Light mode: buttons ── */
[data-theme="light"] .btn-secondary {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}
[data-theme="light"] .btn-secondary:hover { background: #e2e8f0; border-color: #94a3b8; }
[data-theme="light"] .btn-ghost { color: #475569; }
[data-theme="light"] .btn-ghost:hover { color: #1e293b; background: rgba(0,0,0,0.05); }
[data-theme="light"] .btn-primary { color: #fff; }
[data-theme="light"] .btn-danger { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.25); }

/* ── Light mode: inputs & filters ── */
[data-theme="light"] .filter-bar { background: #fff; border-color: #e2e8f0; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
[data-theme="light"] .filter-input,
[data-theme="light"] .filter-select {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}
[data-theme="light"] .filter-input:focus,
[data-theme="light"] .filter-select:focus { border-color: #0284c7; background: #fff; }
[data-theme="light"] .filter-input::placeholder { color: #94a3b8; }

/* ── Light mode: table ── */
[data-theme="light"] .table-wrapper { background: #fff; border-color: #e2e8f0; }
[data-theme="light"] .data-table td { color: #1e293b; }
[data-theme="light"] .data-table th { color: #94a3b8; }

/* ── Light mode: cards ── */
[data-theme="light"] .card,
[data-theme="light"] .stat-card { background: #fff; border-color: #e2e8f0; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
[data-theme="light"] .chart-bar-label { color: #475569; }

/* ── Light mode: modal ── */
[data-theme="light"] .modal { background: #fff; border-color: #e2e8f0; }
[data-theme="light"] .modal-header { border-bottom-color: #e2e8f0; }
[data-theme="light"] .modal-footer { border-top-color: #e2e8f0; background: #f8fafc; }

/* ── Light mode: modal ── */
[data-theme="light"] .modal-close { background: rgba(0,0,0,0.06); }
[data-theme="light"] .modal-close:hover { background: rgba(0,0,0,0.12); }
[data-theme="light"] .modal-footer { background: #f8fafc; border-top-color: #e2e8f0; }
[data-theme="light"] .form-input { background: #f8fafc; border-color: #cbd5e1; }
[data-theme="light"] .form-input:focus { background: #fff; border-color: #0284c7; }
[data-theme="light"] .form-input::placeholder { color: #94a3b8; }

/* ── Light mode: pagination & misc ── */
[data-theme="light"] .page-btn { background: #f1f5f9; border-color: #cbd5e1; color: #334155; }
[data-theme="light"] .page-btn:hover { background: #e2e8f0; border-color: #94a3b8; }
[data-theme="light"] .page-btn.active { background: #0284c7; border-color: #0284c7; color: #fff; }


/* ── Light mode: giữ sidebar text màu sáng vì sidebar luôn dark ── */
[data-theme="light"] .sidebar { color: #e2e8f0; border-right-color: rgba(255,255,255,0.08); }
[data-theme="light"] .sidebar-db-select label { color: #94a3b8; }
[data-theme="light"] .nav-btn { color: #94a3b8; }
[data-theme="light"] .nav-btn:hover { color: #e2e8f0; background: rgba(255,255,255,0.05); }
[data-theme="light"] .nav-btn.active { color: #00d4ff; background: rgba(0,212,255,0.12); }
[data-theme="light"] .sidebar-footer { border-top-color: rgba(255,255,255,0.08); }
[data-theme="light"] .theme-toggle { color: #94a3b8; border-color: rgba(255,255,255,0.1); }
[data-theme="light"] .theme-toggle:hover { color: #e2e8f0; border-color: rgba(255,255,255,0.2); }
[data-theme="light"] .db-status { color: #64748b; }
.db-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-dim);
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


/* ── Main Content ────────────────────────────────────── */

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    overflow-y: auto;
    height: 100vh;
    padding: 32px;
    background:
        radial-gradient(ellipse at 20% 0%, var(--primary-glow) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(124, 58, 237, 0.04) 0%, transparent 50%),
        var(--bg-base);
    transition: background var(--transition);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}


/* ── Cards & Stats ───────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(12px);
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent-color, var(--primary));
    border-radius: 3px 3px 0 0;
}
.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
    line-height: 1;
}
.stat-icon {
    position: absolute;
    top: 20px; right: 20px;
    font-size: 1.5rem;
    opacity: 0.3;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
}

.chart-container { min-height: 180px; }

.chart-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.chart-bar-label {
    width: 80px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
}
.chart-bar-track {
    flex: 1;
    height: 28px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}
.chart-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bg-base);
    min-width: 40px;
}


/* ── Buttons ─────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #0099cc);
    color: var(--bg-base);
    border-color: var(--primary);
}
.btn-primary:hover {
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
    transform: translateY(-1px);
}
.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); }
.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px 12px;
}
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; margin-top: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }


/* ── Filters ─────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
}

.filter-input, .filter-select {
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    transition: all var(--transition);
    outline: none;
}
.filter-input:focus, .filter-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.filter-input { min-width: 200px; }
.filter-input.filter-sm { min-width: 100px; width: 110px; }
.filter-select { min-width: 130px; cursor: pointer; }
.filter-select option { background: var(--bg-surface); color: var(--text); }


/* ── Data Table ──────────────────────────────────────── */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}
.data-table th {
    background: var(--table-header-bg, rgba(15, 23, 42, 0.95));
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: color var(--transition);
}
.data-table th:hover { color: var(--primary); }
.data-table th.sorted { color: var(--primary); }
.data-table th .sort-arrow { margin-left: 4px; font-size: 0.7rem; }

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-table tbody tr {
    transition: background var(--transition);
    cursor: pointer;
}
.data-table tbody tr:hover { background: var(--row-hover, rgba(255,255,255,0.04)); }
.data-table tbody tr:nth-child(even) { background: var(--row-even, rgba(255,255,255,0.015)); }
.data-table tbody tr:nth-child(even):hover { background: var(--row-hover, rgba(255,255,255,0.05)); }

.cell-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
}
/* dark mode — chữ nhạt trên nền trong */
.tag-L900     { background: rgba(239,68,68,0.15);   color: #fca5a5; }
.tag-L1800F1  { background: rgba(16,185,129,0.15);  color: #6ee7b7; }
.tag-L1800F2  { background: rgba(245,158,11,0.15);  color: #fcd34d; }
.tag-L2100    { background: rgba(59,130,246,0.15);  color: #93c5fd; }

/* DB source tags */
.tag-db-4g  { background: rgba(59,130,246,0.15);  color: #93c5fd; }
.tag-db-5g  { background: rgba(16,185,129,0.15);  color: #6ee7b7; }
.tag-db-4t  { background: rgba(245,158,11,0.15);  color: #fcd34d; }
.tag-db-5t  { background: rgba(168,85,247,0.15);  color: #d8b4fe; }

/* light mode — chữ đậm để đủ contrast */
[data-theme="light"] .tag-L900    { background: rgba(239,68,68,0.12);   color: #b91c1c; }
[data-theme="light"] .tag-L1800F1 { background: rgba(16,185,129,0.12);  color: #065f46; }
[data-theme="light"] .tag-L1800F2 { background: rgba(245,158,11,0.12);  color: #92400e; }
[data-theme="light"] .tag-L2100   { background: rgba(59,130,246,0.12);  color: #1e40af; }
[data-theme="light"] .tag-db-4g   { background: rgba(59,130,246,0.12);  color: #1e40af; }
[data-theme="light"] .tag-db-5g   { background: rgba(16,185,129,0.12);  color: #065f46; }
[data-theme="light"] .tag-db-4t   { background: rgba(245,158,11,0.12);  color: #92400e; }
[data-theme="light"] .tag-db-5t   { background: rgba(168,85,247,0.12);  color: #4c1d95; }


/* ── Pagination ──────────────────────────────────────── */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
    padding: 12px;
}
.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}
.page-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.page-btn.active {
    background: var(--primary);
    color: var(--bg-base);
    border-color: var(--primary);
    font-weight: 600;
}
.page-btn:disabled { opacity: 0.3; pointer-events: none; }
.page-info {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin: 0 12px;
}


/* ── Map ─────────────────────────────────────────────── */

.map-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 12px;
}
.map-title { font-size: 1.2rem; font-weight: 700; }
.map-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; width: 100%; }
.map-counter { font-size: 0.8rem; color: var(--text-dim); }
.map-hint { font-size: 0.75rem; color: var(--text-dim); font-style: italic; }
.map-action-row { display: flex; gap: 8px; align-items: center; }
.map-action-row .btn { flex: 1; justify-content: center; }
.map-search-box {
    position: relative;
    width: 100%;
    min-width: 0;
}
.map-search-input {
    width: 100%;
    padding-right: 62px !important;
    min-width: 0;
}
.map-search-btn-go {
    position: absolute;
    right: 4px;
    top: 50%; transform: translateY(-50%);
    background: var(--primary);
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    color: var(--bg-base);
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: opacity var(--transition);
}
.map-search-btn-go:hover { opacity: 0.85; }
.map-search-btn-clear {
    position: absolute;
    right: 38px;
    top: 50%; transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: color var(--transition);
    z-index: 2;
}
.map-search-btn-clear:hover { color: var(--text); }
.site-label-match { background: rgba(250,204,21,0.9); color: #1a1a1a; border: none; border-radius: 3px; font-size: 11px; font-weight: 700; padding: 2px 5px; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
#map-container.zoom-hide-labels .leaflet-tooltip.site-label,
#map-container.zoom-hide-labels .leaflet-tooltip.remote-label { display: none !important; }

#map-container {
    width: 100%;
    height: calc(100vh - 200px);
    min-height: 500px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.map-legend {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 12px 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-color {
    width: 14px; height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
    background: var(--bg-surface) !important;
    color: var(--text) !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
}
.leaflet-popup-tip { background: var(--bg-surface) !important; }
.leaflet-popup-content { font-family: var(--font) !important; font-size: 0.8rem !important; line-height: 1.6 !important; }
.leaflet-popup-content b { color: var(--primary); }

/* Site name labels */
.site-label {
    background: rgba(0,0,0,0.6) !important;
    border: none !important;
    color: #fff !important;
    font-family: var(--font) !important;
    font-size: 10px !important;
    font-weight: 500 !important;
    padding: 1px 5px !important;
    border-radius: 3px !important;
    box-shadow: none !important;
    white-space: nowrap !important;
}
.site-label::before { display: none !important; }
.remote-label {
    background: rgba(6, 182, 212, 0.7) !important;
    color: #fff !important;
    font-weight: 600 !important;
    border: 1px solid rgba(6, 182, 212, 0.9) !important;
}

/* ── Measure Tool ────────────────────────────────────── */

.leaflet-container.crosshair-cursor-enabled {
    cursor: crosshair !important;
}

.measure-tooltip {
    background: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid #fcd34d !important;
    color: #fcd34d !important;
    font-family: var(--mono) !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
    white-space: nowrap !important;
}
.measure-tooltip::before { display: none !important; }


/* ── Import / Export ─────────────────────────────────── */

.io-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}
.io-card { display: flex; flex-direction: column; }

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-dim);
    margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-glow);
    color: var(--primary);
}
.drop-zone svg { margin-bottom: 12px; opacity: 0.5; }
.drop-zone p { margin-bottom: 4px; font-size: 0.9rem; }
.drop-sub { font-size: 0.75rem !important; color: var(--text-dim); }
.drop-zone.has-file {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
    color: var(--success);
}

.import-options {
    margin-bottom: 8px;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px; height: 16px;
}

.diff-action-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.diff-action-row .btn { flex: 1; }
.btn-danger {
    background: rgba(239,68,68,0.15);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.28); }

.import-result, .diff-result {
    margin-top: 16px;
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    display: none;
}
.import-result.show, .diff-result.show { display: block; }
.result-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); color: var(--success); }
.result-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.2);  color: var(--danger); }

.export-desc { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 20px; }
.export-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.btn-export {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-export:hover {
    background: rgba(255,255,255,0.07);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.export-icon { font-size: 1.5rem; }


/* ── Login Overlay ───────────────────────────────────── */

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 26, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    backdrop-filter: blur(8px);
}
.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: min(380px, 92vw);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo { font-size: 2.5rem; margin-bottom: 12px; }
.login-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-error {
    font-size: 0.82rem;
    color: var(--danger);
    min-height: 1.2em;
    text-align: center;
}

.login-divider {
    display: flex; align-items: center; gap: 10px;
    margin: 4px 0; color: var(--text-dim); font-size: 0.8rem;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── User info bar ───────────────────────────────────── */

.user-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    gap: 8px;
}
.user-info-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.user-info-text { display: flex; flex-direction: column; min-width: 0; }
.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 2px;
    width: fit-content;
}
.badge-admin  { background: rgba(0,212,255,0.15); color: var(--primary); }
.badge-viewer { background: rgba(245,158,11,0.15); color: var(--warning); }

.user-info-actions { display: flex; gap: 4px; }
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    color: var(--text-muted);
}
.icon-btn:hover { background: var(--nav-hover); color: var(--text); }

/* ── Viewer mode: ẩn admin-only elements ─────────────── */
body.viewer-mode .admin-only { display: none !important; }

/* ── Modal ───────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: min(600px, 90vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px;
    border: none;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-input {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: all var(--transition);
}
.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.detail-item { }
.detail-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 2px;
}
.detail-value {
    font-size: 0.9rem;
    color: var(--text);
    font-family: var(--mono);
}


/* ── Toast ───────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 360px;
}
.toast-success { background: rgba(16,185,129,0.9); color: #fff; }
.toast-error   { background: rgba(239,68,68,0.9);  color: #fff; }
.toast-info    { background: rgba(59,130,246,0.9);  color: #fff; }

@keyframes toastIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(40px); } }


/* ── Loading ─────────────────────────────────────────── */

.loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ── Responsive ──────────────────────────────────────── */

/* ── Mobile top bar (hidden on desktop) ── */
.mobile-topbar {
    display: none;
}
.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #e2e8f0;
    border-radius: 2px;
    transition: all var(--transition);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.mobile-logo-text {
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Tablet: collapse sidebar to icon bar (769-900px) ── */
@media (min-width: 769px) and (max-width: 900px) {
    .sidebar { width: 64px; }
    .nav-label, .logo-text { display: none; }
    .sidebar-logo { justify-content: center; padding: 0; }
    .nav-btn { justify-content: center; padding: 12px; }
    .main-content { margin-left: 64px; padding: 20px; }
    .db-status .status-text { display: none; }
    .filter-bar { flex-direction: column; }
    .filter-input { min-width: 100%; }
    .charts-grid { grid-template-columns: 1fr; }
    .io-grid { grid-template-columns: 1fr; }
    .sidebar-footer { padding: 10px 8px; align-items: center; }
    .theme-toggle { padding: 6px; justify-content: center; }
    .theme-toggle-icon { font-size: 16px; }
    #theme-label, .theme-toggle-track { display: none; }
}

/* ── Mobile: full drawer ── */
@media (max-width: 768px) {
    /* Top bar */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 52px;
        background: #0f172a;
        border-bottom: 1px solid var(--border);
        padding: 0 16px;
        z-index: 1300;
    }
    [data-theme="light"] .mobile-topbar {
        background: #1e293b;
    }

    /* Sidebar as drawer — z-index > 1000 (Leaflet controls) */
    .sidebar {
        width: var(--sidebar-w) !important;
        transform: translateX(-100%);
        transition: transform var(--transition);
        z-index: 1201;
        top: 0;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    /* Overlay above Leaflet, below sidebar */
    .sidebar-overlay { z-index: 1200; }

    /* Restore all hidden labels inside sidebar */
    .sidebar .nav-label,
    .sidebar .logo-text { display: unset !important; }
    .sidebar .sidebar-logo { justify-content: flex-start !important; padding: 0 20px !important; }
    .sidebar .nav-btn { justify-content: flex-start !important; padding: 12px 16px !important; }
    .sidebar .db-status .status-text { display: unset !important; }
    .sidebar .sidebar-footer { padding: 12px 20px 16px !important; align-items: stretch !important; }
    .sidebar .theme-toggle { padding: 7px 10px !important; justify-content: flex-start !important; }
    #theme-label, .theme-toggle-track { display: unset !important; }

    /* Main content */
    .main-content {
        margin-left: 0 !important;
        padding: 16px !important;
        padding-top: 68px !important;
        height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 16px;
    }
    .page-header h1 { font-size: 1.3rem; }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.5rem; }

    /* Charts */
    .charts-grid { grid-template-columns: 1fr; gap: 12px; }
    .chart-bar-label { width: 60px; font-size: 0.72rem; }

    /* Filter bar */
    .filter-bar {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        margin-bottom: 12px;
    }
    .filter-input,
    .filter-select { min-width: 100% !important; width: 100% !important; }
    .filter-input.filter-sm { width: 100% !important; }

    /* Table: enable touch horizontal scroll */
    .table-wrapper {
        border-radius: var(--radius-sm);
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .data-table td, .data-table th { padding: 8px 10px; font-size: 0.78rem; }

    /* Pagination */
    .pagination { flex-wrap: wrap; gap: 4px; }
    .page-info { margin: 0 4px; }

    /* Map */
    .map-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px 0;
    }
    .map-filters {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .map-filters .filter-select { width: 100%; min-width: 0; }
    .map-search-box { width: 100%; }
    .map-action-row { width: 100%; }
    .map-counter { font-size: 0.75rem; }
    .map-hint { font-size: 0.72rem; width: 100%; }
    #map-container {
        height: calc(100svh - 290px);
        min-height: 320px;
    }
    .map-legend { gap: 8px; font-size: 0.75rem; }

    /* IO grid */
    .io-grid { grid-template-columns: 1fr !important; gap: 14px; }
    .drop-zone { padding: 24px 16px; }
    .export-buttons { grid-template-columns: 1fr 1fr; gap: 8px; }
    .btn-export { padding: 14px 10px; font-size: 0.8rem; }

    /* Diff action row */
    .diff-action-row { flex-direction: row; }

    /* Modal */
    .modal { width: 95vw !important; max-height: 90vh; }
    .modal-body { padding: 16px; }
    .modal-header { padding: 14px 16px; }
}
