:root {
  color-scheme: dark;
  --bg: #07131f;
  --panel: rgba(10, 20, 35, 0.95);
  --panel-2: #14253b;
  --text: #f4f7fb;
  --muted: #8da2bc;
  --accent: #67e8f9;
  --accent-2: #8b5cf6;
  --border: rgba(255, 255, 255, 0.1);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f7ead8;
  --panel: rgba(255, 250, 242, 0.98);
  --panel-2: #f1d5bc;
  --text: #19324c;
  --muted: #607477;
  --accent: #367680;
  --accent-2: #df6a35;
  --border: rgba(130, 85, 50, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  font-family: 'Inter', sans-serif;
  background: radial-gradient(circle at top left, #12304d 0%, var(--bg) 45%, #050b12 100%);
  color: var(--text);
  transition: color 180ms ease, background 180ms ease;
}

button,
input {
  font: inherit;
}

.theme-toggle {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.theme-toggle span {
  font-size: 0.9rem;
}

.theme-toggle small {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
}

.session-loading,
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
}

.session-loading {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
}

.session-loading span {
  font-size: 2rem;
  animation: login-pulse 1s ease-in-out infinite alternate;
}

.login-page {
  display: grid;
  padding: 24px;
  place-items: center;
}

.login-card {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  width: min(1040px, 100%);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: rgba(7, 17, 29, 0.94);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.42);
}

.login-visual {
  position: relative;
  min-height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(103, 232, 249, 0.16), transparent 30%),
    radial-gradient(circle at 18% 78%, rgba(139, 92, 246, 0.2), transparent 32%),
    linear-gradient(150deg, #0b2639, #06111e 62%);
}

.login-grid {
  position: absolute;
  inset: 0;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(103, 232, 249, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 232, 249, 0.12) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

.login-mark {
  position: absolute;
  top: 42%;
  left: 50%;
  display: grid;
  width: 240px;
  height: 240px;
  place-items: center;
  border: 0;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
  filter: drop-shadow(0 0 24px rgba(103, 232, 249, 0.24));
  transform: translate(-50%, -50%);
}

.login-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-orbit {
  position: absolute;
  top: 42%;
  left: 50%;
  border: 1px solid rgba(103, 232, 249, 0.22);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.orbit-one {
  width: 250px;
  height: 250px;
  animation: login-spin 18s linear infinite;
}

.orbit-two {
  width: 390px;
  height: 390px;
  border-color: rgba(167, 139, 250, 0.18);
  animation: login-spin 28s linear infinite reverse;
}

.login-node {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}

.node-one {
  top: calc(42% - 125px);
  left: 50%;
}

.node-two {
  top: 42%;
  left: calc(50% + 195px);
  background: #a78bfa;
  box-shadow: 0 0 14px #a78bfa;
}

.node-three {
  top: calc(42% + 125px);
  left: calc(50% - 20px);
}

.login-visual-copy {
  position: absolute;
  right: 36px;
  bottom: 38px;
  left: 36px;
  display: grid;
  gap: 7px;
}

.login-visual-copy span {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-visual-copy strong {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.login-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 58px;
}

.login-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 58px;
}

.login-topline .login-brand {
  margin-bottom: 0;
}

.login-topline-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.home-link {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 160ms ease;
}

.home-link:hover {
  color: var(--text);
}

.home-link span {
  color: var(--accent-2);
}

.login-brand-logo {
  display: block;
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 0 16px rgba(103, 232, 249, 0.2);
}

.login-brand div {
  display: grid;
}

.login-brand strong {
  font-size: 0.96rem;
}

.login-brand small {
  color: var(--muted);
  font-size: 0.68rem;
}

.login-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.7rem);
}

.login-heading p {
  margin: 9px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 7px;
}

.login-form label > span {
  color: #cbd5e1;
  font-size: 0.76rem;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  padding: 11px 13px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input:focus {
  border-color: rgba(103, 232, 249, 0.65);
  box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.1);
}

.login-form button {
  min-height: 48px;
  margin-top: 5px;
  border: 0;
  border-radius: 13px;
  color: #03111d;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  font-weight: 800;
  cursor: pointer;
}

.login-form button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-error {
  padding: 9px 11px;
  border: 1px solid rgba(248, 113, 113, 0.38);
  border-radius: 10px;
  color: #fecaca;
  background: rgba(248, 113, 113, 0.1);
  font-size: 0.75rem;
}

@keyframes login-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes login-pulse {
  to {
    opacity: 0.45;
    transform: scale(1.12);
  }
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  justify-content: center;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: -10px 0 18px;
}

.session-bar > .home-link {
  margin-right: auto;
}

.session-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-user > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  color: #03111d;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  font-size: 0.68rem;
  font-weight: 800;
}

.session-user div {
  display: grid;
}

.session-user strong {
  font-size: 0.76rem;
}

.session-user small {
  color: var(--muted);
  font-size: 0.62rem;
}

.session-bar button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.68rem;
  cursor: pointer;
}

:root[data-theme='light'] body {
  background:
    radial-gradient(circle at 10% 5%, rgba(227, 166, 49, 0.2), transparent 28%),
    radial-gradient(circle at 88% 16%, rgba(234, 181, 163, 0.28), transparent 31%),
    linear-gradient(145deg, #fff4e4, #f7ead8 58%, #f1dcc5);
}

:root[data-theme='light'] .login-card,
:root[data-theme='light'] .hero-card,
:root[data-theme='light'] .floorplan-card {
  background: rgba(255, 250, 242, 0.94);
  box-shadow: 0 24px 70px rgba(111, 70, 38, 0.16);
}

:root[data-theme='light'] .login-visual {
  background:
    radial-gradient(circle at 50% 42%, rgba(227, 166, 49, 0.25), transparent 30%),
    radial-gradient(circle at 18% 78%, rgba(223, 106, 53, 0.2), transparent 32%),
    linear-gradient(150deg, #f3d2ae, #fff5e5 62%);
}

:root[data-theme='light'] .login-grid {
  opacity: 0.45;
  background-image:
    linear-gradient(rgba(54, 118, 128, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(54, 118, 128, 0.14) 1px, transparent 1px);
}

:root[data-theme='light'] .login-orbit {
  border-color: rgba(54, 118, 128, 0.28);
}

:root[data-theme='light'] .orbit-two {
  border-color: rgba(223, 106, 53, 0.22);
}

:root[data-theme='light'] .login-form input {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}

:root[data-theme='light'] .theme-toggle,
:root[data-theme='light'] .session-bar button,
:root[data-theme='light'] .btn-secondary {
  background: rgba(255, 250, 242, 0.78);
}

:root[data-theme='light'] .btn-primary,
:root[data-theme='light'] .chat-toggle,
:root[data-theme='light'] .login-form button,
:root[data-theme='light'] .playback-button {
  background: linear-gradient(100deg, #e3a631, #df6a35);
}

:root[data-theme='light'] .badge {
  color: #2f6871;
  background: rgba(54, 118, 128, 0.11);
}

:root[data-theme='light'] .stat-card,
:root[data-theme='light'] .floorplan-stats div,
:root[data-theme='light'] .thermal-summary span,
:root[data-theme='light'] .cooling-readings span {
  background: rgba(255, 255, 255, 0.58);
}

:root[data-theme='light'] .floorplan-view-controls button {
  background: rgba(255, 255, 255, 0.62);
}

:root[data-theme='light'] .preview-panel {
  background: linear-gradient(145deg, rgba(242, 204, 163, 0.78), rgba(234, 181, 163, 0.5));
}

:root[data-theme='light'] .preview-item {
  background: rgba(255, 250, 242, 0.66);
  color: var(--text);
  border-color: rgba(130, 85, 50, 0.14);
}

:root[data-theme='light'] .thermal-panel {
  background:
    linear-gradient(90deg, rgba(54, 118, 128, 0.06), transparent 45%),
    rgba(255, 247, 235, 0.78);
}

:root[data-theme='light'] .heatmap-toggle,
:root[data-theme='light'] .metric-switch,
:root[data-theme='light'] .timeline-player,
:root[data-theme='light'] .timeline-navigation,
:root[data-theme='light'] .floorplan-toolbar,
:root[data-theme='light'] .loop-badge {
  background: rgba(255, 255, 255, 0.5);
}

:root[data-theme='light'] .zoom-controls,
:root[data-theme='light'] .pan-controls {
  background: rgba(255, 250, 242, 0.82);
}

:root[data-theme='light'] .metric-switch input:checked + span {
  color: #214f56;
  background: rgba(54, 118, 128, 0.14);
}

:root[data-theme='light'] .cooling-status {
  background: linear-gradient(
    90deg,
    rgba(54, 118, 128, 0.1),
    rgba(223, 106, 53, 0.07)
  );
}

:root[data-theme='light'] .canvas-shell {
  background:
    linear-gradient(rgba(54, 118, 128, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(54, 118, 128, 0.07) 1px, transparent 1px),
    #f3e5d2;
  background-size: 24px 24px;
}

:root[data-theme='light'] .chat-drawer {
  background: rgba(255, 250, 242, 0.98);
  box-shadow: -20px 0 45px rgba(111, 70, 38, 0.18);
}

:root[data-theme='light'] .message.bot {
  color: var(--text);
  background: rgba(54, 118, 128, 0.1);
}

:root[data-theme='light'] .message.user {
  background: linear-gradient(90deg, #367680, #4d8586);
}

:root[data-theme='light'] .chat-form input {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}

:root[data-theme='light'] .rack-inspector {
  border-color: rgba(54, 118, 128, 0.38);
  background: rgba(255, 250, 242, 0.96);
  box-shadow: 0 12px 30px rgba(111, 70, 38, 0.18);
}

:root[data-theme='light'] .rack-inspector strong {
  color: #2f6871;
}

:root[data-theme='light'] .rack-inspector .cooling-connection {
  color: #2f6871;
  background: rgba(54, 118, 128, 0.1);
}

:root[data-theme='light'] .rack-inspector .cooling-connection.uncooled {
  color: #805533;
  background: rgba(223, 106, 53, 0.1);
}

:root[data-theme='light'] .rack-inspector .selected-loop-label {
  color: #805008;
  background: rgba(214, 148, 24, 0.15);
}

:root[data-theme='light'] .rack-operational-readings strong {
  color: #9a3412;
}

:root[data-theme='light'] .sensor-layer-selector label:has(input:checked) {
  border-color: rgba(54, 118, 128, 0.5);
  background: rgba(54, 118, 128, 0.1);
}

:root[data-theme='light'] .placement-status,
:root[data-theme='light'] .leak-status:not(.alarm) {
  color: #356442;
}

:root[data-theme='light'] .leak-status.alarm {
  color: #9b3027;
}

.hero-card {
  width: min(1120px, 100%);
  border: 1px solid var(--border);
  background: rgba(8, 16, 28, 0.82);
  backdrop-filter: blur(16px);
  border-radius: 28px;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.hero-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(103, 232, 249, 0.12);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.badge img {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  object-fit: contain;
  filter: drop-shadow(0 0 5px rgba(103, 232, 249, 0.32));
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.05;
  margin: 14px 0 12px;
}

.hero-title span {
  color: var(--accent);
}

.hero-copy {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 640px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.btn {
  min-height: 44px;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #03111d;
  font-weight: 700;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border: 1px solid var(--border);
}

.stats {
  display: grid;
  gap: 12px;
  margin-top: 26px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.stat-card strong {
  display: block;
  font-size: 1.2rem;
  color: var(--text);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-panel {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(20, 37, 59, 0.96), rgba(7, 19, 31, 0.96));
  border: 1px solid var(--border);
}

.preview-panel h3 {
  margin: 0 0 8px;
}

.preview-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.preview-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.preview-item {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.floorplan-card {
  width: min(1120px, 100%);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(8, 16, 28, 0.88);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

body.floorplan-focus-open {
  overflow: hidden;
}

.floorplan-card.focused {
  position: fixed;
  z-index: 1000;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
}

.popout-shell {
  min-height: 100vh;
}

.floorplan-card.popped-out {
  width: 100%;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.floorplan-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px 20px;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.floorplan-header h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.floorplan-header p {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.floorplan-header code {
  color: #c4b5fd;
}

.floorplan-header-actions {
  display: grid;
  flex: 0 0 auto;
  gap: 9px;
}

.floorplan-view-controls {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.floorplan-view-controls button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
}

.floorplan-view-controls button:hover,
.floorplan-view-controls button:focus-visible,
.floorplan-view-controls button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(103, 232, 249, 0.1);
  outline: none;
}

.floorplan-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  flex: 0 0 auto;
  gap: 8px;
}

.floorplan-stats div {
  min-width: 76px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.floorplan-stats strong,
.floorplan-stats span {
  display: block;
}

.floorplan-stats strong {
  font-size: 1rem;
}

.floorplan-stats span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.thermal-panel {
  display: grid;
  gap: 10px;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--border);
  background:
    linear-gradient(90deg, rgba(103, 232, 249, 0.035), transparent 45%),
    rgba(3, 11, 20, 0.7);
}

.thermal-controls {
  display: grid;
  grid-template-columns: auto auto minmax(240px, 1fr);
  align-items: center;
  gap: 8px;
  order: 1;
}

.facility-equipment-selector {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: 12px;
  background: rgba(96, 165, 250, 0.045);
  order: 3;
}

.facility-equipment-selector legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.facility-equipment-selector::before {
  content: 'Roof plant';
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 750;
  white-space: nowrap;
}

.facility-equipment-count {
  color: var(--muted);
  font-size: 0.66rem;
  white-space: nowrap;
}

.facility-equipment-selector > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.facility-equipment-selector .facility-equipment-banks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.facility-equipment-bank {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.facility-equipment-bank > strong {
  color: #93c5fd;
  font-size: 0.61rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.facility-equipment-bank > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.facility-equipment-selector label {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  font-size: 0.65rem;
}

.facility-equipment-selector label:has(input:checked) {
  border-color: rgba(96, 165, 250, 0.55);
  color: var(--text);
  background: rgba(96, 165, 250, 0.12);
}

.facility-equipment-selector input {
  margin: 0;
  accent-color: #60a5fa;
}

.facility-equipment-selector.floorplan-bottom-panel {
  margin: 0 18px 16px;
  padding: 10px 12px;
  order: initial;
}

.sensor-layer-selector.floorplan-bottom-panel {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  margin: 12px 18px 8px;
  padding: 9px 12px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.sensor-layer-selector legend {
  padding: 0 6px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 750;
}

.sensor-layer-total {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.66rem;
}

.sensor-layer-selector > div {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.sensor-layer-selector label {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  font-size: 0.64rem;
}

.sensor-layer-selector label:has(input:checked) {
  border-color: rgba(52, 211, 153, 0.48);
  color: var(--text);
  background: rgba(52, 211, 153, 0.1);
}

.sensor-layer-selector input {
  margin: 0;
  accent-color: #34d399;
}

.sensor-layer-selector small {
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.56rem;
}

.heatmap-toggle,
.playback-button {
  min-height: 40px;
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.heatmap-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 700;
}

.heatmap-toggle small {
  padding: 2px 5px;
  border-radius: 5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.62rem;
  text-transform: uppercase;
}

.heatmap-toggle.active {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.12);
}

.heatmap-toggle.active small {
  color: #a7f3d0;
  background: rgba(52, 211, 153, 0.13);
}

.toggle-indicator {
  position: relative;
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 160ms ease;
}

.toggle-indicator::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #dbeafe;
  content: '';
  transition: transform 160ms ease;
}

.heatmap-toggle.active .toggle-indicator {
  background: #34d399;
}

.heatmap-toggle.active .toggle-indicator::after {
  transform: translateX(13px);
}

.metric-switch {
  display: inline-flex;
  min-width: 0;
  min-inline-size: 0;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.metric-switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.metric-switch label {
  position: relative;
  display: flex;
  min-height: 32px;
  align-items: center;
  border-radius: 9px;
  cursor: pointer;
}

.metric-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.metric-switch label span {
  display: flex;
  min-height: 32px;
  align-items: center;
  padding: 6px 11px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.metric-switch label i {
  margin-right: 5px;
  color: var(--accent);
  font-style: normal;
}

.metric-switch input:checked + span {
  color: var(--text);
  background: rgba(103, 232, 249, 0.15);
}

.metric-switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.thermal-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 1fr));
  justify-self: end;
  gap: 6px;
  width: min(100%, 270px);
  color: var(--muted);
}

.thermal-summary span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
}

.thermal-summary small {
  color: var(--muted);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.thermal-summary strong {
  color: var(--text);
  font-size: 0.8rem;
}

.temperature-legend {
  display: grid;
  gap: 5px;
  transition: opacity 160ms ease;
  order: 2;
}

.temperature-legend.muted {
  opacity: 0.4;
}

.temperature-gradient {
  height: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    hsl(220 88% 52%),
    hsl(180 88% 48%),
    hsl(110 82% 48%),
    hsl(55 92% 53%),
    hsl(0 88% 54%)
  );
}

.temperature-ticks,
.timeline-bounds,
.timeline-current {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.temperature-ticks {
  color: var(--muted);
  font-size: 0.68rem;
}

.timeline-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  transition: opacity 160ms ease;
  order: 4;
}

.timeline-player.disabled .playback-button,
.timeline-player.disabled .timeline-track,
.timeline-player.disabled .loop-badge {
  opacity: 0.48;
}

.playback-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  color: #03111d;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  font-weight: 800;
}

.playback-button:disabled,
.timeline-player input:disabled {
  cursor: not-allowed;
}

.timeline-track {
  display: grid;
  flex: 1;
  gap: 3px;
  min-width: 0;
}

.timeline-current {
  align-items: baseline;
  color: var(--muted);
  font-size: 0.75rem;
}

.timeline-current strong {
  color: var(--accent);
}

.timeline-track input {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: ew-resize;
}

.timeline-bounds {
  color: var(--muted);
  font-size: 0.66rem;
}

.loop-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.7rem;
}

.cooling-status {
  display: grid;
  grid-template-columns: auto auto minmax(330px, 1fr) 124px;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    rgba(34, 211, 238, 0.07),
    rgba(251, 113, 133, 0.035)
  );
  order: 3;
}

.cooling-status.alarm {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(127, 29, 29, 0.14);
}

.cooling-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cooling-title > span:last-child {
  display: grid;
  gap: 1px;
}

.cooling-title strong {
  font-size: 0.75rem;
  white-space: nowrap;
}

.cooling-title small {
  color: var(--muted);
  font-size: 0.62rem;
}

.cooling-icon {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.75);
}

.pipe-legend {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 0.65rem;
}

.pipe-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pipe-swatch {
  width: 16px;
  height: 3px;
  border-radius: 999px;
}

.pipe-swatch.supply {
  background: #22d3ee;
  box-shadow: 0 0 7px rgba(34, 211, 238, 0.7);
}

.pipe-swatch.return {
  background: #fb7185;
  box-shadow: 0 0 7px rgba(251, 113, 133, 0.6);
}

.cooling-readings {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 5px;
}

.cooling-readings span {
  display: grid;
  gap: 1px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.cooling-readings small {
  color: var(--muted);
  font-size: 0.54rem;
  text-transform: uppercase;
}

.cooling-readings strong {
  font-size: 0.68rem;
  white-space: nowrap;
}

.leak-status {
  display: inline-flex;
  width: 124px;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  color: #a7f3d0;
  font-size: 0.66rem;
  font-weight: 700;
  white-space: nowrap;
}

.leak-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
}

.leak-status.alarm {
  color: #fecaca;
}

.leak-status.alarm i {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: leak-pulse 700ms ease-in-out infinite alternate;
}

@keyframes leak-pulse {
  to {
    opacity: 0.35;
    transform: scale(1.7);
  }
}

.floorplan-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 10px 28px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.analysis-overlay-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 28px 10px;
  padding: 10px 12px;
  border: 1px solid rgba(251, 191, 36, 0.42);
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.1);
}

.analysis-overlay-banner.status-unsafe {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.12);
}

.analysis-overlay-banner div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.analysis-overlay-banner span,
.analysis-overlay-banner small {
  color: var(--muted);
  font-size: 0.68rem;
}

.analysis-overlay-banner strong {
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-overlay-banner button,
.message-visualization-action {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
}

.analysis-overlay-banner button {
  padding: 7px 11px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 0.8rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.legend-swatch.server {
  background: #67e8f9;
  box-shadow: 0 0 10px rgba(103, 232, 249, 0.35);
}

.legend-swatch.network {
  background: #a78bfa;
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.35);
}

.legend-swatch.cold {
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.legend-swatch.hot {
  background: #f87171;
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.35);
}

.placement-status {
  color: #a7f3d0;
  font-size: 0.8rem;
  font-weight: 700;
}

.placement-status::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px #34d399;
  content: '';
}

.timeline-navigation {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  margin-left: 2px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.zoom-controls,
.pan-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.timeline-navigation button {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.timeline-navigation button:hover:not(:disabled) {
  color: #03111d;
  background: var(--accent);
}

.timeline-navigation button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.zoom-controls > span {
  min-width: 44px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.timeline-navigation .reset-view {
  width: auto;
  padding-inline: 9px;
  color: var(--accent);
  font-size: 0.7rem;
}

.mobile-pan-hint {
  display: none;
  color: var(--muted);
  font-size: 0.75rem;
}

.canvas-shell {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  background:
    linear-gradient(rgba(103, 232, 249, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 232, 249, 0.025) 1px, transparent 1px),
    #050c14;
  background-size: 24px 24px;
}

.canvas-shell canvas {
  display: block;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.canvas-shell canvas.dragging {
  cursor: grabbing;
}

.rack-inspector {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  gap: 3px;
  width: min(300px, calc(100% - 36px));
  min-width: 175px;
  padding: 12px 14px;
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 14px;
  background: rgba(7, 19, 31, 0.92);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.rack-operational-readings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 6px;
}

.rack-operational-readings button {
  display: grid;
  min-width: 0;
  gap: 1px;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: inherit;
  text-align: left;
  background: rgba(251, 191, 36, 0.09);
}

.rack-operational-readings button:not(:disabled) {
  cursor: pointer;
}

.rack-operational-readings button:not(:disabled):hover,
.rack-operational-readings button:not(:disabled):focus-visible {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.17);
  outline: none;
}

.rack-operational-readings button:disabled {
  opacity: 1;
}

.rack-operational-readings small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.52rem;
  text-overflow: ellipsis;
  text-transform: capitalize;
  white-space: nowrap;
}

.rack-operational-readings strong {
  display: block;
  overflow: hidden;
  color: #fde68a;
  font-size: 0.67rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rack-inspector strong {
  color: var(--accent);
  font-size: 0.88rem;
}

.rack-inspector span {
  color: var(--muted);
  font-size: 0.76rem;
}

.rack-inspector.selected {
  border-color: rgba(251, 191, 36, 0.85);
  pointer-events: auto;
}

.inspector-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.rack-inspector .cooling-connection {
  margin-top: 5px;
  padding: 5px 7px;
  border-radius: 7px;
  color: #a5f3fc;
  background: rgba(34, 211, 238, 0.1);
  font-weight: 650;
}

.rack-inspector .cooling-connection strong {
  font-size: inherit;
}

.rack-inspector .cooling-connection.uncooled {
  color: #fed7aa;
  background: rgba(251, 146, 60, 0.1);
}

.rack-inspector .intake-reading {
  margin-top: 4px;
  color: #7dd3fc;
  font-weight: 700;
}

.rack-inspector .exhaust-reading {
  color: #fca5a5;
  font-weight: 700;
}

.cdu-inspector {
  border-color: rgba(34, 211, 238, 0.45);
}

.cdu-inspector.selected {
  border-color: rgba(251, 191, 36, 0.85);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.2), 0 12px 30px rgba(0, 0, 0, 0.3);
}

.sensor-inspector {
  min-width: 220px;
  max-height: calc(100% - 36px);
  overflow-y: auto;
  border-color: rgba(52, 211, 153, 0.55);
}

.sensor-inspector.selected {
  border-color: rgba(251, 191, 36, 0.85);
  pointer-events: auto;
}

.sensor-reading-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.sensor-reading-grid button {
  display: grid;
  gap: 1px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: inherit;
  text-align: left;
  background: rgba(255, 255, 255, 0.055);
}

.sensor-reading-grid button:not(:disabled) {
  cursor: pointer;
}

.sensor-reading-grid button:not(:disabled):hover,
.sensor-reading-grid button:not(:disabled):focus-visible {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.14);
  outline: none;
}

.sensor-reading-grid button:disabled {
  opacity: 1;
}

.sensor-reading-grid span {
  text-transform: capitalize;
}

.sensor-reading-grid strong {
  font-size: 0.76rem;
}

.sensor-history-panel {
  position: absolute;
  z-index: 8;
  top: 18px;
  right: 18px;
  display: grid;
  grid-template-columns: minmax(180px, 0.78fr) minmax(250px, 1.22fr);
  align-items: start;
  gap: 12px 16px;
  width: min(520px, calc(100% - 36px));
  padding: 16px;
  border: 1px solid rgba(103, 232, 249, 0.42);
  border-radius: 18px;
  color: var(--text);
  background: rgba(7, 19, 31, 0.97);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.42);
}

.sensor-history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.sensor-history-header div {
  display: grid;
  gap: 2px;
}

.sensor-history-header span,
.sensor-history-header small {
  color: var(--muted);
  font-size: 0.72rem;
}

.sensor-history-header .playback-sync {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.12);
}

.playback-sync i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fbbf24;
}

.playback-sync.playing i {
  animation: playback-sync-pulse 850ms ease-in-out infinite alternate;
}

.sensor-history-header strong {
  color: var(--accent);
  font-size: 1.25rem;
  text-transform: capitalize;
}

.sensor-history-header button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.sensor-history-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
  padding-right: 40px;
}

.sensor-history-stats span {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
}

.sensor-history-stats small {
  color: var(--muted);
  font-size: 0.64rem;
}

.sensor-history-stats strong {
  color: var(--text);
  font-size: 0.72rem;
}

.sensor-chart {
  grid-column: 1 / -1;
  padding: 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.sensor-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.sensor-chart line {
  stroke: rgba(148, 163, 184, 0.16);
  stroke-width: 1;
}

.sensor-chart line.vertical-grid {
  stroke: rgba(148, 163, 184, 0.09);
  stroke-dasharray: 4 5;
}

.sensor-axis-label,
.sensor-axis-unit {
  fill: var(--muted);
  font-family: Inter, sans-serif;
  font-size: 12px;
}

.sensor-axis-label.y-axis {
  text-anchor: end;
}

.sensor-axis-label.x-axis {
  text-anchor: middle;
}

.sensor-axis-unit {
  fill: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.sensor-chart polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sensor-chart circle {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 2;
}

.sensor-chart line.sensor-playhead {
  stroke: #fbbf24;
  stroke-width: 3;
  stroke-dasharray: 7 5;
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.65));
}

.sensor-chart circle.sensor-playhead-point {
  fill: #fbbf24;
  stroke: #fff7d6;
  stroke-width: 4;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.8));
}

.sensor-chart circle.sensor-playhead-point.playing {
  animation: chart-playhead-pulse 700ms ease-in-out infinite alternate;
}

@keyframes playback-sync-pulse {
  to {
    opacity: 0.35;
    transform: scale(0.72);
  }
}

@keyframes chart-playhead-pulse {
  to {
    stroke-width: 8;
  }
}

.sensor-chart-range {
  padding: 2px 8px 4px;
  color: var(--muted);
  font-size: 0.65rem;
  text-align: center;
}

:root[data-theme='light'] .sensor-history-panel {
  border-color: rgba(54, 118, 128, 0.38);
  background: rgba(255, 250, 242, 0.98);
  box-shadow: 0 18px 55px rgba(111, 70, 38, 0.2);
}

:root[data-theme='light'] .sensor-chart {
  background: rgba(54, 118, 128, 0.06);
}

.rack-inspector .selected-loop-label {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.14);
  font-weight: 750;
}

.rack-inspector .sensor-normal {
  margin-top: 4px;
  color: #a7f3d0;
  font-weight: 700;
}

.rack-inspector .sensor-alarm {
  margin-top: 4px;
  color: #fecaca;
  font-weight: 800;
}

.canvas-error {
  display: grid;
  min-height: 280px;
  place-items: center;
  color: #fecaca;
}

.chat-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111e;
  font-size: 1.35rem;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: min(420px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 45px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform 220ms ease;
  z-index: 30;
}

.chat-drawer.open {
  transform: translateX(0);
}

.chat-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.chat-header span {
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-messages {
  flex: 1;
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.message {
  max-width: 85%;
  padding: 11px 12px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 0.95rem;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(90deg, var(--accent-2), #604de6);
  color: white;
}

.message.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.message.error {
  align-self: flex-start;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.message.pending {
  color: var(--muted);
}

.message-visualization-action {
  display: block;
  width: fit-content;
  margin-top: 9px;
  padding: 6px 10px;
  color: var(--accent);
  font-size: 0.72rem;
}

@media (max-width: 640px) {
  .analysis-overlay-banner {
    margin-inline: 12px;
  }

  .analysis-overlay-banner strong {
    max-width: 68vw;
  }
}

.chat-form {
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 14px;
  outline: none;
}

.chat-form button {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #04111e;
  font-weight: 700;
  cursor: pointer;
}

.chat-form button:disabled,
.chat-form input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 860px) {
  .login-card {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 220px;
  }

  .login-mark {
    top: 45%;
    width: 132px;
    height: 132px;
  }

  .login-orbit {
    top: 45%;
  }

  .orbit-one {
    width: 160px;
    height: 160px;
  }

  .orbit-two {
    width: 260px;
    height: 260px;
  }

  .node-one,
  .node-two,
  .node-three {
    display: none;
  }

  .login-visual-copy {
    right: 24px;
    bottom: 22px;
    left: 24px;
  }

  .login-visual-copy strong {
    font-size: 1.45rem;
  }

  .login-form-panel {
    padding: 34px;
  }

  .login-brand {
    margin-bottom: 28px;
  }

  .login-topline {
    margin-bottom: 28px;
  }

  .app-shell {
    gap: 18px;
    padding: 18px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }

  .hero-card {
    padding: 22px;
  }

  .floorplan-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .floorplan-header-actions {
    width: 100%;
  }

  .floorplan-view-controls {
    justify-content: flex-start;
  }

  .floorplan-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .legend {
    flex: 1 1 100%;
  }

  .thermal-summary {
    width: 100%;
  }

  .cooling-status {
    grid-template-columns: 1fr auto;
  }

  .cooling-readings {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 700px) {
  .canvas-shell {
    overflow: hidden;
  }

  .canvas-shell canvas {
    max-width: none;
    touch-action: none;
  }

  .mobile-pan-hint {
    display: inline;
  }

  .sensor-history-panel {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100% - 20px);
    padding: 13px;
    overflow-y: auto;
    grid-template-columns: 1fr;
  }

  .sensor-history-stats {
    grid-column: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-right: 0;
  }

  .sensor-chart svg {
    min-width: 420px;
  }

  .sensor-chart {
    overflow-x: auto;
  }
}

@media (max-width: 600px) {
  .login-page {
    padding: 10px;
    place-items: start center;
  }

  .login-card {
    min-height: calc(100dvh - 20px);
    border-radius: 22px;
  }

  .login-visual {
    min-height: 155px;
  }

  .login-visual-copy span {
    font-size: 0.58rem;
  }

  .login-visual-copy strong {
    font-size: 1.15rem;
  }

  .login-form-panel {
    justify-content: flex-start;
    padding: 25px 20px;
  }

  .login-brand {
    margin-bottom: 23px;
  }

  .login-topline {
    margin-bottom: 23px;
  }

  .login-heading h1 {
    font-size: 2rem;
  }

  .login-heading p {
    font-size: 0.86rem;
  }

  .app-shell {
    padding: 12px;
  }

  .hero-card {
    padding: 18px;
    border-radius: 20px;
  }

  .session-bar {
    margin: -4px 0 16px;
  }

  .hero-title {
    margin-top: 12px;
    font-size: clamp(1.9rem, 10vw, 2.5rem);
  }

  .hero-copy {
    font-size: 0.94rem;
    line-height: 1.6;
  }

  .badge {
    font-size: 0.76rem;
  }

  .badge img {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .floorplan-card {
    border-radius: 20px;
  }

  .floorplan-header {
    padding: 20px 18px 16px;
  }

  .thermal-panel {
    padding: 14px 18px;
  }

  .timeline-player {
    flex-wrap: wrap;
  }

  .timeline-navigation {
    flex: 1 1 100%;
    justify-content: space-between;
    margin: 3px 0 0;
    padding: 8px 0 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .thermal-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .facility-equipment-selector {
    grid-template-columns: 1fr auto;
  }

  .facility-equipment-selector > div {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .facility-equipment-selector .facility-equipment-banks {
    grid-template-columns: 1fr;
  }

  .facility-equipment-selector label {
    align-items: flex-start;
    white-space: normal;
  }

  .facility-equipment-selector.floorplan-bottom-panel {
    margin: 0 12px 12px;
  }

  .sensor-layer-selector.floorplan-bottom-panel {
    align-items: flex-start;
    flex-direction: column;
    margin: 10px 12px 8px;
  }

  .sensor-layer-selector > div {
    justify-content: flex-start;
  }

  .rack-operational-readings {
    grid-template-columns: repeat(3, minmax(74px, 1fr));
    overflow-x: auto;
  }

  .heatmap-toggle,
  .metric-switch {
    width: 100%;
  }

  .heatmap-toggle {
    justify-content: center;
  }

  .metric-switch label {
    flex: 1;
  }

  .metric-switch label span {
    width: 100%;
    justify-content: center;
  }

  .thermal-summary {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: space-between;
    gap: 8px;
  }

  .temperature-ticks {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    font-size: 0.58rem;
  }

  .temperature-ticks span:nth-child(2),
  .temperature-ticks span:nth-child(3) {
    text-align: center;
  }

  .temperature-ticks span:last-child {
    text-align: right;
  }

  .timeline-player {
    align-items: flex-start;
  }

  .timeline-current {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .timeline-current span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .loop-badge {
    display: none;
  }

  .cooling-status {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .cooling-title,
  .pipe-legend,
  .cooling-readings,
  .leak-status {
    grid-column: 1;
    grid-row: auto;
  }

  .leak-status {
    width: 100%;
    justify-content: flex-start;
  }

  .pipe-legend {
    position: absolute;
    right: 28px;
  }

  .cooling-readings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .floorplan-stats {
    width: 100%;
  }

  .floorplan-stats div {
    min-width: 0;
    padding: 9px 10px;
  }

  .floorplan-toolbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 11px 18px;
  }

  .legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 10px;
  }

  .rack-inspector {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    min-width: 0;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .chat-toggle {
    right: 16px;
    bottom: 16px;
    width: 54px;
    height: 54px;
  }

  .chat-header {
    padding: 14px 16px;
  }

  .chat-messages {
    padding: 14px 12px 0;
  }

  .message {
    max-width: 90%;
  }

  .chat-form {
    padding: 10px max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }
}

@media (max-width: 380px) {
  .floorplan-header {
    padding-inline: 14px;
  }

  .floorplan-stats {
    gap: 5px;
  }

  .floorplan-stats div {
    padding-inline: 7px;
  }

  .floorplan-stats strong {
    font-size: 0.92rem;
  }

  .thermal-panel {
    padding-inline: 14px;
  }

  .timeline-navigation {
    justify-content: space-between;
  }

  .heatmap-toggle,
  .metric-switch {
    grid-column: 1 / -1;
  }

  .pipe-legend {
    position: static;
  }

  .chat-form button {
    padding-inline: 11px;
  }
}
