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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #1a472a 0%, #2d5a3d 50%, #1a472a 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 40px;
}

header h1 {
  font-size: 3rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
  font-size: 1.2rem;
  opacity: 0.9;
}

.panel {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.status-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.status-card {
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  padding: 25px;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.status-label {
  font-size: 0.9rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.status-value {
  font-size: 2.5rem;
  font-weight: bold;
  color: #333;
}

.status-value.active {
  color: #2e7d32;
}

.status-value.inactive {
  color: #999;
}

.status-hint {
  font-size: 0.75rem;
  color: #888;
  margin-top: 6px;
}

.controls {
  margin-bottom: 24px;
}

.controls h3 {
  color: #333;
  font-size: 1rem;
  margin-bottom: 10px;
}

.btn-row {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.schedule-section {
  margin-bottom: 30px;
}

.schedule-section h2 {
  color: #333;
  font-size: 1.1rem;
  margin-bottom: 15px;
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 15px;
}

.schedule-card {
  background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
  padding: 18px;
  border-radius: 12px;
}

.schedule-card h4 {
  margin-bottom: 12px;
  color: #333;
}

.schedule-card label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.schedule-card .row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.schedule-card input[type="time"],
.schedule-card input[type="number"] {
  width: 90px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.btn-save {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
  color: white;
  min-width: auto;
  padding: 10px 24px;
}

.btn-light-on {
  background: linear-gradient(135deg, #f9a825 0%, #f57f17 100%);
  color: white;
}

.btn {
  flex: 1;
  min-width: 200px;
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-on {
  background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
  color: white;
}

.btn-off {
  background: linear-gradient(135deg, #c62828 0%, #b71c1c 100%);
  color: white;
}

.video-section {
  margin-top: 30px;
}

.video-section h2 {
  color: #333;
  margin-bottom: 15px;
}

.video-container {
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  padding-bottom: 56.25%;
  min-height: 200px;
}

.video-container.video-loading::after {
  content: 'Загрузка камеры...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #888;
  font-size: 1rem;
}

.video-container.video-error::after {
  content: 'Нет сигнала с камеры';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #999;
  font-size: 1rem;
}

.video-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

footer {
  margin-top: 20px;
  text-align: center;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.connection-status {
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 600;
}

#last-update {
  font-size: 0.9rem;
  opacity: 0.8;
}

.btn-refresh {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 2px solid rgba(255,255,255,0.4);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-refresh:hover {
  background: rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.7);
}

.btn-refresh:active {
  transform: scale(0.95);
}

.btn-refresh.refreshing {
  opacity: 0.6;
  pointer-events: none;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .status-value {
    font-size: 2rem;
  }

  .btn {
    min-width: 100%;
  }
}
