/* ═══════════════════════════════════════════════════════════════
   HAVRE DOMOTIQUE — Design system: Dark OLED + Plus Jakarta Sans
   Colors: #0F172A bg, #1E293B surface, #22C55E accent
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface2: #334155;
  --surface3: #272F42;
  --border: #475569;
  --border-subtle: #334155;
  --text: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --accent: #22C55E;
  --accent-dark: #16A34A;
  --accent-glow: rgba(34,197,94,0.15);
  --accent-border: rgba(34,197,94,0.3);
  --error: #EF4444;
  --error-bg: rgba(239,68,68,0.1);
  --warning: #F59E0B;
  --info: #3B82F6;
  --tuya-color: #F97316;
  --tasmota-color: #06B6D4;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-modal: 0 25px 50px rgba(0,0,0,0.6);
  --header-h: 60px;
  --tabs-h: 52px;
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface2: #F8FAFC;
  --surface3: #EFF2F7;
  --border: #CBD5E1;
  --border-subtle: #E2E8F0;
  --text: #0F172A;
  --text-muted: #475569;
  --text-dim: #94A3B8;
  --accent: #16A34A;
  --accent-dark: #15803D;
  --accent-glow: rgba(22,163,74,0.1);
  --accent-border: rgba(22,163,74,0.25);
  --error: #DC2626;
  --error-bg: rgba(220,38,38,0.08);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-modal: 0 25px 50px rgba(0,0,0,0.25);
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  font-size: 15px;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}

/* ── Header ──────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

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

.app-logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
}

.app-logo svg {
  width: 18px;
  height: 18px;
  color: #fff;
  stroke: #fff;
}

.app-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface3);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 5px 12px 5px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.btn-icon {
  width: 36px;
  height: 36px;
  background: var(--surface3);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.btn-icon.btn-danger:hover {
  background: var(--error-bg);
  border-color: rgba(239,68,68,0.3);
  color: var(--error);
}

/* ── Tabs ─────────────────────────────────────────────────────────── */
.tabs-nav {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 16px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  position: relative;
  bottom: -1px;
}

.tab-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-badge {
  background: var(--surface3);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 22px;
  text-align: center;
}

.tab-btn.active .tab-badge {
  background: var(--accent-glow);
  color: var(--accent);
}

/* ── Main Content ─────────────────────────────────────────────────── */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.btn-add {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform 0.1s;
  box-shadow: 0 2px 8px var(--accent-glow);
  white-space: nowrap;
}

.btn-add:hover { background: var(--accent-dark); box-shadow: 0 4px 12px var(--accent-glow); }
.btn-add:active { transform: scale(0.97); }
.btn-add svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2.5; }

/* ── Device Grid ──────────────────────────────────────────────────── */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.loading-state {
  grid-column: 1/-1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 64px 0;
  color: var(--text-muted);
}

.empty-state {
  grid-column: 1/-1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 0;
  color: var(--text-dim);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-muted); }
.empty-state p { font-size: 14px; }

/* ── Device Card ──────────────────────────────────────────────────── */
.device-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.device-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
  transform: translateY(-1px);
}

.device-card.disabled { opacity: 0.55; }

.card-header {
  padding: 16px 16px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-icon-name {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.device-type-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.device-type-badge.tuya {
  background: rgba(249,115,22,0.15);
  color: var(--tuya-color);
}

.device-type-badge.tasmota {
  background: rgba(6,182,212,0.15);
  color: var(--tasmota-color);
}

.device-type-badge svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

.card-name-info { flex: 1; min-width: 0; }

.card-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  transition: background 0.3s, box-shadow 0.3s;
}
.status-dot.on {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.7);
}
.status-dot.off {
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239,68,68,0.4);
}
.status-dot.unknown {
  background: var(--text-muted);
  animation: dot-pulse 1.8s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 0.9; }
}

.card-function {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.card-action-btn {
  width: 30px;
  height: 30px;
  background: var(--surface3);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.card-action-btn:hover { background: var(--surface2); color: var(--text); }
.card-action-btn.delete:hover { background: var(--error-bg); color: var(--error); border-color: rgba(239,68,68,0.3); }
.card-action-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }

/* Card body */
.card-body { padding: 14px 16px; flex: 1; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.meta-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface3);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.meta-chip.tuya { color: var(--tuya-color); background: rgba(249,115,22,0.1); }
.meta-chip.tasmota { color: var(--tasmota-color); background: rgba(6,182,212,0.1); }

/* Schedule info */
.schedule-info {
  background: var(--surface3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.schedule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.schedule-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.schedule-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.schedule-days {
  display: flex;
  gap: 3px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.day-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-dim);
  text-transform: uppercase;
}

.day-pill.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.no-schedule {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

/* Card footer */
.card-footer {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.control-btns {
  display: flex;
  gap: 6px;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--surface3);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.ctrl-btn:hover { background: var(--surface2); color: var(--text); }
.ctrl-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.5; }

.ctrl-btn.on:hover { background: rgba(34,197,94,0.15); color: var(--accent); border-color: var(--accent-border); }
.ctrl-btn.off:hover { background: var(--error-bg); color: var(--error); border-color: rgba(239,68,68,0.3); }
.ctrl-btn.status:hover { background: rgba(99,102,241,0.12); color: #6366f1; border-color: rgba(99,102,241,0.3); }

/* Toggle switch */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-label-text {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-switch input:focus + .toggle-slider { box-shadow: 0 0 0 3px var(--accent-glow); }

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.status-dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.status-dot.off { background: var(--error); }
.status-dot.unknown { background: var(--text-dim); }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  transform: translateY(24px);
  transition: transform 0.25s ease;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-lg);
    max-height: 88dvh;
  }
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: var(--surface3);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.5; }

.modal-body { padding: 20px; }

/* Form inside modal */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="time"],
.form-group select {
  background: var(--surface3);
  border: 1.5px solid var(--border-subtle);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394A3B8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-divider::before, .section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Days grid */
.days-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.day-check {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.day-check input[type="checkbox"] { display: none; }

.day-check span {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1.5px solid var(--border-subtle);
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}

.day-check input:checked + span {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* Radio group */
.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
}

.radio-item input[type="radio"] { accent-color: var(--accent); cursor: pointer; }

/* Toggle row in form */
.toggle-row .toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.toggle-row .toggle-label span { color: var(--text); }

/* Modal actions */
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.btn-cancel {
  background: var(--surface3);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-cancel:hover { background: var(--surface2); color: var(--text); }

.btn-save {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  padding: 10px 20px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-save:hover { background: var(--accent-dark); }
.btn-save svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2; }

.btn-delete {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--error);
  border: none;
  border-radius: 9px;
  padding: 10px 20px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-delete:hover { background: #DC2626; }
.btn-delete svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2; }

.confirm-text { font-size: 14px; line-height: 1.6; color: var(--text-muted); margin-bottom: 8px; }
.confirm-text strong { color: var(--text); }

/* ── Toast ────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  width: calc(100% - 32px);
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--info); }
.toast-icon { font-size: 16px; flex-shrink: 0; }

/* ── Spinner ──────────────────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app-title { font-size: 15px; }
  .user-badge { display: none; }
  .section-title { font-size: 17px; }
  .main-content { padding: 16px 12px 32px; }
  .devices-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn-cancel,
  .modal-actions .btn-save,
  .modal-actions .btn-delete { width: 100%; justify-content: center; }
  .days-grid { gap: 4px; }
  .day-check span { width: 34px; height: 34px; font-size: 10px; }
}

@media (max-width: 380px) {
  .tab-btn { font-size: 12px; padding: 12px 10px; }
  .tab-badge { display: none; }
}

/* ── Scenarios ─────────────────────────────────────────────────── */
.devices-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}

.device-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface2);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
  border: 1px solid transparent;
  user-select: none;
}

.device-check-item:not(.discover-sub):hover {
  background: var(--surface3);
  border-color: var(--border);
}

.device-check-item:not(.discover-sub):active {
  opacity: 0.75;
}

.device-check-item.discover-sub {
  opacity: 0.6;
  cursor: default;
}

.device-check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.scenario-device-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.scenario-device-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.scenario-schedule-info {
  padding: 4px 16px 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn.activate:hover  { background: rgba(34,197,94,0.15); color: var(--accent); border-color: var(--accent-border); }
.ctrl-btn.deactivate:hover { background: var(--error-bg); color: var(--error); border-color: rgba(239,68,68,0.3); }

/* ── Schedule Slots (device modal) ───────────────────────────────── */
.schedule-slots-list {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
}

.schedule-slot {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.slot-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.slot-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.slot-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color var(--transition), background var(--transition);
}

.slot-delete-btn:hover { color: var(--error); background: var(--error-bg); }

.btn-add-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 16px;
  font-family: inherit;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.btn-add-slot:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: rgba(34,197,94,0.05);
}

.no-schedule-msg {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 10px 0 4px;
  margin: 0;
}

/* Multi-slot card display */
.schedule-slot-row { padding-top: 5px; }
.schedule-slot-row + .schedule-slot-row { border-top: 1px solid var(--border); margin-top: 5px; }
.schedule-slot-row .schedule-days { margin-top: 4px; }

.action-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
}
.action-badge.on  { background: var(--accent-glow); color: var(--accent); }
.action-badge.off { background: rgba(239,68,68,0.12); color: var(--error); }

/* Slot form: label + toggle header, time input below */
.slot-time-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.action-toggle-group { display: flex; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.action-toggle-btn { padding: 3px 10px; font-size: 11px; font-weight: 700; border: none; cursor: pointer; background: var(--surface); color: var(--text-muted); font-family: inherit; transition: background var(--transition), color var(--transition); }
.action-toggle-btn.on.active  { background: var(--accent-glow); color: var(--accent); }
.action-toggle-btn.off.active { background: rgba(239,68,68,0.12); color: var(--error); }
.action-toggle-btn:not(.active):hover { background: var(--surface2); }

/* Slot time type selector (Fixe / Lever / Coucher) */
.slot-timetype-group { display: flex; gap: 4px; margin: 6px 0 8px; }
.slot-timetype-btn { flex: 1; padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; background: transparent; color: var(--text-muted); font-size: 11px; font-family: inherit; cursor: pointer; transition: background var(--transition), color var(--transition), border-color var(--transition); }
.slot-timetype-btn.active { background: var(--accent-glow); color: var(--accent); border-color: var(--accent-border); font-weight: 600; }
.slot-timetype-btn:not(.active):hover { background: var(--surface2); color: var(--text); }
.slot-sun-time { font-size: 1.5rem; font-weight: 700; color: var(--accent); text-align: center; padding: 6px 0 2px; letter-spacing: 0.02em; }

/* ── Activity Log ──────────────────────────────────────────────────────────── */
.activity-filters { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.activity-filters select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 0.85rem; font-family: inherit; cursor: pointer; }
.activity-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.activity-table th { text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.activity-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); color: var(--text); vertical-align: middle; }
.activity-table tr:hover td { background: var(--surface2); }
.activity-datetime { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity-duration { color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.activity-duration.duration-was-on  { color: #22c55e; }
.activity-duration.duration-was-off { color: #ef4444; }
.state-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; }
.state-badge.on  { background: var(--accent-glow); color: var(--accent); }
.state-badge.off { background: rgba(239,68,68,0.12); color: var(--error, #ef4444); }
.activity-empty { text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 0.9rem; }

/* ── Thermor Cozytouch ─────────────────────────────────────────────── */
:root { --thermor-color: #EF4444; }

.device-type-badge.thermor { background: rgba(239,68,68,0.15); color: var(--thermor-color); }
.meta-chip.thermor { color: var(--thermor-color); background: rgba(239,68,68,0.1); }

/* Status dot modes radiateur */
.status-dot.comfort       { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.7); }
.status-dot.eco           { background: #eab308; box-shadow: 0 0 6px rgba(234,179,8,0.5); }
.status-dot.frostprotection { background: #3b82f6; box-shadow: 0 0 6px rgba(59,130,246,0.6); }

/* Action badges modes */
.action-badge.comfort         { background: rgba(34,197,94,0.15);  color: #22c55e; }
.action-badge.eco             { background: rgba(234,179,8,0.15);   color: #eab308; }
.action-badge.frostprotection { background: rgba(59,130,246,0.15); color: #3b82f6; }
.action-badge.off             { background: rgba(107,114,128,0.12); color: #6b7280; }

/* Action toggle — modes radiateur (4 boutons) */
.radiator-mode-toggle { display: flex; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); width: 100%; }
.radiator-mode-toggle .action-toggle-btn { flex: 1; padding: 4px 4px; font-size: 10px; }
.action-toggle-btn.comfort.active         { background: rgba(34,197,94,0.15);  color: #22c55e; }
.action-toggle-btn.eco.active             { background: rgba(234,179,8,0.15);  color: #eab308; }
.action-toggle-btn.frostprotection.active { background: rgba(59,130,246,0.15); color: #3b82f6; }
.radiator-mode-toggle .action-toggle-btn.off.active { background: rgba(107,114,128,0.12);color: #6b7280; }

/* Boutons de contrôle mode */
.ctrl-btn.comfort-mode:hover { background: rgba(34,197,94,0.15);  color: #22c55e; border-color: rgba(34,197,94,0.3); }
.ctrl-btn.eco-mode:hover     { background: rgba(234,179,8,0.15);  color: #eab308; border-color: rgba(234,179,8,0.3); }
.ctrl-btn.frost-mode:hover   { background: rgba(59,130,246,0.15); color: #3b82f6; border-color: rgba(59,130,246,0.3); }
.ctrl-btn.off-mode:hover     { background: rgba(107,114,128,0.12);color: #6b7280; border-color: rgba(107,114,128,0.3); }

/* Consignes de température (confort / éco) */
.meta-chip.consigne-comfort { background: rgba(34,197,94,0.1);  color: #22c55e; border-color: rgba(34,197,94,0.2); }
.meta-chip.consigne-eco     { background: rgba(234,179,8,0.1);  color: #ca8a04; border-color: rgba(234,179,8,0.2); }

/* Capteurs secondaires radiateur (#2 temp · #3 contact · #4 occupation · #5 conso) */
.sensor-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 2px; }
.sensor-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 10px; font-size: 11px; line-height: 1.6;
  background: var(--surface2); color: var(--text-muted);
  border: 1px solid var(--border); white-space: nowrap;
}

/* Stepper de consigne de température */
.temp-stepper {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 6px 12px 2px;
  border-top: 1px solid var(--border-subtle);
}
.temp-stepper-label {
  font-size: 11px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; flex: 1;
}
.temp-step-btn {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 18px; font-weight: 400; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.temp-step-btn:hover:not(:disabled) { background: var(--thermor-color); color: #fff; border-color: var(--thermor-color); }
.temp-step-btn:disabled { opacity: 0.35; cursor: default; }
.temp-step-val {
  min-width: 58px; text-align: center;
  font-size: 20px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -0.5px;
}
