:root {
  --bg: #eef2f7; --panel: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #0f1b2d; --brand2: #16263f; --accent: #f97316; --primary: #2563eb; --danger: #dc2626; --ok: #16a34a;
  --radius: 10px; --side: 290px; --panelw: 400px; --top: 54px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overflow: hidden; font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1em; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
a { color: var(--primary); }
h3 { margin: 0; font-size: 16px; }
h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #cbd5e1; background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.08); }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.icon-btn { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: inherit; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.mini { border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; font-size: 12px; padding: 1px 6px; cursor: pointer; line-height: 18px; }
.mini:hover { background: #f1f5f9; }

/* ---------- formulários ---------- */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field > span { font-weight: 600; }
.field.full { grid-column: 1 / -1; }
.field.check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
.field.check > span { font-weight: 500; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid #cbd5e1; border-radius: 8px; padding: 7px 9px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #60a5fa; }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; }
input[type=color] { padding: 2px; height: 34px; }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

/* ---------- login ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #1e3a5f, var(--brand)); }
.login-card { width: min(360px, 92vw); background: #fff; border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card h1 { font-size: 18px; margin: 0 0 4px; text-align: center; }
.login-logo { width: 56px; height: 56px; align-self: center; }

/* ---------- estrutura ---------- */
#app { position: fixed; inset: 0; display: grid; grid-template-rows: var(--top) 1fr; grid-template-columns: var(--side) 1fr auto; grid-template-areas: "top top top" "side map panel"; }
#top { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--brand); color: #fff; z-index: 20; }
#btnMenu { display: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: 12px; }
.search input { width: 100%; background: var(--brand2); border-color: #2b3f5f; color: #fff; }
.search input::placeholder { color: #94a3b8; }
#searchResults { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; color: var(--ink); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.25); max-height: 60vh; overflow: auto; z-index: 50; }
.sr { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 4px; }
.sr:hover { background: #f1f5f9; }
.top-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.25); min-width: 230px; padding: 6px; z-index: 60; display: flex; flex-direction: column; }
.menu button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; display: flex; align-items: center; gap: 8px; }
.menu button:hover { background: #f1f5f9; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.dropdown.up .menu { bottom: calc(100% + 6px); top: auto; left: 0; right: auto; }
.mobile-only { display: none !important; }

#side { grid-area: side; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 8px 14px 30px; z-index: 10; }
.side-head { display: none; }
#side section { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; }
.tree-row { display: flex; align-items: center; gap: 5px; padding: 4px; border-radius: 6px; }
.tree-row:hover { background: #f1f5f9; }
.tree-row.active { background: #e0ecff; }
.tree-row.active .tree-name { color: #1d4ed8; font-weight: 700; }
.tree-children { display: none; }
.tree-group.open > .tree-children, .tree-group.hov > .tree-children { display: block; }
.chev { width: 18px; height: 18px; border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1; color: #475569; transition: transform .15s; padding: 0; flex: none; }
.chev:disabled { cursor: default; }
.tree-group.open > .tree-row .chev, .tree-group.hov > .tree-row .chev { transform: rotate(90deg); }
.tree-group.open > .tree-row .chev { color: #1d4ed8; }
.fold-ico { line-height: 0; flex: none; }
.tree-name { flex: 1; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-name:hover { color: var(--primary); }
.tree-actions { display: none; gap: 2px; }
.tree-row:hover .tree-actions { display: inline-flex; }
.count { color: var(--muted); font-size: 11px; }
.role { font-size: 10px; color: #475569; background: #e2e8f0; border-radius: 4px; padding: 0 4px; }
.layer { display: flex; align-items: center; gap: 6px; padding: 4px 2px; cursor: pointer; }
.layer .count { margin-left: auto; }
.layer-lbl { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; min-width: 0; }
.layer.opt { font-size: 13px; padding-left: 26px; }
.chev.rot { transform: rotate(90deg); color: #1d4ed8; }
.layer-list { margin: 2px 0 8px 26px; border-left: 2px solid #e2e8f0; padding-left: 8px; max-height: 320px; overflow: auto; }
.layer-q { width: 100%; padding: 4px 8px; font-size: 12px; margin: 2px 0 6px; }
.ll-folder { font-size: 11px; color: #64748b; font-weight: 700; display: flex; align-items: center; gap: 4px; margin: 6px 0 2px; }
.ll-folder .count { margin-left: auto; }
.ll-folder span:first-child { line-height: 0; }
.ll-item { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ll-item:hover { background: #eef2ff; color: #1d4ed8; }
.ll-ico { line-height: 0; }
.layer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.swatch { width: 18px; height: 12px; display: inline-block; flex: none; }
.swatch.line { height: 4px; background: var(--accent); border-radius: 2px; }
.swatch.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); border: 2px solid #111; margin: 0 4px; }
.swatch.pill { border-radius: 6px; background: var(--c); }
.swatch.ring { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--c); margin: 0 3px; }
.swatch.square { background: var(--c); border-radius: 2px; }
.legend-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 13px; }
.lg-line { display: inline-block; width: 22px; height: 5px; border-radius: 3px; flex: none; vertical-align: middle; }
.lg-line.big { width: 26px; height: 7px; }

#mapWrap { grid-area: map; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #d9dee5; }
.map-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 24px; }
#tools { position: absolute; left: 12px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.tool { width: 58px; height: 54px; border: 0; border-radius: 12px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.25); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font: inherit; }
.tool span { font-size: 19px; line-height: 1; }
.tool small { font-size: 10px; color: var(--muted); font-weight: 600; }
.tool:hover { background: #f8fafc; }
#addMenu { min-width: 210px; }
#modeBar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(15,27,45,.95); color: #fff; border-radius: 12px; padding: 8px 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; z-index: 6; max-width: calc(100% - 140px); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
#modeBar .btn { padding: 5px 10px; }
#modeBar select { padding: 4px 6px; }
#modeBar .muted { color: #cbd5e1; }

#panel { grid-area: panel; width: var(--panelw); background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 12px 14px 30px; z-index: 10; }
.panel-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.panel-head > div:first-child { flex: 1; min-width: 0; }
.panel-head h3 { display: flex; align-items: center; gap: 4px; word-break: break-word; }
.panel-head .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.sect { margin-top: 8px; }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row.click, tr.click { cursor: pointer; }
.list-row.click:hover, tr.click:hover { background: #f8fafc; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: #f8fafc; border-radius: 8px; padding: 10px; }
.kv > div { display: flex; flex-direction: column; font-size: 13px; }
.kv span { color: var(--muted); font-size: 11px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.kpis > div { background: #f1f5f9; border-radius: 8px; padding: 8px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; }
.kpis b { font-size: 15px; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #eef2ff; border-radius: 14px; padding: 3px 4px 3px 10px; font-size: 12px; }
.inline { margin-top: 8px; display: flex; }
.inline select { flex: 1; }
.notice { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 10px; }
.steps { padding-left: 20px; margin: 0; font-size: 12px; }
.steps li { margin: 3px 0; }
.badge { display: inline-grid; place-items: center; min-width: 26px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--c); color: #fff; font-size: 9px; font-weight: 800; vertical-align: middle; }
.badge.dot { min-width: 12px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #111; }
.badge.ring { min-width: 16px; background: #fff; color: var(--c); border: 3px solid var(--c); border-radius: 50%; height: 16px; }
.badge.square { border-radius: 3px; }
.fdot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1px solid #334155; vertical-align: -1px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--line); padding: 6px; }
.tbl td { border-bottom: 1px solid var(--line); padding: 6px; vertical-align: middle; }
.tbl tr.off td { opacity: .5; }
.tbl td .btn + .btn { margin-left: 4px; }
td.good, .rx.good { color: var(--ok); font-weight: 700; }
td.warn, .rx.warn { color: #ca8a04; font-weight: 700; }
td.bad, .rx.bad { color: var(--danger); font-weight: 700; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.modal.wide { width: min(980px, 100%); }
.modal.full { width: 100%; height: 100%; max-height: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 16px; overflow: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.import-preview { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.export-tree { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; }
.toast { background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90vw; transition: opacity .3s, transform .3s; }
.toast.ok { background: #166534; }
.toast.error { background: #991b1b; }
.toast.out { opacity: 0; transform: translateY(10px); }

/* ---------- administração ---------- */
.adm { display: grid; grid-template-columns: 190px 1fr; gap: 16px; min-height: 420px; }
.adm-nav { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); padding-right: 10px; }
.adm-nav button { border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 8px; cursor: pointer; font: inherit; }
.adm-nav button.on { background: #eff6ff; color: var(--primary); font-weight: 700; }
.adm-content { min-width: 0; overflow: auto; }
.adm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.help { margin-top: 16px; background: #f8fafc; border-radius: 10px; padding: 4px 14px 10px; font-size: 13px; }

/* ---------- marcadores do mapa ---------- */
.mk { position: relative; transform: translateY(50%); cursor: pointer; line-height: 0; -webkit-user-select: none; user-select: none; touch-action: none; }
.mk svg { display: block; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.65)); transition: transform .12s; }
.mk:hover svg { transform: scale(1.15); }
.mk-label { display: none; position: absolute; top: calc(100% + 2px); left: 50%; transform: translateX(-50%); white-space: nowrap; font: 700 11px/1.2 system-ui, sans-serif; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 2px #000; pointer-events: none; }
.show-labels .mk-label { display: block; }
.mk.sel svg { filter: drop-shadow(0 0 2px #ffe600) drop-shadow(0 0 5px #ffe600) drop-shadow(0 0 9px #ffe600); }
.mk.hl svg { filter: drop-shadow(0 0 2px #ff00d4) drop-shadow(0 0 6px #ff00d4); }
.mk.moving svg { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.3); } }
.vx { width: 11px; height: 11px; border-radius: 50%; background: #ffe600; border: 2px solid #000; transform: translateY(50%); }
.vx.snap { background: #22c55e; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 3px rgba(26,115,232,.35); transform: translateY(50%); }
.map-tip { position: absolute; z-index: 7; pointer-events: none; background: rgba(15,23,42,.92); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.kb { display: inline-flex; vertical-align: middle; line-height: 0; }
.kb svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.lyr-ico { display: inline-flex; width: 22px; justify-content: center; line-height: 0; }

/* ---------- situação (modo projeto) ---------- */
.mk.st-projetado svg { opacity: .55; filter: drop-shadow(0 0 0 #000) grayscale(.3); }
.mk.st-projetado::after, .mk.st-construcao::after { content: ''; position: absolute; inset: -3px; border: 2px dashed #64748b; border-radius: 50%; pointer-events: none; }
.mk.st-construcao::after { border-color: #f59e0b; }
body.project-mode #mapWrap::after { content: 'MODO PROJETO'; position: absolute; top: 10px; left: 12px; background: #f59e0b; color: #111; font: 800 11px system-ui; padding: 3px 8px; border-radius: 6px; z-index: 5; }
.mk-cliente svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.pin { transform: translateY(50%); }
.pin span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; font: 800 13px system-ui; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.pin-viab span { background: #2563eb; }
.pin-otdr span { background: #dc2626; animation: pulse 1s infinite; }
.viab-res { padding: 10px; border-radius: 8px; font-weight: 700; margin: 6px 0 10px; }
.viab-res.ok { background: #dcfce7; color: #166534; }
.viab-res.no { background: #fee2e2; color: #991b1b; }
.ok-txt { color: var(--ok); font-weight: 700; }
.bad-txt { color: var(--danger); font-weight: 700; }
.dot-on { color: var(--ok); }
.tag { font-size: 10px; border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.tag.res { background: #fef3c7; color: #92400e; }
.cli-ico { line-height: 0; display: inline-flex; vertical-align: -2px; }
table.ports td { padding: 4px 6px; }
.otdr-hit { border: 1px solid #fecaca; background: #fff7f7; border-radius: 10px; padding: 4px 10px 10px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.photos figcaption { font-size: 10px; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.tbl-wrap { max-height: 60vh; overflow: auto; }

/* ---------- cartão de informações (clique no mapa) ---------- */
.icard { font: 13px/1.35 system-ui, sans-serif; color: #0f172a; min-width: 230px; max-width: 320px; display: flex; flex-direction: column; gap: 6px; }
.ic-head { display: flex; align-items: center; gap: 8px; }
.ic-head b { font-size: 14px; }
.ic-ico { line-height: 0; }
.ic-stats { background: #f1f5f9; border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.ic-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.ic-actions .btn { padding: 4px 8px; font-size: 12px; }
.ic-tip { font-size: 11px; color: #64748b; }

/* ---------- diagrama de fusões ---------- */
.fz { display: flex; flex-direction: column; height: 100%; gap: 8px; }
.modal.full .modal-body { padding: 10px 12px; display: flex; flex-direction: column; }
.fz-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seg { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; font: inherit; font-weight: 600; }
.seg button.on { background: var(--brand); color: #fff; }
.zoom { display: inline-flex; gap: 2px; }
.fz-sel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #f1f5f9; border-radius: 8px; padding: 8px 10px; min-height: 40px; font-size: 13px; }
.fz-sel .hint { color: #c026d3; font-weight: 600; }
.fz-sel input.loss { width: 90px; padding: 4px 6px; }
.fz-sel input.note-in { width: 300px; max-width: 100%; padding: 4px 6px; }
.fz-add input.note-in { flex: 1; min-width: 160px; }
.note { color: #8a6100; font-weight: 600; }
.endlink { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.fz-sel select { padding: 4px 6px; }
.fz-canvas { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; min-height: 200px; -webkit-overflow-scrolling: touch; }
.fz-canvas svg { display: block; }
.fz-canvas .empty { padding: 40px; text-align: center; }
.fz-canvas .tbl { background: #fff; }
.fz-add { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.fz-add select { flex: 1; min-width: 200px; }

/* ---------- topologia ---------- */
ul.topo, ul.topo ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed #cbd5e1; }
ul.topo { padding-left: 0; border: 0; }
.topo-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; margin: 3px 0; background: #f8fafc; font-size: 13px; }
.topo-item[onclick], .topo-item.cto, .topo-item.splitter { cursor: pointer; }
.topo-item:hover { background: #eef2ff; }
.t-ico { font-size: 9px; font-weight: 800; color: #fff; border-radius: 6px; padding: 2px 5px; background: #64748b; }
.topo-item.pon .t-ico { background: #dc2626; }
.topo-item.splitter .t-ico { background: #f97316; }
.topo-item.cto .t-ico { background: #16a34a; }

/* ---------- celular ---------- */
@media (max-width: 820px) {
  :root { --top: 52px; }
  #app { grid-template-columns: 1fr; grid-template-areas: "top" "map"; }
  #btnMenu { display: block; color: #fff; }
  .brand span { display: none; }
  .search { margin-left: 0; }
  .top-actions .btn.ghost:not(#btnUser) { display: none; }
  #btnUser #userName { display: none; }
  .mobile-only { display: flex !important; }
  #side { position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 88vw); transform: translateX(-110%); transition: transform .2s; z-index: 40; }
  body.side-open #side { transform: none; box-shadow: 0 0 30px rgba(0,0,0,.4); }
  .side-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
  #panel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 62vh; border-radius: 16px 16px 0 0; border-left: 0; box-shadow: 0 -10px 30px rgba(0,0,0,.3); z-index: 30; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  #tools { bottom: 24px; left: 8px; gap: 6px; }
  .tool { width: 52px; height: 48px; }
  #modeBar { left: 8px; right: 8px; transform: none; max-width: none; top: 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-back { padding: 0; }
  .modal { max-height: 100vh; height: auto; border-radius: 14px 14px 0 0; align-self: end; }
  .modal.full, .modal.wide { height: 100%; border-radius: 0; }
  .adm { grid-template-columns: 1fr; }
  .adm-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 6px; }
  .adm-nav button { white-space: nowrap; }
  .kv { grid-template-columns: 1fr 1fr; }
  .fz-toolbar .btn, .seg button { padding: 5px 9px; font-size: 13px; }
  .fz-canvas .tbl thead { display: none; }
  .fz-canvas .tbl tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  .fz-canvas .tbl td { border: 0; padding: 0; font-size: 12px; }
  .fz-canvas .tbl td:nth-child(1), .fz-canvas .tbl td:nth-child(2) { flex: 1 1 45%; font-weight: 600; }
  .fz-canvas .tbl td:nth-child(3) { flex: 1; color: var(--muted); }
  .fz-add select { min-width: 0; flex: 1 1 100%; }
}

/* Permissões */
.perm-intro { margin: 0 0 12px; font-size: 13px; line-height: 1.45; }
.perm-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; background: var(--panel); }
.perm-card.on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.perm-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.perm-cname { font-weight: 700; font-size: 15px; }
.perm-tag { margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--primary); background: #dbeafe; border-radius: 999px; padding: 2px 8px; vertical-align: middle; }
.perm-role-l { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.perm-role { min-width: 290px; font-size: 14px; padding: 6px 8px; }
.perm-status { margin: 8px 0 4px; font-size: 13px; color: var(--ink); background: var(--bg); border-radius: 6px; padding: 6px 10px; }
.perm-folders { margin: 6px 0; }
.perm-folders summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 4px 0; }
.perm-folders .tbl select { min-width: 220px; }
.perm-caps { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 8px; }
.perm-caps-title { font-size: 14px; margin-bottom: 4px; }
.perm h5 { margin: 12px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.perm-matrix th:not(:first-child), .perm-matrix td:not(:first-child) { text-align: center; width: 110px; }
.perm-matrix input[type=checkbox], .perm-list input[type=checkbox] { width: 17px; height: 17px; vertical-align: middle; }
.perm-matrix a.link { cursor: pointer; color: inherit; border-bottom: 1px dashed var(--muted); }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 14px; }
.perm-list label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.perm-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 8px; }
@media (max-width: 700px) { .perm-role { min-width: 0; width: 100%; } .perm-role-l { width: 100%; } }
