:root {
  --bg: #0f1412; --panel: #161d1a; --panel2: #1d2622; --line: #2a3530; --text: #e8efe9; --muted: #8fa199;
  --accent: #3fb68b; --accent2: #c8f169; --warn: #f2c94c; --err: #ff7a6b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.error { color: var(--err); min-height: 1.2em; }

.login { display: grid; place-items: center; height: 100%; padding: 20px; }
.login form { width: min(360px, 100%); display: grid; gap: 14px; text-align: center; }
.logo { font-weight: 800; letter-spacing: .25em; font-size: 28px; color: var(--accent2); }
.logo.small { font-size: 20px; }
.login input { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.login button, .composer button { background: var(--accent2); color: #10200f; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer; }

#app { display: flex; flex-direction: column; height: 100%; }
header { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: .2em; color: var(--accent2); }
.projects { display: flex; gap: 6px; }
.projects button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.projects button.active { background: var(--accent); color: #07140f; border-color: var(--accent); font-weight: 700; }
.projects .badge { background: var(--warn); color: #222; border-radius: 999px; padding: 0 6px; margin-left: 6px; font-size: 12px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { background: transparent; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent2); font-weight: 700; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: var(--accent); } .status-dot.bad { background: var(--err); }
.icon-btn { background: transparent; border: 0; font-size: 20px; cursor: pointer; }
#menu-btn { display: none; }

main { flex: 1; min-height: 0; }
.tab { display: none; height: 100%; }
.tab.active { display: flex; }

aside { width: 320px; border-right: 1px solid var(--line); overflow: auto; padding: 14px; background: var(--panel); }
aside h3 { font-size: 14px; color: var(--muted); margin: 14px 0 8px; }
.list { display: grid; gap: 6px; }
.item { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; }
.item:hover, .item.active { background: var(--panel2); border-color: var(--line); }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #0b0f0d; flex: none; position: relative; }
.avatar.working::after { content: ''; position: absolute; inset: -3px; border-radius: 14px; border: 2px solid var(--accent2); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.item .meta { min-width: 0; }
.item .name { font-weight: 700; }
.item .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { margin-left: auto; background: var(--accent2); color: #10200f; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.pill.warn { background: var(--warn); }
.logout { display: block; margin-top: 24px; color: var(--muted); font-size: 13px; }

.chat { flex: 1; display: flex; min-width: 0; }
.empty { margin: auto; text-align: center; color: var(--muted); }
#chat-view { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-agent { font-weight: 800; font-size: 18px; }
.chat-head select { margin-left: auto; max-width: 45%; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 820px; padding: 12px 14px; border-radius: 14px; background: var(--panel2); line-height: 1.5; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: #24402f; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin: 0; }
.msg ul { margin: 4px 0 8px 18px; padding: 0; }
.msg code { background: #0008; padding: 1px 4px; border-radius: 4px; }
.typing { color: var(--accent2); font-style: italic; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; resize: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; max-height: 40vh; }

.office { flex: 1; position: relative; }
.office canvas { display: block; width: 100%; height: 100%; }
.office .label { position: absolute; transform: translate(-50%, -100%); pointer-events: none; text-align: center; white-space: nowrap; }
.office .label .n { background: #000a; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.office .label .b { display: inline-block; margin-bottom: 4px; background: var(--accent2); color: #10200f; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.office .label .b.work { background: var(--warn); }
.office .zone-label { position: absolute; transform: translate(-50%, -50%); pointer-events: none; color: #fff9; font-weight: 800; font-size: 13px; letter-spacing: .05em; }
.office-hint { position: absolute; left: 16px; bottom: 16px; max-width: 360px; background: #fff; color: #111; padding: 10px 14px; border-radius: 12px; font-size: 14px; }
#tab-kancelaria { position: relative; }

.structure { padding: 24px; overflow: auto; width: 100%; }
.tree { list-style: none; padding-left: 22px; border-left: 1px dashed var(--line); margin: 6px 0; }
.node { padding: 8px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; display: inline-flex; gap: 10px; align-items: center; margin: 4px 0; cursor: pointer; }
.node .role { color: var(--muted); font-size: 13px; }
.node.root { background: #1f3a2e; font-weight: 800; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #000d; padding: 10px 16px; border-radius: 10px; z-index: 50; }
.mobile-only { display: none; }

@media (max-width: 760px) {
  header { gap: 8px; }
  .tabs { margin-left: 0; width: 100%; justify-content: space-around; order: 5; }
  aside { width: 100%; border-right: 0; }
  #tab-praca.chat-open aside { display: none; }
  #tab-praca:not(.chat-open) .chat { display: none; }
  .mobile-only { display: inline-block; }
  .chat-head select { max-width: 40%; }
  .office-hint { right: 16px; font-size: 13px; }
}
