body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    border: 1px solid #4afcff;
}

h1 {
    text-align: center;
    color: #4afcff;
    margin-bottom: 30px;
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

button {
    padding: 12px 20px;
    font-size: 14px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    background: white;
    color: #1a1a2e;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

button.active {
    background: #4afcff;
    color: #1a1a2e;
    box-shadow: 0 0 15px #4afcff;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#connectBtn { 
    background: #4CAF50; 
    color: white; 
}

#disconnectBtn { 
    background: #f44336; 
    color: white; 
}

#loadRoomBtn { 
    background: #9c27b0; 
    color: white; 
}

.small-btn {
    padding: 5px 10px;
    font-size: 12px;
    background: rgba(255,255,255,0.2);
    color: white;
}

.small-btn:hover {
    background: rgba(255,255,255,0.3);
}

.calibration-raw-panel {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.calibration-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.calibration-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4590 100%);
}

.calibration-btn:active {
    transform: translateY(0);
}

.raw-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.raw-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
    background: linear-gradient(135deg, #ff5252 0%, #ff7e3a 100%);
}

.raw-btn:active {
    transform: translateY(0);
}

.raw-btn.active {
    background: linear-gradient(135deg, #f44336 0%, #ff1744 100%);
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.8);
}

.transform-controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 15px 0;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 50px;
    flex-wrap: wrap;
    align-items: center;
}

.transform-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.transform-group label {
    font-size: 14px;
    color: #4afcff;
    margin-right: 10px;
    font-weight: bold;
}

.angle-control {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255,255,255,0.1);
    padding: 5px 15px;
    border-radius: 50px;
}

.angle-control label {
    color: #4afcff;
    font-weight: bold;
    margin-right: 5px;
}

.angle-control button {
    padding: 5px 15px;
    font-size: 18px;
    font-weight: bold;
    background: #4afcff;
    color: #1a1a2e;
    min-width: 40px;
}

.angle-control button:hover {
    background: #7fffff;
}

.angle-control span {
    color: white;
    font-size: 18px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.view-mode-indicator {
    display: inline-block;
    margin-left: 10px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    background: rgba(255,255,255,0.1);
    border: 1px solid #4afcff;
}

.view-mode-calibrated {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    border-color: #4CAF50;
}

.view-mode-raw {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
    border-color: #ff9800;
}

.status-bar {
    background: rgba(255,255,255,0.1);
    padding: 15px 20px;
    border-radius: 10px;
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    border-left: 4px solid #4afcff;
}

.status-led {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.led-green { 
    background: #4CAF50; 
    box-shadow: 0 0 10px #4CAF50; 
}

.led-red { 
    background: #f44336; 
    box-shadow: 0 0 10px #f44336; 
}

.canvas-container {
    background: #0a0a1a;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    border: 2px solid #4afcff;
    box-shadow: 0 0 20px rgba(74,252,255,0.3);
}

canvas {
    display: block;
    margin: 0 auto;
    background: #050510;
    border-radius: 10px;
    max-width: 100%;
    height: auto;
}

.room-history-panel {
    margin-top: 20px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 15px;
}

.room-history-panel h3 {
    margin: 0 0 10px 0;
    color: #4afcff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.room-history-item {
    background: rgba(74,252,255,0.1);
    border-left: 4px solid #4afcff;
    padding: 10px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
}

.room-history-item:hover {
    background: rgba(74,252,255,0.2);
    transform: translateX(5px);
}

.room-history-item.active {
    background: rgba(74,252,255,0.3);
    border-left-width: 8px;
}

.room-history-index {
    font-weight: bold;
    color: #4afcff;
    font-size: 14px;
}

.room-history-preview {
    display: flex;
    gap: 15px;
    color: #aaa;
}

.room-history-date {
    color: #4afcff;
    font-family: monospace;
}

.targets-panel {
    margin-top: 20px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 15px;
    max-height: 250px;
    overflow-y: auto;
}

.targets-panel h3 {
    margin: 0 0 10px 0;
    color: #4afcff;
}

.target-card {
    background: rgba(74,252,255,0.1);
    border-left: 4px solid;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 5px;
    font-size: 13px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.raw-data {
    font-family: monospace;
    font-size: 11px;
    color: #aaa;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #444;
}

.calibration-summary {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #1e1e2f 0%, #2a2a40 100%);
    border: 2px solid #4afcff;
    border-radius: 15px;
    padding: 20px;
    max-width: 400px;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    backdrop-filter: blur(10px);
}

.calibration-summary.visible {
    display: block;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.calibration-summary h4 {
    margin-top: 0;
    color: #4afcff;
    font-size: 18px;
    border-bottom: 1px solid rgba(74,252,255,0.3);
    padding-bottom: 10px;
}

.calibration-summary pre {
    background-color: #0a0a1a;
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    overflow-x: auto;
    max-height: 300px;
    border: 1px solid #4afcff;
    color: #4afcff;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.close-btn:hover {
    background: #f44336;
    color: white;
    transform: rotate(90deg);
}

/* ===== PANEL DETEKCJI DRZWI ===== */
.door-control-panel {
    background: rgba(30, 30, 40, 0.9);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    border-left: 4px solid #e67e22;
}

.door-control-panel h3 {
    margin: 0 0 15px 0;
    color: #e67e22;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.door-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.door-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ccc;
    font-size: 14px;
    cursor: pointer;
}

.door-controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #e67e22;
}

/* Panel marginesów */
.door-margins-panel {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 12px;
    margin-top: 5px;
}

.door-margins-panel h4 {
    margin: 0 0 10px 0;
    color: #e67e22;
    font-size: 14px;
    font-weight: normal;
}

.margins-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.margin-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.margin-item label {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 2px;
}

.margin-item input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #333;
    outline: none;
    
}

.margin-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e67e22;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.margin-item span {
    font-weight: bold;
    color: #e67e22;
    text-align: right;
    font-size: 13px;
}

.margin-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.margin-presets button {
    padding: 5px 10px;
    background: #e67e22;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
    flex: 1;
    min-width: 60px;
}

.margin-presets button:hover {
    background: #d35400;
}

/* ===== PANEL STAŁYCH CZASOWYCH ===== */
.time-constants-panel {
    margin: 15px 0;
    padding: 15px;
    background: rgba(30, 30, 40, 0.9);
    border-radius: 8px;
    border-left: 4px solid #9b59b6;
}

.time-constants-panel h3 {
    margin: 0 0 15px 0;
    color: #9b59b6;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.time-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.time-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.time-item label {
    font-weight: bold;
    font-size: 14px;
    color: #ccc;
}

.time-item input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #333;
    outline: none;
    
}

.time-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #9b59b6;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.time-item span {
    font-weight: bold;
    color: #9b59b6;
    text-align: right;
    font-size: 13px;
}

.time-desc {
    color: #777;
    font-size: 11px;
    margin-top: 2px;
}

.time-presets {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.time-presets button {
    padding: 6px 10px;
    background: #9b59b6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
    flex: 1;
    min-width: 70px;
}

.time-presets button:hover {
    background: #8e44ad;
}

/* Lista zdarzeń drzwi */
.door-events-list {
    margin-top: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.door-events-list h4 {
    margin: 0 0 10px 0;
    color: #e67e22;
    font-size: 14px;
}

.door-event-item {
    padding: 8px;
    margin: 5px 0;
    background: rgba(230, 126, 34, 0.1);
    border-radius: 4px;
    font-size: 13px;
    color: #fff;
    border-left: 3px solid #e67e22;
}

#doorEntryCounter {
    color: #e67e22;
    font-weight: bold;
}

/* Responsywność dla mniejszych ekranów */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .controls {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
    
    .transform-controls {
        flex-direction: column;
        border-radius: 15px;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .margins-grid {
        grid-template-columns: 1fr;
    }
    
    .margin-presets {
        flex-direction: column;
    }
    
    .time-presets {
        flex-direction: column;
    }
    
    .calibration-summary {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}