:root {
  --ink: #1c2430;
  --muted: #5c6b7a;
  --paper: #f3efe6;
  --paper-2: #e7e1d4;
  --line: #c9c0b0;
  --teal: #0f6b6b;
  --teal-deep: #0a4f4f;
  --amber: #c9842a;
  --rose: #a33b4a;
  --ok: #2f7d4a;
  --shadow: 0 18px 50px rgba(28, 36, 48, 0.12);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Outfit", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15, 107, 107, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(201, 132, 42, 0.12), transparent 50%),
    linear-gradient(180deg, #f7f4ec 0%, var(--paper) 45%, #ebe4d7 100%);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.brand { display: flex; gap: 0.85rem; align-items: center; }
.brand__mark {
  width: 2.5rem; height: 2.5rem; border-radius: 0.8rem;
  background: linear-gradient(145deg, var(--teal), var(--teal-deep));
}
.brand__eyebrow {
  margin: 0; font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.brand__title {
  margin: 0.05rem 0 0; font-family: var(--font-display);
  font-size: 1.4rem; font-weight: 700; line-height: 1.1;
}

.nav {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
}
.nav__btn {
  border: 1px solid transparent;
  background: rgba(255,255,255,0.4);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.nav__btn.is-active,
.nav__btn:hover {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.topbar__badge {
  margin: 0;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.55);
  font-size: 0.8rem;
  color: var(--muted);
}

.demo-banner {
  margin: 0 0 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  border: 1px dashed var(--amber);
  background: rgba(201, 132, 42, 0.12);
  font-size: 0.9rem;
}

.view[hidden],
[hidden] { display: none !important; }

/* Mantener el canvas Phaser con tama?o estable al salir de Oficina (evita WebGL negro) */
#view-floor.view-floor--parked {
  display: block !important;
  position: absolute !important;
  left: -10000px !important;
  top: 0 !important;
  width: 960px !important;
  height: 640px !important;
  overflow: hidden !important;
  visibility: hidden !important;
  pointer-events: none !important;
  z-index: -1 !important;
}
#view-floor.view-floor--parked .office-stage,
#view-floor.view-floor--parked .game-root {
  height: 640px !important;
  min-height: 640px !important;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-head h2 {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
}
.muted { color: var(--muted); margin: 0.25rem 0 0; }
.tiny { font-size: 0.8rem; }
.subh { margin: 0 0 0.6rem; font-size: 1rem; }
.warn {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(163, 59, 74, 0.1);
  color: var(--rose);
  font-size: 0.85rem;
}

.card {
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(201,192,176,0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  backdrop-filter: blur(8px);
}
.card--narrow { max-width: 420px; margin: 2rem auto; }

/* ?? Escena oficina 2D ?? */
.scene-shell {
  padding: 0.75rem;
  overflow: hidden;
}
.scene-wrap {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #d4cbb8;
  box-shadow: inset 0 0 0 1px rgba(28, 36, 48, 0.08);
}
.scene-wrap svg.office-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(72vh, 640px);
}
.scene-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  margin-top: 0.65rem;
  padding: 0 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.scene-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.dot {
  width: 0.55rem; height: 0.55rem; border-radius: 50%; display: inline-block;
}
.dot--ok { background: var(--ok); }
.dot--busy { background: var(--teal); }
.dot--wait { background: var(--amber); }
.dot--err { background: var(--rose); }

.office-room {
  cursor: pointer;
  transition: filter 0.2s ease;
}
.office-room:hover .room-floor,
.office-room:focus-within .room-floor {
  filter: brightness(1.06);
}
.office-room:focus { outline: none; }
.office-room:focus-visible .room-hit {
  stroke: var(--teal);
  stroke-width: 3;
}

.agent-fig {
  cursor: pointer;
  outline: none;
}
.agent-fig:focus-visible .agent-halo {
  opacity: 1;
}
.agent-halo { opacity: 0; transition: opacity 0.15s ease; }

.agent-fig.is-trabajando .agent-body {
  animation: work-bob 1.1s ease-in-out infinite;
}
.agent-fig.is-trabajando .screen-glow {
  animation: screen-pulse 1.2s ease-in-out infinite;
}
.agent-fig.is-esperando_aprobacion .status-badge {
  animation: wait-pulse 1.6s ease-in-out infinite;
}
.agent-fig.is-error .status-badge {
  animation: err-blink 1s steps(2, end) infinite;
}

@keyframes work-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes screen-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@keyframes wait-pulse {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}
@keyframes err-blink {
  50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .agent-fig.is-trabajando .agent-body,
  .agent-fig.is-trabajando .screen-glow,
  .agent-fig.is-esperando_aprobacion .status-badge,
  .agent-fig.is-error .status-badge {
    animation: none !important;
  }
}

.a11y-depts {
  margin-top: 0.9rem;
}
.a11y-depts__label {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.a11y-depts__btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.agent-tooltip {
  position: fixed;
  z-index: 50;
  min-width: 160px;
  max-width: 240px;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(28, 36, 48, 0.94);
  color: #f3efe6;
  font-size: 0.82rem;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.agent-tooltip strong { display: block; font-size: 0.9rem; margin-bottom: 0.15rem; }

.agent.is-selected {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.5rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; background: var(--paper-2);
}
.pill--ok { background: rgba(47,125,74,0.15); color: var(--ok); }
.pill--busy { background: rgba(15,107,107,0.14); color: var(--teal-deep); }
.pill--wait { background: rgba(201,132,42,0.18); color: #8a5a12; }
.pill--err { background: rgba(163,59,74,0.14); color: var(--rose); }
.pill--demo { background: #1c2430; color: #f3efe6; }

.chat-task-list {
  margin: 0.55rem 0 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  line-height: 1.35;
}
.chat-task-list li { margin: 0; }

.dept-layout {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 1rem;
}
@media (max-width: 800px) {
  .dept-layout { grid-template-columns: 1fr; }
}

.agents { display: grid; gap: 0.55rem; }
.agent {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.7rem;
  align-items: center; padding: 0.65rem; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
}
.avatar {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--teal);
}
.avatar--fiscal { background: #355c7d; }
.avatar--laboral { background: #6b4f3a; }
.avatar--admin { background: #3d5a4c; }
.agent__name { margin: 0; font-weight: 600; }
.agent__role { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--muted); }

.chat__hint { margin: 0 0 0.55rem; font-size: 0.85rem; color: var(--muted); }
.chat__log {
  max-height: 220px; overflow: auto; display: grid; gap: 0.4rem; margin-bottom: 0.65rem;
}
.bubble {
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: min(92%, 34rem);
  word-break: break-word;
}
.bubble--user {
  background: rgba(15, 107, 107, 0.14);
  justify-self: end;
  border-bottom-right-radius: 4px;
}
.bubble--bot {
  background: #fff;
  border: 1px solid rgba(28, 36, 48, 0.08);
  justify-self: start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(15, 28, 48, 0.04);
}
.chat__form { display: grid; grid-template-columns: 1fr auto; gap: 0.45rem; }
.chat__form input, .form input, .form select, .form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 0.6rem 0.7rem; font: inherit; background: #fff;
}

.btn {
  border: 0; border-radius: 10px; padding: 0.55rem 0.85rem;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-deep); }
.btn--ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn--ok { background: var(--ok); color: #fff; }
.btn--danger { background: var(--rose); color: #fff; }
.btn--sm { padding: 0.35rem 0.6rem; font-size: 0.82rem; }

.split {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
}

.form { display: grid; gap: 0.65rem; }
.form label { display: grid; gap: 0.3rem; font-size: 0.88rem; font-weight: 600; }
.form .check { display: flex; align-items: center; gap: 0.45rem; font-weight: 500; }
.form__actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.table-wrap { overflow: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 0.88rem;
}
table.data th, table.data td {
  text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }

.trays-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}
@media (max-width: 700px) {
  .trays-board { grid-template-columns: 1fr; }
}
.tray-col {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.65);
  padding: 0.85rem;
}
.tray-col h3 { margin: 0 0 0.55rem; font-size: 1rem; }
.proposal {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  background: #fff;
  margin-bottom: 0.55rem;
}
.proposal__title { margin: 0; font-weight: 600; }
.proposal__meta { margin: 0.25rem 0 0.5rem; font-size: 0.8rem; color: var(--muted); }
.proposal__actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* Modal documento (estilo Facturas) */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(28, 36, 48, 0.55);
  backdrop-filter: blur(4px);
}
.modal__dialog {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.4rem;
}
.modal__dialog--wide { max-width: 560px; }
.modal__dialog--xl { max-width: 820px; }
.modal__title {
  font-family: var(--display, Georgia, serif);
  color: var(--ink);
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
  padding-right: 2rem;
}
.modal__lead { color: var(--muted); margin: 0 0 1rem; font-size: 0.92rem; }

.btn--orders {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.btn-orders__ico { font-size: 1rem; line-height: 1; }

.orders-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.orders-list__item {
  border: 1px solid rgba(28, 36, 48, 0.1);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: var(--paper-2, #f6f4ef);
}
.orders-list__title {
  display: block;
  color: var(--ink);
  font-size: 0.98rem;
  margin-bottom: 0.35rem;
}
.orders-list__desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}
.orders-list__ex {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: var(--ink);
  line-height: 1.35;
}
.orders-list__ex-label {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--teal-deep, #0f6b6b);
  background: rgba(15, 107, 107, 0.1);
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.orders-list__empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}
.modal__close {
  position: absolute; top: 0.7rem; right: 0.7rem;
  width: 2rem; height: 2rem; border: none; border-radius: 50%;
  background: var(--paper-2); color: var(--muted); font-size: 1.3rem; cursor: pointer;
}
.modal__actions { display: flex; justify-content: flex-end; gap: 0.55rem; flex-wrap: wrap; margin-top: 0.5rem; }
.modal__actions--top { margin: 0 0 1rem; padding-right: 2rem; }

.doc {
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(28, 36, 48, 0.1);
  border-radius: 12px;
  padding: 1.5rem;
}
.doc__head {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.35rem;
  padding-bottom: 1.1rem;
  border-bottom: 2px solid var(--teal);
}
.doc__logo-mark {
  width: 64px; height: 64px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--teal), var(--teal-deep));
  color: #fff; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.02em;
  margin-bottom: 0.4rem;
}
.doc__brand { font-family: var(--font-display); font-size: 1.2rem; color: var(--teal-deep); }
.doc__emisor { font-size: 0.86rem; color: var(--muted); margin-top: 0.3rem; line-height: 1.45; }
.doc__meta { text-align: right; }
.doc__tipo {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.45rem;
  background: #e6f3f3;
  color: var(--teal-deep);
}
.doc__tipo--borrador { background: #f5e8d4; color: #8a5a12; }
.doc__num { font-size: 1.3rem; font-weight: 700; color: var(--teal-deep); }
.doc__dates { font-size: 0.88rem; color: var(--muted); margin-top: 0.3rem; }
.doc__parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}
.doc__box {
  background: var(--paper);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  font-size: 0.88rem;
}
.doc__box h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.doc-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-bottom: 0.9rem; }
.doc-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid rgba(28, 36, 48, 0.15);
}
.doc-table td { padding: 0.6rem 0.35rem; border-bottom: 1px solid rgba(28, 36, 48, 0.08); vertical-align: top; }
.doc-table .num { text-align: right; white-space: nowrap; }
.doc-row-suplido td { color: var(--muted); }
.doc__totales { margin-left: auto; width: min(280px, 100%); font-size: 0.9rem; }
.doc__totales div { display: flex; justify-content: space-between; padding: 0.3rem 0; }
.doc__totales .grand {
  font-weight: 700; font-size: 1.08rem;
  border-top: 2px solid var(--teal); margin-top: 0.3rem; padding-top: 0.5rem; color: var(--teal-deep);
}
.doc__nota { margin-top: 0.9rem; font-size: 0.82rem; color: var(--muted); }
.doc__footer {
  margin-top: 1.35rem; padding-top: 0.75rem;
  border-top: 1px solid rgba(28, 36, 48, 0.1);
  font-size: 0.76rem; color: var(--muted); text-align: center;
}
@media (max-width: 700px) {
  .doc__parties { grid-template-columns: 1fr; }
  .doc__head { flex-direction: column; }
  .doc__meta { text-align: left; }
}

.draft-edit {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.draft-edit h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-family: var(--font-display);
}
.draft-edit__hint { margin: 0 0 0.75rem; font-size: 0.8rem; color: var(--muted); }
.draft-edit-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-bottom: 0.65rem; }
.draft-edit-table th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); padding: 0.35rem 0.25rem; border-bottom: 1px solid var(--line);
}
.draft-edit-table td { padding: 0.35rem 0.25rem; vertical-align: middle; border-bottom: 1px solid rgba(28,36,48,0.06); }
.draft-edit-table input[type="text"],
.draft-edit-table input[type="number"] {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 0.35rem 0.45rem; font: inherit; background: #fff;
}
.draft-edit-table .col-desc { min-width: 12rem; }
.draft-edit-table .col-num { width: 4.5rem; }
.draft-edit-table .col-iva { width: 4rem; }
.draft-edit-table .col-tipo { width: 5.5rem; }
.draft-edit-table .col-del { width: 2.2rem; }
.draft-edit-table select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 0.35rem 0.3rem; font: inherit; background: #fff;
}
.draft-edit__tools { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.65rem; }
.draft-edit__notas label {
  display: grid; gap: 0.25rem; font-size: 0.8rem; font-weight: 600; margin-top: 0.45rem;
}
.draft-edit__notas input {
  border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.5rem; font: inherit; background: #fff;
}
.draft-edit__totales {
  margin-top: 0.55rem; font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem;
  color: var(--muted);
}
.draft-edit__totales strong { color: var(--teal-deep); }

.filters { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.filters button.is-on { background: var(--teal); color: #fff; border-color: var(--teal); }

.step-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.35rem; }
.step-list li {
  display: flex; justify-content: space-between; gap: 0.5rem;
  padding: 0.45rem 0.55rem; border-radius: 8px; background: var(--paper-2); font-size: 0.85rem;
}

.footer {
  margin-top: 1.75rem; text-align: center; color: var(--muted); font-size: 0.82rem;
}
.footer p { margin: 0; }

.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 0.7rem 1rem; border-radius: 999px;
  font-size: 0.9rem; z-index: 40; box-shadow: var(--shadow);
}

.vehicle-item {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem;
  background: #fff; margin-bottom: 0.5rem; cursor: pointer; font: inherit;
}
.vehicle-item:hover { border-color: var(--teal); }
.vehicle-item.is-active { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }

/* ===== Fase 1.3 ? secci?n Oficina (Phaser embebido) ===== */
.office-toolbar { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.office-stage {
  position: relative;
  padding: 0;
  overflow: hidden;
  min-height: min(78vh, 720px);
  height: min(78vh, 720px);
}
.game-root {
  width: 100%;
  height: 100%;
  min-height: min(78vh, 720px);
  position: relative;
  background: #c4b8a4;
}
.game-root canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
kbd {
  font-family: var(--font-body);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.3rem;
  font-size: 0.85em;
}

.panel {
  position: fixed;
  z-index: 40;
  top: 5.5rem;
  right: 0.75rem;
  bottom: 0.75rem;
  width: min(400px, calc(100vw - 1.5rem));
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.panel--chat .chat__log { flex: 1; min-height: 140px; }
.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.panel__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
}
.panel .chat__form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.touch-pad {
  display: none;
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  z-index: 25;
  gap: 0.35rem;
  flex-direction: column;
  align-items: center;
}
.touch-mid { display: flex; gap: 0.35rem; }
.touch-pad button {
  width: 48px; height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
@media (max-width: 900px), (pointer: coarse) {
  .touch-pad { display: flex; }
}

/* Ampliar ?rea de juego */
body.oficina-expanded .app {
  max-width: none;
  padding: 0.5rem;
}
body.oficina-expanded .office-stage,
body.oficina-expanded .game-root {
  height: calc(100vh - 9rem);
  min-height: calc(100vh - 9rem);
}
body.oficina-expanded .demo-banner,
body.oficina-expanded .footer,
body.oficina-expanded .scene-legend {
  display: none;
}

/* ===== Fase 1.5 ? editor de oficina ===== */
.office-edit-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: stretch;
}
body.oficina-editing .office-edit-layout {
  grid-template-columns: minmax(180px, 220px) 1fr minmax(180px, 240px);
}
.edit-panel {
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  max-height: min(78vh, 720px);
  overflow: auto;
}
.edit-panel h3, .edit-panel h4 {
  margin: 0.4rem 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1rem;
}
.edit-panel h4 {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.85rem;
}
.edit-catalog-list { display: flex; flex-direction: column; gap: 0.35rem; }
.edit-cat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: #fff;
  cursor: pointer;
  font: inherit;
}
.edit-cat-item:hover { border-color: var(--teal); background: #f7fffe; }
.edit-cat-item span { color: var(--muted); font-size: 0.8rem; }
.edit-props { font-size: 0.92rem; line-height: 1.45; }
.edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem;
  background: rgba(28,36,48,0.92);
  border-radius: 12px 12px 0 0;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 30;
}
.edit-toolbar .btn { color: #fff; border-color: rgba(255,255,255,0.25); }
.edit-toolbar .btn--primary { background: var(--teal); border-color: var(--teal); }
body.oficina-editing .office-stage { padding-top: 0; }
body.oficina-editing .game-root { padding-top: 3rem; }
body.oficina-editing .touch-pad { display: none !important; }
@media (max-width: 960px) {
  body.oficina-editing .office-edit-layout {
    grid-template-columns: 1fr;
  }
  .edit-panel { max-height: 220px; }
}

.edit-build-tools { margin-top: 0.75rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }
.edit-tool-row { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.45rem; }
.btn--sm { font-size: 0.78rem; padding: 0.3rem 0.45rem; }
body.oficina-editing #edit-build-tools { display: block !important; }
.edit-hint { font-size: 0.75rem; margin: 0.2rem 0 0.45rem; line-height: 1.35; }
.edit-agents-list { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.5rem; }
.edit-agent-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  text-align: left; width: 100%; padding: 0.4rem 0.5rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer;
}
.edit-agent-item:hover, .edit-agent-item.is-active { border-color: var(--teal); background: #f7fffe; }
.edit-agent-item strong { font-size: 0.85rem; }
.edit-agent-item span { color: var(--muted); font-size: 0.72rem; }

/* Chat agentes (workspace overlay) */
.workspace-overlay {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  pointer-events: auto;
}
.workspace-overlay[hidden] { display: none !important; }
.workspace-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 28, 40, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}
.workspace-panel {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(92vh, 820px);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.1rem 1.15rem 1rem;
  margin: 0.75rem;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(15, 28, 48, 0.28);
  overflow: hidden;
  animation: workspace-in 0.22s ease;
}
@keyframes workspace-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  flex-shrink: 0;
}
.workspace-head__text { min-width: 0; }
.workspace-eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal-deep, #0f6b6b);
}
.workspace-head h2 {
  margin: 0.15rem 0 0;
  font-size: 1.35rem;
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.2;
}
.workspace-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.workspace-close {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: var(--paper-2, #f3f1eb);
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.workspace-close:hover { background: #ebe7df; color: var(--ink); }
.workspace-chat {
  flex: 1 1 auto;
  min-height: 180px;
  max-height: min(48vh, 420px);
  overflow: auto;
  display: grid;
  gap: 0.55rem;
  align-content: start;
  padding: 0.75rem;
  background: linear-gradient(180deg, #faf9f6 0%, #fff 40%);
  border: 1px solid rgba(28, 36, 48, 0.08);
  border-radius: 14px;
}
.workspace-toolbar,
.workspace-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}
.workspace-quick {
  max-height: 5.5rem;
  overflow: auto;
  padding-bottom: 0.1rem;
}
.workspace-composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: end;
  flex-shrink: 0;
  padding: 0.55rem;
  background: var(--paper-2, #f6f4ef);
  border: 1px solid rgba(28, 36, 48, 0.1);
  border-radius: 16px;
}
.workspace-input {
  width: 100%;
  min-height: 2.75rem;
  max-height: 8rem;
  resize: vertical;
  border: none;
  background: #fff;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(28, 36, 48, 0.08);
  outline: none;
}
.workspace-input:focus {
  box-shadow: inset 0 0 0 2px rgba(15, 107, 107, 0.35);
}
.workspace-input::placeholder { color: #9aa3ad; }
.workspace-send {
  align-self: stretch;
  min-height: 2.75rem;
  padding-inline: 1.1rem;
  border-radius: 12px;
}
.workspace-status {
  margin: 0;
  min-height: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}
.workspace-form { display: flex; gap: 0.4rem; align-items: center; }
.workspace-form input { flex: 1; }
body.ov-chat-open { overflow: hidden; }

@media (min-width: 720px) {
  .workspace-overlay {
    align-items: center;
    padding: 1.25rem;
  }
  .workspace-panel {
    margin: 0;
    max-height: min(88vh, 780px);
  }
  .workspace-chat {
    min-height: 240px;
    max-height: min(52vh, 460px);
  }
}
@media (max-width: 520px) {
  .workspace-overlay { align-items: stretch; }
  .workspace-panel {
    width: 100%;
    max-height: 100%;
    height: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    padding: 0.9rem 0.85rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }
  .workspace-composer {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "mic input"
      "send send";
  }
  .workspace-composer .btn--mic { grid-area: mic; }
  .workspace-input { grid-area: input; }
  .workspace-send { grid-area: send; width: 100%; }
  .workspace-quick { max-height: 4.2rem; }
  .workspace-head h2 { font-size: 1.2rem; }
}
.ov-file-btn { cursor: pointer; display: inline-flex; align-items: center; }
.ov-adjuntos {
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; min-height: 0.5rem;
}
.ov-adjunto-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.2rem 0.45rem 0.2rem 0.55rem; color: var(--ink);
}
.ov-adjunto-x {
  border: 0; background: transparent; cursor: pointer; font-size: 1rem;
  line-height: 1; color: var(--muted); padding: 0 0.15rem;
}
.ov-adjunto-x:hover { color: var(--rose); }
.ov-adjunto-hint { font-size: 0.78rem; color: var(--muted); }
/* En escritorio usamos getUserMedia; en móvil el input capture es más fiable */
.ov-cam-mobile { display: none; }
@media (max-width: 820px) {
  .ov-cam-mobile { display: inline-flex; }
  button[data-ws="camera"] { display: none; }
}

.ov-camera {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(28, 36, 48, 0.72);
  backdrop-filter: blur(4px);
  border-radius: inherit;
}
.ov-camera[hidden] { display: none !important; }
.ov-camera__panel {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 0.9rem;
  box-shadow: var(--shadow);
}
.ov-camera__title {
  margin: 0 0 0.55rem;
  font-weight: 700;
  font-size: 0.95rem;
}
.ov-camera__video {
  display: block;
  width: 100%;
  max-height: 52vh;
  object-fit: cover;
  border-radius: 10px;
  background: #111;
  aspect-ratio: 4 / 3;
}
.ov-camera__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.btn--mic {
  flex: 0 0 auto;
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn--mic:hover:not(:disabled) { background: #fff; border-color: var(--teal); }
.btn--mic:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--mic .mic-icon {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 40% 40% 45% 45%;
  background: currentColor;
  position: relative;
  display: block;
}
.btn--mic .mic-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.28rem;
  width: 0.55rem;
  height: 0.28rem;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 6px 6px;
  transform: translateX(-50%);
}
.btn--mic.is-listening {
  background: var(--rose);
  border-color: var(--rose);
  color: #fff;
  animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(163, 59, 74, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(163, 59, 74, 0); }
}
