:root { --primary: #3b82f6; --bg: #f3f4f6; --text-main: #1f2937; --text-muted: #6b7280; --online: #10b981; --local-online: #0ea5e9; --offline: #9ca3af; --card-bg: #ffffff; --border: #e5e7eb; --item-bg: #f9fafb; --item-hover: #f3f4f6; --input-bg: #ffffff; --track-bg: #d1d5db; }
[data-theme="dark"] { --bg: #0f172a; --text-main: #f8fafc; --text-muted: #94a3b8; --card-bg: #1e293b; --border: #334155; --item-bg: #334155; --item-hover: #475569; --input-bg: #0f172a; --track-bg: #475569; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text-main); padding: 30px 20px; margin: 0; line-height: 1.5; padding-bottom: 100px; transition: 0.3s; }
.container { max-width: 1200px; margin: 0 auto; position: relative;}
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; }
.header-left { display: flex; align-items: center; gap: 15px;}
.header h2 { margin: 0; font-size: 24px; font-weight: 700; }
#sync-status { font-size: 12px; color: var(--text-muted); font-weight: 500; background: var(--item-bg); padding: 6px 12px; border-radius: 20px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); }
.theme-toggle-btn { background: transparent; border: 1px solid var(--border); color: var(--text-muted); width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; }
.theme-toggle-btn:hover { background: var(--item-bg); color: var(--primary); border-color: var(--primary); }
.video-panel { display: none; position: sticky; top: 20px; z-index: 1500; background: var(--card-bg); border-radius: 16px; padding: 20px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25), 0 0 0 1px var(--border); margin-bottom: 30px; flex-direction: column; }
.video-panel.active { display: flex; animation: slideDown 0.3s ease-out; }
.video-panel:fullscreen { padding: 0; background: #000; border-radius: 0; position: fixed; top:0; left:0; width:100%; height:100%; max-width: none; margin: 0; z-index: 9999; }
.video-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.video-panel:fullscreen .video-header { padding: 15px 20px; background: rgba(0,0,0,0.8); position: absolute; top: 0; left: 0; width: 100%; z-index: 10; opacity: 0; transition: opacity 0.3s; box-sizing: border-box; }
.video-panel:fullscreen .video-header:hover { opacity: 1; }
.view-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end;}
.view-btn { background: var(--item-bg); border: 1px solid var(--border); padding: 6px 15px; border-radius: 6px; font-weight: 600; font-size: 13px; color: var(--text-muted); cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 5px;}
.view-btn:hover { background: var(--item-hover); color: var(--text-main); }
.view-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.view-btn.danger { background: #fee2e2; color: #ef4444; border-color: #fca5a5; }
.video-container { background: #000; border-radius: 12px; overflow: hidden; width: 100%; display: flex; align-items: center; justify-content: center; max-height: 70vh;}
.video-panel:fullscreen .video-container { border-radius: 0; height: 100vh; max-height: none;}
.video-grid { width: 100%; height: 100%; }
.video-grid.single { display: block; aspect-ratio: 16/9; }
.video-grid.single .vid-slot:not(:first-child) { display: none; }
.video-grid.single .vid-slot { width: 100%; height: 100%; }
.video-grid.quad { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; aspect-ratio: 16/9; background: #374151;}
.video-grid.quad .vid-slot { display: flex; width: 100%; height: 100%; background: #000;}
.vid-slot { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; box-sizing: border-box; border: 2px solid transparent; transition: border-color 0.2s; cursor: pointer; }
.vid-slot.ptz-active { border-color: var(--primary); }
.vid-slot video, .vid-slot img { width: 100%; height: 100%; object-fit: contain; display: none; }
.slot-placeholder { color: var(--text-muted); font-weight: 600; font-size: 14px; position: absolute; pointer-events: none; }
.close-slot-btn { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.6); color: white; border: none; border-radius: 4px; padding: 4px 8px; font-size: 12px; cursor: pointer; display: none; z-index: 10;}
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.2px; margin: 40px 0 20px; display: flex; align-items: center; gap: 10px; }
.section-title.collapsible { cursor: pointer; user-select: none; transition: 0.2s; }
.section-title.collapsible:hover { color: var(--primary); }
.section-title::after { content: ''; height: 1px; background: var(--border); flex-grow: 1; }
.toggle-icon { font-size: 14px; transition: transform 0.2s; display: inline-block; }
.offline-container, .debug-wrapper { display: none; } 
.offline-container.open, .debug-wrapper.open { display: block; }
.offline-container.open .toggle-icon, .debug-wrapper.open .toggle-icon { transform: rotate(90deg); }
.device-grid { display: block; column-width: 320px; column-gap: 24px; width: 100%; }
.card { break-inside: avoid; page-break-inside: avoid; margin-bottom: 0; background: var(--card-bg); padding: 24px; border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02); position: relative; transition: all 0.3s ease; display: flex; flex-direction: column; width: 100%; box-sizing: border-box; }.card:hover { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05); border-color: var(--text-muted); }
.card-header { margin-bottom: 20px; padding-right: 30px; }
.card-name { font-weight: 600; display: block; font-size: 16px; color: var(--text-main); margin-bottom: 4px; }
.card-status { font-size: 13px; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--offline); transition: background 0.3s; }
.card.online .status-dot { background: var(--online); }
.card.local-online .status-dot { background: var(--local-online); box-shadow: 0 0 6px rgba(14, 165, 233, 0.5); }
.card-icon { position: absolute; top: 24px; right: 24px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; opacity: 0.5; } 
.card-content { flex-grow: 1; display: flex; flex-direction: column; gap: 10px; }
.gang-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.gang-grid.single-switch { grid-template-columns: 1fr; }
.gang-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: var(--item-bg); border-radius: 10px; border: 1px solid var(--border); cursor: pointer; transition: 0.2s; }
.gang-item:hover { background: var(--item-hover); }
.gang-label { font-size: 13px; font-weight: 500; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 8px; }
.toggle-track { flex-shrink: 0; width: 36px; height: 20px; background: var(--track-bg); border-radius: 12px; position: relative; transition: 0.3s; }
.toggle-thumb { width: 16px; height: 16px; background: white; border-radius: 50%; position: absolute; top: 2px; left: 2px; transition: 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.gang-item.on .toggle-track { background: var(--primary); }
.gang-item.on .toggle-thumb { transform: translateX(16px); }
.action-btn { background: rgba(59, 130, 246, 0.1); color: var(--primary); border: 1px solid rgba(59, 130, 246, 0.3); padding: 12px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; width: 100%; transition: 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px; }
.action-btn:hover { background: var(--primary); color: white; }
.input-group { display: flex; gap: 8px; margin-top: 5px; }
.input-group select, .input-group input { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; background: var(--input-bg); color: var(--text-main); }
.input-group button { background: var(--item-bg); color: var(--text-muted); border: 1px solid var(--border); padding: 0 12px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.input-group button:hover { background: var(--item-hover); color: var(--text-main); border-color: var(--border); }
.floating-ptz { position: fixed; bottom: 30px; right: 30px; background: var(--card-bg); padding: 20px; border-radius: 16px; box-shadow: 0 15px 35px rgba(0,0,0,0.3); border: 1px solid var(--border); display: none; z-index: 3000; flex-direction: column; align-items: center; gap: 8px; }
.floating-ptz.active { display: flex; }
.ptz-header { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; margin-bottom: 5px; }
.ptz-name { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.ptz-row { display: flex; gap: 8px; }
.ptz-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--item-bg); cursor: pointer; display: flex; justify-content: center; align-items: center; transition: 0.2s; }
.ptz-btn:hover { background: var(--primary); color: white; }
.sensor-container { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 10px;}
.sensor-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--item-bg); border-radius: 10px; font-size: 13px; }
.sensor-label { color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.sensor-label svg { color: var(--primary); } 
.sensor-value { font-weight: 600; text-align: right;}
.inline-reset { cursor: pointer; color: var(--text-muted); transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-reset:hover { color: var(--primary); transform: rotate(180deg); }
.debug-container { background: #000; border-radius: 12px; padding: 20px; color: #34d399; font-family: 'Courier New', monospace; font-size: 13px; overflow-y: auto; max-height: 250px; margin-top: 5px; }
/* --- PREMIUM APP LOGO --- */
.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px; /* Slightly smaller */
    font-weight: 700; /* Dialed back the boldness */
    letter-spacing: -0.3px;
    color: var(--text-main); /* Removed the heavy gradient entirely */
    margin: 0;
    user-select: none;
}
.app-logo svg {
    stroke: var(--primary);
    width: 24px;
    height: 24px;
    /* Removed the drop-shadow for a flatter, cleaner look */
}/* --- MOBILE OPTIMIZATIONS --- */
@media (max-width: 650px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .header > .header-left:nth-child(2) {
        width: 100%;
        justify-content: space-between;
    }
    /* ADD THIS: Hides unnecessary words on small screens */
    .sync-mobile-hide {
        display: none;
    }
}
/* --- SCADA FLOORPLAN WIDGET --- */
#floorplan-wrapper {
    position: relative;
    width: 100%;
    max-width: 380px; /* Constrains it to a sleek widget size */
    margin: 0 auto;
}
#floorplan-wrapper svg {
    width: 100%;
    height: auto;
    display: block;
}
#floorplan-wrapper rect {
    transition: all 0.5s ease;
    fill: var(--item-bg);
    stroke: var(--border);
    stroke-width: 2px;
}
[data-theme="dark"] #floorplan-wrapper rect {
    fill: rgba(255, 255, 255, 0.02);
}

/* --- SCADA FLOORPLAN WIDGET --- */
#floorplan-wrapper {
    position: relative;
    width: 100%;
    max-width: 380px; 
    margin: 0 auto;
}
#floorplan-wrapper svg {
    width: 100%;
    height: auto;
    display: block;
}
#floorplan-wrapper rect {
    transition: all 0.5s ease;
    fill: var(--item-bg);
    stroke: var(--border);
    stroke-width: 2px;
}
[data-theme="dark"] #floorplan-wrapper rect {
    fill: rgba(255, 255, 255, 0.02);
}

/* SCADA Breathing Pulse (Leveraging CSS Variables for Layer Targeting) */
@keyframes roomPulse {
    0% { fill: var(--p-fill-0, rgba(59, 130, 246, 0.15)); stroke: var(--p-str-0, rgba(59, 130, 246, 0.5)); }
    50% { fill: var(--p-fill-50, rgba(59, 130, 246, 0.35)); stroke: var(--p-str-50, rgba(59, 130, 246, 1)); }
    100% { fill: var(--p-fill-100, rgba(59, 130, 246, 0.15)); stroke: var(--p-str-100, rgba(59, 130, 246, 0.5)); }
}
#floorplan-wrapper rect.lit-up {
    animation: roomPulse 3s infinite ease-in-out;
    stroke-width: 2px;
}

/* KITCHEN SPLIT HACKS */
#kitchen-left, #kitchen-right {
    stroke: none !important;
    --p-str-0: transparent;
    --p-str-50: transparent;
    --p-str-100: transparent;
}
#kitchen-outline {
    fill: none !important;
    pointer-events: none;
    --p-fill-0: transparent;
    --p-fill-50: transparent;
    --p-fill-100: transparent;
}

/* Room Tag Overlays */
.room-label {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}
.room-name {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg);
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.room-temp {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-main);
    text-shadow: 0px 1px 3px var(--bg);
}

/* Make Room Labels Interactive Buttons */
.room-label.clickable {
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.room-label.clickable:hover {
    transform: translate(-50%, -50%) scale(1.1);
    z-index: 10;
}
.room-label.clickable .room-name {
    border-color: var(--primary);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}