:root {
  --bg: #0b111e;
  --card: #131c31;
  --card-border: #1e2d4a;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #0ea5e9;
  --accent-hover: #0284c7;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top right, #16233d, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  padding: 20px;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* TOPBAR */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 16px 22px;
  border-radius: 16px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo-badge {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.1rem; letter-spacing: 1px;
}
.brand h1 { font-size: 1.35rem; line-height: 1.1; }
.subtitle { font-size: 0.78rem; color: var(--muted); }

.topbar-controls { display: flex; align-items: center; gap: 12px; }

.status-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.5px;
  background: rgba(245, 158, 11, 0.15); color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.status-badge.online {
  background: rgba(16, 185, 129, 0.15); color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}
.status-badge .dot {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor;
}

.lang-switch {
  display: flex; background: #0b111e; padding: 3px; border-radius: 10px;
  border: 1px solid var(--card-border);
}
.lang-btn {
  background: none; border: none; color: var(--muted);
  padding: 5px 10px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 0.8rem;
}
.lang-btn.active { background: var(--accent); color: #fff; }

.icon-btn {
  background: #0b111e; border: 1px solid var(--card-border);
  color: var(--text); width: 38px; height: 38px; border-radius: 10px;
  cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { border-color: var(--accent); }

/* SCENARIOS */
.scenarios-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  background: var(--card); border: 1px solid var(--card-border);
  padding: 14px 22px; border-radius: 14px;
}
.section-label { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.scenario-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.scenario-btn {
  background: #0b111e; border: 1px solid var(--card-border);
  color: var(--text); padding: 9px 16px; border-radius: 10px;
  cursor: pointer; font-weight: 600; transition: 0.2s;
}
.scenario-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

/* GRID & CARDS */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.card-header { display: flex; justify-content: space-between; align-items: center; }
.card-header h2 { font-size: 1.05rem; font-weight: 600; }

.badge-pill {
  background: rgba(14, 165, 233, 0.15);
  color: var(--accent);
  padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 700;
}
.badge-pill.secure { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-pill.unlocked { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* CLIMATE */
.climate-readout { display: flex; justify-content: space-between; align-items: center; }
.big-temp { font-size: 2.4rem; font-weight: 800; color: var(--accent); }
.sub-metrics { font-size: 0.85rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

.slider { width: 100%; accent-color: var(--accent); cursor: pointer; }

.mode-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-btn {
  background: #0b111e; border: 1px solid var(--card-border);
  color: var(--muted); padding: 8px 6px; border-radius: 8px;
  cursor: pointer; font-size: 0.78rem; font-weight: 600;
}
.mode-btn.active, .mode-btn:hover {
  border-color: var(--accent); color: var(--text);
}

/* BLINDS */
.blind-visual { display: flex; justify-content: center; }
.window-frame {
  width: 100%; height: 90px;
  background: linear-gradient(180deg, #1e3a5f 0%, #38bdf8 100%);
  border: 2px solid #334155; border-radius: 10px;
  position: relative; overflow: hidden;
  display: grid; place-items: center;
}
.blind-curtain {
  position: absolute; top: 0; left: 0; right: 0;
  background: repeating-linear-gradient(
    0deg, #1e293b, #1e293b 6px, #0f172a 7px, #0f172a 9px
  );
  transition: height 0.35s ease;
  border-bottom: 3px solid var(--accent);
}
.window-label {
  position: relative; z-index: 2;
  background: rgba(11, 17, 30, 0.7); padding: 3px 10px;
  border-radius: 6px; font-size: 0.78rem;
}

/* SECURITY */
.security-box {
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.lock-icon { font-size: 2.3rem; }
.lock-desc { font-size: 0.85rem; color: var(--muted); }
.sensors-row { display: flex; gap: 8px; justify-content: space-between; }
.sensor-chip {
  flex: 1; background: #0b111e; border: 1px solid var(--card-border);
  padding: 7px 10px; border-radius: 8px; font-size: 0.78rem; text-align: center;
}

/* ENERGY & SWITCH */
.energy-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric-box {
  background: #0b111e; border: 1px solid var(--card-border);
  padding: 12px; border-radius: 10px; display: flex; flex-direction: column; gap: 4px;
}
.metric-label { font-size: 0.75rem; color: var(--muted); }
.metric-val { font-size: 1.25rem; }
.metric-val.accent { color: var(--success); }
.dimmer-row { display: flex; flex-direction: column; gap: 8px; font-size: 0.85rem; color: var(--muted); }

.switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: #334155; transition: .3s; border-radius: 24px;
}
.switch-slider:before {
  position: absolute; content: ""; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%;
}
input:checked + .switch-slider { background-color: var(--accent); }
input:checked + .switch-slider:before { transform: translateX(22px); }

/* BUTTONS */
.primary-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 18px; border-radius: 10px; font-weight: 700; cursor: pointer; width: 100%;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn.danger { background: var(--danger); }
.text-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.82rem; }
.text-btn:hover { color: var(--text); }

/* LOG */
.log-list {
  list-style: none; max-height: 150px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem;
}
.log-list li {
  background: #0b111e; padding: 8px 12px; border-radius: 8px;
  border-left: 3px solid var(--accent); color: #cbd5e1;
}

/* MODALS */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72);
  display: grid; place-items: center; z-index: 100; padding: 16px;
}
.modal.hidden, .hidden { display: none !important; }
.modal-content {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 24px; width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 16px;
}
.modal-content.small { max-width: 340px; text-align: center; }
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.close-modal { background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }

.form-group { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.form-group label { font-size: 0.82rem; color: var(--muted); }
.form-group input, .form-group select, .pin-input {
  background: #0b111e; border: 1px solid var(--card-border);
  color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 0.95rem;
}
.pin-input { text-align: center; font-size: 1.4rem; letter-spacing: 6px; }
.hint-text { font-size: 0.8rem; color: var(--muted); }
.error-text { font-size: 0.82rem; color: var(--danger); font-weight: 600; }
