
*{box-sizing:border-box}
:root{
 --bg:#eef1f5;--panel:#fff;--text:#17202a;--muted:#6b7280;--border:#d9dee5;
 --accent:#2563eb;--accent-soft:#eff6ff;--shelf:#efa27d;--shelf-border:#914b29;
 --passage:#bdbdbd;--room:#9dc3e6;--open:#c4b5fd;--found:#22c55e;--selected:#f59e0b;
 --danger:#dc2626;--success:#15803d;
}
html,body{margin:0;min-height:100%;font-family:Inter,Segoe UI,Arial,sans-serif;color:var(--text);background:var(--bg)}
button,input,select{font:inherit}
button{cursor:pointer}
.app{min-height:100vh;display:grid;grid-template-columns:370px minmax(0,1fr)}
.sidebar{background:#fff;border-right:1px solid var(--border);padding:20px;overflow:auto;max-height:100vh}
.brand{display:flex;gap:12px;align-items:center;margin-bottom:20px}
.logo{width:48px;height:48px;border-radius:13px;background:#111827;color:#fff;display:grid;place-items:center;font-weight:800}
.brand h1{font-size:20px;margin:0}.brand p{margin:3px 0 0;color:var(--muted);font-size:13px}
.box{background:#fff;border:1px solid var(--border);border-radius:14px;padding:15px;margin-bottom:15px}
.box-title{display:flex;justify-content:space-between;gap:10px;align-items:center;font-weight:800;margin-bottom:12px}
.label{font-weight:700;font-size:12px;display:block;margin:10px 0 6px}
input,select{width:100%;border:1px solid var(--border);border-radius:9px;padding:9px 10px;outline:none;background:#fff}
input:focus,select:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(37,99,235,.10)}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.btn{border:1px solid var(--border);background:#fff;border-radius:9px;padding:9px 11px}
.btn.primary{background:var(--accent);color:#fff;border-color:var(--accent);font-weight:700}
.btn.danger{background:#fff1f2;color:#be123c;border-color:#fecdd3}
.btn.success{background:#f0fdf4;color:#166534;border-color:#bbf7d0}
.btnbar{display:flex;flex-wrap:wrap;gap:8px}
.small{font-size:12px;color:var(--muted)}
main{min-width:0;display:flex;flex-direction:column;min-height:100vh}
.toolbar{min-height:72px;display:flex;justify-content:space-between;align-items:center;padding:14px 20px;background:#fff;border-bottom:1px solid var(--border)}
.toolbar>div:first-child{display:flex;flex-direction:column;gap:3px}.toolbar small{color:var(--muted)}
.toolbar-actions{display:flex;gap:8px;align-items:center}
.viewport{flex:1;overflow:auto;padding:20px}
.stage{min-width:1000px;transform-origin:top left}
#map{width:100%;height:auto;display:block;background:#fff;border-radius:14px;box-shadow:0 15px 40px rgba(15,23,42,.12);user-select:none}
.map-bg{fill:#fafafa}.grid{fill:none;stroke:#e5e7eb;stroke-width:1}
.passage rect{fill:var(--passage);stroke:#1f2937;stroke-width:1}.passage text{fill:#111;font-size:13px;pointer-events:none}
.access rect{fill:var(--room);stroke:#1f2937;stroke-width:1}.access text{fill:#111;font-size:12px;pointer-events:none}
.place{cursor:pointer}
.place rect{stroke-width:1.2;transition:filter .12s,stroke-width .12s}
.place text{fill:#111;font-size:12px;pointer-events:none;font-weight:600}
.place.estante rect{fill:var(--shelf);stroke:var(--shelf-border)}
.place.quarto rect{fill:var(--room);stroke:#315f86}
.place.zona_aberta rect{fill:var(--open);stroke:#6d28d9;stroke-dasharray:4 3}
.place:hover rect{filter:brightness(1.04);stroke-width:2}
.place.selected rect{stroke:#111827;stroke-width:3;filter:drop-shadow(0 0 5px rgba(0,0,0,.25))}
.place.found rect{fill:var(--found)!important;stroke:#166534!important;stroke-width:2.5}
.legend div{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted);margin:8px 0}
.swatch{width:14px;height:14px;border-radius:3px;border:1px solid rgba(0,0,0,.2)}
.s-shelf{background:var(--shelf)}.s-room{background:var(--room)}.s-open{background:var(--open)}.s-passage{background:var(--passage)}
.searchbar{display:grid;grid-template-columns:1fr auto;gap:8px}
.search-result{display:block;width:100%;text-align:left;border:1px solid var(--border);background:#fff;border-radius:9px;margin-top:7px;padding:8px}
.search-result:hover{background:var(--accent-soft);border-color:var(--accent)}
.search-result strong,.search-result span{display:block}.search-result strong{font-size:12px}.search-result span{font-size:11px;color:var(--muted);margin-top:2px}
.pill{font-size:11px;background:#f3f4f6;color:#6b7280;border-radius:999px;padding:4px 8px}
.floor-list{display:grid;gap:8px}
.floor{border:1px solid var(--border);border-radius:10px;overflow:hidden}
.floor-head{background:#f8fafc;padding:8px 10px;font-size:12px;font-weight:800;border-bottom:1px solid var(--border)}
.floor-body{padding:9px 10px;font-size:12px}
.article{padding:5px 0;border-bottom:1px dashed #e5e7eb}.article:last-child{border-bottom:0}
.article-code{font-weight:800}.article-name{margin-top:2px}.empty{font-size:13px;color:var(--muted);line-height:1.5}
.status{font-size:12px;padding:7px 9px;border-radius:8px;display:none;margin-top:10px}
.status.ok{display:block;background:#f0fdf4;color:#166534}.status.err{display:block;background:#fef2f2;color:#991b1b}
.editor-note{background:#fffbeb;border:1px solid #fde68a;color:#92400e;padding:9px 10px;border-radius:9px;font-size:12px;line-height:1.4}
.prat-row{display:grid;grid-template-columns:1fr auto auto;gap:6px;align-items:center;margin-top:7px}
.prat-row input{padding:7px 8px}
.icon-btn{width:34px;height:34px;border:1px solid var(--border);background:#fff;border-radius:8px;display:grid;place-items:center;padding:0}
.drag-hint{font-size:11px;color:var(--muted);margin-top:8px}
.coords{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}.coords label{font-size:10px;color:var(--muted)}.coords input{padding:7px 6px}
@media(max-width:900px){.app{grid-template-columns:1fr}.sidebar{max-height:none;border-right:0;border-bottom:1px solid var(--border)}.stage{min-width:850px}}
