* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #142339;
  color: #d5d8dc;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #111d2f;
  border-bottom: 1px solid #213450;
}

header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

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

#conn-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #2a3e5a;
}

#conn-status.connected {
  background: #1e4d2b;
  color: #7ee2a0;
}

#conn-status.disconnected {
  background: #4d1e1e;
  color: #e27e7e;
}

#main-row {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

#game {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#game canvas {
  display: block;
  cursor: grab;
}

#game canvas:active {
  cursor: grabbing;
}

/* docked column on the right of the office; the map shrinks to make room */
#robot-panel {
  position: relative;
  flex: 0 0 290px;
  width: 290px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #111d2f;
  border-left: 1px solid #213450;
  padding: 16px 18px 12px;
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#robot-panel.hidden {
  display: none;
}

#robot-panel-close {
  position: absolute;
  top: 12px;
  right: 10px;
  background: none;
  border: none;
  color: #a3abb6;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

#robot-panel-close:hover {
  color: #d5d8dc;
}

#robot-panel h2 {
  margin: 0 0 10px 0;
  font-size: 15px;
  padding-right: 20px;
}

.robot-panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #d5d8dc;
  padding: 4px 0;
  border-top: 1px solid #1a2e49;
}

.robot-panel-row {
  gap: 12px;
}

.robot-panel-row .label {
  flex-shrink: 0;
  color: #8691a2;
}

.robot-panel-row > :last-child {
  text-align: right;
}

/* one line per figure: executions, hours, R$ */
#robot-panel-economia {
  white-space: pre-line;
  line-height: 1.5;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: #a3abb6;
}

.panel-toggle-tab {
  position: fixed;
  top: 90px;
  left: 0;
  width: 26px;
  height: 52px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111d2f;
  border: 1px solid #213450;
  border-left: none;
  border-radius: 0 10px 10px 0;
  color: #a3abb6;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.3);
  transition: left 0.2s ease, color 0.15s ease;
}

.panel-toggle-tab:hover {
  color: #d5d8dc;
}

.panel-toggle-tab.panel-open {
  left: 280px;
}

#cadastro-panel {
  flex: 0 0 280px;
  width: 280px;
  height: 100%;
  overflow-y: auto;
  background: #111d2f;
  border-right: 1px solid #213450;
  padding: 16px 18px 18px;
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.35);

  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: #374b67 #111d2f;
}

/* Chromium/WebKit — a slim dark scrollbar instead of the default OS one */
#cadastro-panel::-webkit-scrollbar,
#robot-panel-history::-webkit-scrollbar,
.cadastro-list::-webkit-scrollbar {
  width: 8px;
}

#cadastro-panel::-webkit-scrollbar-track,
#robot-panel-history::-webkit-scrollbar-track,
.cadastro-list::-webkit-scrollbar-track {
  background: transparent;
}

#cadastro-panel::-webkit-scrollbar-thumb,
#robot-panel-history::-webkit-scrollbar-thumb,
.cadastro-list::-webkit-scrollbar-thumb {
  background-color: #374b67;
  border-radius: 999px;
  border: 2px solid #111d2f;
}

#cadastro-panel::-webkit-scrollbar-thumb:hover,
#robot-panel-history::-webkit-scrollbar-thumb:hover,
.cadastro-list::-webkit-scrollbar-thumb:hover {
  background-color: #4a5d78;
}

#cadastro-panel.hidden {
  display: none;
}

#cadastro-panel-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: #a3abb6;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

#cadastro-panel-close:hover {
  color: #d5d8dc;
}

#cadastro-panel h2 {
  margin: 0 0 14px 0;
  font-size: 16px;
  font-weight: 600;
  padding-right: 20px;
  letter-spacing: 0.01em;
}

.cadastro-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px 12px 14px;
  background: #142339;
  border: 1px solid #1a2e49;
  border-radius: 10px;
}

.cadastro-section label {
  font-size: 10.5px;
  color: #959fad;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.cadastro-section input,
.cadastro-section select {
  background: #0d1726;
  border: 1px solid #2a3e5a;
  color: #d5d8dc;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.cadastro-section input:focus,
.cadastro-section select:focus {
  outline: none;
  border-color: #e5a82e;
}

.cadastro-section button {
  margin-top: 4px;
  background: #e5a82e;
  border: none;
  color: #1a2e49;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.cadastro-section button:hover {
  background: #e9b853;
}

.cadastro-section button:active {
  background: #cc9119;
}

#cadastro-feedback {
  font-size: 12px;
  padding: 0 2px;
  min-height: 16px;
}

#cadastro-feedback:not(:empty) {
  margin-bottom: 12px;
}

#cadastro-feedback.error {
  color: #e27e7e;
}

#cadastro-feedback.success {
  color: #7ee2a0;
}

.cadastro-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 2px;
}

.cadastro-list-empty {
  font-size: 12px;
  color: #65758b;
  font-style: italic;
  padding: 2px 0;
}

.cadastro-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: #e3e5e8;
  background: #0d1726;
  border: 1px solid #1a2e49;
  border-radius: 7px;
  padding: 7px 6px 7px 10px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.cadastro-list-item:hover {
  background: #111d2f;
  border-color: #374b67;
}

.cadastro-list-item .item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cadastro-list-item .item-sub {
  color: #8691a2;
  font-size: 10.5px;
  flex: 0 0 auto;
  background: #1a2e49;
  padding: 2px 7px;
  border-radius: 999px;
}

.cadastro-list-item button {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: #959fad;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 4px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.cadastro-list-item button:hover {
  color: #ff9a9a;
  background: rgba(226, 126, 126, 0.12);
}

#zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #172840;
  border: 1px solid #213450;
  border-radius: 999px;
  padding: 2px;
}

#zoom-controls button {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #d5d8dc;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

#zoom-controls button:hover {
  background: #2a3e5a;
}

#zoom-label {
  min-width: 42px;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #d5d8dc;
}

.header-pill {
  height: 30px;
  padding: 0 12px;
  border: 1px solid #213450;
  border-radius: 999px;
  background: #172840;
  color: #d5d8dc;
  font-size: 12px;
  cursor: pointer;
}

.header-pill:hover {
  background: #2a3e5a;
}

/* Escritório | Painel: the two ways to watch the robots */
.vista-switch {
  display: inline-flex;
  padding: 2px;
  border: 1px solid #213450;
  border-radius: 999px;
  background: #172840;
}

.vista-switch a {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  color: #a3abb6;
  font-size: 12px;
  text-decoration: none;
}

.vista-switch a:hover {
  color: #eef0f2;
}

.vista-switch a[aria-current="page"] {
  background: var(--brand);
  color: var(--brand-text, #111);
  font-weight: 600;
}

.vista-switch a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---- live summary in the header ---- */

#summary {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  /* "safe": when the chips don't fit they overflow to the right instead of
     spilling over the client's name */
  justify-content: safe center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  padding: 0 16px;
  font-size: 12px;
  color: #d5d8dc;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #172840;
  border: 1px solid #213450;
  white-space: nowrap;
}

.summary-chip .status-dot {
  margin-right: 2px;
}

.summary-chip b {
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.summary-chip.bump b {
  animation: bump 0.4s ease;
}

@keyframes bump {
  40% {
    color: #efca80;
  }
}

.summary-sep {
  width: 1px;
  height: 18px;
  background: #213450;
  margin: 0 4px;
}

.summary-note {
  color: #74839a;
  font-size: 11px;
  white-space: nowrap;
}

@media (max-width: 1600px) {
  .summary-note,
  .summary-economia-texto {
    display: none;
  }
}

@media (max-width: 1500px) {
  body:not(.painel-page) .brand-sub,
  .summary-sep {
    display: none;
  }
}

/* the mouse wheel / trackpad still zoom the office */
@media (max-width: 1300px) {
  #zoom-controls {
    display: none;
  }
}

@media (max-width: 900px) {
  #summary {
    display: none;
  }
}

/* ---- robot panel extras ---- */

.panel-button {
  width: 100%;
  margin: 10px 0 4px;
  padding: 7px 10px;
  border: 1px solid #2a3e5a;
  border-radius: 7px;
  background: #142339;
  color: #e3e5e8;
  font-size: 12px;
  cursor: pointer;
}

.panel-button:hover {
  background: #1a2e49;
}

.robot-panel-history-title {
  margin: 10px 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #959fad;
}

#robot-panel-history {
  flex: 1 1 auto;
  min-height: 0;
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #374b67 #111d2f;
}

#robot-panel-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
  color: #d5d8dc;
  border-top: 1px solid #1a2e49;
}

#robot-panel-history li .when {
  color: #8691a2;
  font-variant-numeric: tabular-nums;
}

#robot-panel-history .empty {
  color: #65758b;
  font-style: italic;
  justify-content: flex-start;
}

/* ---- minimap frame (the map itself is a Phaser camera underneath) ---- */

#minimap-frame {
  position: absolute;
  pointer-events: none;
  border: 2px solid #213450;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

#minimap-frame.hidden {
  display: none;
}

/* ---- client branding (color set at runtime from the client's settings) ---- */

:root {
  --brand: #e5a82e;
  --brand-soft: #e5a82e33;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 0 auto;
}

.brand-logo {
  height: 30px;
  max-width: 120px;
  object-fit: contain;
}

.brand-badge {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-text, #fff);
  font-weight: 700;
  font-size: 15px;
}

.colmeia-logo {
  height: 28px;
  width: auto;
  display: block;
}

.colmeia-logo-sub {
  padding-left: 10px;
  border-left: 1px solid #2a3e5a;
  line-height: 28px;
}

.brand-text {
  line-height: 1.15;
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: #8691a2;
  white-space: nowrap;
}

/* accents follow the client's color */
.cadastro-section button {
  background: var(--brand);
  color: var(--brand-text, #fff);
}

.cadastro-section button:hover {
  filter: brightness(1.12);
  background: var(--brand);
}

.cadastro-section input:focus,
.cadastro-section select:focus {
  border-color: var(--brand);
}

/* ---- user menu ---- */

.user-menu {
  position: relative;
}

.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px 0 4px;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: var(--brand-text, #fff);
  font-size: 11px;
  font-weight: 700;
}

.caret {
  color: #8691a2;
  font-size: 10px;
}

.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 220px;
  padding: 6px;
  background: #111d2f;
  border: 1px solid #213450;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}

.dropdown.hidden {
  display: none;
}

.dropdown-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid #1a2e49;
  margin-bottom: 4px;
  font-size: 13px;
}

.muted {
  color: #8691a2;
  font-size: 11.5px;
}

.dropdown-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px 8px;
  border-bottom: 1px solid #1a2e49;
  margin-bottom: 4px;
}

.dropdown-section label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #959fad;
}

.dropdown-section select {
  background: #0d1726;
  border: 1px solid #2a3e5a;
  color: #d5d8dc;
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 13px;
}

.dropdown a,
.dropdown > button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: none;
  color: #e3e5e8;
  font-size: 13px;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
}

.dropdown a:hover,
.dropdown > button:hover {
  background: #172840;
}

/* hidden menu items stay hidden even when their class sets display */
.dropdown [hidden] {
  display: none;
}

/* ---- registration: robot ID ---- */

#novo-robo-id {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
}

.field-hint {
  font-size: 11px;
  color: #74839a;
  line-height: 1.35;
}

/* ---- robot panel: ID and messages ---- */

.id-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.id-cell code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11.5px;
  color: #e3e5e8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}

.mini-btn {
  border: 1px solid #2a3e5a;
  border-radius: 5px;
  background: #142339;
  color: #d5d8dc;
  font-size: 10.5px;
  padding: 2px 6px;
  cursor: pointer;
}

.mini-btn:hover {
  background: #1a2e49;
}

#robot-panel-history li {
  flex-wrap: wrap;
}

#robot-panel-history li .msg {
  flex: 1 0 calc(100% - 14px);
  min-width: 0;
  margin: 2px 0 0 14px;
  font-size: 11px;
  color: #e9a5a5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- empty state ---- */

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #a3abb6;
  z-index: 5;
}

.empty-state.hidden {
  display: none;
}

.empty-state h2 {
  color: #d5d8dc;
  font-size: 18px;
  margin: 0 0 6px;
}

.empty-state a {
  color: var(--brand-link, var(--brand));
}

/* ---- TV mode: only the office, fitted to the screen ---- */

#tv-hud,
#tv-controls {
  display: none;
}

/* inside the dashboard (Mix): just the office, no TV controls */
body.embutido #tv-hud,
body.embutido #tv-controls {
  display: none !important;
}

body.tv-mode header,
body.tv-mode #cadastro-panel,
body.tv-mode #cadastro-toggle-tab,
body.tv-mode #robot-panel,
body.tv-mode #minimap-frame {
  display: none !important;
}

body.tv-mode #tv-hud {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(17, 29, 47, 0.82);
  border: 1px solid #213450;
  font-size: 13px;
  color: #d5d8dc;
  pointer-events: none;
}

#tv-brand {
  font-weight: 600;
  color: #fff;
  padding: 0 4px;
}

#tv-conn {
  color: #ffb4a8;
}

#tv-conn[hidden] {
  display: none;
}

#tv-sector {
  padding: 0 4px;
  color: #fff;
}

#tv-sector[hidden] {
  display: none;
}

body.tv-mode #tv-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity 0.3s ease;
}

.tv-switch {
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: #172840;
  border: 1px solid #213450;
}

.tv-switch button {
  height: 24px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #d5d8dc;
  font-size: 12px;
  cursor: pointer;
}

.tv-switch button.active {
  background: var(--brand);
  color: var(--brand-text, #fff);
}

.tv-carousel-controls {
  display: none;
  gap: 6px;
}

body.tv-carousel .tv-carousel-controls {
  display: flex;
}

/* when the mouse sits still: no cursor, no controls */
body.tv-mode.tv-idle #tv-controls {
  opacity: 0;
  pointer-events: none;
}

body.tv-mode.tv-idle,
body.tv-mode.tv-idle * {
  cursor: none !important;
}

/* ---- room decoration editor (right-click menu + notice) ---- */

.decor-menu {
  position: fixed;
  z-index: 50;
  min-width: 180px;
  max-width: 320px;
  padding: 6px;
  background: rgba(17, 29, 47, 0.96);
  border: 1px solid #2a3e5a;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 13px;
}

.decor-menu-title {
  padding: 6px 8px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #8691a2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.decor-menu-item {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #d5d8dc;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.decor-menu-item:hover,
.decor-menu-item:focus-visible {
  background: #213450;
  outline: none;
}

.decor-menu-item.perigo {
  color: #ff9a9a;
}

.decor-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.decor-menu-peca {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-height: 64px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #172840;
  color: #d5d8dc;
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
}

.decor-menu-peca:hover,
.decor-menu-peca:focus-visible {
  border-color: var(--brand);
  outline: none;
}

.decor-menu-peca img {
  max-height: 32px;
  max-width: 44px;
  image-rendering: pixelated;
}

.decor-menu-sep {
  margin: 6px 4px;
  border: none;
  border-top: 1px solid #2a3e5a;
}

#decor-aviso {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  background: rgba(17, 29, 47, 0.96);
  border: 1px solid #2a3e5a;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  color: #d5d8dc;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#decor-aviso.visivel {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

#decor-aviso.erro {
  border-color: #5a2a2a;
  color: #ff9a9a;
}

#decor-aviso button {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: var(--brand);
  color: var(--brand-text, #1a2e49);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* the hidden attribute always wins over a class's display */
[hidden] {
  display: none !important;
}

/* savings this month, in the header and on the TV */
.summary-economia b {
  color: #efca80;
}
