* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', Roboto, sans-serif;
    background-color: #0F1216;
    color: #E8EDF2;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 8px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Toolbar / Header */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    background-color: #1A2027;
    border: 1px solid #2D3748;
    border-radius: 8px;
    padding: 0 12px;
    margin-bottom: 8px;
    gap: 8px;
}

.toolbar-brand {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-dot {
    font-size: 10px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    color: #FFF;
    white-space: nowrap;
}

.brand-badge {
    background-color: #007ACC;
    color: #FFF;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}

.toolbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 200px;
}

.camera-select-dropdown {
    background: #2D3748;
    color: #FFF;
    border: 1px solid #4A5568;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
    width: 100%;
    height: 32px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn {
    height: 34px;
    min-width: 36px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid #4A5568;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #FFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.btn-primary { background: #007ACC; border-color: #0098FF; }
.btn-secondary { background: #2D3748; border-color: #4A5568; }
.btn-action { background: #2C3E50; border-color: #34495E; font-size: 12px; }

.btn:active {
    transform: scale(0.97);
}

/* Main Body */
.main-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 12px;
}

/* Focused Main Video Card */
.main-video-section {
    width: 100%;
}

.main-video-card {
    background-color: #1A2027;
    border: 1px solid #2D3748;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.video-overlay-header {
    background: #232D38;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2D3748;
}

.cam-title {
    font-size: 14px;
    font-weight: 700;
    color: #4DEEEA;
}

.stream-type-badge {
    background-color: #10B981;
    color: #064E3B;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.main-video-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.active-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #000;
}

.video-placeholder {
    position: absolute;
    inset: 0;
    background: #0B0E11;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #A0AEC0;
    z-index: 2;
}

.placeholder-icon {
    font-size: 32px;
}

.hidden {
    display: none !important;
}

/* Control Bar Under Video */
.video-control-bar {
    padding: 8px 10px;
    background: #141920;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-top: 1px solid #2D3748;
    flex-wrap: wrap;
}

.cam-switch-group {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.cam-btn {
    height: 32px;
    padding: 0 10px;
    border-radius: 6px;
    background: #2D3748;
    border: 1px solid #4A5568;
    color: #E2E8F0;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.cam-btn.active {
    background: #007ACC;
    border-color: #0098FF;
    color: #FFF;
    box-shadow: 0 0 8px rgba(0, 122, 204, 0.6);
}

.action-btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* PTZ Panel */
.ptz-panel {
    background: #1A2027;
    padding: 12px;
    border-top: 1px solid #2D3748;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.ptz-grid {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 6px;
}

.ptz-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #2D3748;
    border: 1px solid #4A5568;
    color: #FFF;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ptz-btn:active {
    background: #007ACC;
}

.ptz-stop {
    background: #E53E3E;
    border-color: #FC8181;
}

.ptz-zoom-group {
    display: flex;
    gap: 8px;
}

.zoom-btn {
    width: auto;
    padding: 0 16px;
    font-size: 13px;
    height: 38px;
}

/* Modal Backdrop & Card */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.modal-card {
    background-color: #1A2027;
    border: 1px solid #3A4756;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

.modal-header {
    background-color: #232D38;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2D3748;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: #4DEEEA;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: #A0AEC0;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 8px;
}

.modal-close-btn:hover {
    color: #FFF;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #CBD5E0;
}

.form-input, .form-select {
    background: #0F1216;
    color: #FFF;
    border: 1px solid #3A4756;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    width: 100%;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: #007ACC;
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.4);
}

.modal-divider {
    border: none;
    border-top: 1px solid #2D3748;
    margin: 4px 0;
}

/* Dynamic Camera List in Modal */
.dynamic-camera-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.camera-config-card {
    background: #141920;
    border: 1px solid #2D3748;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.camera-card-header {
    font-size: 13px;
    font-weight: 700;
    color: #007ACC;
    border-bottom: 1px solid #232D38;
    padding-bottom: 4px;
}

.modal-footer {
    background-color: #141920;
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid #2D3748;
}

/* Desktop Collapsible Details Panel */
.desktop-panel-details {
    background: #1A2027;
    border: 1px solid #2D3748;
    border-radius: 8px;
    overflow: hidden;
}

.panel-toggle-summary {
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #A0AEC0;
    cursor: pointer;
    background: #232D38;
}

.panel-container {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-grid {
    background: #141920;
    border: 1px solid #2D3748;
    border-radius: 6px;
    overflow: hidden;
}

.card-header {
    background: #232D38;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    color: #CBD5E0;
}

.table-wrapper {
    max-height: 150px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

th, td {
    padding: 6px;
    text-align: center;
    border-bottom: 1px solid #2D3748;
}

th {
    background: #2D3748;
    color: #E2E8F0;
}

.log-console {
    max-height: 120px;
    background: #0B0E11;
    font-family: Consolas, monospace;
    font-size: 11px;
    color: #4DEEEA;
    padding: 6px;
    overflow-y: auto;
}

/* Footer Status Bar */
.status-bar {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #718096;
    padding: 0 6px;
    margin-top: auto;
}

.ctv-info {
    color: #38A169;
    font-weight: 600;
}

/* Mobile Media Queries */
@media (max-width: 768px) {
    .app-container {
        padding: 4px;
    }
    
    .toolbar {
        height: 44px;
        padding: 0 8px;
    }

    .brand-title {
        font-size: 14px;
    }

    .brand-badge {
        display: none;
    }

    .video-control-bar {
        justify-content: center;
    }

    .modal-card {
        max-height: 95vh;
    }
}
