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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0f1117;
    color: #e1e4e8;
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, #1a1d27, #252830);
    border-bottom: 1px solid #2d3139;
    padding: 1.5rem 2rem;
}

.header-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #58a6ff;
    letter-spacing: -0.5px;
}

.subtitle {
    color: #8b949e;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    padding-bottom: 280px;
}

/* Credentials Section */
.credentials-section {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.cred-fields {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.cred-fields input {
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 160px;
    outline: none;
    transition: border-color 0.2s;
}

.cred-fields input:focus {
    border-color: #58a6ff;
}

.cred-fields input::placeholder {
    color: #484f58;
}

#save-creds-btn {
    background: #1f2937;
    color: #58a6ff;
    border: 1px solid #58a6ff;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#save-creds-btn:hover {
    background: #58a6ff;
    color: #0f1117;
}

.cred-status {
    font-size: 0.8rem;
    font-weight: 500;
}

.cred-ok { color: #3fb950; }
.cred-error { color: #f85149; }

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
}

.card-label {
    font-size: 0.85rem;
    color: #8b949e;
    margin-top: 0.25rem;
}

.card-total .card-value { color: #e1e4e8; }
.card-camera .card-value { color: #f85149; }
.card-hotspot .card-value { color: #58a6ff; }
.card-router .card-value { color: #3fb950; }

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

#scan-btn {
    background: #238636;
    color: #fff;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#scan-btn:hover { background: #2ea043; }
#scan-btn:disabled {
    background: #1a1d27;
    color: #484f58;
    cursor: not-allowed;
}

.filters {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    background: #1a1d27;
    color: #8b949e;
    border: 1px solid #2d3139;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover { border-color: #58a6ff; color: #e1e4e8; }
.filter-btn.active {
    background: #1f2937;
    border-color: #58a6ff;
    color: #58a6ff;
}

/* Loading */
#loading {
    text-align: center;
    padding: 3rem;
    color: #8b949e;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2d3139;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error-msg {
    background: #3d1a1a;
    border: 1px solid #f85149;
    color: #f85149;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background: #1a1d27;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #2d3139;
}

thead th {
    background: #252830;
    color: #8b949e;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid #2d3139;
}

tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid #21262d;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #21262d; }

/* Device Type Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-camera {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.badge-hotspot {
    background: rgba(88, 166, 255, 0.15);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.badge-router {
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-unknown {
    background: rgba(139, 148, 158, 0.1);
    color: #8b949e;
    border: 1px solid rgba(139, 148, 158, 0.2);
}

.badge-group {
    background: rgba(163, 113, 247, 0.15);
    color: #a371f7;
    border: 1px solid rgba(163, 113, 247, 0.3);
}

.group-header-row td {
    background: #1a1d27 !important;
    color: #e6edf3;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.75rem 1rem !important;
    border-bottom: 2px solid #2d3139;
    letter-spacing: 0.3px;
    user-select: none;
}
.group-header-row:hover td {
    background: #21262d !important;
}
.group-page-card-clients {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}
.group-client-chip {
    display: inline-block;
    background: rgba(56, 139, 253, 0.12);
    color: #58a6ff;
    border: 1px solid rgba(56, 139, 253, 0.25);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    cursor: help;
}
.group-clients-badge {
    display: inline-block;
    background: rgba(56, 139, 253, 0.15);
    color: #58a6ff;
    border: 1px solid rgba(56, 139, 253, 0.3);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 0.5rem;
    cursor: help;
    white-space: pre-line;
}
.group-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #8b949e;
    font-size: 0.85rem;
    cursor: pointer;
    margin-left: 0.5rem;
    white-space: nowrap;
}
.group-toggle input { accent-color: #a371f7; }

.badge-nvr {
    background: rgba(210, 153, 34, 0.15);
    color: #d29922;
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.badge-system {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(88, 166, 255, 0.1);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.2);
}

/* Ports */
.port-list {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.8rem;
    color: #8b949e;
}

/* Preview Button */
.preview-btn {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-btn:hover {
    background: #f85149;
    color: #fff;
}

.preview-btn-connect {
    background: rgba(88, 166, 255, 0.15);
    color: #58a6ff;
    border-color: rgba(88, 166, 255, 0.3);
}

.preview-btn-connect:hover {
    background: #58a6ff;
    color: #fff;
}

/* Admin Button */
.admin-btn {
    display: inline-block;
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
    border: 1px solid rgba(63, 185, 80, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.admin-btn:hover {
    background: #3fb950;
    color: #fff;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #2d3139;
}

.modal-header span {
    font-weight: 600;
    font-size: 1rem;
    color: #e1e4e8;
}

.modal-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #f85149;
}

.modal-body {
    padding: 1.25rem;
}

.channel-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.channel-selector label {
    color: #8b949e;
    font-size: 0.85rem;
}

.channel-selector select {
    background: #0f1117;
    color: #e1e4e8;
    border: 1px solid #2d3139;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.channel-selector select:focus {
    border-color: #58a6ff;
}

.modal-image-wrapper {
    background: #0f1117;
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.modal-image-wrapper img {
    max-width: 100%;
    max-height: 60vh;
    display: block;
}

.modal-image-wrapper video-stream {
    width: 100%;
    max-height: 60vh;
    display: block;
}

.modal-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 17, 23, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 5;
    color: #8b949e;
    font-size: 0.85rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.modal-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #2d3139;
    background: #252830;
    color: #e1e4e8;
    transition: all 0.2s;
}

.modal-btn:hover {
    border-color: #58a6ff;
    color: #58a6ff;
}

.modal-btn-live {
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
    border-color: rgba(63, 185, 80, 0.3);
}

.modal-btn-live:hover {
    background: #3fb950;
    color: #fff;
}

.modal-btn-stop {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
    border-color: rgba(248, 81, 73, 0.3);
}

.modal-btn-stop:hover {
    background: #f85149;
    color: #fff;
}

/* Per-device credential modal */
.modal-content-sm {
    max-width: 420px;
}

.cred-modal-desc {
    color: #8b949e;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.cred-modal-desc strong {
    color: #58a6ff;
}

.cred-modal-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.cred-modal-fields input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.cred-modal-fields input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus {
    border-color: #58a6ff;
}

.cred-modal-fields input::placeholder {
    color: #484f58;
}

.cred-modal-error {
    background: #3d1a1a;
    border: 1px solid #f85149;
    color: #f85149;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.cred-modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #484f58;
}

.empty-state p { font-size: 1rem; }

/* View Switch (Preview / Live Grid toggle) */
.view-switch {
    display: flex;
    gap: 2px;
    background: #0f1117;
    border-radius: 6px;
    padding: 2px;
    border: 1px solid #2d3139;
}

.view-switch-btn {
    background: transparent;
    color: #8b949e;
    border: none;
    padding: 0.3rem 0.85rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.view-switch-btn:hover {
    color: #e1e4e8;
}

.view-switch-btn.active {
    background: #58a6ff;
    color: #fff;
}

/* Grid Modal */
.grid-modal-content {
    background: #0f1117;
    width: 96vw;
    height: 96vh;
    border-radius: 12px;
    border: 1px solid #2d3139;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.grid-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: #1a1d27;
    border-bottom: 1px solid #2d3139;
    flex-shrink: 0;
}

.grid-title {
    font-weight: 600;
    font-size: 1rem;
    color: #e1e4e8;
}

.grid-size-selector {
    display: flex;
    gap: 0.35rem;
}

.grid-size-btn {
    background: #252830;
    color: #8b949e;
    border: 1px solid #2d3139;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.grid-size-btn:hover {
    border-color: #58a6ff;
    color: #e1e4e8;
}

.grid-size-btn.active {
    background: #1f2937;
    border-color: #58a6ff;
    color: #58a6ff;
}

/* Grid Container */
.grid-container {
    flex: 1;
    display: grid;
    gap: 2px;
    padding: 2px;
    min-height: 0;
}

.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Grid Cell */
.grid-cell {
    position: relative;
    background: #1a1d27;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.grid-cell img,
.grid-cell video-stream {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.grid-cell-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.35rem 0.5rem;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
    display: flex;
    align-items: center;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.2s;
}

.grid-cell:hover .grid-cell-overlay {
    opacity: 1;
}

.grid-cell-overlay select {
    background: rgba(15, 17, 23, 0.85);
    color: #e1e4e8;
    border: 1px solid #2d3139;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    outline: none;
    cursor: pointer;
    max-width: 100%;
}

.grid-cell-overlay select:focus {
    border-color: #58a6ff;
}

.grid-cell-empty {
    color: #484f58;
    font-size: 0.85rem;
}

/* Grid cell loading state */
.grid-cell-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #8b949e;
    font-size: 0.8rem;
    z-index: 0;
}

.grid-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #2d3139;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.grid-cell-error {
    color: #f85149;
    font-size: 0.8rem;
}

.grid-cell-label {
    color: #e1e4e8;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: auto;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    white-space: nowrap;
}

/* Camera Groups Section */
.groups-section {
    margin-bottom: 1.5rem;
}

.groups-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.groups-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e1e4e8;
}

.group-add-btn {
    background: rgba(88, 166, 255, 0.15);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.3);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.group-add-btn:hover {
    background: #58a6ff;
    color: #fff;
}

.groups-list {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.groups-empty {
    color: #484f58;
    font-size: 0.9rem;
}

/* Group Card */
.group-card {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    min-width: 180px;
    max-width: 280px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.group-card:hover {
    border-color: #58a6ff;
    background: #1f2937;
}

.group-card-name {
    font-weight: 600;
    font-size: 1rem;
    color: #e1e4e8;
    margin-bottom: 0.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-card-count {
    font-size: 0.8rem;
    color: #8b949e;
}

.group-card-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.group-card:hover .group-card-actions {
    opacity: 1;
}

.group-card-action {
    background: rgba(15, 17, 23, 0.7);
    border: 1px solid #2d3139;
    color: #8b949e;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.group-card-action:hover {
    color: #e1e4e8;
    border-color: #58a6ff;
}

.group-card-action.delete:hover {
    color: #f85149;
    border-color: #f85149;
}

/* Group Modal */
.modal-content-group {
    max-width: 520px;
}

.group-modal-field {
    margin-bottom: 1rem;
}

.group-modal-field label {
    display: block;
    color: #8b949e;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.group-modal-field input[type="text"] {
    width: 100%;
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.group-modal-field input[type="text"]:focus {
    border-color: #58a6ff;
}

.group-modal-field input[type="text"]::placeholder {
    color: #484f58;
}

.group-camera-list {
    max-height: 300px;
    overflow-y: auto;
    background: #0f1117;
    border: 1px solid #2d3139;
    border-radius: 6px;
    padding: 0.5rem;
}

.group-camera-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.group-camera-item:hover {
    background: #1a1d27;
}

.group-camera-item input[type="checkbox"] {
    accent-color: #58a6ff;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.group-camera-item label {
    color: #e1e4e8;
    font-size: 0.85rem;
    cursor: pointer;
    flex: 1;
}

.group-camera-device {
    color: #8b949e;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.5rem 0.5rem 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-top: 1px solid #21262d;
    margin-top: 0.25rem;
}

.group-camera-device:first-child {
    border-top: none;
    margin-top: 0;
}

/* Groups page link on main page */
.group-manage-link {
    color: #58a6ff;
    font-size: 0.85rem;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.group-manage-link:hover {
    color: #79c0ff;
    text-decoration: underline;
}

/* Groups page */
.groups-page-nav {
    margin-bottom: 1.5rem;
}

.back-link {
    color: #58a6ff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: #79c0ff;
    text-decoration: underline;
}

.groups-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.groups-page-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Group page card (full-width row) */
.group-page-card {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s;
}

.group-page-card:hover {
    border-color: #373b44;
}

.group-page-card-info {
    flex: 1;
    min-width: 0;
}

.group-page-card-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: #e1e4e8;
    margin-bottom: 0.2rem;
}

.group-page-card-detail {
    font-size: 0.8rem;
    color: #8b949e;
}

.group-page-card-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ============================================================
   Navigation Bar
   ============================================================ */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.main-nav {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    color: #8b949e;
    text-decoration: none;
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-link:hover {
    color: #fafafa;
    background: #1a1a1f;
}

.nav-link.active {
    color: #1f6feb;
    background: rgba(31, 111, 235, 0.12);
}

/* ============================================================
   Map Page Layout
   ============================================================ */

.map-layout {
    display: flex;
    height: calc(100vh - 73px);
    position: relative;
    overflow: hidden;
}

.map-container {
    flex: 1;
    min-width: 0;
    z-index: 1;
}

/* --- Map Sidebar --- */

.map-sidebar {
    width: 280px;
    background: #1a1d27;
    border-right: 1px solid #2d3139;
    display: flex;
    flex-direction: column;
    z-index: 2;
    transition: margin-left 0.3s ease;
    flex-shrink: 0;
}

.map-sidebar.collapsed {
    margin-left: -280px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #2d3139;
}

.sidebar-header h3 {
    font-size: 0.95rem;
    color: #e1e4e8;
    font-weight: 600;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s;
}

.sidebar-toggle:hover {
    color: #e1e4e8;
}

.sidebar-open-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-left: none;
    border-radius: 0 6px 6px 0;
    color: #8b949e;
    font-size: 1rem;
    padding: 0.75rem 0.35rem;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.sidebar-open-btn:hover {
    color: #58a6ff;
}

.sidebar-search {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #2d3139;
}

.sidebar-search input {
    width: 100%;
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-search input:focus {
    border-color: #58a6ff;
}

.sidebar-search input::placeholder {
    color: #484f58;
}

.sidebar-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(248, 81, 73, 0.1);
    border-bottom: 1px solid #2d3139;
    color: #f85149;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-badge:hover {
    background: rgba(248, 81, 73, 0.2);
}

.sidebar-badge span {
    background: #f85149;
    color: #fff;
    font-size: 0.75rem;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-camera-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.sidebar-device-header {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-top: 1px solid #21262d;
    margin-top: 0.25rem;
}

.sidebar-device-header:first-child {
    border-top: none;
    margin-top: 0;
}

.sidebar-camera-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.82rem;
    color: #e1e4e8;
}

.sidebar-camera-item:hover {
    background: #21262d;
}

.sidebar-camera-item.unlocated {
    opacity: 0.5;
}

.sidebar-cam-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-cam-online {
    background: #3fb950;
}

.sidebar-cam-offline {
    background: #f85149;
}

.sidebar-cam-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.sidebar-cam-count {
    font-size: 0.7rem;
    color: #8b949e;
    flex-shrink: 0;
}
.sidebar-group-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.4rem;
    flex-shrink: 0;
}

.sidebar-empty {
    padding: 1.5rem;
    text-align: center;
    color: #484f58;
    font-size: 0.85rem;
}

/* --- Map Marker --- */

.camera-marker {
    background: none !important;
    border: none !important;
}

.camera-marker-unlocated {
    opacity: 0.5;
}

/* Edit mode marker pulse */
.edit-mode .camera-marker {
    animation: marker-pulse 1.5s ease-in-out infinite;
}

@keyframes marker-pulse {
    0%, 100% { filter: drop-shadow(0 0 0px transparent); }
    50% { filter: drop-shadow(0 0 8px rgba(88, 166, 255, 0.7)); }
}

/* --- Edit Toolbar --- */

.edit-toolbar {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10;
}

.edit-mode-btn {
    background: #252830;
    color: #e1e4e8;
    border: 1px solid #2d3139;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-mode-btn:hover {
    border-color: #58a6ff;
    color: #58a6ff;
}

.edit-mode-btn.active {
    background: rgba(88, 166, 255, 0.15);
    border-color: #58a6ff;
    color: #58a6ff;
}

/* --- Preview Panel (slides up from bottom) --- */

.preview-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 300px;
    background: #1a1d27;
    border-top: 1px solid #2d3139;
    z-index: 15;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #2d3139;
    flex-shrink: 0;
}

.preview-header span {
    font-weight: 600;
    font-size: 0.95rem;
    color: #e1e4e8;
}

.preview-body {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.preview-video-wrapper {
    flex: 1;
    background: #0f1117;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.preview-video-wrapper video-stream {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.preview-no-stream {
    color: #484f58;
    font-size: 0.85rem;
    text-align: center;
    padding: 2rem;
}

.preview-info {
    width: 220px;
    padding: 0.75rem 1rem;
    overflow-y: auto;
    border-left: 1px solid #2d3139;
    flex-shrink: 0;
}

.preview-detail-row {
    font-size: 0.8rem;
    color: #e1e4e8;
    padding: 0.25rem 0;
}

.preview-label {
    color: #8b949e;
    font-weight: 600;
}

/* --- Unlocated cameras list --- */

.unlocated-list {
    max-height: 350px;
    overflow-y: auto;
}

.unlocated-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid #21262d;
    gap: 0.5rem;
}

.unlocated-item:last-child {
    border-bottom: none;
}

.unlocated-item-info {
    min-width: 0;
    flex: 1;
}

.unlocated-item-name {
    font-size: 0.85rem;
    color: #e1e4e8;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unlocated-item-detail {
    font-size: 0.75rem;
    color: #8b949e;
}

.unlocated-place-btn {
    flex-shrink: 0;
    font-size: 0.75rem !important;
    padding: 0.3rem 0.75rem !important;
}

/* ============================================================
   Panic Button
   ============================================================ */

.panic-button {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    border: 5px solid #ef4444;
    font-size: 2.4rem;
    font-weight: 800;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.5);
    animation: panic-pulse 2s ease-in-out infinite;
    transition: all 0.3s;
    letter-spacing: 1px;
}

.panic-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(220, 38, 38, 0.7);
}

.panic-button.panic-active {
    background: #6b7280;
    border-color: #9ca3af;
    box-shadow: none;
    animation: none;
    cursor: not-allowed;
    opacity: 0.6;
}

@keyframes panic-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(220, 38, 38, 0.5); }
    50% { box-shadow: 0 4px 30px rgba(220, 38, 38, 0.8), 0 0 0 8px rgba(220, 38, 38, 0.15); }
}

.panic-notification {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.85rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    z-index: 10000;
    animation: notif-slide-in 0.3s ease-out;
    white-space: nowrap;
}

.panic-notification-success {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.panic-notification-error {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
}

@keyframes notif-slide-in {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ============================================================
   Alerts Page
   ============================================================ */

.alert-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.alert-tab {
    background: #1a1d27;
    color: #8b949e;
    border: 1px solid #2d3139;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.alert-tab:hover {
    border-color: #58a6ff;
    color: #e1e4e8;
}

.alert-tab.active {
    background: rgba(88, 166, 255, 0.15);
    border-color: #58a6ff;
    color: #58a6ff;
}

.alert-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.alert-feed-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #e1e4e8;
}

.alert-filters select,
.alert-filters input {
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
}

.alert-filters select:focus,
.alert-filters input:focus {
    border-color: #58a6ff;
}

.alert-filters input::placeholder {
    color: #484f58;
}

.sse-status {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
}

.sse-connected {
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
}

.sse-disconnected {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
}

.alert-feed {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.alert-feed-empty {
    color: #484f58;
    font-size: 0.9rem;
    text-align: center;
    padding: 3rem 1rem;
}

/* Alert Card */
.alert-card {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 8px;
    border-left: 4px solid #58a6ff;
    transition: border-color 0.2s;
}

.alert-card:hover {
    border-color: #373b44;
}

.alert-card-critical {
    border-left-color: #f85149;
}

.alert-card-warning {
    border-left-color: #d29922;
}

.alert-card-info {
    border-left-color: #58a6ff;
}

.alert-card-body {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
}

.alert-card-info {
    flex: 1;
    min-width: 0;
}

.alert-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #e1e4e8;
    margin-bottom: 0.15rem;
}

.alert-card-meta {
    font-size: 0.8rem;
    color: #8b949e;
}

.alert-card-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    cursor: pointer;
    border: 1px solid #2d3139;
}

.alert-card-thumb:hover {
    border-color: #58a6ff;
}

.alert-card-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.alert-card-actions .modal-btn {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.plate-text {
    font-family: "SF Mono", "Fira Code", monospace;
    letter-spacing: 1px;
}

/* Watchlist form */
.watchlist-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.watchlist-form input {
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    flex: 1;
    min-width: 120px;
}

.watchlist-form input:focus {
    border-color: #58a6ff;
}

.watchlist-form input::placeholder {
    color: #484f58;
}

/* Incident detail modal */
.incident-detail h3 {
    color: #e1e4e8;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.incident-detail h4 {
    color: #e1e4e8;
    font-size: 0.95rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.incident-detail p {
    color: #8b949e;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.incident-snapshots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

.incident-snap {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #2d3139;
}

.incident-snap img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
}

.incident-snap-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #e1e4e8;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    text-align: center;
}

/* ============================================================
   Analyzer Tab
   ============================================================ */

.analyzer-panel {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.analyzer-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #e1e4e8;
    margin-bottom: 0.75rem;
}

.analyzer-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.analyzer-controls {
    display: flex;
    gap: 0.5rem;
}

.analyzer-add-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.analyzer-form-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.analyzer-form-options label {
    color: #8b949e;
    font-size: 0.85rem;
    font-weight: 500;
}

.analyzer-form-options input[type="number"] {
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 70px;
    outline: none;
    margin: 0 0.25rem;
}

.analyzer-form-options input[type="number"]:focus {
    border-color: #58a6ff;
}

.analyzer-form-options input[type="range"] {
    vertical-align: middle;
    accent-color: #58a6ff;
    margin: 0 0.35rem;
}

.analyzer-class-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.analyzer-class-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #e1e4e8;
    font-size: 0.85rem;
    font-weight: 400;
    cursor: pointer;
}

.analyzer-class-item input[type="checkbox"] {
    accent-color: #58a6ff;
    cursor: pointer;
}

.analyzer-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.analyzer-toggle-label input[type="checkbox"] {
    accent-color: #58a6ff;
    cursor: pointer;
}

.analyzer-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(88, 166, 255, 0.12);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.25);
}

.analyzer-badge-lpr {
    background: rgba(210, 153, 34, 0.15);
    color: #d29922;
    border-color: rgba(210, 153, 34, 0.3);
}

/* Analyzer Camera Grid */
.analyzer-camera-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.analyzer-cam-card {
    position: relative;
    background: #0f1117;
    border: 2px solid #2d3139;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.analyzer-cam-card:hover {
    border-color: #58a6ff;
}

.analyzer-cam-card.selected {
    border-color: #3fb950;
    box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.2);
}

.analyzer-cam-card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    background: #1a1d27;
}

.analyzer-cam-label {
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
    color: #e1e4e8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #1a1d27;
}

.analyzer-cam-active-badge {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    background: rgba(63, 185, 80, 0.85);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    z-index: 1;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ============================================================
   Access Control
   ============================================================ */

.access-person-thumb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #2d3139;
}

.access-no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #252830;
    color: #484f58;
    font-size: 0.55rem;
    text-align: center;
}

.access-badge-granted {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.access-badge-denied {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.access-photo-upload input[type="file"] {
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 100%;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    main { padding: 1rem; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    table { font-size: 0.85rem; }
    thead th, tbody td { padding: 0.6rem 0.5rem; }
    .controls { flex-direction: column; align-items: stretch; }
    .filters { justify-content: center; }
    .credentials-section { flex-direction: column; align-items: stretch; }
    .cred-fields { flex-direction: column; }
    .cred-fields input { width: 100%; }
    .modal-content { width: 95%; }

    /* Map responsive */
    .map-sidebar { width: 100%; height: auto; max-height: 200px; border-right: none; border-bottom: 1px solid #2d3139; }
    .map-sidebar.collapsed { margin-left: 0; margin-top: -200px; }
    .map-layout { flex-direction: column; }
    .preview-panel { height: 250px; }
    .preview-info { display: none; }

    .main-nav { gap: 0; }
    .nav-link { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

    header { padding: 1rem 1.25rem; }

    .panic-button { width: 168px; height: 168px; font-size: 2rem; bottom: 1.25rem; right: 1.25rem; }
    .alert-tabs { gap: 0.15rem; }
    .alert-tab { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
    .alert-card-body { flex-direction: column; align-items: flex-start; }
    .alert-card-thumb { width: 100%; height: auto; max-height: 120px; }
    .watchlist-form { flex-direction: column; }
    .analyzer-status-row { flex-direction: column; align-items: flex-start; }
    .analyzer-class-checkboxes { gap: 0.35rem 0.75rem; }
    .analyzer-camera-grid { grid-template-columns: repeat(2, 1fr); }
    .login-card { width: 90%; min-width: 0; }
    .admin-tabs { gap: 0.15rem; }
    .admin-tenant-card { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Login Page
   ============================================================ */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #58a6ff;
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: #8b949e;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-btn {
    width: 100%;
    background: #238636;
    color: #fff;
    border: none;
    padding: 0.7rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover { background: #2ea043; }
.login-btn:disabled { background: #1a1d27; color: #484f58; cursor: not-allowed; }

/* ============================================================
   User Menu (header)
   ============================================================ */

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.user-name {
    color: #8b949e;
    font-size: 0.85rem;
    font-weight: 500;
}

.user-role-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    background: rgba(88, 166, 255, 0.12);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.25);
}

.logout-btn {
    background: rgba(248, 81, 73, 0.12);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.25);
    padding: 0.3rem 0.85rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #f85149;
    color: #fff;
}

/* ============================================================
   Admin Panel
   ============================================================ */

.admin-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.admin-tab {
    background: #1a1d27;
    color: #8b949e;
    border: 1px solid #2d3139;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-tab:hover {
    border-color: #58a6ff;
    color: #e1e4e8;
}

.admin-tab.active {
    background: rgba(88, 166, 255, 0.15);
    border-color: #58a6ff;
    color: #58a6ff;
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #e1e4e8;
}

.admin-tenant-list,
.admin-user-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-tenant-card {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: border-color 0.2s;
}

.admin-tenant-card:hover { border-color: #373b44; }

.admin-tenant-info { flex: 1; min-width: 0; }

.admin-tenant-name {
    font-weight: 600;
    font-size: 1rem;
    color: #e1e4e8;
    margin-bottom: 0.15rem;
}

.admin-tenant-detail {
    font-size: 0.8rem;
    color: #8b949e;
}

.admin-tenant-actions,
.admin-user-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.admin-user-row {
    background: #1a1d27;
    border: 1px solid #2d3139;
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: border-color 0.2s;
}

.admin-user-row:hover { border-color: #373b44; }

.admin-user-info { flex: 1; min-width: 0; }

.admin-user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #e1e4e8;
}

.admin-user-detail {
    font-size: 0.8rem;
    color: #8b949e;
}

.admin-badge-superadmin {
    background: rgba(210, 153, 34, 0.15);
    color: #d29922;
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.admin-badge-admin {
    background: rgba(88, 166, 255, 0.12);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.25);
}

.admin-badge-user {
    background: rgba(139, 148, 158, 0.1);
    color: #8b949e;
    border: 1px solid rgba(139, 148, 158, 0.2);
}

.admin-badge-inactive {
    background: rgba(248, 81, 73, 0.12);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.25);
}

.admin-filter-select {
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
}

.admin-filter-select:focus { border-color: #58a6ff; }

/* Permission grid */
.perm-section { border-top: 1px solid #2d3139; padding-top: 0.75rem; }
.perm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    font-size: 0.85rem;
}
.perm-grid label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    color: #c9d1d9;
}
.perm-grid input[type=checkbox] {
    accent-color: #58a6ff;
    width: 15px;
    height: 15px;
}
.preset-btn {
    font-size: 0.7rem !important;
    padding: 0.2rem 0.5rem !important;
    background: #21262d !important;
    border-color: #30363d !important;
}
.preset-btn:hover {
    background: #30363d !important;
    border-color: #58a6ff !important;
}

/* Watchlist cards */
.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    padding: 0.5rem 0;
}
.wl-card {
    background: #161b22;
    border: 1px solid #2d3139;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s;
}
.wl-card:hover { border-color: #f85149; }
.wl-card-photo {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #0f1117;
}
.wl-card-no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #484f58;
}
.wl-card-body { padding: 0.75rem; flex: 1; }
.wl-card-name {
    font-weight: 600;
    font-size: 1rem;
    color: #e1e4e8;
    margin-bottom: 0.25rem;
}
.wl-card-meta {
    font-size: 0.8rem;
    color: #8b949e;
    margin-bottom: 0.25rem;
}
.wl-card-notes {
    font-size: 0.8rem;
    color: #b1bac4;
    margin: 0.4rem 0;
    line-height: 1.4;
    max-height: 4.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wl-card-actions {
    padding: 0.5rem 0.75rem;
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid #2d3139;
}
.photo-upload-area { margin-top: 0.5rem; }
.photo-preview-container {
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.photo-placeholder {
    width: 100px;
    height: 100px;
    background: #0f1117;
    border: 2px dashed #2d3139;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #484f58;
    font-size: 0.85rem;
}

/* Hotspot leads table */
.leads-table {
    width: 100%;
    border-collapse: collapse;
    background: #161b22;
    border: 1px solid #2d3139;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.88rem;
}
.leads-table thead { background: #0f1117; }
.leads-table th {
    text-align: left;
    padding: 0.65rem 0.85rem;
    color: #8b949e;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #2d3139;
}
.leads-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}
.leads-table th.sortable:hover { color: #58a6ff; }
.leads-table th .sort-ind {
    display: inline-block;
    min-width: 14px;
    color: #58a6ff;
    font-weight: 700;
}
.leads-table td {
    padding: 0.6rem 0.85rem;
    color: #c9d1d9;
    border-bottom: 1px solid #21262d;
}
.leads-table tbody tr:hover { background: #1c2128; }
.leads-table tbody tr:last-child td { border-bottom: none; }
.leads-table .empty-state {
    text-align: center;
    padding: 2rem;
    color: #8b949e;
}

/* Toggle switch (iOS-style) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #30363d;
    border-radius: 28px;
    transition: background 0.25s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
}
.toggle-switch input:checked + .toggle-slider { background: #3fb950; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(24px); }
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}
.toggle-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e1e4e8;
}

/* Hotspot sub-tabs */
.admin-sub-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #2d3139;
}
.admin-sub-tab {
    background: transparent;
    border: 1px solid #2d3139;
    color: #8b949e;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}
.admin-sub-tab:hover { color: #c9d1d9; border-color: #484f58; }
.admin-sub-tab.active {
    background: rgba(88, 166, 255, 0.12);
    color: #58a6ff;
    border-color: #58a6ff;
}

/* Hotspot settings form */
.hotspot-settings-form {
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: #161b22;
    border: 1px solid #2d3139;
    border-radius: 8px;
}
.hotspot-settings-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: #c9d1d9;
    font-size: 0.85rem;
}
.hotspot-settings-form input {
    background: #0f1117;
    border: 1px solid #2d3139;
    color: #e1e4e8;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
}
.hotspot-settings-form input:focus { border-color: #58a6ff; }

/* Under Construction */
.under-construction {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    color: #8b949e;
}
.under-construction .uc-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: spin 4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.under-construction h2 {
    font-size: 1.8rem;
    color: #e6edf3;
    margin-bottom: 0.5rem;
}
.under-construction p {
    font-size: 1.1rem;
    max-width: 400px;
}

/* Clients */
.clients-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}
.client-search {
    flex: 1;
    max-width: 400px;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    border: 1px solid #2d3139;
    background: #1a1d27;
    color: #e6edf3;
    font-size: 0.95rem;
    outline: none;
}
.client-search:focus { border-color: #58a6ff; }
.clients-empty {
    text-align: center;
    color: #484f58;
    padding: 3rem;
    font-size: 1.1rem;
}
.client-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #161b22;
    border: 1px solid #2d3139;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s;
}
.client-card:hover { border-color: #58a6ff; }
.client-card-main { flex: 1; min-width: 0; }
.client-card-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: #e6edf3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.client-card-business {
    font-size: 0.85rem;
    color: #8b949e;
    margin-top: 0.15rem;
}
.client-card-details {
    display: flex;
    gap: 1.5rem;
    color: #8b949e;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.client-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}
.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 4px;
    border: 1px solid #2d3139;
    cursor: pointer;
    background: #1a1d27;
    color: #e6edf3;
    transition: all 0.15s;
}
.btn-sm:hover { border-color: #58a6ff; }
.btn-sm.btn-edit { border-color: #58a6ff; color: #58a6ff; }
.btn-sm.btn-danger { border-color: #f85149; color: #f85149; }
.btn-sm.btn-danger:hover { background: #f85149; color: #fff; }
.btn-primary {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    border: none;
    background: #238636;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover { background: #2ea043; }
.btn-secondary {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    border: 1px solid #2d3139;
    background: transparent;
    color: #e6edf3;
    font-size: 0.9rem;
    cursor: pointer;
}
.client-modal-box {
    width: 560px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.client-form-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid #2d3139;
    padding-bottom: 0.5rem;
}
.client-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: #8b949e;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 4px 4px 0 0;
    transition: all 0.15s;
}
.client-tab.active {
    color: #58a6ff;
    border-bottom: 2px solid #58a6ff;
}
.client-tab-content label {
    display: block;
    color: #8b949e;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    margin-top: 0.75rem;
}
.client-tab-content label:first-child { margin-top: 0; }
.client-tab-content input[type="text"],
.client-tab-content input[type="email"],
.client-tab-content input[type="number"] {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #2d3139;
    background: #0f1117;
    color: #e6edf3;
    font-size: 0.9rem;
    outline: none;
}
.client-tab-content input:focus { border-color: #58a6ff; }
.client-map {
    width: 100%;
    height: 250px;
    border-radius: 6px;
    border: 1px solid #2d3139;
    margin-bottom: 0.5rem;
}
.geo-row {
    display: flex;
    gap: 1rem;
}
.geo-row > div { flex: 1; }
.asset-select-box {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #2d3139;
    border-radius: 6px;
    background: #0f1117;
    padding: 0.5rem;
}
.asset-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.25rem;
    font-size: 0.85rem;
    color: #e6edf3;
    cursor: pointer;
}
.asset-check:hover { background: #1a1d27; border-radius: 4px; }
.asset-check input[type="checkbox"] { accent-color: #58a6ff; }
.asset-check small { color: #484f58; }
.asset-empty {
    color: #484f58;
    font-size: 0.85rem;
    padding: 1rem;
    text-align: center;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #2d3139;
    margin-top: 1rem;
}
@media (max-width: 768px) {
    .clients-header { flex-direction: column; }
    .client-search { max-width: 100%; }
    .client-card { flex-direction: column; align-items: flex-start; }
    .client-card-details { flex-wrap: wrap; }
}

/* ===== Monitor Page ===== */

.monitor-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
.monitor-body header {
    flex-shrink: 0;
}

.monitor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.25rem;
    background: #1a1d27;
    border-bottom: 1px solid #2d3139;
    flex-shrink: 0;
}
.monitor-toolbar-left { display: flex; align-items: center; gap: 0.75rem; }
.monitor-toolbar-right { display: flex; align-items: center; gap: 0.75rem; }

#group-select {
    background: #252830;
    color: #e1e4e8;
    border: 1px solid #2d3139;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    min-width: 200px;
    cursor: pointer;
}
#group-select:focus { border-color: #58a6ff; outline: none; }

.monitor-grid {
    flex: 1;
    display: grid;
    gap: 2px;
    padding: 2px;
    min-height: 0;
    background: #0a0c10;
}

.monitor-cell {
    position: relative;
    background: #1a1d27;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    min-width: 0;
}
.monitor-cell video-stream {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.monitor-cell-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.3rem 0.6rem;
    background: rgba(0,0,0,0.65);
    color: #c9d1d9;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.monitor-cell:hover .monitor-cell-label {
    opacity: 1;
}

.monitor-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8b949e;
    font-size: 1.1rem;
}

.monitor-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem;
    background: #1a1d27;
    border-top: 1px solid #2d3139;
    flex-shrink: 0;
}
.monitor-pager-btn {
    background: #252830;
    color: #e1e4e8;
    border: 1px solid #2d3139;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}
.monitor-pager-btn:hover:not(:disabled) { border-color: #58a6ff; color: #58a6ff; }
.monitor-pager-btn:disabled { opacity: 0.4; cursor: default; }
.monitor-pager-info { color: #8b949e; font-size: 0.85rem; }

@media (max-width: 768px) {
    .monitor-toolbar { flex-direction: column; gap: 0.5rem; padding: 0.5rem; }
    #group-select { min-width: 100%; }
}
