* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; margin: 0; background: #f0f4f8; color: #2d3748; min-height: 100vh; }

.app-body { display: flex; flex-direction: column; min-height: 100vh; }

.header { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1.25rem; background: #fff; border-bottom: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.header .site-title { margin: 0; font-size: 1.25rem; font-weight: 600; flex: 1; color: #1a202c; }
.header .user { color: #718096; font-size: 0.85rem; }
.btn { padding: 0.4rem 0.8rem; border-radius: 8px; text-decoration: none; font-size: 0.85rem; cursor: pointer; border: none; }
.btn-outline { color: #3182ce; border: 1px solid #3182ce; background: transparent; }
.btn-outline:hover { background: #ebf8ff; }
.btn-primary { background: #3182ce; color: #fff; }
.btn-primary:hover { background: #2c5282; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-edit { color: #3182ce; background: transparent; }
.btn-delete { color: #e53e3e; background: transparent; }
.btn-delete:hover { background: #fff5f5; }

.menu-toggle { display: none; width: 44px; height: 44px; padding: 0; border: none; background: transparent; cursor: pointer; border-radius: 8px; flex-shrink: 0; align-items: center; justify-content: center; }
.menu-toggle:hover { background: #f7fafc; }
.menu-toggle span { display: block; width: 22px; height: 2px; background: #4a5568; border-radius: 1px; }
.menu-toggle span::before, .menu-toggle span::after { content: ""; display: block; width: 22px; height: 2px; background: #4a5568; border-radius: 1px; margin-top: 6px; }
.menu-toggle span::after { margin-top: 4px; }

.app-wrap { display: flex; flex: 1; min-height: 0; }
.sidebar { width: 200px; min-width: 200px; background: #fff; border-right: 1px solid #e2e8f0; padding: 1rem 0; }
.nav-link { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.25rem; color: #4a5568; text-decoration: none; font-size: 0.95rem; border-left: 3px solid transparent; cursor: pointer; }
.nav-link .nav-icon { width: 1.1rem; text-align: center; opacity: 0.9; }
.nav-link:hover { background: #f7fafc; color: #1a202c; }
.nav-link.active { font-weight: 600; color: #3182ce; border-left-color: #3182ce; background: #ebf8ff; }
.nav-link.active .nav-icon { opacity: 1; }
.nav-no-access { display: block; padding: 0.6rem 1.25rem; font-size: 0.9rem; }

.main { flex: 1; overflow: auto; padding: 1.25rem; }
.panel { display: none; }
.panel.active { display: block; }
.main.webasto-main-dark { background: #0f172a; }
.panel-title { margin: 0 0 1rem; font-size: 1.1rem; color: #2d3748; }
.server-version { margin: -0.5rem 0 1rem; font-size: 0.85rem; }
.server-version i { margin-right: 0.25rem; }

.error { color: #e53e3e; margin-bottom: 0.75rem; font-size: 0.9rem; }
.message { color: #276749; margin-bottom: 0.75rem; font-size: 0.9rem; }
.muted { color: #718096; font-size: 0.9rem; }

.card-block { margin-bottom: 1.5rem; padding: 1rem 1.25rem; background: #fff; border-radius: 12px; border: 1px solid #e2e8f0; }
.card-block h3 { margin: 0 0 0.35rem; font-size: 1rem; color: #1a202c; }
.card-block .muted { margin-bottom: 0.5rem; }

.card-block h3 .fa-solid, .card-block h3 .fa-regular { margin-right: 0.35rem; opacity: 0.85; }
.panel-title .fa-solid { margin-right: 0.35rem; }

.btn-icon { padding: 0.4rem 0.65rem; }
.btn-icon .fa-solid, .btn-icon .fa-regular { font-size: 0.9em; }
.devices-manage-item .devices-item-icon { color: #718096; width: 1.25rem; text-align: center; }
.webasto-default-select { padding: 0.5rem 0.65rem; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; font-size: 0.9rem; width: 100%; max-width: 320px; margin-top: 0.35rem; }
.webasto-default-device-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; }
.webasto-default-device-row .webasto-default-select { margin-top: 0; flex: 0 1 280px; }

.api-key-box { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.api-key-value { flex: 1; min-width: 180px; padding: 0.4rem 0.6rem; word-break: break-all; font-size: 0.85rem; background: #f7fafc; border-radius: 8px; border: 1px solid #e2e8f0; }
.btn-copy { padding: 0.4rem 0.75rem; border: none; border-radius: 8px; background: #3182ce; color: #fff; cursor: pointer; font-size: 0.85rem; }
.btn-copy:hover { background: #2c5282; }

.add-device-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.add-device-form input { padding: 0.45rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; color: #2d3748; font-size: 0.9rem; }
.add-device-form input[name="device_id"] { width: 200px; }
.add-device-form input[name="device_name"] { width: 160px; }
.add-device-form button { padding: 0.45rem 0.9rem; border: none; border-radius: 8px; background: #3182ce; color: #fff; cursor: pointer; font-size: 0.9rem; }

.devices-manage-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.devices-manage-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }
.devices-manage-item:last-child { border-bottom: none; }
.dm-name { flex: 1; min-width: 120px; font-weight: 500; }

/* Webasto: вид как в приложении (тёмная тема, неоморфизм) */
#panel-webasto.panel { padding: 0; }
#panel-webasto .panel-title { display: none; }
.panel-webasto-app .webasto-app {
  max-width: 420px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  min-height: 100%;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #e2e8f0;
  border-radius: 0;
}
.webasto-device-picker {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  max-width: 420px;
  margin: 0 auto 0.75rem;
  padding: 0 0.5rem;
}
.webasto-device-picker-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}
.webasto-active-device-select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.95rem;
}
.webasto-app-bar {
  text-align: center;
  padding: 0.6rem 0;
  margin-bottom: 1rem;
  position: relative;
}
.webasto-app-status {
  font-size: 0.9rem;
  color: #f87171;
}
.webasto-app-status.connected { color: #4ade80; }
.webasto-app-status i { margin-right: 0.35rem; }
.webasto-dial-wrap { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.webasto-dial {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2d3a4f, #1a2332);
  box-shadow: 8px 8px 16px #0d1321, -8px -8px 16px #2d3a4f;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.webasto-dial-progress {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(#f97316 calc(var(--progress, 0) * 360deg), transparent 0);
  opacity: 0.85;
  pointer-events: none;
}
.webasto-dial-inner {
  text-align: center;
  padding: 1rem;
  position: relative;
  z-index: 1;
  background: linear-gradient(145deg, #2d3a4f, #1a2332);
  border-radius: 50%;
  margin: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.webasto-dial-time { display: block; font-size: 1.75rem; font-weight: 700; margin-bottom: 0.2rem; }
.webasto-dial-label { display: block; font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.35rem; }
.webasto-dial-state { display: block; font-size: 0.85rem; color: #94a3b8; }
.webasto-dial-icon {
  display: block;
  margin-bottom: 0.25rem;
  line-height: 1;
}
.webasto-dial-icon:empty { display: none; }
.webasto-dial-icon--running .webasto-dial-icon-flame {
  font-size: 2.5rem;
  color: #f97316;
}
.webasto-dial-icon--preheater {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}
.webasto-dial-icon--preheater .webasto-dial-icon-engine {
  font-size: 2rem;
  color: #94a3b8;
}
.webasto-dial-icon--preheater .webasto-dial-icon-flame-small {
  font-size: 1.25rem;
  color: #f97316;
}
.webasto-dial.webasto-dial--preheater .webasto-dial-time,
.webasto-dial.webasto-dial--preheater .webasto-dial-label { display: none; }
.webasto-dial.webasto-dial--preheater .webasto-dial-state {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f97316;
}
.webasto-dial.webasto-dial--off .webasto-dial-time,
.webasto-dial.webasto-dial--off .webasto-dial-label { display: none; }
.webasto-dial.webasto-dial--off .webasto-dial-state {
  font-size: 1.75rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.02em;
}
.webasto-temps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.webasto-temps-top {
  margin-bottom: 1rem;
}
.webasto-datetime-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(145deg, #252f42, #1a2332);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
}
.webasto-datetime-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.webasto-datetime-label {
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.webasto-datetime-label i { margin-right: 0.25rem; }
.webasto-datetime-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
}
.webasto-scheduler-hint { font-size: 0.8rem; margin-bottom: 0.75rem; }
.webasto-scheduler-alarms-title { font-size: 1rem; margin: 1.25rem 0 0.5rem; color: #e2e8f0; }
.webasto-upcoming-list { list-style: none; margin: 0 0 0.5rem; padding: 0; max-height: 280px; overflow-y: auto; }
.webasto-upcoming-item { padding: 0.4rem 0.5rem; font-size: 0.9rem; color: #64748b; border-radius: 8px; }
.webasto-upcoming-item.muted { color: #475569; }
.webasto-upcoming-day { font-weight: 600; color: #94a3b8; }
.scheduler-once-day { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.35rem; }
.scheduler-day-btn { padding: 0.3rem 0.5rem; font-size: 0.8rem; border-radius: 8px; }
.scheduler-day-btn.active { background: #f97316; color: #fff; border-color: #f97316; }
.scheduler-date-label { font-size: 0.8rem; color: #64748b; margin: 0 0.25rem 0 0; }
.scheduler-edit-once-day { margin-top: 0.5rem; }
.scheduler-edit-once-day label { display: block; margin-bottom: 0.25rem; }
.webasto-btn-save-schedules { margin-top: 1rem; }
.webasto-settings-subtitle { font-size: 1rem; margin: 1rem 0 0.5rem; color: #94a3b8; }
.webasto-auto-temp-card { margin-top: 1rem; }
.webasto-settings-input {
  display: block;
  width: 100%;
  max-width: 200px;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 1rem;
}
.webasto-temp-block {
  background: linear-gradient(145deg, #252f42, #1a2332);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 6px 6px 12px #0d1321, -4px -4px 10px #252f42;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid rgba(255,255,255,0.06);
}
.webasto-temps-top .webasto-temp-block {
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  flex-direction: row;
}
.webasto-temps-top .webasto-temp-block:hover {
  transform: scale(1.02);
  box-shadow: 4px 4px 10px #0d1321, -2px -2px 8px #252f42;
}
.webasto-temps-top .webasto-temp-icon { font-size: 0.75rem; }
.webasto-temps-top .webasto-temp-label { font-size: 0.55rem; }
.webasto-temps-top .webasto-temp-value { font-size: 0.85rem; }
.webasto-temps-top .webasto-temp-meta { font-size: 0.55rem; }
.webasto-temps.webasto-temps-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.webasto-temp-icon {
  font-size: 1.25rem;
  color: #f97316;
  opacity: 0.9;
}
.webasto-temp-block:last-child .webasto-temp-icon { color: #38bdf8; }
.webasto-temp-label {
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.webasto-temp-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.02em;
}
.webasto-temp-meta {
  font-size: 0.7rem;
  color: #f87171;
  min-height: 1em;
}
.webasto-actions-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.webasto-actions-row .webasto-app-btn {
  min-width: 0;
}
.webasto-app-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  border: none;
  border-radius: 16px;
  background: linear-gradient(145deg, #2d3a4f, #1a2332);
  box-shadow: 6px 6px 12px #0d1321, -6px -6px 12px #2d3a4f;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: box-shadow 0.2s;
}
.webasto-app-btn:hover:not(:disabled) {
  box-shadow: 4px 4px 8px #0d1321, -4px -4px 8px #2d3a4f;
}
.webasto-app-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.webasto-app-btn i { font-size: 1.25rem; }
.webasto-app-btn.webasto-btn-toggle { color: #4ade80; }
.webasto-app-btn.webasto-btn-toggle:hover:not(:disabled) { color: #86efac; }
.webasto-app-btn.webasto-btn-stop { color: #f87171; }
.webasto-app-btn.webasto-btn-stop:hover:not(:disabled) { color: #fca5a5; }
.webasto-app-btn.webasto-btn-extend { color: #94a3b8; }
.webasto-app-btn.webasto-btn-extend:hover:not(:disabled) { color: #e2e8f0; }
.webasto-app-btn.webasto-btn-preheater { color: #94a3b8; }
.webasto-app-btn.webasto-btn-preheater:hover:not(:disabled) { color: #e2e8f0; }
.webasto-app-btn.webasto-btn-preheater.active { color: #f97316; }
.webasto-settings-wrap { padding: 1rem; max-width: 420px; margin: 0 auto; }
.webasto-settings-inner { padding: 0.5rem 0; }
.webasto-back {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: #e2e8f0;
  font-size: 1.1rem;
  padding: 0.4rem;
}
.webasto-settings-card {
  background: linear-gradient(145deg, #252f42, #1a2332);
  border-radius: 16px;
  padding: 1.25rem;
  margin-top: 1rem;
  box-shadow: 6px 6px 12px #0d1321;
}
.webasto-settings-label { display: block; font-size: 0.85rem; color: #94a3b8; margin-bottom: 0.5rem; }
.webasto-settings-label i { margin-right: 0.35rem; }
.webasto-settings-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.webasto-settings-hint { font-size: 0.8rem; color: #64748b; margin: 0 0 1rem; line-height: 1.4; }
.webasto-settings-deploy-time { font-size: 0.75rem; color: #475569; margin: 0 0 0.75rem; padding: 0.25rem 0; }
.webasto-settings-deploy-time i { margin-right: 0.35rem; opacity: 0.9; }
.webasto-settings-deploy-time .webasto-firmware-version { margin-left: 0.25rem; }
.webasto-btn-save-settings { width: 100%; }
.webasto-app-bar .webasto-back + .webasto-app-status { display: inline-block; }

.webasto-history-wrap { padding: 1rem; max-width: 420px; margin: 0 auto; }
.webasto-history-inner { padding: 0.5rem 0; }
.webasto-history-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.webasto-history-filter-label { font-size: 0.8rem; color: #64748b; margin-right: 0.25rem; }
.webasto-history-date {
  padding: 0.4rem 0.5rem;
  border-radius: 10px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.85rem;
}
.webasto-history-date-sep { color: #64748b; }
.webasto-history-apply {
  padding: 0.4rem 0.75rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(145deg, #2d3a4f, #1a2332);
  color: #e2e8f0;
  font-size: 0.8rem;
  cursor: pointer;
}
.webasto-history-apply:hover { background: #334155; }
.webasto-temp-modal-inner { max-width: 95vw; width: 700px; max-height: 90vh; display: flex; flex-direction: column; }
.webasto-temp-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.webasto-temp-modal-header h3 { margin: 0; font-size: 1.1rem; color: #e2e8f0; }
.webasto-temp-modal-close { background: transparent; color: #94a3b8; border: none; cursor: pointer; padding: 0.5rem; }
.webasto-temp-modal-close:hover { color: #e2e8f0; }
.webasto-temp-modal-chart-wrap { position: relative; min-height: 280px; flex: 1; }
.webasto-temp-modal-chart-wrap canvas { width: 100% !important; height: 100% !important; min-height: 280px; }
.webasto-temp-modal-period { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.webasto-temp-modal-period label { font-size: 0.85rem; color: #64748b; }
.webasto-history-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.webasto-history-item .webasto-history-time { display: flex; flex-direction: column; gap: 0.1rem; }
.webasto-history-ago { font-weight: 500; }
.webasto-history-exact { font-size: 0.75rem; color: #64748b; }
.webasto-temp-chart-wrap { height: 220px; margin-bottom: 1rem; }
.webasto-history-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.webasto-history-tab {
  flex: 1;
  padding: 0.6rem 0.5rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, #252f42, #1a2332);
  color: #64748b;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.webasto-history-tab:hover { color: #e2e8f0; }
.webasto-history-tab.active { color: #f97316; background: linear-gradient(145deg, #2d3a4f, #1e293b); }
.webasto-history-panel { display: none; padding: 0.5rem 0; }
.webasto-history-panel.active { display: block; }
.webasto-history-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.webasto-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.35rem;
  background: linear-gradient(145deg, #252f42, #1a2332);
  border-radius: 12px;
  font-size: 0.85rem;
}
.webasto-history-time { color: #64748b; font-size: 0.8rem; }
.webasto-history-action { color: #e2e8f0; font-weight: 500; }
.webasto-temp-item .webasto-temp-values { color: #94a3b8; font-size: 0.85rem; }
.webasto-history-empty { text-align: center; padding: 1.5rem 0.5rem; color: #64748b; font-size: 0.9rem; }
  background: rgba(30, 41, 59, 0.8);
  border-color: #334155;
  color: #e2e8f0;
}
.webasto-scheduler-wrap .card-block h3 { color: #e2e8f0; }
.webasto-scheduler-wrap .scheduler-form input,
.webasto-scheduler-wrap .scheduler-form select { background: #1e293b; border-color: #475569; color: #e2e8f0; }
.webasto-scheduler-wrap .scheduler-item { border-color: #334155; }
.webasto-bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.75rem 1rem;
  background: linear-gradient(145deg, #252f42, #1a2332);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
  border-radius: 20px 20px 0 0;
}
.webasto-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  color: #64748b;
  text-decoration: none;
  font-size: 0.7rem;
  padding: 0.35rem 0.75rem;
  border-radius: 12px;
  transition: color 0.2s;
}
.webasto-nav-item:hover { color: #e2e8f0; }
.webasto-nav-item.active { color: #f97316; }
.webasto-nav-item i { font-size: 1.1rem; }
.webasto-no-device { color: #94a3b8; }
.scheduler-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.scheduler-form label { font-size: 0.8rem; color: #718096; margin-bottom: 0.2rem; }
.scheduler-form input[type="time"], .scheduler-form select { padding: 0.45rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 0.9rem; }
.scheduler-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.scheduler-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid #e2e8f0; }
.scheduler-item-time { font-weight: 600; min-width: 4rem; }
.scheduler-item-repeat { color: #718096; font-size: 0.9rem; flex: 1; }
.scheduler-item-remove { margin-left: auto; }

/* Старые стили Webasto (если понадобятся) */
.webasto-layout { max-width: 480px; }
.scheduler-form label { font-size: 0.8rem; color: #718096; margin-bottom: 0.2rem; }
.scheduler-form input[type="time"], .scheduler-form select { padding: 0.45rem 0.6rem; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 0.9rem; }
.scheduler-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.scheduler-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid #e2e8f0; }
.scheduler-item-time { font-weight: 600; min-width: 4rem; }
.scheduler-item-repeat { color: #718096; font-size: 0.9rem; flex: 1; }
.scheduler-item-remove { margin-left: auto; }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); padding: 0.6rem 1.2rem; background: #2d3748; color: #fff; border-radius: 10px; font-size: 0.9rem; box-shadow: 0 4px 12px rgba(0,0,0,0.2); z-index: 200; max-width: 90%; }
.toast.warn { background: #c53030; }
.device-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.75rem; }
.device-card { background: #fff; border-radius: 12px; padding: 0.9rem 1rem; border: 1px solid #e2e8f0; box-shadow: 0 1px 4px rgba(0,0,0,0.04); transition: box-shadow 0.2s; }
.device-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.device-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; min-height: 28px; }
.device-header h3 { margin: 0; font-size: 0.95rem; font-weight: 600; color: #1a202c; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 0.7rem; padding: 0.15rem 0.4rem; border-radius: 999px; font-weight: 500; }
.badge.online { background: #c6f6d5; color: #22543d; }
.badge.offline { background: #e2e8f0; color: #718096; }
.device-id { margin: 0 0 0.5rem; font-size: 0.75rem; color: #718096; }
.device-id code { background: #f7fafc; padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.75rem; color: #4a5568; }

.device-controls { display: flex; flex-direction: column; gap: 0.5rem; }
.device-led-row { display: flex; align-items: center; gap: 0.5rem; }
.led-label { font-size: 0.8rem; color: #4a5568; min-width: 3.5rem; }
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cbd5e0; border-radius: 22px; transition: 0.2s; }
.toggle-slider::before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: 0.2s; }
.toggle input:checked + .toggle-slider { background: #48bb78; }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle input:disabled + .toggle-slider { opacity: 0.6; cursor: not-allowed; }

.slider-row { display: flex; align-items: center; gap: 0.5rem; }
.slider-row label { font-size: 0.8rem; color: #4a5568; min-width: 3.5rem; }
.slider-row input[type="range"] { flex: 1; height: 6px; -webkit-appearance: none; appearance: none; background: #e2e8f0; border-radius: 3px; }
.slider-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #3182ce; cursor: pointer; }
.slider-row input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #3182ce; cursor: pointer; border: none; }
.slider-value { font-size: 0.8rem; color: #718096; min-width: 1.5rem; text-align: right; }

/* Webasto (legacy) */
.webasto-buttons { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.webasto-status-content { margin-top: 0.5rem; }
.webasto-status-dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1.5rem; font-size: 0.9rem; }
.webasto-status-dl dt { color: #718096; font-weight: normal; }
.webasto-status-dl dd { margin: 0; color: #1a202c; }

/* Карточки устройств (умный дом) */

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; padding: 1.25rem; border-radius: 12px; min-width: 280px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); }
.modal h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.modal label { display: block; font-size: 0.85rem; color: #4a5568; margin-bottom: 0.25rem; }
.modal input { width: 100%; padding: 0.5rem; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 0.75rem; }
.modal select { width: 100%; padding: 0.5rem; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 0.75rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.modal-actions .btn { padding: 0.4rem 0.8rem; }

.users-toolbar { margin-bottom: 1rem; }
.table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.users-table th, .users-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.users-table th { font-weight: 600; color: #4a5568; background: #f7fafc; }
.users-table tbody tr:hover { background: #f7fafc; }
.user-permissions { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.5rem 0; }
.user-permissions .checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.9rem; }
.user-permissions input[type="checkbox"] { margin: 0; }
.user-permissions-fieldset { margin: 1rem 0; padding: 0.75rem 1rem; border: 1px solid #e2e8f0; border-radius: 8px; background: #fafbfc; }
.user-permissions-fieldset legend { font-weight: 600; padding: 0 0.35rem; color: #2d3748; }
.user-permissions-hint { margin: 0 0 0.5rem 0; font-size: 0.85rem; }
.user-permissions-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.user-permissions-list li { margin: 0; padding: 0; }
.user-permissions-list .checkbox-label { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.9rem; }
.user-permissions-list input[type="checkbox"] { margin: 0; flex-shrink: 0; }
.user-devices-fieldset { margin-top: 0.75rem; padding: 0.75rem 1rem; border: 1px solid #e2e8f0; border-radius: 8px; background: #fafbfc; }
.user-devices-fieldset legend { font-weight: 600; padding: 0 0.35rem; color: #2d3748; }
.user-devices-wrap { margin-top: 1rem; }
.user-devices-wrap .muted { margin-bottom: 0.35rem; font-size: 0.85rem; }
.user-devices-list { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; max-height: 200px; overflow-y: auto; }
.user-devices-list .checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.9rem; }
.user-devices-list .checkbox-label code { font-size: 0.8rem; color: #718096; }
#userModalPasswordHint { font-size: 0.85rem; }

.sidebar-overlay { display: none; }

/* Страница входа (без sidebar) */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
.login-box { background: #fff; padding: 2rem; border-radius: 16px; width: 100%; max-width: 320px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.login-box h1 { margin: 0 0 0.25rem; font-size: 1.5rem; color: #1a202c; }
.login-box .subtitle { color: #718096; font-size: 0.9rem; margin-bottom: 1.5rem; }
.login-box input { width: 100%; padding: 0.6rem 0.8rem; margin-bottom: 0.75rem; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; color: #2d3748; font-size: 16px; min-height: 48px; }
.login-box button { width: 100%; padding: 0.7rem; border: none; border-radius: 10px; background: #3182ce; color: #fff; font-weight: 600; cursor: pointer; min-height: 48px; }

/* ---------- Адаптация под мобильные ---------- */
@media (max-width: 768px) {
  .menu-toggle { display: flex; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 220px; min-width: 220px; z-index: 60; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 4px 0 12px rgba(0,0,0,0.08); }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open { overflow: hidden; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 55; }
  body.menu-open .sidebar-overlay { display: block; }
  .main { padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  .header { padding: 0.6rem 1rem; }
  .header .site-title { font-size: 1.1rem; }
  .header .user { font-size: 0.8rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .device-list { grid-template-columns: 1fr; gap: 0.75rem; }
  .card-block { padding: 1rem; margin-bottom: 1rem; }
  .add-device-form { flex-direction: column; }
  .add-device-form input[name="device_id"], .add-device-form input[name="device_name"] { width: 100%; }
  .api-key-box { flex-direction: column; align-items: stretch; }
  .api-key-value { min-width: 0; }
  .devices-manage-item { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .dm-name { min-width: 0; }
  .devices-manage-item .btn { align-self: flex-start; }
  .modal { width: 100%; max-width: calc(100vw - 2rem); margin: 1rem; }
  .modal-overlay { padding: 1rem; align-items: flex-start; padding-top: 2rem; }
  .toast { max-width: calc(100vw - 2rem); bottom: max(1rem, env(safe-area-inset-bottom)); }
  .slider-row input[type="range"] { min-height: 44px; }
  .toggle { width: 44px; height: 26px; }
  .toggle-slider::before { width: 20px; height: 20px; left: 2px; bottom: 3px; }
  .toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
}
