* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }

#map { position: absolute; inset: 0; }

.topbar {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
    background: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 14px;
}
.topbar a { color: #2563eb; text-decoration: none; margin-left: 10px; }

.popup-content { min-width: 220px; }
.popup-content img { width: 100%; border-radius: 6px; display: block; margin: 6px 0; background: #eee; }
.popup-content .snapshot-placeholder {
    width: 100%;
    min-height: 90px;
    border-radius: 6px;
    margin: 6px 0;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
}
.popup-content .status { font-weight: 600; }
.popup-content .status.online { color: #16a34a; }
.popup-content .status.offline { color: #dc2626; }
.popup-content .status.unknown { color: #9ca3af; }
.popup-content .actions { display: flex; gap: 8px; margin-top: 8px; }
.popup-content button {
    flex: 1;
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
}
.popup-content button:hover { background: #1d4ed8; }

#live-wall {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    gap: 8px;
    padding: 8px;
    pointer-events: none;
}
.live-panel {
    pointer-events: auto;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    width: 320px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.live-panel .live-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111;
    color: #fff;
    padding: 4px 8px;
    font-size: 13px;
}
.live-panel .live-panel-header button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.live-panel video { width: 100%; display: block; aspect-ratio: 16 / 9; background: #000; }

.toast {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background: #111;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.toast.show { opacity: 0.95; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    width: min(700px, 92vw);
    max-height: 85vh;
    overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal .close-btn {
    float: right;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}
.range-select { margin-bottom: 12px; }
.range-select button {
    margin-right: 6px;
    padding: 4px 10px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
}
.range-select button.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* Settings page */
.settings-wrap { max-width: 640px; margin: 40px auto; padding: 0 16px; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
.settings-wrap h1 { font-size: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field input, .field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#pick-map { height: 260px; border-radius: 8px; margin-bottom: 14px; }
.submit-btn {
    padding: 10px 18px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.msg { margin-top: 12px; font-size: 14px; }
.msg.error { color: #dc2626; }
.msg.success { color: #16a34a; }

#camera-list { display: flex; flex-direction: column; gap: 8px; }
.camera-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.camera-row .camera-row-info { font-size: 14px; }
.camera-row .camera-row-info small { display: block; color: #6b7280; }
.camera-row .camera-row-actions { display: flex; gap: 6px; }
.camera-row button {
    padding: 5px 10px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.camera-row button.delete-btn { color: #dc2626; border-color: #fca5a5; }

#csv-import-results table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
#csv-import-results th, #csv-import-results td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #e5e7eb; }
#csv-import-results tr.row-ok td.status { color: #16a34a; }
#csv-import-results tr.row-error td.status { color: #dc2626; }
