body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111827;
  color: #e5e7eb;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header-left .title {
  font-size: 1.4rem;
  font-weight: 600;
}

.header-left .subtitle {
  font-size: 0.9rem;
  color: #9ca3af;
}

.header-center {
  font-family: monospace;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #1f2937;
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #4b5563;
}

.status-dot.online {
  background: #22c55e;
}

.settings-btn {
  background: #1f2937;
  border: none;
  color: #e5e7eb;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

/* SIDEBAR */

.sidebar {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  height: 100vh;
  background: #020617;
  box-shadow: -4px 0 16px rgba(0,0,0,0.6);
  transition: right 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar.open {
  right: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #1f2937;
}

.sidebar-close {
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 1rem;
  cursor: pointer;
}

.sidebar-content {
  padding: 12px 16px 24px;
  overflow-y: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.field label {
  font-size: 0.8rem;
  color: #9ca3af;
}

.field input {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.connect-btn {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background: #22c55e;
  color: #020617;
  font-weight: 600;
  cursor: pointer;
}

.connect-btn.disconnect {
  background: #ef4444;
  color: #f9fafb;
}

/* MAIN LAYOUT */

.content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  background: #020617;
  border-radius: 10px;
  padding: 10px 12px 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.card-icon {
  font-size: 1.1rem;
}

.card-body {
  font-size: 0.85rem;
}

/* GAUGE */

.gauge-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
}

.gauge {
  width: 120px;
  height: 120px;
}

.gauge-bg {
  fill: none;
  stroke: #1f2937;
  stroke-width: 8;
}

.gauge-needle {
  stroke: #f97316;
  stroke-width: 2.5;
  stroke-linecap: round;
  transform-origin: 50px 50px;
  transform: rotate(-120deg);
  transition: transform 0.2s ease-out;
}

.gauge-center {
  fill: #e5e7eb;
}

.current-info .value-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.value-main {
  font-size: 1.6rem;
  font-weight: 600;
}

.value-unit {
  font-size: 0.9rem;
  color: #9ca3af;
}

.value-sub {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* HEAT STATUS */

.heat-status-block {
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  background: #020617;
  border: 1px solid #1f2937;
}

.heat-status-block.heat-active {
  border-color: #f97316;
  box-shadow: 0 0 0 1px rgba(249,115,22,0.4);
}

.heat-status-main {
  font-weight: 600;
  margin-bottom: 4px;
}

.heat-status-sub {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #9ca3af;
}

.heat-status-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-top: 4px;
}

.heat-status-error {
  margin-top: 4px;
  font-size: 0.8rem;
  color: #f97316;
}

.heat-status-warning {
  margin-top: 4px;
  font-size: 0.8rem;
  color: #facc15;
}

.heat-reset-btn {
  margin-top: 6px;
  width: 100%;
  padding: 6px;
  border-radius: 6px;
  border: none;
  background: #f97316;
  color: #020617;
  font-size: 0.8rem;
  cursor: pointer;
}

/* CONTROLS */

.control-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.control-label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: #9ca3af;
}

.control-inputs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.control-inputs-wide {
  flex-direction: column;
}

.number-input {
  width: 100%;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
}

/* SHELLY */

.shelly-state {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shelly-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #4b5563;
}

.shelly-dot.on {
  background: #22c55e;
}

/* BADGES */

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
}

.badge.red {
  background: #7f1d1d;
  color: #fecaca;
}

/* DIAGNOSE */

.diag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 0.8rem;
}

.diag-row {
  display: flex;
  justify-content: space-between;
}

.diag-label {
  color: #9ca3af;
}

.diag-value {
  font-weight: 500;
}

.diag-error {
  color: #f97316;
}

/* CHART */

.chart-container {
  margin-top: 8px;
  height: 180px;
}

.chart-range-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.range-btn {
  border: none;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
  background: #111827;
  color: #e5e7eb;
  cursor: pointer;
}

.range-btn.active {
  background: #2563eb;
}

.range-dropdown {
  position: relative;
}

.range-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #020617;
  border-radius: 8px;
  border: 1px solid #1f2937;
  padding: 4px;
  display: none;
}

.range-dropdown:hover .range-dropdown-menu {
  display: block;
}
