:root {
  color-scheme: dark;
  --bg: #0a0e17;
  --panel: #101623;
  --panel-2: #171f2f;
  --line: #24304272;
  --text: #e9eef7;
  --muted: #94a1b7;
  --teal: #3ecfe0;
  --amber: #f3b75f;
  --rose: #ff7a90;
  --green: #58d98c;
  --blue: #5f95ff;
  --shadow: rgba(2, 6, 16, 0.45);
  --rail-w: 84px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 480px at 80% -10%, rgba(95, 149, 255, 0.09), transparent 60%),
    radial-gradient(700px 400px at -10% 40%, rgba(62, 207, 224, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
}

.pin-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(16, 19, 24, 0.94);
}

.pin-box {
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px var(--shadow);
}

.pin-box input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  padding: 0 12px;
}

.pin-box .remember-pin {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pin-box .remember-pin input {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--teal);
}

.pin-box button {
  height: 44px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: #1d3a37;
  color: var(--text);
  cursor: pointer;
}

.pin-error {
  min-height: 18px;
  margin: 0;
  color: var(--rose);
  font-size: 13px;
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  background: rgba(16, 19, 24, 0.52);
  backdrop-filter: blur(2px);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(238, 242, 246, 0.22);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.small {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

.spinner.tiny {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.component-loader {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  background: rgba(18, 22, 28, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inline-loader {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) minmax(360px, 440px);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Side rail (main menu) ── */
.side-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 10px calc(16px + env(safe-area-inset-bottom));
  border-right: 1px solid var(--line);
  background: rgba(13, 18, 29, 0.92);
}

.rail-brand {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: #06111c;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.04em;
  flex: none;
  user-select: none;
}

.side-rail .top-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  width: 100%;
  min-height: 0;
}

.rail-sep {
  width: 32px;
  height: 1px;
  margin: 4px 0;
  background: var(--line);
  flex: none;
}

.rail-push {
  margin-top: auto;
  background: transparent;
}

@media (min-width: 981px) {
  .shell {
    height: 100dvh;
    overflow: hidden;
  }
}

body.detail-mode {
  height: 100dvh;
  overflow: hidden;
}

body.detail-mode .shell {
  height: 100dvh;
  overflow: hidden;
}

.office {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  border-right: 1px solid var(--line);
}

.office-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}

.agents-section {
  padding: 18px 22px 24px;
  overflow-y: auto;
}

.agents-section-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  align-content: start;
  min-height: 0;
}

/* Legacy office floor map — nothing renders into it anymore */
.floor {
  display: none !important;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 29, 0.9);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 10;
  overflow: visible;
}

.top-actions .nav-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 56px;
  height: 54px;
  padding: 4px 2px;
  border-radius: 12px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.top-actions .nav-btn:hover {
  background: rgba(95, 149, 255, 0.1);
}

.top-actions .nav-icon {
  font-size: 17px;
  line-height: 1;
}

.top-actions .nav-abbr {
  max-width: 100%;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions .nav-btn:hover .nav-abbr {
  color: var(--teal);
}

.top-actions .nav-btn::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 17, 26, 0.97);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 40;
}

.top-actions .nav-btn:hover::after,
.top-actions .nav-btn:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 20px;
  font-weight: 750;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.icon-btn,
.chat-form button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover,
.chat-form button:hover {
  border-color: var(--teal);
}

.floor {
  position: relative;
  min-height: calc(100vh - 86px);
  min-height: calc(100dvh - 86px);
  overflow: hidden;
  image-rendering: pixelated;
  background:
    repeating-linear-gradient(45deg, #3a3a3a 0 12px, #4a4a4a 12px 24px),
    repeating-linear-gradient(-45deg, #3a3a3a 0 12px, #4a4a4a 12px 24px),
    linear-gradient(180deg, #2f2f2f 0%, #262626 100%);
}

.floor-team-label {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 14, 20, 0.78);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.desks-grid {
  position: absolute;
  inset: 12% 6% 6%;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(var(--desk-cols, 3), minmax(0, 1fr));
  grid-auto-rows: minmax(150px, 1fr);
  gap: 20px 28px;
  align-content: center;
  justify-items: center;
}

.desk-pod {
  position: relative;
  width: min(100%, 180px);
  min-height: 150px;
  display: grid;
  place-items: end center;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.desk-pod:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.desk-pod.active {
  filter: drop-shadow(0 0 10px rgba(65, 214, 195, 0.35));
}

.desk-pod .char-chip {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  max-width: 160px;
}

.char-chip-gesture {
  font-size: 12px;
  line-height: 1;
}

.desk-computer {
  width: 96px;
  height: 96px;
  object-fit: contain;
  image-rendering: pixelated;
  z-index: 2;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35));
}

.desk-chair {
  position: absolute;
  bottom: 10px;
  width: 34px;
  height: 34px;
  object-fit: contain;
  image-rendering: pixelated;
  z-index: 1;
  opacity: 0.95;
}

.desk-avatar {
  position: absolute;
  bottom: 44px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  z-index: 4;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  background: #27313b;
}

.desk-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.zones-layer,
.deco-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.zones-layer {
  display: none;
}

.deco-layer {
  opacity: 0.35;
}

.zone {
  position: absolute;
  border: 1px solid rgba(var(--zone-color), 0.32);
  background: rgba(var(--zone-color), 0.06);
  border-radius: 14px;
  transition: left 0.5s ease, top 0.5s ease, width 0.5s ease, height 0.5s ease;
}

.zone-label {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: rgba(var(--zone-color), 0.65);
}

.deco {
  position: absolute;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  opacity: 0.92;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35));
}

.workstation {
  position: relative;
  left: auto;
  width: 100%;
  max-width: 100%;
  min-height: 78px;
  transform: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 40px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  box-shadow: 0 10px 30px var(--shadow);
  cursor: pointer;
  color: var(--text);
  z-index: 1;
  user-select: none;
  touch-action: none;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.workstation:hover {
  border-color: rgba(95, 149, 255, 0.45);
  transform: translateY(-1px);
}

.workstation.draggable {
  cursor: grab;
}

.workstation.dragging {
  z-index: 30;
  cursor: grabbing;
  border-color: var(--teal);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.45);
  opacity: 0.96;
}

.workstation:hover {
  z-index: 10;
}

.workstation.active {
  z-index: 12;
  border-color: var(--teal);
}

.workstation-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  flex: 0 0 auto;
}

.workstation-meta {
  min-width: 0;
  max-width: 100%;
  display: grid;
  gap: 3px;
  align-items: center;
}

.card-menu {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.card-menu-trigger {
  width: 30px;
  height: 30px;
  background: rgba(17, 21, 27, 0.86);
}

.workstation > .menu {
  right: 8px;
  top: 42px;
}

.walker {
  position: absolute;
  width: 64px;
  height: 64px;
  overflow: visible;
  z-index: 2;
  transform: translate(-50%, -50%);
  transition-property: left, top;
  transition-timing-function: ease-in-out;
  cursor: pointer;
  image-rendering: pixelated;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.walker .char-sprite {
  position: absolute;
  top: -1px;
  left: 0;
  height: 66px;
  image-rendering: pixelated;
  will-change: transform;
  clip-path: inset(1px 0);
  -webkit-clip-path: inset(1px 0);
  animation: sprite-cycle 0.5s steps(6) infinite;
}

.char-chip {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 140px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 14, 20, 0.92);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.char-chip-name {
  max-width: 104px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.5);
}

.char-chip.status-online .char-chip-dot {
  background: #4ade80;
}

.char-chip.status-busy .char-chip-dot {
  background: #fb7185;
}

.char-chip.status-standby .char-chip-dot {
  background: #fbbf24;
}

@keyframes sprite-cycle {
  from { transform: translateX(0); }
  to { transform: translateX(-384px); }
}

.walker.seated {
  height: 48px;
  z-index: 3;
  transform: translate(-50%, -168%);
}

.walker.seated .char-sprite {
  animation-duration: 1.2s;
}

.gesture-bubble {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 4;
}

.walker.seated .gesture-bubble {
  opacity: 1;
  animation: gesture-float 1.6s ease-in-out infinite;
}

@keyframes gesture-float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #27313b;
  color: var(--text);
  font-weight: 800;
  border: 2px solid rgba(255, 255, 255, 0.18);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-name {
  max-width: 100%;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-position {
  max-width: 100%;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 18px;
  width: fit-content;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.status-online {
  background: var(--green);
}

.status-standby {
  background: var(--amber);
}

.status-busy {
  background: var(--rose);
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--panel);
  padding: 22px;
}

@media (min-width: 981px) {
  .panel {
    height: 100dvh;
    overflow: hidden;
  }
}

body.detail-mode .panel {
  height: 100dvh;
  overflow: hidden;
}

.detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.monitor-page,
.hass-page,
.plane-page,
.mikrotik-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-mark {
  font-size: 44px;
  color: var(--teal);
}

.hidden {
  display: none !important;
}

.detail-head {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 42px;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  flex-shrink: 0;
}

.page-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.page-bar .icon-btn {
  width: 36px;
  height: 36px;
  font-size: 22px;
}

.page-toggle {
  margin-left: auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.detail.chat-summary-collapsed .detail-head,
.detail.chat-summary-collapsed .status-line,
.detail.chat-summary-collapsed .meta {
  display: none;
}

.agent-menu {
  position: relative;
  align-self: start;
}

.menu-trigger {
  width: 40px;
  height: 40px;
}

.menu {
  position: absolute;
  right: 0;
  top: 46px;
  z-index: 5;
  width: 150px;
  display: grid;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 18px 48px var(--shadow);
}

.menu button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
}

.menu button:hover {
  background: rgba(65, 214, 195, 0.12);
}

.menu .danger {
  color: #ffd6dd;
}

.detail-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 2px solid rgba(255, 255, 255, 0.14);
  font-size: 22px;
  font-weight: 800;
}

.detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  flex-shrink: 0;
}

.agent-form button,
.agent-form input,
.agent-form select,
.agent-form textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
}

.agent-form button {
  min-height: 38px;
  cursor: pointer;
}

.agent-form button:hover {
  border-color: var(--teal);
}

.meta {
  display: grid;
  gap: 10px;
  margin: 0 0 20px;
  flex-shrink: 0;
}

.meta div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.meta dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.meta dd {
  margin: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.page-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.info-page.page-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.manager,
.info-box,
.monitor-box,
.plane-box {
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.agent-form {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.agent-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.agent-form .check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.agent-form input,
.agent-form select {
  height: 38px;
  padding: 0 10px;
}

.agent-form textarea {
  resize: vertical;
  min-height: 58px;
  padding: 10px;
}

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

.coord-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.avatar-field {
  display: grid;
  gap: 8px;
}

.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-preview.empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.avatar-field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avatar-field-actions button {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.avatar-field-actions button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--rose);
  font-size: 13px;
}

.monitor-list {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: #11151b;
}

.monitor-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.monitor-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.monitor-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.monitor-title strong {
  color: var(--teal);
  font-size: 14px;
}

.monitor-title span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.monitor-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.monitor-meta div {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.monitor-meta dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.monitor-meta dd {
  margin: 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.plane-status {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.plane-status a {
  color: #8ec5ff;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.plane-status a:hover {
  text-decoration: underline;
}

.plane-links {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #11151b;
}

.plane-link {
  display: grid;
  gap: 4px;
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.025);
}

.plane-link:hover {
  border-color: var(--teal);
}

.plane-link span {
  color: var(--teal);
  font-weight: 800;
}

.plane-link small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.mikrotik-router-card {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.mikrotik-router-card strong {
  font-size: 13px;
}

.mikrotik-router-card span {
  color: var(--muted);
  font-size: 11px;
}

.mikrotik-router-card:hover,
.mikrotik-router-card.active {
  border-color: var(--teal);
}

.mikrotik-router-card.active {
  background: rgba(65, 214, 195, 0.08);
}

.mikrotik-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mikrotik-hint {
  margin: 0;
  padding: 10px 12px 0;
  color: var(--muted);
  font-size: 12px;
}

.mikrotik-shortcuts {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.mikrotik-shortcut-input {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.mikrotik-shortcut-input input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
}

.mikrotik-shortcut-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mikrotik-shortcut-status {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.plane-issue-form {
  border-top: 0;
  border-bottom: 1px solid var(--line);
}

.plane-issues-list {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: #11151b;
}

.plane-issue {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.plane-issue strong {
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.plane-issue span,
.plane-issue small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.bill-diff {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid rgba(65, 214, 195, 0.22);
  border-radius: 8px;
  background: rgba(65, 214, 195, 0.07);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.bill-diff.saved {
  color: var(--text);
}

.plane-issue-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.plane-issue-card div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.plane-issue-card strong {
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.plane-issue-card span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.plane-issue-card a {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.monitor-meta dd a {
  color: #8ec5ff;
  text-decoration: none;
}

.monitor-meta dd a:hover {
  text-decoration: underline;
}

.monitor-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.monitor-steps span,
.monitor-steps button {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
}

.monitor-steps button {
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.monitor-steps button:hover {
  border-color: var(--teal);
  background: rgba(105, 210, 122, 0.08);
}

.monitor-steps button.failed:hover {
  border-color: rgba(255, 122, 144, 0.7);
  background: rgba(255, 122, 144, 0.08);
}

.monitor-steps .passed {
  border-color: rgba(105, 210, 122, 0.45);
  color: #c8f4d0;
}

.monitor-steps .failed {
  border-color: rgba(255, 122, 144, 0.45);
  color: #ffd6dd;
}

.monitor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.monitor-actions button {
  flex: 1 1 120px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  cursor: pointer;
}

.monitor-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.monitor-actions button:hover {
  border-color: var(--teal);
}

.monitor-actions .monitor-enabled-btn {
  font-weight: 700;
}

.monitor-actions .monitor-enabled-btn.is-enabled {
  border-color: rgba(105, 210, 122, 0.55);
  background: rgba(105, 210, 122, 0.14);
  color: #c8f4d0;
}

.monitor-actions .monitor-enabled-btn.is-enabled:hover {
  border-color: rgba(105, 210, 122, 0.9);
  background: rgba(105, 210, 122, 0.2);
}

.monitor-actions .monitor-enabled-btn.is-disabled {
  border-color: rgba(255, 122, 144, 0.5);
  background: rgba(255, 122, 144, 0.1);
  color: #ffd6dd;
}

.monitor-actions .monitor-enabled-btn.is-disabled:hover {
  border-color: rgba(255, 122, 144, 0.85);
  background: rgba(255, 122, 144, 0.16);
}

.monitor-actions button.danger {
  border-color: rgba(255, 122, 144, 0.45);
  color: var(--rose);
}

.monitor-notify-options {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.monitor-notify-options label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.monitor-step-detail {
  display: grid;
  gap: 0;
}

.monitor-step-detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.monitor-step-detail-meta div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.monitor-step-detail-meta .monitor-step-detail-wide {
  grid-column: 1 / -1;
}

.monitor-step-detail-meta dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.monitor-step-detail-meta dd {
  margin: 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.monitor-step-detail-meta .passed-text {
  color: #c8f4d0;
}

.monitor-step-detail-meta .failed-text {
  color: #ffd6dd;
}

.monitor-step-detail-body {
  background: #0d1015;
}

.monitor-step-detail-body pre {
  margin: 0;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  color: var(--text);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.monitor-inline-pre {
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1015;
  color: var(--text);
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 160px;
  overflow: auto;
}

.form-note {
  min-height: 18px;
  margin: 0;
  color: var(--teal);
  font-size: 13px;
}

.info-content {
  padding: 10px;
  background: #11151b;
}

.info-section {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.info-section summary {
  padding: 10px 12px;
  cursor: pointer;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

.info-section pre {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--text);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.skills-box {
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.skills-head-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.skills-name-summary {
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-toggle-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}

.skill-toggle-btn:hover {
  border-color: var(--teal);
}

.skills-content {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: #11151b;
}

.skill-card {
  display: grid;
  gap: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.skill-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

.skill-card-title {
  flex: 1;
  min-width: 0;
}

.skill-card-head strong {
  color: var(--teal);
  font-size: 13px;
}

.skill-card-meta {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-card-body {
  border-top: 1px solid var(--line);
  background: #0d1015;
}

.skill-card-body pre {
  margin: 0;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  color: var(--text);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.skill-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.skill-card-actions button,
.skills-box .head-actions button,
.skill-form button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  cursor: pointer;
}

.skills-box .head-actions .skill-toggle-btn {
  min-height: 30px;
  padding: 0;
}

.skill-form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-template-columns: none;
}

.skill-form-actions .inline-loader {
  flex: 1;
  min-width: 0;
}

.skill-form-actions button {
  flex: 1;
}

.skill-card-actions button:hover,
.skills-box .head-actions button:hover,
.skill-form button:hover {
  border-color: var(--teal);
}

.skill-card-actions button.danger {
  border-color: rgba(255, 122, 144, 0.45);
  color: var(--rose);
}

.skill-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.skill-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.skill-form input,
.skill-form select,
.skill-form textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
}

.skill-form input,
.skill-form select {
  height: 38px;
  padding: 0 10px;
}

.skill-form textarea {
  resize: vertical;
  min-height: 180px;
  padding: 10px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.memory-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.memory-actions button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  cursor: pointer;
}

.memory-actions button:hover {
  border-color: var(--teal);
}

.chat-source {
  color: var(--muted);
  font-size: 11px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-editor {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  min-height: 180px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  resize: vertical;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.chat-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-head button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  cursor: pointer;
}

.chat-log {
  flex: 1;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #11151b;
}

.chat-log.loading {
  opacity: 0.72;
}

.chat-empty {
  height: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.chat-date {
  margin: 14px 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.message-wrap {
  display: grid;
  gap: 4px;
  max-width: 92%;
  margin-bottom: 10px;
}

.message-wrap.user {
  margin-left: auto;
  justify-items: end;
}

.message-wrap.agent,
.message-wrap.error {
  justify-items: start;
}

.message-time {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  padding: 0 4px;
}

.message {
  width: fit-content;
  max-width: 100%;
  margin-bottom: 0;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.4;
  font-size: 14px;
  white-space: pre-wrap;
  animation: messageIn 0.16s ease-out;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  margin-left: auto;
  background: #24423e;
}

.message.agent {
  background: #252b34;
}

.message.error {
  background: #46242c;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50px;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  flex-shrink: 0;
}

.chat-form textarea {
  resize: vertical;
  min-height: 52px;
  max-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151b;
  color: var(--text);
  padding: 10px;
}

@media (max-width: 1280px) {
  .shell {
    grid-template-columns: var(--rail-w) minmax(0, 1fr) minmax(340px, 400px);
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  /* Side rail becomes a fixed bottom bar */
  .side-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(11, 15, 24, 0.95);
    backdrop-filter: blur(12px);
  }

  .rail-brand {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 12px;
  }

  .side-rail .top-actions {
    flex-direction: row;
    justify-content: space-around;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .side-rail .top-actions::-webkit-scrollbar {
    display: none;
  }

  .rail-sep {
    width: 1px;
    height: 30px;
    margin: 0 2px;
    flex: none;
  }

  .rail-push {
    margin-top: 0;
    margin-left: auto;
  }

  .top-actions .nav-btn {
    width: 52px;
    height: 50px;
    flex: none;
  }

  /* Tooltip above the button in bottom-bar mode */
  .top-actions .nav-btn::after {
    left: 50%;
    top: auto;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
  }

  body {
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }

  .office {
    border-right: 0;
  }

  .office-body {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
    border-top: 1px solid var(--line);
  }

  body.detail-mode .office {
    display: none;
  }

  /* Full-screen page view: hide the bar, panel has its own back button */
  body.detail-mode .side-rail {
    display: none;
  }

  body.detail-mode {
    padding-bottom: 0;
  }

  body.detail-mode .panel {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    border-top: 0;
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 60px;
    padding: 10px 14px;
  }

  h1 {
    font-size: 18px;
  }

  h2 {
    font-size: 20px;
  }

  .agents-section {
    padding: 14px;
  }

  .agents-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
  }

  .panel {
    padding: 16px;
  }

  .empty-state {
    min-height: 220px;
  }

  .detail-head {
    grid-template-columns: 64px minmax(0, 1fr) 42px;
  }

  .detail-avatar {
    width: 64px;
    height: 64px;
  }

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

@media (max-width: 440px) {
  .pin-box {
    width: calc(100vw - 24px);
    padding: 18px;
  }

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

  .panel {
    padding: 12px;
  }

  .chat-form {
    grid-template-columns: minmax(0, 1fr) 44px;
    padding: 8px;
  }

  .chat-form button {
    width: 44px;
    height: 44px;
  }

  .message {
    max-width: 96%;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .char-sprite {
    animation: none !important;
  }

  .walker {
    transition: none !important;
  }

  .workstation,
  .top-actions .nav-btn {
    transition: none !important;
  }
}
