:root {
  color-scheme: dark;
  --bg: #090d10;
  --panel: #12181c;
  --panel-2: #182126;
  --line: #2c3a42;
  --text: #eef6f5;
  --muted: #95a6aa;
  --cyan: #58c7e8;
  --ok: #4bd07b;
  --warn: #f2ba42;
  --danger: #ff5361;
  --unknown: #748086;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Bahnschrift, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.dashboard {
  height: 100vh;
  padding: 3px 5px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 5px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(245px, 0.48fr) minmax(0, 2fr) minmax(420px, 0.8fr);
  gap: 6px;
  align-items: stretch;
  min-height: 46px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #11181c, #0d1215);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--cyan);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(19px, 1.2vw, 23px);
  line-height: 0.96;
  font-weight: 800;
}

h2 {
  font-size: 11px;
  font-weight: 800;
}

.header-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 4px;
}

.metric,
.card,
.video-panel,
.teeth-strip {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.metric {
  min-height: 37px;
  padding: 4px 6px 3px;
  border-radius: 6px;
}

.metric span,
.asset-grid span,
label {
  color: var(--muted);
  font-size: 9px;
}

.metric strong {
  display: block;
  min-width: 0;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1;
}

.metric.NORMAL strong {
  color: var(--ok);
}

.metric.WARNING strong {
  color: var(--warn);
}

.metric.CRITICAL,
.metric.danger.active {
  border-color: color-mix(in srgb, var(--danger), white 18%);
  background: #251018;
}

.metric.CRITICAL strong,
.metric.danger.active strong {
  color: var(--danger);
}

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(336px, 23vw);
  gap: 5px;
}

.main-column,
.side-column {
  min-height: 0;
  display: grid;
  gap: 3px;
}

.main-column {
  grid-template-rows: minmax(260px, var(--video-panel-height, 58vh)) auto 68px;
}

.side-column {
  grid-auto-rows: max-content;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.brand-block {
  display: grid;
  align-content: center;
}

.top-asset {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
}

.top-asset .card-head {
  min-height: 0;
  padding: 3px 6px;
  border-right: 1px solid var(--line);
  border-bottom: 0;
  align-items: center;
}

.top-asset .asset-grid {
  padding: 3px 4px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.top-asset .asset-grid div {
  min-height: 28px;
  padding: 3px 5px;
  border-radius: 6px;
}

.top-asset .asset-grid strong {
  margin-top: 2px;
  font-size: 9px;
  line-height: 1;
}

.old-side-asset,
.old-side-timeline {
  display: none;
}

.video-panel {
  min-height: 0;
  max-height: var(--video-panel-height, 58vh);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-title,
.card-head {
  min-height: 26px;
  padding: 3px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.card-head h2 {
  margin-right: auto;
}

.panel-title > div:first-child {
  flex: 0 0 132px;
  min-width: 0;
}

.panel-title > div:first-child span,
.panel-title > div:first-child strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-title span,
.card-head span {
  color: var(--cyan);
  font-size: 8px;
  font-weight: 800;
}

.panel-title strong {
  display: block;
  margin-top: 2px;
  font-size: 9px;
}

.video-actions {
  display: flex;
  gap: 3px;
  align-items: center;
  justify-content: end;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: thin;
}

.video-actions.collapsed > :not(#toggleTools) {
  display: none;
}

.video-actions button.active,
.tool-pin {
  border-color: var(--cyan);
  background: #09222b;
  color: #bff3ff;
}

button,
.file-button,
select,
input[type="number"],
input[type="text"] {
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1114;
  color: var(--text);
  font-size: 11px;
}

button {
  padding: 0 6px;
  cursor: pointer;
  white-space: nowrap;
}

.file-button {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  color: var(--text);
  cursor: pointer;
}

.file-button input {
  display: none;
}

#simulateLoss {
  border-color: #6a4b1e;
  background: #271f0d;
}

#resetLoss {
  border-color: #4a555b;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  background: #040607;
  overflow: hidden;
}

#canvas,
#video,
#image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
}

#video,
#image {
  visibility: hidden;
}

.seek-control {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  z-index: 4;
  display: none;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(88, 199, 232, 0.42);
  border-radius: 8px;
  background: rgba(5, 10, 12, 0.82);
  backdrop-filter: blur(8px);
}

.seek-control.active {
  display: grid;
}

.seek-control span {
  color: #d7f7ff;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.seek-bar {
  position: relative;
  height: 18px;
  cursor: ew-resize;
  touch-action: none;
}

.seek-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 7px;
  height: 4px;
  border-radius: 999px;
  background: #24343b;
}

.seek-progress {
  position: absolute;
  left: 0;
  top: 7px;
  width: 0%;
  height: 4px;
  border-radius: 999px;
  background: var(--cyan);
}

.seek-thumb {
  position: absolute;
  left: 0%;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid #d7f7ff;
  border-radius: 50%;
  background: #0b1114;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px rgba(88, 199, 232, 0.18);
}

.critical-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 48px;
  z-index: 5;
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--danger), white 18%);
  border-radius: 8px;
  background: rgba(52, 12, 18, 0.92);
}

.critical-banner.active {
  display: flex;
}

.critical-banner span {
  color: #ffdadd;
  font-size: 11px;
}

.teeth-strip {
  min-height: 43px;
  max-height: 48px;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(10, minmax(54px, 1fr));
  gap: 4px;
  overflow-x: auto;
}

.tooth {
  min-height: 35px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c1114;
  padding: 4px 6px;
  display: grid;
  align-content: center;
  gap: 1px;
}

.tooth strong {
  font-size: 10px;
}

.tooth span {
  font-size: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.tooth.OK {
  border-color: color-mix(in srgb, var(--ok), black 15%);
}

.tooth.SUSPECT {
  border-color: var(--warn);
  background: #251e0d;
}

.tooth.MISSING {
  border-color: var(--danger);
  background: #251018;
}

.tooth.UNKNOWN {
  border-color: var(--unknown);
}

.card {
  overflow: hidden;
}

.accordion-card {
  min-height: 0;
}

.accordion-card > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.accordion-card > summary::-webkit-details-marker {
  display: none;
}

.accordion-card > summary::before {
  content: "▸";
  color: var(--cyan);
  font-size: 10px;
  margin-right: 2px;
  transition: transform 0.14s ease;
}

.accordion-card[open] > summary::before {
  transform: rotate(90deg);
}

.accordion-card:not([open]) {
  background: #0f1518;
}

.accordion-card:not([open]) > summary {
  border-bottom: 0;
}

.asset-grid,
.control-grid,
.operation-grid,
.event-log {
  padding: 6px;
}

.asset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.asset-grid div {
  min-height: 33px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c1114;
  padding: 5px 6px;
}

.asset-grid strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.operation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.annotation-grid {
  padding: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.annotation-grid button.active {
  border-color: var(--cyan);
  background: #09222b;
  color: #bff3ff;
}

#saveTrainingFrame {
  border-color: color-mix(in srgb, var(--ok), black 10%);
  background: #0d2417;
}

.dataset-grid {
  padding: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.operation-grid button,
.operation-grid .check-row {
  min-height: 26px;
}

.annotation-grid button,
.dataset-grid button {
  min-height: 26px;
}

label {
  display: grid;
  gap: 3px;
}

input,
select {
  width: 100%;
  padding: 0 5px;
}

input[type="range"] {
  accent-color: var(--cyan);
  padding: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.timeline-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.main-timeline .event-log {
  display: flex;
  gap: 6px;
  overflow: auto;
}

.main-timeline .event {
  min-width: 230px;
}

.event-log {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 5px;
  font-size: 9px;
}

.event {
  border-left: 3px solid var(--cyan);
  background: #0c1114;
  padding: 5px 7px;
  color: var(--muted);
}

.event.alert {
  border-left-color: var(--danger);
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .dashboard {
    height: auto;
  }

  .app-header,
  .layout {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    aspect-ratio: 16 / 9;
  }

  .teeth-strip {
    grid-template-columns: repeat(5, minmax(72px, 1fr));
  }
}

@media (max-width: 680px) {
  .header-metrics,
  .control-grid,
  .operation-grid,
  .asset-grid,
  .teeth-strip {
    grid-template-columns: 1fr 1fr;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }
}

/* VPS only: show only Vista A, Vista B and IA Pala 2 */
.video-actions > :not(#loadOverview):not(#loadTeeth):not(#loadPala2) {
  display: none !important;
}

.video-actions {
  justify-content: flex-start;
}
/* /VPS only */
