:root {
  color-scheme: light;
  --page: #f4f6fb;
  --page-deep: #e8edf6;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(121, 131, 148, 0.28);
  --text: #111827;
  --muted: #687386;
  --soft: #98a2b3;
  --free: #30b574;
  --free-soft: #e8f8ef;
  --occupied: #ff5f57;
  --occupied-soft: #fff0ee;
  --warning: #ffb340;
  --accent: #007aff;
  --accent-soft: #e7f1ff;
  --shadow: 0 18px 55px rgba(44, 58, 84, 0.14);
  --shadow-soft: 0 8px 24px rgba(44, 58, 84, 0.1);
  --radius: 8px;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(239, 244, 251, 0.72)),
    linear-gradient(160deg, #f7f9fc 0%, #edf2fa 46%, #f9f4ef 100%);
  color: var(--text);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(17, 24, 39, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 24, 39, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 82%);
  content: "";
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(245, 248, 252, 0.62));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(1.25);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  color: #0f172a;
  font-size: clamp(1.85rem, 3vw, 3.35rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  color: #1f2937;
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.sync-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 238px;
  padding: 14px 16px;
  border: 1px solid rgba(0, 122, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(231, 241, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.sync-label,
.metric-label,
.bench-label,
.section-title-row span,
.thermal-area p,
.timeline-row > span,
.bench-details span {
  color: var(--muted);
  font-size: 0.78rem;
}

.sync-panel strong {
  display: block;
  margin-top: 3px;
  color: #0f172a;
  font-size: 0.92rem;
}

.live-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--free);
  box-shadow: 0 0 0 8px rgba(48, 181, 116, 0.12);
  animation: pulse 1.8s infinite;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(540px, 1.45fr);
  gap: 18px;
  align-items: stretch;
  margin-top: 18px;
}

.status-column {
  display: grid;
  grid-template-rows: 1fr;
}

.bench-panel,
.timeline-panel,
.thermal-area,
.activity-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(1.18);
}

.bench-panel {
  position: relative;
  overflow: hidden;
  padding: 18px;
  transition:
    border-color 220ms ease,
    background 220ms ease,
    transform 220ms ease,
    box-shadow 220ms ease;
}

.workstation-overview {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  padding: 24px;
}

.bench-panel::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--soft);
  content: "";
}

.bench-panel.is-occupied {
  border-color: rgba(255, 95, 87, 0.34);
  background: linear-gradient(135deg, rgba(255, 240, 238, 0.94), rgba(255, 255, 255, 0.76));
}

.bench-panel.is-occupied::before {
  background: var(--occupied);
}

.bench-panel.is-free {
  border-color: rgba(48, 181, 116, 0.28);
  background: linear-gradient(135deg, rgba(232, 248, 239, 0.94), rgba(255, 255, 255, 0.76));
}

.bench-panel.is-free::before {
  background: var(--free);
}

.bench-panel.is-warning {
  border-color: rgba(255, 179, 64, 0.42);
  background: linear-gradient(135deg, rgba(255, 247, 232, 0.96), rgba(255, 255, 255, 0.76));
}

.bench-panel.is-warning::before {
  background: var(--warning);
}

.bench-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.bench-heading h2 {
  margin-top: 8px;
  color: #0f172a;
  font-size: clamp(3.3rem, 7vw, 6rem);
  line-height: 0.92;
}

.status-indicator {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: var(--soft);
}

.status-indicator.is-occupied {
  background: var(--occupied);
  box-shadow: 0 0 0 8px rgba(255, 95, 87, 0.12);
}

.status-indicator.is-free {
  background: var(--free);
  box-shadow: 0 0 0 8px rgba(48, 181, 116, 0.12);
}

.bench-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 26px;
}

.bench-details span {
  padding: 10px;
  border: 1px solid rgba(121, 131, 148, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.58);
}

.bench-details strong {
  display: block;
  margin-top: 5px;
  color: #111827;
  font-size: 1rem;
}

.state-context {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.state-context > div {
  padding: 12px;
  border: 1px solid rgba(121, 131, 148, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.46);
}

.state-context span,
.compact-history-heading {
  color: var(--muted);
  font-size: 0.78rem;
}

.state-context strong {
  display: block;
  margin-top: 5px;
  color: #111827;
  font-size: 1rem;
}

.compact-history {
  margin-top: auto;
  padding-top: 24px;
}

.compact-history-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.timeline-panel,
.activity-panel,
.control-panel,
.thermal-area {
  padding: 18px;
}

.section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.thermal-area p {
  margin-top: 6px;
  max-width: 600px;
}

.heatmap-frame {
  position: relative;
  overflow: hidden;
  min-height: 430px;
  border: 1px solid rgba(18, 25, 38, 0.18);
  border-radius: var(--radius);
  background: #0b1018;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -18px 40px rgba(0, 0, 0, 0.18);
  aspect-ratio: 1.54;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#thermalSnapshot {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b1018;
}

#thermalSnapshot.is-visible {
  display: block;
}

#thermalSnapshot.is-visible ~ .roi {
  display: none;
}

.roi {
  position: absolute;
  top: 14%;
  width: 34%;
  height: 68%;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 6px;
  pointer-events: none;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.16),
    inset 0 0 0 1px rgba(15, 23, 42, 0.14);
}

.roi span {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.68);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.roi-one {
  right: 8%;
}

.legend-row {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.78rem;
}

.legend-bar {
  height: 10px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: linear-gradient(90deg, #1c2a68, #1675ad, #42b883, #f2c14e, #ff5f57);
  box-shadow: var(--shadow-soft);
}

.timeline-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
}

.timeline span {
  height: 30px;
  border-radius: 4px;
  background: #d7dee9;
}

.timeline span.is-free {
  background: linear-gradient(180deg, #59d999, #30b574);
}

.timeline span.is-occupied {
  background: linear-gradient(180deg, #ff8d85, #ff5f57);
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  margin-top: 18px;
}

#eventLog {
  display: grid;
  gap: 10px;
  max-height: 194px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

#eventLog li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(121, 131, 148, 0.2);
  color: var(--muted);
  font-size: 0.86rem;
}

#eventLog strong {
  color: #1f2937;
  font-weight: 650;
}

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

button {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid rgba(0, 122, 255, 0.18);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(237, 246, 255, 0.92));
  color: #005ecb;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 8px 18px rgba(0, 122, 255, 0.08);
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

button:hover {
  border-color: rgba(0, 122, 255, 0.34);
  background: linear-gradient(180deg, #ffffff, #eaf4ff);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 12px 24px rgba(0, 122, 255, 0.12);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:last-child {
  grid-column: 1 / -1;
  border-color: rgba(255, 179, 64, 0.36);
  background: linear-gradient(180deg, #fffaf1, #fff1d9);
  color: #9a5b00;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 10px 22px rgba(255, 179, 64, 0.12);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.78);
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 28px, 760px);
  }

  .topbar,
  .workspace,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .heatmap-frame {
    min-height: 300px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 520px);
    padding: 18px 0;
  }

  .bench-details,
  .state-context,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .sync-panel {
    min-width: 0;
  }

  .heatmap-frame {
    min-height: 230px;
  }

  .timeline-row {
    grid-template-columns: 1fr;
  }
}
