:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #ffffff;
  color: #111111;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #ffffff;
}

button {
  font: inherit;
}

.page-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 220px;
  min-width: 220px;
  padding: 24px 16px;
  border-right: 1px solid rgba(143, 19, 41, 0.12);
  background: #ffffff;
}

.sidebar__header h1,
.panel__header h2,
.chart-card__header h3 {
  margin: 0;
}

.sidebar__header p,
.panel__header p {
  margin: 8px 0 0;
  color: #666666;
  font-size: 14px;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100vh - 132px);
  margin-top: 24px;
  overflow-y: auto;
  padding-right: 4px;
}

.device-card,
.state-card,
.metric-chip,
.range-switch,
.chart-card {
  border: 1px solid rgba(143, 19, 41, 0.14);
  border-radius: 8px;
  background: #ffffff;
}

.device-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  min-height: 84px;
  padding: 16px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.device-card:hover,
.metric-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(143, 19, 41, 0.45);
}

.device-card.is-active {
  background: #8f1329;
  border-color: #8f1329;
  box-shadow: 0 12px 26px rgba(143, 19, 41, 0.12);
  color: #ffffff;
}

.device-card.is-active .device-card__model {
  color: rgba(255, 255, 255, 0.82);
}

.device-card__id {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.device-card__model {
  font-size: 13px;
  color: #666666;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 24px;
  height: 100vh;
  overflow: hidden;
}

.panel {
  height: calc(100vh - 48px);
  padding: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(143, 19, 41, 0.12);
  box-shadow: 0 18px 40px rgba(143, 19, 41, 0.08);
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #444444;
  font-size: 13px;
}

.action-button,
.login-button {
  border: 1px solid #8f1329;
  border-radius: 8px;
  background: #8f1329;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.action-button {
  min-height: 36px;
  padding: 8px 12px;
}

.action-button:hover,
.login-button:hover {
  background: #741020;
  border-color: #741020;
}

.action-button:disabled,
.login-button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.metric-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #8f1329;
  cursor: grab;
  transition: border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
  border-color: #8f1329;
}

.metric-chip.is-active {
  background: #8f1329;
  border-color: #8f1329;
  color: #ffffff;
}

.metric-chip:not(.is-active) {
  opacity: 0.52;
}

.metric-chip.is-dragging {
  opacity: 0.28;
}

.metric-chip__handle {
  color: #8f1329;
  font-weight: 700;
}

.metric-chip.is-active .metric-chip__handle {
  color: rgba(255, 255, 255, 0.8);
}

.range-switch {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 4px;
  margin-bottom: 20px;
  user-select: none;
  touch-action: none;
}

.range-switch__thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--segment-count));
  border-radius: 6px;
  background: linear-gradient(135deg, #8f1329, #b33a53);
  transition: transform 0.16s ease;
}

.range-switch__option {
  position: relative;
  z-index: 1;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: #6b6b6b;
  cursor: pointer;
}

.range-switch__option.is-active {
  color: #ffffff;
}

.chart-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.chart-card {
  padding: 16px;
  flex: 0 0 auto;
}

.chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-card__header h3 {
  font-size: 16px;
}

.chart-canvas {
  width: 100%;
  height: 240px;
}

.chart-canvas:hover {
  cursor: ew-resize;
}

.chart-canvas:hover canvas {
  cursor: ew-resize !important;
}

.chart-zoom-controls {
  display: inline-flex;
  gap: 6px;
}

.chart-zoom-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(143, 19, 41, 0.32);
  border-radius: 6px;
  background: #ffffff;
  color: #8f1329;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.chart-zoom-button:hover,
.chart-zoom-button:focus-visible {
  border-color: #8f1329;
  background: #8f1329;
  color: #ffffff;
  outline: none;
}

.state-card {
  padding: 20px;
  color: #444444;
}

.state-card--error {
  color: #8f1329;
  border-color: rgba(143, 19, 41, 0.25);
  background: #fff2f4;
}

.login-body {
  min-height: 100vh;
  background: #f7f8fa;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  border: 1px solid rgba(143, 19, 41, 0.14);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(17, 17, 17, 0.08);
}

.login-panel__header h1,
.login-panel__header p {
  margin: 0;
}

.login-panel__header h1 {
  font-size: 28px;
}

.login-panel__header p {
  margin-top: 8px;
  color: #666666;
}

.turnstile-box {
  min-height: 72px;
}

.login-button {
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  font-weight: 700;
}

@media (max-width: 1080px) {
  .page-shell {
    flex-direction: column;
  }

  .sidebar {
    width: auto;
    min-width: 0;
    border-right: 0;
    border-bottom: 1px solid rgba(143, 19, 41, 0.12);
  }

  .device-list {
    height: auto;
    max-height: 280px;
  }

  .panel,
  .content {
    height: auto;
  }

  .panel__header {
    flex-direction: column;
  }

  .panel__actions {
    justify-content: flex-start;
  }

  .chart-stack {
    flex: 0 0 auto;
    max-height: none;
  }
}
