* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: monospace;
    background: #050805;
    color: #00ff88;
    padding: 12px;
}

/* ===== HEADER BAR ===== */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    gap: 16px;
}

h1 {
    font-size: 22px;
    margin: 0;
    flex: 1;
}

/* ===== CAMERA BUTTON (теперь в header) ===== */
.cam-btn {
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.6);
    color: #00ff88;
    border: 1px solid #00ff88;
    border-radius: 8px;
    cursor: pointer;
    font-family: monospace;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.cam-btn:hover {
    background: rgba(0, 255, 136, 0.2);
}

.cam-btn-icon {
    font-size: 16px;
}

/* ===== GRID ===== */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
}

@media (min-width: 900px) {
    .grid {
        grid-template-columns: 1fr 1fr;
    }
    .wide {
        grid-column: span 2;
    }
}

/* ===== CARD ===== */
.card {
    border: 1px solid #00ff88;
    border-radius: 10px;
    padding: 14px;
    background: rgba(0,255,136,0.05);
    overflow: hidden;
    
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card h3 {
    margin: 0 0 10px;
    font-size: 18px;
}

/* ===== STATUS ===== */
#status {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 8px;
}

.status-ok {
    color: #00ff88 !important;
}

.status-lost {
    color: #ffffff !important;
    animation: blink 1.5s infinite;
}

.status-error {
    color: #ff4444 !important;
}

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

/* ===== META ===== */
#meta {
    font-size: 14px;
    opacity: 0.8;
    word-break: break-word;
}

/* ===== PROGRESS BARS ===== */
.progress-row {
    margin-bottom: 16px;
}

.progress-label {
    font-size: 16px;
    margin-bottom: 6px;
    color: #ffffff;
    opacity: 0.9;
}

.progress {
    width: 100%;
    height: 34px;
    padding: 6px;
    border: 3px solid #8a8a8a;
    background: #222;
    box-shadow:
        inset 0 0 6px rgba(255,255,255,0.15),
        0 0 4px rgba(0,0,0,0.8);
}

.progress-with-signal {
    display: flex;
    align-items: center;
    gap: 0;
}

.progress-90 {
    flex: 0 0 86%;
    margin-right: 10px;
}

.fill {
    height: 100%;
    width: 0%;
    background: #e6852d;
    box-shadow:
        inset 0 0 4px rgba(255,255,255,0.2),
        0 0 6px rgba(230,133,45,0.5);
    transition: width 0.25s linear;
}

.fill.no-connection {
    background: #555555 !important;
    box-shadow: none !important;
    width: 0% !important;
}

/* ===== SIGNAL ICON ===== */
.signal-icon {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.sig-bar {
    flex: 1;
    border-radius: 2px;
    min-width: 5px;
    border: 1.5px solid #e6852d;
    background-color: transparent;
    transition: background-color 0.3s, border-color 0.3s;
}

.sig-bar-1 { height: 33%; }
.sig-bar-2 { height: 66%; }
.sig-bar-3 { height: 100%; }

.sig-bar.dim {
    background-color: transparent;
    border-color: #1a3a1a;
}

.sig-bar.active-1,
.sig-bar.active-2,
.sig-bar.active-3 {
    background-color: #e6852d;
    border-color: #c46b1f;
}

.sig-bar.no-connection {
    background-color: #555555 !important;
    border-color: #555555 !important;
    opacity: 0.3 !important;
}

/* ===== LAST BYTE ===== */
#last-byte {
    font-size: 18px;
    font-weight: bold;
    color: #00ff88;
}

/* ===== CHART ===== */
#signalChart {
    width: 100%;
    background: #050805;
    border: 1px solid #e6852d;
    border-radius: 8px;
}

/* ===== HISTORY ===== */
#history {
    font-size: 13px;
    line-height: 1.35;
    max-height: 420px;
    overflow-y: auto;
    white-space: nowrap;
    padding-right: 4px;
    margin: 0;
}

/* ===== ACCORDION ===== */
.accordion-header {
    cursor: pointer;
    user-select: none;
    padding: 10px 0;
    margin: 0;
}

.accordion-header:hover {
    opacity: 0.7;
}

.accordion-body {
    max-height: 520px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.accordion-body.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ===== SPLIT LAYOUT (FIXED) ===== */
.layout {
    display: flex;
    height: calc(100vh - 100px);
    width: 100%;
    margin: 0;
    padding: 0;
}

/* панели */
.panel {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* LEFT */
.left {
    flex: 1 1 auto;
    min-width: 300px;
    padding: 10px;
}

/* RIGHT */
.right {
    flex: 0 0 40%;
    min-width: 0;
    background: black;
    position: relative;
    overflow: hidden;
}

.right.hidden {
    flex: 0 0 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* ===== RESIZER ===== */
.resizer {
    width: 8px;
    min-width: 8px;
    cursor: col-resize;
    background: #00ff88;
    opacity: 0.3;
    flex-shrink: 0;
    z-index: 10;
}

.resizer:hover {
    opacity: 0.8;
}

.resizer.hidden {
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* камера */
.cam-modal {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: black;
}

.cam-header {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: #111;
    color: #00ff88;
}

.cam-frame {
    flex: 1;
    width: 100%;
    object-fit: contain;
    background: black;
}
/* ===== CAMERA OVERLAY ===== */
.cam-frame-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
    background: black;
    overflow: hidden;
}

.cam-frame {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: black;
}

/* Перекрестие (crosshair) */
.cam-crosshair {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Вертикальная линия */
.crosshair-v {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 100%;
    background: #00ff88;
    box-shadow: 0 0 4px rgba(0, 255, 136, 0.3);
}

/* Горизонтальная линия */
.crosshair-h {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 1px;
    background:  #00ff88;
    box-shadow: 0 0 4px rgba(0, 255, 136, 0.3);
}

/* Центральный квадрат */
.crosshair-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border: 2px solid #00ff88;
    box-shadow: 
        0 0 10px rgba(0, 255, 136, 0.3),
        inset 0 0 10px rgba(0, 255, 136, 0.1);
}

/* ===== MOBILE ===== */
@media (max-width: 500px) {
    .header-bar {
        flex-direction: column;
        gap: 8px;
    }
    
    h1 {
        font-size: 18px;
    }

    #status {
        font-size: 22px;
    }

    .progress {
        height: 30px;
        padding: 5px;
    }

    .progress-label {
        font-size: 15px;
    }

    #history {
        font-size: 16px;
        line-height: 1.5;
        max-height: 55vh;
    }
    
    .layout {
        flex-direction: column;
        height: auto;
    }
    
    .left {
        min-height: 50vh;
    }
    
    .right {
        flex: 0 0 50vh !important;
        min-width: 100% !important;
    }
    
    .resizer {
        display: none;
    }
}