/* Painel: empresas e funcionários. Usa as cores de style.css (:root). */
html.admin-page, html.admin-page body { height: auto; min-height: 100%; overflow: auto; }
html.admin-page body { background: radial-gradient(1200px 500px at 50% -200px, #2c2a52 0%, var(--bg) 70%) fixed, var(--bg); }
.admin-page svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------ topo */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; padding: 0 24px; background: #1d1f2bcc; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #8b7cf6, #5b4bd6); box-shadow: 0 4px 14px #6c5ce755; }
.brand-sep { width: 1px; height: 18px; background: var(--line); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 4px; }
.user-chip .who { display: flex; flex-direction: column; line-height: 1.25; }
.user-chip .who b { font-size: 13px; }
.user-chip .who span { font-size: 11px; }

/* ------------------------------------------------ botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, filter .15s; }
.btn:hover { border-color: #ffffff2e; filter: brightness(1.12); }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.btn.primary { width: auto; padding: 0 16px; background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 6px 18px #6c5ce740; }
.btn.danger-solid { background: var(--danger); border-color: transparent; color: #fff; }
.btn.icon { width: 36px; padding: 0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card); }

/* ------------------------------------------------ página */
.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.head-title { display: flex; align-items: center; gap: 16px; }
.crumbs { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }

/* resumo */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.stat b { display: block; font-size: 24px; line-height: 1.1; }
.stat span:not(.stat-icon) { color: var(--muted); font-size: 12px; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: #6c5ce726; color: #b3a9ff; }
.stat-icon.live { background: #4caf6a24; color: #7fdc9a; }

/* tabela */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.panel-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; min-width: min(320px, 100%); border-radius: 9px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 13px; }
.segmented { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.segmented button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.segmented button.on { background: var(--card); color: var(--text); }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #ffffff06; }
.table tr.clickable { cursor: pointer; }
.table tr.inactive .cell-main, .table tr.inactive td:nth-child(2) { opacity: .5; }
.table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.table td.actions .btn { height: 32px; }
.cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-main .lines { display: flex; flex-direction: column; min-width: 0; }
.cell-main .lines b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-main .lines span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you { font-size: 11px; font-weight: 600; color: #b3a9ff; margin-left: 6px; }

/* iniciais coloridas */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-size: 13px; font-weight: 700; color: #fff; position: relative; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }
.avatar.square { border-radius: 10px; }
.avatar.online::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--panel); }

/* etiquetas */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--card); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: #4caf6a1f; color: #7fdc9a; }
.pill.off { background: #e052521f; color: #ff9696; }
.pill.admin { background: #6c5ce726; color: #c2b9ff; }
.pill.admin::before, .pill.plain::before { display: none; }
.page-head .pill { font-size: 12px; }

/* vazio */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 48px 16px; }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--card); color: var(--muted); margin-bottom: 6px; }
.empty p { margin: 0 0 12px; }

/* menu "⋯" */
.menu { position: fixed; z-index: 40; min-width: 200px; padding: 6px; background: var(--card); border: 1px solid #ffffff1f; border-radius: 12px; box-shadow: 0 16px 40px #000a; display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: #ffffff10; }
.menu button.danger { color: #ff8a8a; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ------------------------------------------------ janelas */
.modal { width: min(560px, calc(100% - 32px)); padding: 0; border: 1px solid #ffffff1a; border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 30px 80px #000c; }
.modal.sm { width: min(420px, calc(100% - 32px)); }
.modal.wide { width: min(1040px, calc(100% - 32px)); }
.modal::backdrop { background: #0b0c14b3; backdrop-filter: blur(3px); }
.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-head { padding: 22px 24px 4px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head p { margin: 6px 0 0; font-size: 13px; line-height: 1.45; }
.modal-body { padding: 16px 24px 4px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 22px; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
fieldset + fieldset { margin-top: 6px; }
legend { padding: 0; margin-bottom: 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.input { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #c9cce0; }
.input small { font-weight: 400; font-size: 12px; }
.input input { height: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid #ffffff1c; background: var(--bg); color: var(--text); font: inherit; font-weight: 400; outline: 0; transition: border-color .15s, box-shadow .15s; }
.input input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #6c5ce733; }
.input input::placeholder { color: #6d7290; }
.password { display: flex; gap: 8px; }
.password input { flex: 1; min-width: 0; }
.password .btn { height: 40px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: flex; flex-direction: column; gap: 3px; height: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid #ffffff1c; background: var(--bg); transition: border-color .15s, background .15s; }
.choice b { font-size: 13px; color: var(--text); }
.choice small { color: var(--muted); font-weight: 400; }
.choice input:checked + span { border-color: var(--accent); background: #6c5ce71a; box-shadow: 0 0 0 3px #6c5ce722; }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px #6c5ce755; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 9px; background: #e052521f; color: #ffb0b0; font-size: 13px; }

/* dados de acesso */
.success-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: #4caf6a24; color: #7fdc9a; margin-bottom: 12px; }
.success-icon svg { width: 22px; height: 22px; }
.access { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; padding: 14px 16px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.access dt { color: var(--muted); }
.access dd { margin: 0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; }

/* avisos */
.toasts { position: fixed; top: 72px; right: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast-item { display: flex; align-items: center; gap: 10px; max-width: 380px; padding: 12px 14px; border-radius: 11px; background: var(--card); border: 1px solid #ffffff1a; box-shadow: 0 12px 30px #0009; font-size: 13px; animation: slide .2s ease-out; }
.toast-item::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.toast-item.error::before { background: var(--danger); }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } }

/* ------------------------------------------------ editor do mapa */
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
html.admin-page body.editing { overflow: hidden; }
.editor { position: fixed; top: 60px; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; z-index: 10; background: var(--bg); }
.editor-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.editor-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.editor-title b { font-size: 15px; }
.editor-actions { display: flex; gap: 8px; }
.editor-actions .btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.editor-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 280px 1fr 280px; }
.editor-catalog, .editor-inspector { min-height: 0; overflow-y: auto; background: var(--panel); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.editor-catalog { border-right: 1px solid var(--line); }
.editor-inspector { border-left: 1px solid var(--line); }
.editor-catalog .search { min-width: 0; }
.cat-sector summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 6px 2px; list-style-position: inside; }
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0 10px; }
.cat-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); cursor: pointer; font: inherit; font-size: 11px; line-height: 1.2; text-align: center; }
.cat-item:hover { border-color: #ffffff30; }
.cat-item.on { border-color: var(--accent); background: #6c5ce726; }
.cat-item canvas { width: 56px; height: 56px; image-rendering: pixelated; border-radius: 6px; }
.editor-stage { position: relative; min-width: 0; min-height: 0; display: flex; }
#me-scroll { flex: 1; overflow: auto; padding: 12px; }
#me-canvas { display: block; image-rendering: pixelated; border-radius: 6px; box-shadow: 0 10px 40px #0008; touch-action: none; }
.editor-zoom { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 6px; padding: 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 8px 24px #0008; }
.editor-hint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 10px; background: #6c5ce7; color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px #0008; pointer-events: none; }
.editor-hint:empty { display: none; }
.insp-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.insp-head b { font-size: 16px; }
#me-selected { display: flex; flex-direction: column; gap: 12px; }
#me-selected .input input, #me-selected .input select { height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.insp-actions { display: flex; gap: 8px; }
.insp-actions .btn { flex: 1; }
#me-problems:empty { display: none; }
#me-problems { padding: 12px; border-radius: 10px; background: #e052521a; border: 1px solid #e0525240; font-size: 13px; }
#me-problems b { color: #ffb0b0; }
#me-problems ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; color: #ffd0d0; }
#me-problems li.clickable { cursor: pointer; text-decoration: underline dotted; }
.editor-help { margin-top: auto; display: flex; flex-direction: column; gap: 4px; font-size: 12px; line-height: 1.5; }
@media (max-width: 1100px) {
  .editor-body { grid-template-columns: 220px 1fr; }
  .editor-inspector { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
  .editor-body { grid-template-rows: 1fr auto; }
}

/* ------------------------------------------------ celular */
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .user-chip .who, .brand-sep, .brand .muted, #btn-office .label { display: none; }
  .page { padding: 24px 16px 60px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat-icon { display: none; }
  .stat b { font-size: 20px; }
  .grid-2, .choices { grid-template-columns: 1fr; }
  .table thead { display: none; }
  .table tr { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 4px 10px; }
  .table td:first-child { grid-column: 1; }
  .table td.actions { grid-column: 2; grid-row: 1; }
  .table td:not(:first-child):not(.actions) { grid-column: 1 / -1; display: inline-block; }
  .segmented { overflow-x: auto; max-width: 100%; }
}

/* escolha do mapa (planta) */
.plan-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.plan-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.plan-card canvas { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; border-radius: 8px; background: #14151f; image-rendering: pixelated; }
.plan-card h3 { display: flex; align-items: center; gap: 8px; margin: 2px 0 0; font-size: 15px; }
.plan-card p { flex: 1; margin: 0; font-size: 12.5px; line-height: 1.45; }
.plan-card .plan-size { font-size: 12px; font-weight: 600; color: var(--muted); }
.plan-card .plan-actions { display: flex; gap: 6px; }
.plan-card .plan-actions .btn { flex: 1; padding: 0 8px; }

/* cor do objeto: lista pronta + seletor de qualquer cor */
.me-color { display: flex; gap: 6px; align-items: center; }
.me-color select { flex: 1; min-width: 0; }
.me-pick { width: 36px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; flex: none; }

/* saúde das chamadas */
.panel.health { margin-top: 16px; }
.health-head { display: flex; flex-direction: column; gap: 2px; }
.health-head b { font-size: 15px; }
.health-summary { display: flex; gap: 6px; flex-wrap: wrap; }
.health-alert { margin: 12px 14px 0; padding: 10px 12px; border-radius: 10px; background: #e0525222; border: 1px solid #e0525266; font-size: 13px; }
.panel.health td.cause { color: var(--muted); font-size: 12.5px; max-width: 420px; line-height: 1.45; }
.panel.health td.nowrap { white-space: nowrap; }
.pill.warn { background: #f2b63233; color: #ffd77a; }
.pill.muted-pill { background: var(--card); color: var(--muted); }
.panel.health .lines { display: flex; flex-direction: column; min-width: 0; }
