.hmh-dashboard {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  margin-top: 20px;
  font-family: Georgia, 'Times New Roman', serif;
}

.hmh-auth-shell {
  max-width: 480px;
  margin: 32px auto;
  font-family: Georgia, 'Times New Roman', serif;
}

.hmh-auth-card,
.hmh-auth-topbar,
.hmh-auth-inline-message {
  border: 1px solid #d6d3d1;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffdf8, #f7f2e8);
  box-shadow: 0 14px 30px rgba(41, 37, 36, 0.08);
}

.hmh-auth-card {
  padding: 24px;
}

.hmh-auth-kicker {
  margin: 0 0 8px;
  color: #0f766e;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hmh-auth-title {
  margin: 0 0 10px;
}

.hmh-auth-copy {
  margin: 0 0 18px;
  color: #57534e;
}

.hmh-auth-form {
  display: grid;
  gap: 14px;
}

.hmh-auth-label {
  display: grid;
  gap: 6px;
  color: #44403c;
  font-size: 14px;
}

.hmh-auth-label input {
  width: 100%;
  border: 1px solid #d6d3d1;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
}

.hmh-auth-message,
.hmh-auth-inline-message {
  margin-bottom: 14px;
  padding: 12px 14px;
  color: #44403c;
}

.hmh-auth-message-success,
.hmh-auth-inline-message-success {
  border-left: 4px solid #16a34a;
}

.hmh-auth-message-error,
.hmh-auth-inline-message-error {
  border-left: 4px solid #dc2626;
}

.hmh-auth-message-warning {
  border-left: 4px solid #d97706;
}

.hmh-public-shell {
  display: grid;
  gap: 16px;
}

.hmh-auth-topbar {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.hmh-auth-topbar span {
  display: block;
  color: #6b7280;
  font-size: 12px;
}

.hmh-sidebar,
.hmh-card,
.hmh-gateway-item,
.hmh-device-card {
  border: 1px solid #d6d3d1;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffdf8, #f7f2e8);
  box-shadow: 0 14px 30px rgba(41, 37, 36, 0.08);
}

.hmh-sidebar {
  padding: 18px;
  align-self: start;
  position: sticky;
  top: 24px;
}

.hmh-sidebar-head h2,
.hmh-card-head h2,
.hmh-card-head h3 {
  margin: 0;
}

.hmh-sidebar-head p,
.hmh-subtle {
  color: #6b7280;
  margin: 6px 0 0;
}

.hmh-gateway-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.hmh-gateway-list-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 2px;
}
.hmh-gateway-sort-label {
  display: grid;
  gap: 4px;
  color: #57534e;
  font-size: 12px;
  font-weight: 700;
}
.hmh-gateway-sort-label select {
  min-width: 140px;
  border: 1px solid #d6d3d1;
  border-radius: 10px;
  padding: 8px 10px;
  background: #ffffff;
  color: #292524;
}

.hmh-gateway-item {
  padding: 14px;
  display: grid;
  gap: 6px;
  text-align: left;
  cursor: pointer;
}

.hmh-gateway-item.is-selected {
  border-color: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.hmh-main,
.hmh-summary,
.hmh-metrics,
.hmh-recent,
.hmh-toolbar {
  display: grid;
  gap: 18px;
}

.hmh-card {
  padding: 18px;
}

.hmh-metric-card {
  cursor: zoom-in;
}

.hmh-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.hmh-card-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hmh-device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.hmh-device-card {
  padding: 14px;
}

.hmh-device-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.hmh-device-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.hmh-device-state {
  display: inline-block;
  margin: 10px 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.hmh-device-state.is-enabled {
  background: #dcfce7;
  color: #166534;
}

.hmh-device-state.is-disabled {
  background: #fee2e2;
  color: #991b1b;
}

.hmh-device-meta,
.hmh-latest-row span,
.hmh-gateway-item span {
  color: #57534e;
  font-size: 13px;
}

.hmh-device-countdown {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 118, 110, 0.08);
  color: #115e59;
  font-size: 12px;
  font-weight: 700;
}

.hmh-latest-block {
  margin-top: 18px;
}

.hmh-latest-row {
  padding: 8px 0;
  border-top: 1px solid #e7e5e4;
  display: grid;
  gap: 4px;
}

.hmh-metrics {
  grid-template-columns: 1fr;
}

.hmh-device-metric-group {
  display: grid;
  gap: 16px;
}

.hmh-device-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.hmh-chart {
  width: 100%;
  height: 240px;
  display: block;
  background: linear-gradient(180deg, rgba(255,255,255,0.85), rgba(241,245,249,0.75));
  border-radius: 12px;
}

.hmh-sleep-stage-segment {
  stroke-width: 2.2;
  stroke-linecap: round;
}

.hmh-sleep-stage-transition {
  stroke: rgba(71, 85, 105, 0.8);
  stroke-width: 0.8;
}

.hmh-sleep-breakdown-bar {
  display: flex;
  overflow: hidden;
  height: 18px;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.9);
  margin-bottom: 14px;
}

.hmh-sleep-breakdown-segment {
  display: block;
  height: 100%;
}

.hmh-sleep-stage-note {
  margin-top: 12px;
  color: #6b7280;
  font-size: 12px;
}

body.hmh-zoom-open {
  overflow: hidden;
}

.hmh-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
}

.hmh-zoom-overlay.is-open {
  display: block;
}

.hmh-zoom-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}

.hmh-zoom-dialog {
  position: absolute;
  inset: 20px;
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hmh-zoom-close {
  align-self: flex-end;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  font-size: 14px;
  cursor: pointer;
}

.hmh-zoom-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.hmh-zoom-content .hmh-metric-card-expanded {
  min-height: 100%;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}

.hmh-zoom-content .hmh-metric-card-expanded .hmh-chart {
  height: min(72vh, 760px);
}

.hmh-axis-line {
  stroke: #78716c;
  stroke-width: 0.7;
}

.hmh-grid-line {
  stroke: rgba(148, 163, 184, 0.4);
  stroke-width: 0.35;
}

.hmh-grid-line-vertical {
  stroke-dasharray: 1.2 1.2;
}

.hmh-axis-text {
  fill: #6b7280;
  font-size: 2.6px;
}

.hmh-chart-point {
  opacity: 0.9;
  cursor: pointer;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 0.45;
  transition: r 120ms ease, opacity 120ms ease;
}

.hmh-chart-point:hover,
.hmh-chart-point:focus {
  opacity: 1;
  r: 1.8;
}

.hmh-legend {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.hmh-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.hmh-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.hmh-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hmh-toolbar-group-danger {
  align-items: center;
}

.hmh-toolbar-group-system {
  align-items: center;
}

.hmh-button-danger {
  border-color: #dc2626 !important;
  color: #991b1b !important;
}

.hmh-button-danger.is-armed {
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
}

.hmh-button-warn {
  border-color: #d97706 !important;
  color: #9a3412 !important;
}

.hmh-button-warn.is-armed {
  background: #d97706 !important;
  border-color: #d97706 !important;
  color: #ffffff !important;
}

.hmh-toolbar-note {
  color: #7c2d12;
  font-size: 13px;
}

.hmh-control-note {
  display: block;
  margin-top: -6px;
}

.hmh-settings-card {
  display: grid;
  gap: 14px;
}

.hmh-interval-form {
  display: grid;
  gap: 14px;
}

.hmh-interval-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.hmh-interval-field {
  display: grid;
  gap: 6px;
  color: #44403c;
  font-size: 14px;
}

.hmh-interval-field input {
  width: 100%;
  border: 1px solid #d6d3d1;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
}

.hmh-profile-form {
  display: grid;
  gap: 14px;
}

.hmh-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.hmh-profile-field {
  display: grid;
  gap: 6px;
  color: #44403c;
  font-size: 14px;
}

.hmh-profile-field input,
.hmh-profile-field select {
  width: 100%;
  border: 1px solid #d6d3d1;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
}

.hmh-interval-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.hmh-wifi-card {
  gap: 18px;
}

.hmh-wifi-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.hmh-wifi-stat,
.hmh-wifi-list-card {
  border: 1px solid #e7e5e4;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.hmh-wifi-stat {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
}

.hmh-wifi-stat span {
  color: #6b7280;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hmh-wifi-stat strong {
  color: #292524;
  font-size: 16px;
}

.hmh-wifi-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.hmh-wifi-list-card {
  padding: 14px;
}

.hmh-wifi-list-card h4 {
  margin: 0 0 10px;
}

.hmh-wifi-table th,
.hmh-wifi-table td {
  font-size: 13px;
}

.hmh-wifi-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hmh-wifi-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  margin-right: 6px;
  border-radius: 999px;
  background: #e7e5e4;
  color: #44403c;
  font-size: 11px;
  font-weight: 700;
}

.hmh-wifi-badge.is-good {
  background: #dcfce7;
  color: #166534;
}

.hmh-wifi-checkbox {
  align-content: end;
}

.hmh-wifi-checkbox input {
  width: auto;
  margin: 0;
}

.hmh-form-status.is-error {
  color: #991b1b;
}

.hmh-form-note {
  color: #57534e;
  font-size: 13px;
}

.hmh-form-status {
  color: #0f766e;
  font-size: 13px;
  font-weight: 700;
}

.hmh-table {
  width: 100%;
  border-collapse: collapse;
}

.hmh-table th,
.hmh-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #e7e5e4;
  text-align: left;
  vertical-align: top;
}

.hmh-empty {
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  color: #64748b;
}

@media (max-width: 960px) {
  .hmh-dashboard {
    grid-template-columns: 1fr;
  }

  .hmh-sidebar {
    position: static;
  }

  .hmh-zoom-dialog {
    inset: 10px;
  }

  .hmh-zoom-content .hmh-metric-card-expanded .hmh-chart {
    height: min(62vh, 520px);
  }
}
