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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #141420;
    --bg-tertiary: #1a1a2e;
    --bg-header: #0f1626;
    --sidebar-bg: #12121d;
    --sidebar-bg-hover: #1b1b2e;
    --sidebar-border: #2a2a3c;
    --accent-gold: #ffcc00;
    --accent-gold-dark: #e6b800;
    --accent-gold-dim: #b8960e;
    --accent-blue: #0099ff;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a80;
    --border-color: #2a2a3a;
    --success: #00d26a;
    --error: #ff4d4f;
    --warning: #ffaa00;
    --online: #00d26a;
    --offline: #ff4d4f;
    --sidebar-w: 240px;
}

html, body {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', 'Inter', -apple-system, sans-serif;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.app.sidebar-collapsed {
    --sidebar-w: 0px;
}

.app.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    width: 0;
    opacity: 0;
    pointer-events: none;
    border-right: none;
    overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, #12111a 0%, #0c0c14 100%);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    transition: width .25s ease, transform .25s ease, opacity .25s ease;
    z-index: 50;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,204,0,0.2); border-radius: 4px; }

.sidebar-logo {
    padding: 16px 14px 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo-badge {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: radial-gradient(circle at 30% 30%, #2a1e00 0%, #0a0a0f 70%);
    border: 1px solid rgba(255,204,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 12px rgba(255,204,0,0.1), 0 0 14px rgba(255,204,0,0.1);
}

.logo-badge svg { width: 26px; height: 26px; }

.logo-text h2 {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 2.2px;
    color: var(--text-primary);
    line-height: 1.1;
    text-transform: uppercase;
}

.logo-text h2.gold {
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(255,204,0,0.25);
}

.logo-text p {
    margin-top: 3px;
    font-size: 8px;
    color: var(--text-muted);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    line-height: 1.4;
}

/* sidebar menu */
.sidebar-menu {
    flex: 1;
    padding: 8px 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    transition: all .18s ease;
}

.menu-item:hover {
    background: var(--sidebar-bg-hover);
    color: var(--text-primary);
    border-color: rgba(255,204,0,0.1);
}

.menu-item.active {
    background: linear-gradient(90deg, rgba(255,204,0,0.16) 0%, rgba(255,204,0,0.04) 100%);
    border-color: rgba(255,204,0,0.45);
    color: var(--accent-gold);
    box-shadow: inset 3px 0 0 0 var(--accent-gold), 0 0 10px rgba(255,204,0,0.08);
}

.menu-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
}

.menu-item.active .menu-icon {
    background: linear-gradient(180deg, rgba(255,204,0,0.22) 0%, rgba(255,204,0,0.08) 100%);
    border-color: rgba(255,204,0,0.3);
}

.menu-icon svg { width: 16px; height: 16px; }

.menu-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-text strong {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-sub {
    font-size: 9.5px;
    color: var(--text-muted);
    letter-spacing: 0.2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-item.active .menu-sub {
    color: rgba(255,204,0,0.65);
}

.menu-sub2 {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.4px;
    line-height: 1.2;
}

.menu-arrow {
    font-size: 18px;
    color: var(--text-muted);
    line-height: 1;
    opacity: 0;
    transition: opacity .15s, transform .15s;
    transform: translateX(-4px);
}

.menu-item:hover .menu-arrow,
.menu-item.active .menu-arrow {
    opacity: 1;
    transform: translateX(0);
    color: var(--accent-gold);
}

/* sidebar user */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 4px 8px 6px;
    border: 1px solid rgba(255,204,0,0.25);
    background: linear-gradient(90deg, rgba(255,204,0,0.08) 0%, transparent 80%);
    border-radius: 8px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c49800 0%, #6b4f00 100%);
    color: #1a1300;
    font-weight: 900;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(255,204,0,0.6);
    box-shadow: 0 0 8px rgba(255,204,0,0.15);
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-info strong {
    font-size: 12px;
    color: var(--accent-gold);
    font-weight: 800;
    letter-spacing: 0.3px;
}

.user-info span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9.5px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.status-dot-mini {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 5px var(--success);
    animation: pulse-green 2s infinite;
}

/* sidebar logout */
.sidebar-logout {
    margin: 2px 8px 12px;
    padding: 10px 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(180deg, #8a1010 0%, #5c0a0a 100%);
    border: 1px solid rgba(255,77,79,0.35);
    color: #fff;
    border-radius: 8px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.7px;
    cursor: pointer;
    transition: all .18s;
}

.sidebar-logout:hover {
    background: linear-gradient(180deg, #a81414 0%, #720e0e 100%);
    box-shadow: 0 2px 14px rgba(255,40,40,0.3);
}

.sidebar-logout svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ===== MAIN WRAP ===== */
.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    overflow: hidden;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #1a2338 0%, var(--bg-header) 100%);
    border-bottom: 2px solid var(--accent-gold);
    padding: 10px 20px;
    min-height: 60px;
}

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

.menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 32px;
    height: 24px;
    background: none;
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    padding: 4px 5px;
    cursor: pointer;
}

.menu-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--accent-gold);
    border-radius: 1px;
}

.title-block {
    position: relative;
}
.title-line {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}
.title-block h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent-gold);
    letter-spacing: 2px;
    text-shadow: 0 0 20px rgba(255, 204, 0, 0.3);
    position: relative;
    z-index: 2;
}
.diamond {
    width: 8px;
    height: 8px;
    background: var(--accent-gold);
    transform: rotate(45deg);
    box-shadow: 0 0 8px var(--accent-gold);
    position: relative;
}
.diamond::before,
.diamond::after {
    content: '';
    position: absolute;
    top: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold-dark));
    width: 80px;
}
.diamond:first-child::after { right: 14px; }
.diamond:last-child::before { left: 14px; background: linear-gradient(90deg, var(--accent-gold-dark), transparent); }

.title-block p {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    letter-spacing: 0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.welcome-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.welcome-info span {
    font-size: 12px;
    color: var(--text-secondary);
}

.welcome-info strong {
    color: var(--accent-gold);
    font-weight: 600;
}

.clock {
    font-size: 14px;
    font-family: 'Consolas', monospace;
    font-weight: 600;
    color: var(--accent-blue);
}

.status-indicators {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}

.status-badge.small {
    padding: 3px 8px;
    font-size: 10px;
}

.status-badge.status-online {
    background: rgba(0, 210, 106, 0.12);
    border-color: rgba(0, 210, 106, 0.4);
    color: var(--success);
}

.status-badge.status-offline {
    background: rgba(255, 77, 79, 0.12);
    border-color: rgba(255, 77, 79, 0.4);
    color: var(--error);
}

.status-badge.status-starting {
    background: rgba(255, 170, 0, 0.12);
    border-color: rgba(255, 170, 0, 0.4);
    color: var(--warning);
}

.status-badge.status-error {
    background: rgba(255, 77, 79, 0.12);
    border-color: rgba(255, 77, 79, 0.4);
    color: var(--error);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    position: relative;
}

.status-online .status-dot {
    animation: pulse-green 2s ease-in-out infinite;
    box-shadow: 0 0 8px currentColor;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(180deg, #c72020 0%, #a01717 100%);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: linear-gradient(180deg, #e02525 0%, #b81c1c 100%);
    box-shadow: 0 2px 12px rgba(255, 0, 0, 0.3);
}

.btn-icon {
    width: 12px;
    height: 12px;
    background: no-repeat center/contain;
    filter: brightness(0) invert(1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E");
}

/* ==========================================================================
   MARQUEE / RUNNING TEXT HEADER
   Tema gelap + aksen emas (sesuai preferensi user)
   ========================================================================== */
.marquee-bar {
    position: relative;
    display: flex;
    align-items: stretch;
    min-height: 40px;
    overflow: hidden;
    background:
        linear-gradient(90deg, #1a1300 0%, #2a1f00 30%, #1f1a00 55%, #1a1300 100%),
        repeating-linear-gradient(90deg, rgba(255,204,0,0.05) 0px, rgba(255,204,0,0.05) 2px, transparent 2px, transparent 6px);
    background-blend-mode: normal;
    border-top: 1px solid rgba(255, 204, 0, 0.35);
    border-bottom: 1px solid rgba(255, 204, 0, 0.25);
    box-shadow:
        inset 0 2px 12px rgba(255, 196, 0, 0.08),
        inset 0 -2px 12px rgba(0,0,0,0.5),
        0 2px 6px rgba(0,0,0,0.4);
}

.marquee-bar::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 0% 50%, rgba(255, 204, 0, 0.18), transparent 50%),
        radial-gradient(ellipse at 100% 50%, rgba(255, 140, 0, 0.14), transparent 50%);
    pointer-events: none;
    animation: marqueeGlow 4s ease-in-out infinite alternate;
}

@keyframes marqueeGlow {
    0%   { opacity: 0.6; }
    50%  { opacity: 1; }
    100% { opacity: 0.5; }
}

.marquee-label {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px 0 16px;
    background: linear-gradient(135deg, #ffcc00 0%, #e6a100 55%, #c78a00 100%);
    color: #141000;
    font-weight: 900;
    font-size: 12px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    box-shadow:
        2px 0 0 rgba(255,255,255,0.25) inset,
        -3px 0 12px rgba(255,204,0,0.45),
        0 0 20px rgba(255,204,0,0.25);
    border-right: 2px solid rgba(0,0,0,0.55);
    clip-path: polygon(0 0, 100% 0, 92% 100%, 0 100%);
}

.marquee-label .spin-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff2d2d;
    box-shadow:
        0 0 0 2px rgba(255, 45, 45, 0.25),
        0 0 12px rgba(255, 45, 45, 0.95),
        0 0 20px rgba(255, 60, 60, 0.6);
    animation: pulseBlink 0.9s ease-in-out infinite;
}

@keyframes pulseBlink {
    0%, 100% { transform: scale(1);   opacity: 1; }
    45%      { transform: scale(1.4); opacity: 0.85; }
    60%      { transform: scale(1);   opacity: 0.6; }
}

.marquee-viewport {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    overflow: hidden;
    mask-image: linear-gradient(90deg, transparent 0, #000 3%, #000 97%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 3%, #000 97%, transparent 100%);
}

.marquee-track {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 9px 0;
    animation: marqueeScroll 38s linear infinite;
    will-change: transform;
}

.marquee-viewport:hover .marquee-track {
    animation-play-state: paused;
}

@keyframes marqueeScroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.marquee-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #ffe68a;
    text-shadow:
        0 0 2px rgba(255,215,0,0.55),
        0 1px 0 rgba(0,0,0,0.65),
        0 0 12px rgba(255,196,0,0.15);
    background: linear-gradient(180deg, rgba(255,220,90,0.05), rgba(255,220,90,0) 70%);
    text-transform: uppercase;
}

.marquee-item.alt {
    color: #ffd6ff;
    text-shadow:
        0 0 2px rgba(255,150,255,0.55),
        0 1px 0 rgba(0,0,0,0.65);
    background: linear-gradient(180deg, rgba(255,120,255,0.05), rgba(255,120,255,0) 70%);
}

.marquee-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.marquee-item .dot.gold {
    background: #ffcc00;
    box-shadow:
        0 0 0 1.5px rgba(255,204,0,0.25),
        0 0 10px rgba(255,204,0,0.9),
        0 0 22px rgba(255,196,0,0.5);
}

.marquee-item .dot.red {
    background: #ff3b3b;
    box-shadow:
        0 0 0 1.5px rgba(255,59,59,0.25),
        0 0 10px rgba(255,59,59,0.9),
        0 0 22px rgba(255,40,40,0.55);
}

.marquee-item .dot.blink {
    animation: dotBlink 1s steps(2, end) infinite;
}

@keyframes dotBlink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

.marquee-sep {
    display: inline-block;
    color: #ffcc00;
    font-size: 12px;
    padding: 0 18px;
    opacity: 0.9;
    text-shadow: 0 0 8px rgba(255,204,0,0.7);
    animation: sepTwinkle 2.4s ease-in-out infinite;
}

@keyframes sepTwinkle {
    0%, 100% { opacity: 0.95; transform: scale(1); }
    50%      { opacity: 0.45; transform: scale(0.85); }
}

.marquee-tail {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    width: 32px;
    background:
        linear-gradient(135deg, transparent 50%, #ffcc00 50%),
        linear-gradient(225deg, transparent 50%, #c78a00 50%);
    clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
    filter: drop-shadow(-1px 0 6px rgba(255,204,0,0.3));
}

@media (max-width: 768px) {
    .marquee-bar { min-height: 34px; }
    .marquee-label { font-size: 10px; letter-spacing: 1.5px; padding: 0 14px 0 12px; }
    .marquee-item { font-size: 12px; padding: 0 6px; letter-spacing: 0.4px; }
    .marquee-sep { padding: 0 10px; }
    .marquee-track { animation-duration: 52s; }
    .marquee-tail { width: 20px; }
}

@media (max-width: 576px) {
    .marquee-bar { min-height: 30px; }
    .marquee-label { font-size: 9px; letter-spacing: 1px; padding: 0 10px 0 8px; }
    .marquee-label .spin-dot { width: 8px; height: 8px; }
    .marquee-item { font-size: 11px; padding: 0 4px; }
    .marquee-tail { width: 14px; }
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 20px;
    min-height: 42px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cam-info {
    background: rgba(0, 153, 255, 0.1);
    border: 1px solid rgba(0, 153, 255, 0.3);
    padding: 5px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-blue);
}

.cam-info span {
    color: var(--text-primary);
}

.layout-switcher {
    display: inline-flex;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.layout-btn {
    padding: 6px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border-right: 1px solid var(--border-color);
}

.layout-btn:last-child {
    border-right: none;
}

.layout-btn:hover {
    background: rgba(255, 204, 0, 0.08);
    color: var(--text-primary);
}

.layout-btn.active {
    background: linear-gradient(180deg, #ffcc00 0%, #e6b800 100%);
    color: #1a1a1a;
}

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

.debug-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px 5px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #ffd36b;
    background: linear-gradient(180deg, rgba(255, 180, 0, 0.13), rgba(120, 70, 0, 0.22));
    border: 1px solid rgba(255, 204, 0, 0.45);
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 0 0 0 rgba(255, 204, 0, 0.15);
    animation: debugGlow 2.8s ease-in-out infinite;
}

@keyframes debugGlow {
    0% { box-shadow: 0 0 0 0 rgba(255, 204, 0, 0.22); }
    50% { box-shadow: 0 0 0 6px rgba(255, 204, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 204, 0, 0); }
}

.debug-btn:hover {
    background: linear-gradient(180deg, rgba(255, 200, 0, 0.25), rgba(160, 90, 0, 0.35));
    filter: drop-shadow(0 0 5px rgba(255, 204, 0, 0.5));
}

.debug-btn:active {
    transform: scale(0.96);
}

.objek-vital {
    background: rgba(255, 204, 0, 0.1);
    border: 1px solid rgba(255, 204, 0, 0.3);
    padding: 5px 14px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 0.5px;
}

.objek-vital span {
    font-size: 14px;
    font-weight: 800;
    margin-left: 4px;
}

.video-grid {
    flex: 1;
    padding: 10px;
    gap: 10px;
    display: grid;
    background: var(--bg-primary);
    overflow: hidden;
}

.video-grid.layout-2x2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.video-grid.layout-3x2 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.video-grid.layout-3x3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.video-grid.layout-4x2 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.video-grid.layout-4x3 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.video-grid.layout-4x4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.camera-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s;
}

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

.camera-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: linear-gradient(180deg, rgba(255, 204, 0, 0.15) 0%, rgba(255, 204, 0, 0.05) 100%);
    border-bottom: 1px solid var(--border-color);
    min-height: 34px;
}

.cam-label {
    background: linear-gradient(180deg, #0099ff 0%, #0077cc 100%);
    color: #fff;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.cam-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.cam-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
}

.cam-arrow {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.cam-arrow:hover {
    opacity: 1;
}

.camera-header .status-badge {
    padding: 3px 8px;
    font-size: 10px;
    flex-shrink: 0;
}

.video-wrapper {
    flex: 1;
    position: relative;
    background: #000;
    min-height: 0;
    overflow: hidden;
}

.video-player {
    width: 100%;
    height: 100%;
    object-fit: fill;
    background: #000;
}

.live-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: rgba(255, 0, 0, 0.85);
    color: #fff;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(255, 0, 0, 0.4);
}

.live-dot {
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    animation: blink 1s ease-in-out infinite;
}

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

.timestamp {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-family: 'Consolas', monospace;
    font-size: 11px;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 3px 8px;
    border-radius: 3px;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.no-signal {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    z-index: 5;
}

.no-signal-inner {
    text-align: center;
    opacity: 0.7;
}

.no-signal .antenna {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    background: no-repeat center/contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a6a80' stroke-width='1.5'%3E%3Cpath d='M2 12c3.5-3.5 16.5-3.5 20 0'/%3E%3Cpath d='M6 16c2-2 10-2 12 0'/%3E%3Cline x1='12' y1='20' x2='12.01' y2='20'/%3E%3C/svg%3E");
}

.no-signal p {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 2px;
    font-weight: 600;
}

.expand-btn {
    position: absolute;
    bottom: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.restart-btn {
    position: absolute;
    bottom: 8px;
    left: 44px;
    width: 28px;
    height: 28px;
    background: rgba(50, 30, 0, 0.55);
    border: 1px solid rgba(255, 210, 100, 0.35);
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    box-shadow: 0 0 0 0 rgba(255, 204, 0, 0);
    animation: restartPulseGlow 2.4s ease-in-out infinite;
}

@keyframes restartPulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(255, 204, 0, 0.15); }
    50% { box-shadow: 0 0 0 4px rgba(255, 204, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 204, 0, 0); }
}

.video-wrapper:hover .expand-btn,
.video-wrapper:hover .restart-btn {
    display: flex;
}

.expand-btn:hover {
    background: rgba(255, 204, 0, 0.3);
    border-color: var(--accent-gold);
}

.restart-btn:hover {
    background: rgba(255, 150, 0, 0.45);
    border-color: #ffd36b;
    filter: drop-shadow(0 0 4px rgba(255, 204, 0, 0.5));
}
.restart-btn:active {
    transform: scale(0.9);
}

.system-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 8px 20px;
    min-height: 36px;
}

.footer-left {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.footer-left span {
    color: var(--accent-gold);
    font-weight: 600;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sys-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    font-family: 'Consolas', monospace;
}

.sys-stat span:last-child {
    color: var(--accent-gold);
    font-weight: 700;
}

.cpu-icon, .ram-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    background: no-repeat center/contain;
    filter: invert(0.6);
}

.cpu-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Crect x='4' y='4' width='16' height='16' rx='2'/%3E%3Crect x='9' y='9' width='6' height='6'/%3E%3Cline x1='9' y1='1' x2='9' y2='4'/%3E%3Cline x1='15' y1='1' x2='15' y2='4'/%3E%3Cline x1='9' y1='20' x2='9' y2='23'/%3E%3Cline x1='15' y1='20' x2='15' y2='23'/%3E%3Cline x1='20' y1='9' x2='23' y2='9'/%3E%3Cline x1='20' y1='14' x2='23' y2='14'/%3E%3Cline x1='1' y1='9' x2='4' y2='9'/%3E%3Cline x1='1' y1='14' x2='4' y2='14'/%3E%3C/svg%3E");
}

.ram-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Crect x='2' y='6' width='20' height='12' rx='2'/%3E%3Cline x1='6' y1='10' x2='6' y2='14'/%3E%3Cline x1='10' y1='10' x2='10' y2='14'/%3E%3Cline x1='14' y1='10' x2='14' y2='14'/%3E%3Cline x1='18' y1='10' x2='18' y2='14'/%3E%3C/svg%3E");
}

@media (max-width: 1400px) {
    .title-block h1 { font-size: 18px; }
    .cam-name { font-size: 10px; }
    .live-badge { font-size: 9px; }
}

@media (max-width: 1000px) {
    .video-grid.layout-4x4,
    .video-grid.layout-4x3,
    .video-grid.layout-4x2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   MOBILE RESPONSIVE (TABLET ≤ 768px)
   ======================================== */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 280px;
    }

    html, body {
        height: 100dvh;
        overflow: hidden;
        -webkit-tap-highlight-color: transparent;
        overscroll-behavior: none;
    }

    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .app {
        position: relative;
        height: 100dvh;
    }

    /* --- Sidebar: FIXED OVERLAY di mobile (tidak dorong konten) --- */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100dvh;
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0,0,0,0.6);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* --- Backdrop transparan saat sidebar dibuka --- */
    .app:not(.sidebar-collapsed)::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        backdrop-filter: blur(2px);
        z-index: 150;
        animation: fadeIn .18s ease;
    }

    @keyframes fadeIn { from { opacity:0;} to{opacity:1;} }

    .app.sidebar-collapsed { --sidebar-w: 280px; }
    .app.sidebar-collapsed .sidebar {
        transform: translateX(-105%);
        opacity: 0;
        pointer-events: none;
        width: var(--sidebar-w);
    }
    .app:not(.sidebar-collapsed) .sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
        width: var(--sidebar-w);
    }

    /* --- Header wrap mobile --- */
    .top-header {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 10px !important;
    }
    .header-left, .header-right {
        width: 100%;
        flex-wrap: wrap;
        gap: 4px;
    }
    .title-block h1 { font-size: 16px !important; letter-spacing: 1.5px; }
    .header-sub { font-size: 10px !important; }
    .welcome-info { font-size: 10px; }
    .clock { font-size: 11px; }
    .logout-btn { padding: 4px 8px; font-size: 10px; }

    /* --- Toolbar wrap vertical --- */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px 10px;
    }
    .toolbar-left, .toolbar-right {
        justify-content: space-between;
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }
    .layout-switcher {
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap !important;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }
    .layout-switcher .layout-btn {
        flex: 0 0 auto;
        padding: 4px 10px;
        font-size: 10px;
    }
    .cam-info {
        font-size: 11px;
        padding: 4px 8px;
    }
    .objek-vital {
        padding: 4px 10px;
        font-size: 11px;
        justify-content: center;
    }

    /* --- Grid video untuk TABLET: 2 kolom --- */
    .video-grid {
        padding: 6px;
        gap: 6px;
    }
    .video-grid.layout-2x2,
    .video-grid.layout-3x2,
    .video-grid.layout-3x3,
    .video-grid.layout-4x2 {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: none;
        grid-auto-rows: minmax(140px, 1fr);
    }
    .video-grid.layout-4x3,
    .video-grid.layout-4x4 {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: none;
        grid-auto-rows: minmax(120px, 1fr);
    }

    .main-wrap {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
    }

    .camera-header {
        padding: 4px 6px;
        gap: 4px;
    }
    .cam-label { font-size: 9px; padding: 2px 5px; }
    .cam-name { font-size: 9px !important; }
    .status-badge { font-size: 9px; padding: 1px 5px; }
    .status-badge.status-online::before { width:6px; height:6px; margin-right:3px; }
    .cam-arrow { display:none; }
    .expand-btn {
        width: 26px; height: 26px;
        right: 4px; bottom: 4px;
        left: auto;
    }
    .restart-btn {
        width: 26px; height: 26px;
        right: 38px; bottom: 4px;
        left: auto;
    }
    .timestamp { font-size: 9px; padding: 2px 4px; }
    .live-badge { font-size: 9px !important; padding: 1px 6px; }

    .system-footer {
        flex-direction: column;
        padding: 6px 10px;
        gap: 4px;
        font-size: 10px;
    }
    .footer-right { gap: 10px; width:100%; justify-content: space-between; }
    .footer-left { width:100%; text-align:center; }
}

/* ========================================
   HP KECIL ≤ 576px - 1 KOLOM (fullscreen per slot video scroll)
   ======================================== */
@media (max-width: 576px) {
    .title-block h1 { font-size: 14px !important; letter-spacing: 1.2px; }
    .header-sub { font-size: 9px !important; }
    .diamond { width: 6px; height: 6px; }

    .sidebar { width: 85vw; max-width: 320px; }
    .app.sidebar-collapsed { --sidebar-w: 85vw; }

    /* --- 1 KOLOM video: hp kecil, scroll vertical --- */
    .video-grid {
        padding: 4px;
        gap: 6px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .video-grid.layout-2x2,
    .video-grid.layout-3x2,
    .video-grid.layout-3x3,
    .video-grid.layout-4x2,
    .video-grid.layout-4x3,
    .video-grid.layout-4x4 {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-auto-rows: minmax(210px, 58vh);
    }

    .camera-card { border-radius: 4px; }
    .timestamp { font-size: 8.5px; }
    .live-badge { font-size: 8.5px !important; }
    .layout-switcher .layout-btn { padding: 3px 8px; font-size: 10px; }
    .cam-info { font-size: 10px; }
    .objek-vital { font-size: 10px; }
    .sys-stat { font-size: 10px; }
    .footer-left, .footer-right { font-size: 9.5px; }
}

/* ========================================
   MINI HP ≤ 400px
   ======================================== */
@media (max-width: 400px) {
    .menu-btn { width:32px; height:32px; }
    .menu-btn::before { font-size: 16px; line-height: 30px; }
    .logo-badge { width:36px; height:36px; }
    .logo-text h2 { font-size: 12px; }
    .logo-text h3 { font-size: 9px; }
    .sidebar-logo { padding: 10px; gap: 8px; }
    .menu-item { padding: 9px 10px; gap: 10px; }
    .menu-icon { width: 24px; height: 24px; }
    .menu-text strong { font-size: 12px; }
    .menu-sub { font-size: 9.5px; }
    .menu-sub2 { display:none; }
    .sidebar-user { padding: 10px; gap: 8px; }
    .user-avatar { width: 32px; height:32px; font-size: 13px; }
    .sidebar-logout { padding: 8px; font-size: 11px; margin: 10px; }
}
