:root {
    --bg-dark: #0a0d14;
    --bg-panel: #111724;
    --bg-card: #182234;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 230, 153, 0.3);
    --primary: #00e699;
    --primary-hover: #00c784;
    --accent-blue: #00b4d8;
    --accent-gold: #ffb703;
    --danger: #ff4d6d;
    --warning: #ffa200;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --shadow-glow: 0 0 25px rgba(0, 230, 153, 0.15);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
.gym-header {
    background: rgba(17, 23, 36, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-block {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-badge {
    background: linear-gradient(135deg, #00e699 0%, #00b4d8 100%);
    color: #05131a;
    font-weight: 800;
    font-size: 1.1rem;
    padding: 6px 12px;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

.logo-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-title p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.role-switcher {
    display: flex;
    background: #090e17;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 3px;
}

.role-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.role-btn.active {
    background: var(--primary);
    color: #061e14;
    box-shadow: 0 2px 10px rgba(0, 230, 153, 0.3);
}

.apparatus-selector select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Athlete Banner */
.athlete-bar {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.athlete-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.country-flag {
    font-size: 1.2rem;
}

.athlete-name {
    font-weight: 700;
    font-size: 1.05rem;
}

.routine-status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-active {
    background: rgba(0, 230, 153, 0.15);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.status-completed {
    background: rgba(0, 180, 216, 0.15);
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
}

/* Main Dashboard Grid */
.gym-main {
    padding: 24px 28px;
    display: grid;
    grid-template-columns: 2.1fr 1fr;
    gap: 24px;
    flex: 1;
}

/* 6-Camera Multi-View Section */
.cameras-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cameras-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.camera-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s, border-color 0.2s;
}

.camera-card:hover {
    border-color: rgba(0, 230, 153, 0.4);
}

.camera-card.occluded {
    border-color: var(--warning);
}

.camera-header {
    background: rgba(9, 14, 23, 0.7);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

.cam-title {
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cam-angle {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.cam-status-pill {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.pill-streaming {
    background: rgba(0, 230, 153, 0.2);
    color: var(--primary);
}

.pill-occluded {
    background: rgba(255, 162, 0, 0.2);
    color: var(--warning);
}

.cam-qr-btn {
    background: rgba(0, 230, 153, 0.12);
    border: 1px solid rgba(0, 230, 153, 0.35);
    border-radius: 4px;
    color: var(--primary);
    cursor: pointer;
    padding: 2px 7px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    transition: background 0.15s, transform 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.cam-qr-btn:hover {
    background: rgba(0, 230, 153, 0.25);
    border-color: var(--primary);
    transform: scale(1.04);
}

.camera-canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #070a10;
}

.camera-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.camera-overlay-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.65);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    color: #94a3b8;
    backdrop-filter: blur(4px);
}

.camera-occlusion-alert {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 162, 0, 0.9);
    color: #000;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    display: none;
}

.camera-card.occluded .camera-occlusion-alert {
    display: block;
}

/* Sidebar Analytics & Judging Panels */
.analytics-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Scoreboard */
.scoreboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.score-box {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.score-box-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.score-box-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
}

.total-score-card {
    background: linear-gradient(135deg, rgba(0, 230, 153, 0.15) 0%, rgba(0, 180, 216, 0.15) 100%);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    box-shadow: var(--shadow-glow);
}

.total-score-label {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.total-score-number {
    font-size: 2.4rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: -1px;
}

/* Angle Biometrics */
.angle-meters-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.angle-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.angle-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
}

.angle-bar-bg {
    width: 100%;
    height: 7px;
    background: #090e17;
    border-radius: 4px;
    overflow: hidden;
}

.angle-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

/* Static Hold Timer */
.hold-timer-container {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    border: 1px solid var(--border-color);
}

.hold-text h4 {
    font-size: 0.85rem;
    color: #fff;
}

.hold-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.hold-clock {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent-gold);
}

.hold-clock.passed {
    color: var(--primary);
}

/* Consensus Box */
.consensus-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.consensus-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) 0% 98%, #1e293b 98% 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: #fff;
}

.consensus-details h4 {
    font-size: 0.85rem;
    color: #fff;
    margin-bottom: 2px;
}

.consensus-details p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Element Timeline */
.timeline-list {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.timeline-item {
    background: var(--bg-card);
    border-left: 3px solid var(--primary);
    padding: 8px 10px;
    border-radius: 0 8px 8px 0;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-item.error {
    border-left-color: var(--danger);
}

.timeline-item-title {
    font-weight: 600;
    color: #fff;
}

.timeline-item-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.timeline-item-score {
    font-weight: 700;
    color: var(--primary);
}

.timeline-item.error .timeline-item-score {
    color: var(--danger);
}

/* Action Simulation Buttons */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.btn-primary {
    background: var(--primary);
    color: #061e14;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: rgba(255, 255, 255, 0.25);
    background: #1f2c42;
}

/* Modal for Inquiry Video Review */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 880px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.modal-header h3 {
    font-size: 1.15rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
}

.inquiry-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.inquiry-cam-box {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.78rem;
}

/* Responsive */
@media (max-width: 1100px) {
    .gym-main {
        grid-template-columns: 1fr;
    }
    .cameras-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
