:root {
  --ink: #332d26;
  --ink-soft: #6f6558;
  --ink-faint: #9a9083;
  --paper: #f3eee4;
  --card: rgba(255, 252, 246, 0.88);
  --card-solid: #fffdf8;
  --line: rgba(68, 57, 45, 0.12);
  --line-strong: rgba(68, 57, 45, 0.2);
  --accent: #2f6f68;
  --accent-soft: #e0f1ed;
  --warn: #b06a2e;
  --warn-soft: #fbeadb;
  --alert: #a34d44;
  --alert-soft: #f8e4e1;
  --ok: #4b7f5a;
  --ok-soft: #e4f1e6;
  --shadow: 0 18px 50px rgba(65, 52, 38, 0.13), 0 2px 6px rgba(65, 52, 38, 0.05);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

#scene {
  position: absolute;
  inset: 0;
  touch-action: none;
}

#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.scene-wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 72% 65%, rgba(255, 255, 255, 0) 35%, rgba(243, 238, 228, 0.38) 100%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.35), rgba(243, 238, 228, 0) 28%);
  z-index: 1;
}

.topbar {
  position: absolute;
  top: 20px;
  left: 24px;
  right: 24px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: var(--ink);
  color: #f8f1e3;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.04em;
}

.brand h1 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.14em;
  font-weight: 750;
}

.brand p {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}

.chip-muted {
  color: var(--ink-soft);
}

.chip-wait {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(176, 106, 46, 0.2);
}

.chip-live {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: rgba(75, 127, 90, 0.22);
}

.chip-down {
  color: var(--alert);
  background: var(--alert-soft);
  border-color: rgba(163, 77, 68, 0.22);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent);
}

.chip-live .dot {
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.icon-button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(65, 52, 38, 0.05);
  backdrop-filter: blur(12px);
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

.icon-button:hover {
  background: var(--card-solid);
  transform: translateY(-1px);
}

.icon-button:focus-visible,
.nav-pill:focus-visible,
.details-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tv-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tv-controls .icon-button.is-on {
  border-color: var(--accent);
  color: var(--accent);
}

.tv-controls .icon-button {
  text-align: center;
}

#tv-audio-toggle {
  min-width: 92px;
}

#tv-fullscreen-toggle {
  min-width: 136px;
}

#tv-pip-toggle {
  min-width: 90px;
}

.tv-volume {
  width: 88px;
  accent-color: var(--accent);
  cursor: pointer;
}

.tv-theater {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 12, 13, 0.94);
  backdrop-filter: blur(8px);
}

.tv-theater[hidden] {
  display: none;
}

.tv-theater-frame {
  width: min(96vw, 1600px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tv-theater-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.tv-theater-screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.tv-theater-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #e6f0ee;
  font-size: 12px;
  font-weight: 600;
}

.tv-theater-bar .icon-button {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #f4fbf9;
}

.department-nav {
  position: absolute;
  left: 24px;
  top: 104px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.nav-pill {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 620;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.nav-pill:hover {
  background: rgba(47, 111, 104, 0.08);
  color: var(--ink);
}

.nav-pill.is-active {
  background: var(--ink);
  color: #f8f1e3;
}

.details {
  position: absolute;
  z-index: 6;
  top: 100px;
  right: 24px;
  width: 344px;
  max-height: calc(100% - 240px);
  overflow: auto;
  padding: 20px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.details[hidden] {
  display: none;
}

.details-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card-solid);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.details h2 {
  margin: 0;
  padding-right: 28px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.details-subtitle {
  margin: 4px 0 16px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

.details-body {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row dt {
  color: var(--ink-faint);
  flex: 0 0 auto;
}

.detail-row dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-block {
  margin-top: 4px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(243, 238, 228, 0.72);
  border: 1px solid var(--line);
}

.detail-block h3 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.detail-block p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  background: var(--ok-soft);
  color: var(--ok);
}

.state-pill[data-state="executing"],
.state-pill[data-state="analyzing"],
.state-pill[data-state="receiving_task"] {
  background: #fbf0dc;
  color: #96651f;
}

.state-pill[data-state="waiting_approval"],
.state-pill[data-state="investigating"],
.state-pill[data-state="escalating"] {
  background: var(--warn-soft);
  color: var(--warn);
}

.state-pill[data-state="unavailable"] {
  background: #ece8e1;
  color: #7e7467;
}

.readonly-note {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line-strong);
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.5;
}

.activity-panel {
  position: absolute;
  z-index: 4;
  right: 24px;
  bottom: 24px;
  width: 372px;
  padding: 15px 16px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.activity-head h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  max-height: 132px;
  overflow: hidden;
}

.activity-item {
  display: grid;
  grid-template-columns: 42px 8px 1fr;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  font-size: 11.5px;
  line-height: 1.4;
  border-top: 1px solid var(--line);
}

.activity-item:first-child {
  border-top: 0;
}

.activity-item[data-source="history"] .activity-text {
  color: var(--ink-faint);
}

.activity-more {
  margin-top: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.activity-more:hover,
.activity-more:focus-visible {
  color: var(--ink);
  border-color: var(--accent);
}

.activity-more:disabled {
  opacity: 0.5;
  cursor: progress;
}

.activity-time {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}

.activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  transform: translateY(-1px);
}

.activity-item[data-severity="ok"] .activity-dot {
  background: var(--ok);
}

.activity-item[data-severity="warn"] .activity-dot {
  background: var(--warn);
}

.activity-item[data-severity="alert"] .activity-dot {
  background: var(--alert);
}

.activity-text {
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item:first-child .activity-text {
  color: var(--ink);
  font-weight: 600;
}

.activity-empty {
  color: var(--ink-faint);
  font-size: 11.5px;
  padding: 5px 0;
}

.legend {
  position: absolute;
  z-index: 4;
  left: 24px;
  bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  justify-content: flex-start;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.72);
  color: var(--ink-soft);
  font-size: 10px;
  backdrop-filter: blur(12px);
  max-width: 330px;
}

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

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--swatch);
}

.banner {
  position: absolute;
  z-index: 8;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid rgba(163, 77, 68, 0.24);
  background: var(--alert-soft);
  color: var(--alert);
  font-size: 11px;
  box-shadow: 0 10px 30px rgba(163, 77, 68, 0.12);
}

.banner[hidden] {
  display: none;
}

.list-view {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(51, 45, 38, 0.28);
  backdrop-filter: blur(6px);
}

.list-view[hidden] {
  display: none;
}

.list-card {
  width: min(980px, 100%);
  max-height: min(760px, 100%);
  overflow: auto;
  padding: 24px;
  border-radius: 26px;
  border: 1px solid var(--line);
  background: var(--card-solid);
  box-shadow: 0 30px 90px rgba(50, 40, 30, 0.24);
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}

.list-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.list-head p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.list-columns {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 22px;
}

.list-columns h3 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.list-rows {
  display: grid;
  gap: 8px;
}

.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 11px 12px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: #fbf7ef;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.list-row:hover {
  border-color: rgba(47, 111, 104, 0.42);
}

.list-row strong {
  font-size: 12px;
  font-weight: 650;
}

.list-row span {
  font-size: 10.5px;
  color: var(--ink-soft);
  grid-column: 1 / -1;
}

.list-row .mini-state {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}

.list-empty {
  padding: 18px;
  border-radius: 13px;
  border: 1px dashed var(--line-strong);
  color: var(--ink-faint);
  font-size: 12px;
}

.loading {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(243, 238, 228, 0.78);
  backdrop-filter: blur(10px);
}

.loading[hidden] {
  display: none;
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 420px;
  padding: 20px 24px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--card-solid);
  box-shadow: var(--shadow);
}

.loading-card strong {
  font-size: 14px;
}

.loading-card p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

.loading-card .icon-button {
  margin-top: 10px;
}

.spinner {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(47, 111, 104, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1080px) {
  #tenant-chip {
    display: none;
  }
  .activity-panel {
    width: min(420px, calc(100% - 48px));
  }
  .legend {
    display: none;
  }
  .details {
    width: 310px;
  }
}

@media (max-width: 760px) {
  .topbar {
    top: 12px;
    left: 12px;
    right: 12px;
  }
  .brand p,
  #tenant-chip,
  #quality-toggle {
    display: none;
  }
  .tv-volume {
    display: none;
  }
  .department-nav {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    flex-direction: row;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .nav-pill {
    white-space: nowrap;
  }
  .activity-panel {
    left: 12px;
    right: 12px;
    bottom: 76px;
    width: auto;
    max-height: 150px;
  }
  .details {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 76px;
    width: auto;
    max-height: 46%;
  }
  .details:not([hidden]) ~ .activity-panel {
    display: none;
  }
  .list-columns {
    grid-template-columns: 1fr;
  }
  .banner {
    top: 74px;
    width: calc(100% - 24px);
    justify-content: center;
  }
}
