/* Alliance — Sede digital. Dark navy + gold (from the Alliance ERP icon). WCAG AA contrast on all text. */
:root {
  color-scheme: dark;
  --bg: #070b1a; --bg-2: #0b1126; --panel: #0f1730; --panel-2: #15203f; --panel-3: #1b2850;
  --line: #26345f; --line-2: #33457a;
  --text: #eef1f8; --muted: #aab4cf; --faint: #8390b3;
  --gold: #e6bf5c; --gold-2: #f3d68b; --accent: #8fb0ff;
  --ok: #4ade80; --work: #6ea8ff; --warn: #fbbf24; --bad: #fb7185; --plan: #b69cff; --done: #2dd4bf; --grey: #94a3b8;
  --radius: 14px; --tap: 44px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: radial-gradient(1200px 700px at 50% -10%, #13204a 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text); font: 15px/1.5 var(--font); display: flex; flex-direction: column; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: #1a1300; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
[hidden] { display: none !important; }

/* ---------- demo banner ---------- */
.demo-banner {
  background: repeating-linear-gradient(135deg, #5b3b00 0 14px, #6b4600 14px 28px); color: #fff4d6;
  text-align: center; padding: 8px 14px; font-size: .9rem; border-bottom: 2px solid var(--gold); z-index: 40;
}
.demo-banner strong { letter-spacing: .08em; background: #1a1300; color: var(--gold-2); padding: 2px 8px; border-radius: 6px; margin-right: 4px; }
.demo-banner a { color: #fff; font-weight: 600; margin-left: 8px; }
.demo-banner .short { display: none; }
@media (max-width: 600px) { .demo-banner { padding: 6px 10px; font-size: .82rem; } .demo-banner .long { display: none; } .demo-banner .short { display: inline; } }

/* ---------- header ---------- */
header.top {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(10,16,40,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand img { border-radius: 10px; box-shadow: 0 0 0 1px rgba(230,191,92,.35); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand .b1 { font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: .92rem; color: var(--gold-2); }
.brand .b2 { font-size: .78rem; color: var(--muted); }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a {
  color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: .9rem;
  min-height: 40px; display: inline-flex; align-items: center;
}
.mainnav a:hover { color: var(--text); background: var(--panel-2); }
.mainnav a[aria-current="page"] { color: #1a1300; background: var(--gold); }
.mainnav a.ext { font-weight: 400; font-size: .8rem; }
.search { position: relative; margin-left: auto; }
.search input {
  width: 300px; max-width: 42vw; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 9px 14px; min-height: 42px;
}
.search input::placeholder { color: var(--faint); }
.qresults {
  position: absolute; right: 0; top: calc(100% + 6px); width: min(440px, 92vw); max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); z-index: 50; padding: 6px;
}
.qres { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text); }
.qres:hover, .qres[aria-selected="true"] { background: var(--panel-3); }
.qres .qn { font-weight: 600; }
.qres .qp { font-size: .8rem; color: var(--muted); }
.qres .qt { font-size: .72rem; color: var(--gold-2); text-transform: uppercase; letter-spacing: .06em; margin-right: 6px; }
.menu-btn { display: none; min-height: var(--tap); padding: 0 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-2); }

/* ---------- breadcrumbs ---------- */
.crumbs {
  display: flex; align-items: center; gap: 4px; padding: 8px 18px; font-size: .9rem; overflow-x: auto; white-space: nowrap;
  border-bottom: 1px solid var(--line); background: rgba(11,17,38,.7);
}
.crumbs a, .crumbs span { padding: 6px 8px; border-radius: 8px; text-decoration: none; }
.crumbs a { color: var(--accent); }
.crumbs a:hover { background: var(--panel-2); }
.crumbs span[aria-current] { color: var(--text); font-weight: 700; }
.crumbs .sep { color: var(--faint); padding: 0 2px; }
.crumbs .back-btn { margin-right: 6px; }

/* ---------- stage ---------- */
.stage { flex: 1; position: relative; display: flex; min-height: 0; outline: none; }
.scene-wrap { position: relative; flex: 1; min-width: 0; min-height: 420px; }
.scene { position: absolute; inset: 0; touch-action: none; cursor: grab; }
.scene canvas { display: block; }
.scene.hovering { cursor: pointer; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.hud { position: absolute; left: 14px; top: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.hud button { display: grid; place-items: center; color: var(--text);
  width: var(--tap); height: var(--tap); border-radius: 12px; border: 1px solid var(--line-2); background: rgba(15,23,48,.9);
  font-size: 1.2rem; cursor: pointer; box-shadow: var(--shadow);
}
.hud button:hover { border-color: var(--gold); }
.scene-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: .8rem; color: var(--muted);
  background: rgba(10,16,40,.8); padding: 6px 12px; border-radius: 999px; pointer-events: none; text-align: center; max-width: 90%;
}
.legend {
  position: absolute; left: 70px; top: 14px; z-index: 6; width: 290px; background: rgba(15,23,48,.96); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 12px 14px; font-size: .85rem; box-shadow: var(--shadow);
}
.legend h3 { margin: 0 0 8px; font-size: .9rem; }
.legend ul { list-style: none; margin: 0 0 8px; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.legend p { margin: 6px 0 0; color: var(--muted); }

/* labels inside 3D */
.b-label {
  transform: translateY(-8px); text-align: center; pointer-events: none; font-family: var(--font);
  background: rgba(8,13,32,.82); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px 12px; color: var(--text);
  box-shadow: var(--shadow); white-space: nowrap;
}
.b-label .wm { font-weight: 800; letter-spacing: .08em; font-size: .95rem; }
.b-label.hq .wm { color: var(--gold-2); }
.b-label .sm { font-size: .72rem; color: var(--muted); }
.f-label {
  pointer-events: none; font-size: .75rem; background: rgba(8,13,32,.8); padding: 3px 8px; border-radius: 8px; white-space: nowrap;
  border-left: 3px solid var(--grey); color: var(--text); transform: translateX(50%);
}
/* office wing (pilot): compact room tags, full name only for the selected room */
.ala-label { display: inline-flex; gap: 6px; align-items: baseline; max-width: 10.5rem; border-left-width: 3px; background: rgba(10,22,60,.88); }
.ala-label .ala-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ala-label .ala-c { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.ala-label.sel { max-width: 18rem; font-size: .82rem; box-shadow: 0 0 0 1px rgba(110,168,255,.55); }
.a-label { pointer-events: none; font-size: .7rem; background: rgba(8,13,32,.85); padding: 2px 7px; border-radius: 7px; white-space: nowrap; color: var(--text); transform: translateY(14px); }

/* ---------- panel / bottom sheet ---------- */
.panel {
  width: 420px; flex-shrink: 0; border-left: 1px solid var(--line); background: rgba(12,19,42,.96); display: flex; flex-direction: column; min-height: 0;
}
.panel-body { overflow-y: auto; padding: 18px 18px 40px; flex: 1; }
.sheet-handle { display: none; }
.stage.page-mode .panel { display: none; }

.page { flex: 1; overflow-y: auto; padding: 22px clamp(14px, 3vw, 36px) 60px; }
.page-inner { max-width: 1180px; margin: 0 auto; }
.stage.panel-only .panel { width: 100%; border-left: 0; }
.stage.panel-only .panel-body { max-width: 900px; margin: 0 auto; width: 100%; }

/* ---------- typography & blocks ---------- */
h1.title { font-size: 1.55rem; margin: 2px 0 6px; line-height: 1.2; }
h2.sec { font-size: .82rem; text-transform: uppercase; letter-spacing: .09em; color: var(--gold-2); margin: 22px 0 10px; font-weight: 700; }
p.lead { color: var(--muted); margin: 0 0 12px; }
.kicker { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
}
a.card, button.card { display: block; width: 100%; text-align: left; text-decoration: none; color: var(--text); cursor: pointer; }
a.card:hover, button.card:hover { border-color: var(--gold); background: var(--panel-3); }
.card .ct { font-weight: 700; font-size: 1rem; }
.card .cs { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.card .cm { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--muted); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .n { font-size: 1.45rem; font-weight: 800; }
.stat .l { font-size: .78rem; color: var(--muted); }
dl.facts { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .88rem; }
dl.facts dd { margin: 0; }
@media (max-width: 520px) { dl.facts { grid-template-columns: 1fr; gap: 2px; } dl.facts dd { margin-bottom: 8px; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; text-decoration: none; color: var(--text); font-weight: 600;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); color: #1a1300; border-color: var(--gold); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .85rem; }

/* chips (filters) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.chip {
  min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer;
  font-size: .86rem; font-weight: 600; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--panel-3); color: var(--text); border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.chip .cnt { opacity: .8; margin-left: 4px; font-weight: 400; }

/* status badges */
.badge {
  text-transform: none; letter-spacing: 0;
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-ATIVO { color: var(--ok); background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.35); }
.st-A_TRABALHAR { color: var(--work); background: rgba(110,168,255,.12); border-color: rgba(110,168,255,.4); }
.st-PARADO { color: var(--grey); background: rgba(148,163,184,.12); border-color: rgba(148,163,184,.3); }
.st-BLOQUEADO { color: var(--bad); background: rgba(251,113,133,.12); border-color: rgba(251,113,133,.4); }
.st-PLANEADO { color: var(--plan); background: rgba(182,156,255,.1); border-color: rgba(182,156,255,.4); border-style: dashed; }
.st-CONCLUIDO { color: var(--done); background: rgba(45,212,191,.12); border-color: rgba(45,212,191,.35); }
.st-DESCONHECIDO { color: var(--grey); background: rgba(148,163,184,.08); border-color: rgba(148,163,184,.25); border-style: dotted; }
.badge.live::before { animation: pulse 1.6s ease-in-out infinite; box-shadow: 0 0 0 0 currentColor; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .badge.live::before, .skel { animation: none !important; } }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex-shrink: 0; }

/* freshness */
.fresh { position: relative; }
.fresh > summary { list-style: none; cursor: pointer; }
.fresh > summary::-webkit-details-marker { display: none; }
.fr { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .82rem; border: 1px solid; min-height: 36px; }
.fr-ATUALIZADO { color: var(--ok); border-color: rgba(74,222,128,.45); background: rgba(74,222,128,.08); }
.fr-DESATUALIZADO { color: var(--warn); border-color: rgba(251,191,36,.5); background: rgba(251,191,36,.08); }
.fr-AUSENTE { color: var(--bad); border-color: rgba(251,113,133,.5); background: rgba(251,113,133,.08); }
.fr-NAO_COMPROVADO { color: var(--grey); border-color: rgba(148,163,184,.45); background: rgba(148,163,184,.08); border-style: dashed; }
.fresh .pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(340px, 90vw); background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 12px 14px; z-index: 60; box-shadow: var(--shadow); font-size: .88rem;
}
.inline-fresh { margin: 4px 0 10px; }
.inline-fresh .pop { left: 0; right: auto; }

/* flags (4 separate capability flags) */
.flags { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
@media (max-width: 520px) { .flags { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.flag { border-radius: 10px; padding: 6px 8px; font-size: .78rem; border: 1px solid var(--line); background: var(--bg-2); }
.flag .fl { color: var(--muted); display: block; font-size: .72rem; }
.flag .fv { font-weight: 700; }
.flag.yes { border-color: rgba(74,222,128,.4); } .flag.yes .fv { color: var(--ok); }
.flag.no { border-color: rgba(251,113,133,.4); } .flag.no .fv { color: var(--bad); }
.flag.unk { border-style: dashed; } .flag.unk .fv { color: var(--faint); font-style: italic; }

/* technical details */
details.tech { margin-top: 12px; border: 1px dashed var(--line-2); border-radius: 12px; background: rgba(7,11,26,.5); }
details.tech > summary { cursor: pointer; padding: 10px 14px; color: var(--muted); font-size: .85rem; min-height: var(--tap); display: flex; align-items: center; }
details.tech[open] > summary { border-bottom: 1px dashed var(--line-2); }
details.tech .tbody { padding: 10px 14px; position: relative; }
details.tech pre {
  margin: 0; font: .78rem/1.45 var(--mono); color: #cfd8f0; white-space: pre-wrap; word-break: break-all; max-height: 340px; overflow: auto;
}
details.tech .copy { position: absolute; right: 10px; top: 8px; }

/* work (6 human fields) */
.work .wq { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; margin-top: 10px; font-size: .9rem; }
.work .wq dt { color: var(--muted); }
.work .wq dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.work .imp { color: var(--bad); font-weight: 600; }
@media (max-width: 520px) { .work .wq { grid-template-columns: 1fr; gap: 0; } .work .wq dd { margin-bottom: 8px; } }

/* process stepper */
.steps { list-style: none; margin: 0; padding: 0; position: relative; }
.steps > li { position: relative; padding: 0 0 18px 46px; }
.steps > li::before { content: ""; position: absolute; left: 17px; top: 36px; bottom: 0; width: 2px; background: var(--line-2); }
.steps > li:last-child::before { display: none; }
.steps .num {
  position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--panel-3); border: 2px solid var(--line-2);
}
.steps li.s-CONCLUIDO .num { border-color: var(--done); color: var(--done); }
.steps li.s-A_TRABALHAR .num { border-color: var(--work); color: var(--work); }
.steps li.s-BLOQUEADO .num { border-color: var(--bad); color: var(--bad); }
.steps li.s-VAZIO .num { border-style: dashed; color: var(--faint); }
.steps .sh { font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; color: var(--gold-2); font-weight: 700; padding-top: 7px; }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.t { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.t th, table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { background: var(--panel-2); color: var(--muted); font-weight: 600; position: sticky; top: 0; }
table.t tr:last-child td { border-bottom: 0; }
.yn { font-weight: 700; } .yn.y { color: var(--ok); } .yn.n { color: var(--bad); } .yn.u { color: var(--faint); font-style: italic; font-weight: 400; }

/* list view (tree) */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 22px; border-left: 1px dashed var(--line-2); margin-left: 12px; }
.tree li { margin: 4px 0; }
.tree .node {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text);
  min-height: var(--tap); border: 1px solid transparent;
}
.tree .node:hover, .tree .node:focus-visible { background: var(--panel-2); border-color: var(--line-2); }
.tree .lvl { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); min-width: 92px; }
.tree .nm { font-weight: 600; }

/* states */
.skel { background: linear-gradient(90deg, var(--panel-2) 0%, var(--panel-3) 50%, var(--panel-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.state-box { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 22px; background: var(--panel); text-align: left; }
.state-box.err { border-color: rgba(251,113,133,.5); }
.state-box h3 { margin: 0 0 6px; font-size: 1.05rem; }
.empty { color: var(--muted); padding: 14px; border: 1px dashed var(--line-2); border-radius: 12px; text-align: center; }
.notice { padding: 12px 14px; border-radius: 12px; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.4); margin-bottom: 14px; }

/* brain */
.brain-layout { display: grid; grid-template-columns: 1fr 360px; gap: 14px; }
.brain-canvas { position: relative; height: min(72vh, 760px); min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius); background: radial-gradient(800px 500px at 50% 30%, #101a3b, #080d20); }
.brain-canvas .cy { position: absolute; inset: 0; }
.brain-side { max-height: min(72vh, 760px); overflow-y: auto; }
.brain-filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 12px; }
.brain-filters .fg { display: flex; flex-direction: column; gap: 4px; }
.brain-filters label, .fg .lab { font-size: .78rem; color: var(--muted); }
select, .input {
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; min-height: 42px;
}
.layer-note { font-size: .8rem; color: var(--muted); }
.legend-inline { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); margin: 8px 0; }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.edge-key { width: 26px; height: 0; border-top: 3px solid; display: inline-block; }

/* login + toast */
.login { position: fixed; inset: 0; background: rgba(4,7,18,.88); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 200; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.login-card img { border-radius: 14px; align-self: center; }
.login-card h1 { font-size: 1.3rem; margin: 4px 0; text-align: center; }
.login-card p { color: var(--muted); margin: 0; font-size: .92rem; }
.login-card input { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; min-height: var(--tap); }
.login-err { color: var(--bad) !important; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-3); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 12px; z-index: 120; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }
.noscript { padding: 20px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .brain-layout { grid-template-columns: 1fr; }
  .brain-side { max-height: none; }
  .panel { width: 360px; }
}
@media (max-width: 860px) {
  header.top { flex-wrap: wrap; gap: 10px; padding: 8px 12px; }
  .search { order: 5; margin-left: 0; flex: 1 1 100%; }
  .search input { width: 100%; max-width: none; }
  .fresh-slot { order: 2; }
  .brand .b2 { display: none; }
  .crumbs { padding: 4px 10px; font-size: .85rem; }
  .scene-hint { display: none; }
  /* bottom sheet */
  .b-label { padding: 4px 8px; white-space: normal; max-width: 130px; }
  .b-label .wm { font-size: .72rem; letter-spacing: .03em; }
  .b-label .sm { display: none; }
  .hud { gap: 6px; left: auto; right: 10px; top: 10px; }
  .legend { left: 10px; right: 64px; }
  .stage.scene-mode .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 40%; border-left: 0; border-top: 1px solid var(--line-2);
    border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.45); z-index: 10; transition: height .25s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .stage.scene-mode .panel[data-sheet="full"] { height: 88%; }
  .stage.scene-mode .panel[data-sheet="min"] { height: 76px; }
  .stage.scene-mode .sheet-handle {
    display: flex; justify-content: center; align-items: center; min-height: 30px; width: 100%; background: none; border: 0; cursor: pointer; flex-shrink: 0;
  }
  .sheet-handle span { width: 46px; height: 5px; border-radius: 3px; background: var(--line-2); }
  .panel-body { padding: 4px 14px 30px; }
  .legend { width: auto; }
  h1.title { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.orig { display: inline-block; font-size: .68rem; font-weight: 600; color: var(--faint); border: 1px dashed var(--line-2); border-radius: 6px; padding: 0 6px; margin-left: 4px; vertical-align: middle; white-space: nowrap; }
.more { margin-top: 6px; }
.card .badge { white-space: normal; }

/* representation switcher */
.repbar { display: flex; align-items: center; gap: 10px; padding: 6px 18px; border-bottom: 1px solid var(--line); background: rgba(10,16,40,.85); overflow-x: auto; }
.repbar .mainnav { flex-wrap: nowrap; align-items: center; }
.repbar .mainnav a { white-space: nowrap; min-height: 38px; }
.navlab { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-right: 4px; white-space: nowrap; }
.navsep { width: 1px; height: 22px; background: var(--line-2); margin: 0 6px; flex-shrink: 0; }
.selchip { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; background: var(--panel-3); border: 1px solid var(--gold); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: .82rem; white-space: nowrap; max-width: 46vw; }
.selchip .t { overflow: hidden; text-overflow: ellipsis; }
.selchip button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--panel-2); cursor: pointer; font-size: 1rem; }
.ask-btn { min-height: 40px; }
/* Perguntar drawer */
.ask { position: fixed; right: 0; top: 0; bottom: 0; width: min(460px, 100%); background: var(--panel); border-left: 1px solid var(--line-2); z-index: 150; box-shadow: var(--shadow); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.ask .ask-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ask .ask-head h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.ask .ask-body { overflow-y: auto; padding: 14px 16px 40px; flex: 1; }
.ask .conv-turn, .ask .conv-src li { overflow-wrap: anywhere; }
.ask .conv-out { margin-bottom: 10px; }
.ask #convForm { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ask #convForm #convQ { flex: 1 1 100%; min-width: 0; }
.ask #askOut .card { overflow-wrap: anywhere; min-width: 0; }
.ask form { display: flex; gap: 8px; margin: 10px 0; }
.ask form input { flex: 1; }
/* organograma */
.org-emp { margin-bottom: 26px; }
.org-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.org-dep { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.org-dep > .row a { font-weight: 700; color: var(--text); text-decoration: none; }
.org-tree, .org-tree ul { list-style: none; margin: 0; padding: 0; }
.org-tree ul { margin-left: 14px; padding-left: 12px; border-left: 2px solid var(--line-2); }
.org-tree li { position: relative; margin: 6px 0; }
.org-tree ul > li::before { content: ""; position: absolute; left: -12px; top: 18px; width: 10px; border-top: 2px solid var(--line-2); }
.org-node { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; width: 100%; text-align: left; min-height: 40px; }
.org-node:hover { border-color: var(--gold); }
.org-node.boss { border-color: rgba(230,191,92,.5); }
.org-node .role { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.org-node .nm { font-weight: 600; }
.is-sel { outline: 3px solid var(--gold); outline-offset: 1px; }
.org-tasks { font-size: .82rem; margin: 4px 0 0 10px; }
.selbar { position: sticky; top: 0; z-index: 5; background: var(--panel-3); border: 1px solid var(--gold); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* agent tabs + status ladder */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line-2); margin: 16px 0 12px; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px; min-height: 44px; cursor: pointer; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); }
.ladder { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 10px; }
.orig-d { display: block; margin-top: 4px; font-size: .82rem; color: var(--muted); }
.orig-d summary { cursor: pointer; color: var(--faint); font-size: .75rem; }
.mode-banner { padding: 10px 14px; border-radius: 12px; margin-bottom: 10px; font-weight: 600; }
.mode-banner.live { background: rgba(110,168,255,.1); border: 1px solid rgba(110,168,255,.45); }
.mode-banner.replay { background: rgba(182,156,255,.1); border: 1px dashed rgba(182,156,255,.6); }
@media (max-width: 860px) { .repbar { padding: 4px 10px; } .navlab { display: none; } .ask-btn { order: 3; } .selchip { max-width: 60vw; } }

.b-label .wm-short { display: none; }
@media (max-width: 860px) { .b-label .wm-long { display: none; } .b-label .wm-short { display: inline; } .b-label { max-width: 110px; } }
.crumbs a, .crumbs span[aria-current], .crumbs > span:not(.sep) { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
@media (max-width: 860px) { .crumbs a, .crumbs > span:not(.sep) { max-width: 38vw; } .crumbs { scrollbar-width: none; } }
html, body { overflow-x: hidden; }

/* ---------- session indicator (§17) ---------- */
.sess-slot { position: relative; flex-shrink: 1; min-width: 0; }
.sess-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; max-width: 280px; padding: 0 12px; border-radius: 12px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line-2); font-size: .8rem; font-weight: 600; color: var(--text);
}
.sess-btn .sess-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sess-btn .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--grey); }
.sess-on .dot { background: var(--ok); }
.sess-off .dot { background: var(--warn); }
.sess-demo .dot { background: var(--gold); }
.sess-menu {
  position: absolute; right: 0; top: calc(100% + 6px); width: min(360px, calc(100vw - 24px)); z-index: 60;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.sess-menu h3 { margin: 0 0 8px; font-size: 1rem; }
.sess-menu dl.facts { grid-template-columns: 90px 1fr; margin-bottom: 8px; }
@media (max-width: 860px) {
  .sess-slot { order: 3; }
  .sess-btn { max-width: 46vw; }
  .sess-menu { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
}

/* ---------- loading with deadline, pagination ---------- */
.load-timer, .load-inline { margin: 6px 0; }
.load-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--gold); animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.pager .btn[disabled] { opacity: .45; cursor: default; }
.pager-info { color: var(--muted); }
.inline-err { border: 1px solid rgba(251,113,133,.4); background: rgba(251,113,133,.08); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }

/* ---------- defect fixes (visual verification 2026-09-27) ---------- */
/* mobile: long agent state badges wrapped instead of clipped */
.badge { white-space: normal; max-width: 100%; overflow-wrap: break-word; line-height: 1.3; }
.badge::before { flex-shrink: 0; }
/* desktop: wide tables scroll inside their own container instead of pushing the page wider */
.stage, .page, .panel, .page-inner { min-width: 0; }
.page-inner { width: 100%; }
.tablewrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tablewrap table.t { min-width: 720px; }
@media (max-width: 860px) {
  .sess-slot { order: 2; margin-left: auto; }
  .sess-btn { width: 44px; min-height: 40px; padding: 0; justify-content: center; }
  .sess-btn .sess-t { display: none; }
  .sess-btn .dot { width: 12px; height: 12px; }
  .brand .b1 { font-size: .8rem; letter-spacing: .1em; }
}
@media (max-width: 420px) { .brand-txt { display: none; } }
