/* PAILON — estilos. Tema claro/escuro via prefers-color-scheme. */
:root {
  color-scheme: light; --scene: #e5e7e8; --ground: #ced1cb;
  --bg: #f3f5f7; --panel: #ffffff; --ink: #1d2733; --mute: #5d6b7a; --line: #d9e0e7; --accent: #1f6fb2; --accent-ink: #fff;
  --warn: #b3261e; --warn-bg: #fdeceb; --ok: #2e7d32; --chip: #eaf0f6; --shadow: 0 2px 10px rgba(20, 40, 60, .12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; --scene: #30383e; --ground: #626a65; --bg: #14181d; --panel: #1d242c; --ink: #e6ecf2; --mute: #9aa8b6; --line: #2f3944; --accent: #5aa9e6; --accent-ink: #0b1620; --warn: #ff8a80; --warn-bg: #3a1f1d; --ok: #81c784; --chip: #28323d; --shadow: 0 2px 10px rgba(0,0,0,.5); }
}
:root[data-theme="dark"] { color-scheme: dark; --scene: #30383e; --ground: #626a65; --bg: #14181d; --panel: #1d242c; --ink: #e6ecf2; --mute: #9aa8b6; --line: #2f3944; --accent: #5aa9e6; --accent-ink: #0b1620; --warn: #ff8a80; --warn-bg: #3a1f1d; --ok: #81c784; --chip: #28323d; --shadow: 0 2px 10px rgba(0,0,0,.3); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.info-sidebar { overflow-y: auto; }
.sidebar-section { flex:none; border-bottom:1px solid var(--line); }
.sidebar-section > summary { padding:10px; cursor:pointer; font-weight:600; background:var(--chip); }
.sidebar-section .panel { display:block; overflow:visible; flex:none; }
.editor-section { margin:10px 0; border:1px solid var(--line); border-radius:8px; }
.editor-section > summary { padding:10px; cursor:pointer; font-weight:600; background:var(--chip); }
.section-body { padding:10px; }
.section-body > button { margin:3px; }
.opinion-dialog { color:var(--ink); background:var(--panel); border:1px solid var(--line); border-radius:12px; width:min(850px,94vw); max-height:90dvh; }
.opinion-dialog textarea { width:100%; color:var(--ink); background:var(--bg); resize:vertical; }
.opinion-dialog::backdrop { background:#0008; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--chip); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.on, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--warn); }
input[type=number], input[type=text], select { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; min-width: 0; }
input[type=color] { padding: 0; height: 28px; width: 40px; border: 1px solid var(--line); border-radius: 5px; background: none; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 22px; color: var(--accent); }
.brand b { display: block; letter-spacing: .08em; }
.brand small { color: var(--mute); display: block; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border-color: transparent; background: transparent; }
.tabs button.on { background: var(--accent); }
.badge { background: var(--warn); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; }
.badge.zero { background: var(--ok); }
.actions { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.save { color: var(--mute); font-size: 12px; min-width: 120px; text-align: right; }
.disclaimer { background: var(--warn-bg); color: var(--warn); font-size: 12px; padding: 4px 14px; border-bottom: 1px solid var(--line); }

main { flex: 1; min-height: 0; position: relative; }
.tab { display: none; height: 100%; }
.tab.on { display: block; }
#tab-modelo.on { display: grid; grid-template-columns: 320px minmax(0, 1fr); transition: grid-template-columns .2s ease; }
#tab-modelo.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.info-sidebar { width: 320px; transition: opacity .16s ease, visibility .16s ease; }
#tab-modelo.sidebar-collapsed .info-sidebar { opacity: 0; visibility: hidden; pointer-events: none; }
.sidebar-title { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 7px 12px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--mute); }
.icon-button { width: 30px; height: 30px; min-width: 30px; padding: 0; display: inline-grid; place-items: center; font-size: 18px; line-height: 1; }
.sidebar-title .icon-button { width: 26px; height: 26px; min-width: 26px; background: transparent; border-color: transparent; }
.subtabs { display: flex; border-bottom: 1px solid var(--line); }
.subtabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 8px; }
.subtabs button span { display: block; margin-top: 2px; font-size: 10px; }
.subtabs button.on { background: var(--chip); color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px var(--accent); }
.panel { display: none; overflow: auto; padding: 10px; flex: 1; min-height: 0; }
.panel.on { display: block; }

.stage { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.sidebar-toggle { position: absolute; top: 10px; left: 10px; z-index: 3; background: var(--panel); box-shadow: var(--shadow); }
#tab-modelo:not(.sidebar-collapsed) .sidebar-toggle { display: none; }
#view3d { flex: 1; min-height: 0; position: relative; background: var(--scene); }
#view3d canvas { display: block; }
.toolbar { position: relative; display: flex; flex-wrap: wrap; gap: 6px; padding: 7px; padding-left: 48px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 2; flex: none; align-items: flex-start; }
.toolbar .grp { display: flex; gap: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; box-shadow: var(--shadow); pointer-events: auto; align-items: center; }
.toolbar button { padding: 4px 8px; font-size: 13px; }
.toolbar .cut { font-size: 12px; color: var(--mute); display: flex; align-items: center; gap: 4px; }
.toolbar .cut input { width: 70px; }
.selbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: 112px; display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: var(--shadow); max-width: 96%; flex-wrap: wrap; justify-content: center; }
.selbar span { align-self: center; padding: 0 6px; font-weight: 600; font-size: 13px; }
.hint { display: none; }
.stagebar { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 12px 10px; }
.stagebar .head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; margin-bottom: 4px; }
.stagebar .pct { font-size: 22px; font-weight: 700; color: var(--accent); }
.stagebar .nm { font-weight: 600; }
.stagebar .head .sp { margin-left: auto; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--mute); }
.segs { display: flex; height: 22px; gap: 2px; margin-bottom: 2px; }
.segs button { min-width: 0; border-radius: 4px; background: var(--chip); border: 1px solid var(--line); font-size: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; cursor: pointer; color: var(--mute); padding: 0 2px; }
.segs button.done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.segs button.current { background: var(--chip); color: var(--ink); border: 2px solid var(--accent); }
#stageRange { width: 100%; accent-color: var(--accent); }

/* biblioteca */
.search { width: 100%; margin-bottom: 8px; }
.cat h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); }
.items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--bg); cursor: grab; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; font-size: 12px; user-select: none; }
.item:hover { border-color: var(--accent); }
.item small { color: var(--mute); font-size: 10.5px; }
.item canvas { width: 44px; height: 44px; }
.lay { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 4px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lay .chip { width: 12px; height: 12px; border-radius: 3px; }
.lay input[type=range] { grid-column: 2 / 5; width: 100%; }
.lay label { font-size: 12px; color: var(--mute); display: flex; gap: 3px; align-items: center; }

/* inspetor */
.field { display: grid; grid-template-columns: 1fr 96px; gap: 6px; align-items: center; margin: 5px 0; }
.field label { color: var(--mute); font-size: 12.5px; }
.field input, .field select { width: 100%; }
.sec { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); }
.btnrow { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.kv { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; border-bottom: 1px dotted var(--line); }
.note { font-size: 12px; color: var(--mute); }
.warn { color: var(--warn); }
.check { display: flex; gap: 6px; align-items: flex-start; margin: 4px 0; font-size: 13px; }
.stlist .st { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.stlist .st:hover { background: var(--chip); }
.stlist .st.cur { outline: 1px solid var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot.done { background: var(--ok); } .dot.current { background: var(--accent); }
table.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
table.mini td, table.mini th { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.mini td.r, table.mini th.r { text-align: right; }

/* páginas */
.page { height: 100%; overflow: auto; padding: 16px 18px 40px; max-width: 1280px; margin: 0 auto; }
.page h2 { margin: 6px 0 10px; }
.page h3 { margin: 18px 0 6px; }
.banner { background: var(--warn-bg); color: var(--warn); padding: 6px 14px; font-size: 13px; }
.banner:empty { display: none; }
.pagehead { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button.on { background: var(--accent); }
#tab-plantas.on { display: flex; flex-direction: column; }
.sheetwrap { flex: 1; overflow: auto; padding: 14px; background: #8a939c33; }
#planCanvas { display: block; margin: 0 auto; max-width: 100%; height: auto; background: #fff; box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: middle; }
table.data th { background: var(--chip); position: sticky; top: 0; z-index: 1; font-size: 12px; }
table.data td.r, table.data th.r { text-align: right; }
table.data input[type=number] { width: 84px; text-align: right; }
table.data input[type=text] { width: 100%; min-width: 110px; }
table.data tr.grp td { background: var(--chip); font-weight: 700; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin: 10px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.card b { display: block; font-size: 18px; }
.card span { color: var(--mute); font-size: 12px; }
.pend { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 8px; padding: 8px 12px; margin: 8px 0; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; }
.pend.ok { border-left-color: var(--ok); opacity: .75; }
.pend.opt { border-left-color: #c58b00; }
.tag { font-size: 11px; border-radius: 4px; padding: 1px 6px; background: var(--warn-bg); color: var(--warn); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 8px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 50; max-width: 90%; }
.toast.on { opacity: 1; }

@media (max-width: 1100px) {
  #tab-modelo.on { grid-template-columns: 280px minmax(0, 1fr); }
  .info-sidebar { width: 280px; }
}
@media (max-width: 760px) {
  #tab-modelo.on { display: block; height: 100%; }
  #tab-modelo .stage { height: 100%; }
  #tab-modelo .info-sidebar { position: absolute; z-index: 5; top: 0; left: 0; bottom: 0; width: min(320px, 88vw); max-height: none; border: 0; border-right: 1px solid var(--line); box-shadow: var(--shadow); }
  #tab-modelo.sidebar-collapsed .info-sidebar { display: none; }
  #tab-modelo:not(.sidebar-collapsed) .sidebar-toggle { display: none; }
  .hint { display: none; }
  .brand small { display: none; }
  .toolbar .grp { flex-wrap: wrap; }
  .selbar { bottom: 130px; }
  .field { grid-template-columns: 1fr 90px; }
}

/* Controles compactos; detalhes permanecem acessíveis sem cobrir o modelo. */
button:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
button:disabled { opacity: .45; cursor: default; }
.theme-label { display: flex; gap: 5px; align-items: center; font-size: 12px; color: var(--mute); }
summary { cursor: pointer; font-size: 12px; padding: 7px 9px; color: var(--ink); border-radius: 6px; }
summary:hover { background: var(--chip); }
.file-menu { position: relative; }
.file-actions { position: absolute; right: 0; top: 100%; z-index: 20; display: grid; gap: 5px; min-width: 170px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.view-details { border: 1px solid var(--line); border-radius: 8px; }
.view-details .grp { flex-wrap: wrap; box-shadow: none; border: 0; max-width: 360px; }
.toolbar .grp { box-shadow: none; }
.toolbar .cut { padding: 4px; }
.cut output { min-width: 24px; font-variant-numeric: tabular-nums; }
.zoom-tools { margin-left: auto; }
.topbar { gap: 8px 14px; padding: 7px 12px; }
.save { min-width: 0; }
.panel h3 { margin: 4px 0 8px; font-size: 15px; }
.item { padding: 5px; gap: 1px; }
.item canvas { width: 36px; height: 36px; }
.advanced { margin-top: 12px; border-top: 1px solid var(--line); }
.advanced summary { padding-left: 0; color: var(--mute); }
.stage-key { display: flex; gap: 12px; flex-wrap: wrap; font-size: 10px; color: var(--mute); margin-top: 2px; }
.stage-key span { display: inline-flex; align-items: center; gap: 4px; }
.stage-key .pending { background: transparent; border: 1px dashed var(--mute); }
.stagebar { padding: 6px 10px; }
.stagebar .pct { font-size: 19px; }
.selbar { bottom: 155px; }
@media (max-width: 1100px) {
  #tab-modelo.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
  .brand small { max-width: 180px; }
}
@media (max-width: 760px) {
  .topbar { gap: 5px; padding: 6px 8px; }
  .tabs { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; }
  .tabs button { flex: none; font-size: 12px; padding: 6px 8px; }
  .actions { gap: 4px; }
  .save { display: none; }
  .disclaimer { font-size: 10px; padding: 4px 8px; max-height: 56px; overflow: auto; }
  .toolbar { gap: 4px; padding: 5px 5px 5px 43px; }
  .toolbar button { font-size: 11px; padding: 6px; min-height: 30px; }
  .toolbar summary { padding: 7px 6px; }
  .stagebar .nm { font-size: 11px; }
  .stagebar .head { gap: 3px 8px; }
  .stagebar .head .sp { font-size: 11px; }
  .segs { height: 22px; }
  .page { padding: 10px 8px 30px; }
  .sidebar-toggle { left: 6px; top: 7px; }
}

/* Lateral global: navegação e exportação acompanham todas as telas. */
.workspace { flex: 1; min-height: 0; position: relative; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.workspace.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.workspace .info-sidebar { width: 300px; }
.workspace.sidebar-collapsed .info-sidebar { display: none; }
.workspace main { grid-column: 2; min-width: 0; overflow: hidden; }
#tab-modelo.on { display: block; height: 100%; }
#tab-modelo .stage { height: 100%; }
.side-nav { display: grid; gap: 4px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.side-nav button { text-align: left; }
.sidebar-tools { flex: none; max-height: 46%; overflow: auto; padding: 6px 10px; border-top: 1px solid var(--line); }
.export-list { display: flex; flex-direction: column; gap: 5px; }
.export-list button { width: 100%; text-align: left; }
.export-dpi { display: grid; gap: 4px; font-size: 11px; margin: 8px 0; }
.sidebar-note { color: var(--mute); font-size: 10px; margin: 6px 0 0; }
.cat summary { font-size: 11px; font-weight: 650; letter-spacing: .03em; color: var(--mute); padding: 10px 0 5px; }
.toolbar { padding-left: 7px; }
.selbar { bottom: 15px; }
.stage:fullscreen, .stage.fullscreen-fallback { background: var(--panel); width: 100vw; height: 100dvh !important; }
.stage.fullscreen-fallback { position: fixed; inset: 0; z-index: 60; }
@media (max-width: 1100px) { .workspace { grid-template-columns: 270px minmax(0, 1fr); } .workspace .info-sidebar { width: 270px; } }
@media (max-width: 760px) {
  .workspace { display: block; }
  .workspace main { height: 100%; }
  .workspace .info-sidebar { position: absolute; z-index: 5; top: 0; bottom: 0; left: 0; width: min(320px, 88vw); box-shadow: var(--shadow); }
  .toolbar { padding-left: 5px; }
  .workspace .sidebar-tools { max-height: 42%; }
}

/* A lateral inteira rola; cada seção mantém o seu conteúdo no fluxo. */
.workspace .info-sidebar { display:block; overflow-y:auto; }
.workspace .sidebar-tools { max-height:none; overflow:visible; }

/* ---- Lista de projetos na lateral: cada projeto é um item; o aberto contém menus, biblioteca, camadas e propriedades ---- */
.projects-head { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.projects-head .primary-new { width: 100%; font-weight: 700; padding: 9px; background: var(--accent); color: #fff; border-color: var(--accent); }
.project-item { border-bottom: 1px solid var(--line); }
.project-item > summary { padding: 11px 12px; cursor: pointer; font-weight: 700; background: var(--chip); list-style: none; overflow-wrap: anywhere; }
.project-item > summary::-webkit-details-marker { display: none; }
.project-item > summary::before { content: '▸'; display: inline-block; width: 1.1em; color: var(--mute); }
.project-item[open] > summary::before { content: '▾'; }
.project-item.ativo > summary { color: var(--accent); box-shadow: inset 3px 0 var(--accent); }
.project-item:not(.ativo) > summary { font-weight: 500; }

/* Documentos do cliente */
.docsLayout{display:flex;gap:12px;height:calc(100vh - 70px);padding:10px;box-sizing:border-box}
.docsSide{width:280px;flex:none;display:flex;flex-direction:column;gap:8px;overflow:auto}
.docsSide #docList{display:flex;flex-direction:column;gap:4px}
.docsSide .doc{display:flex;gap:4px;align-items:center}
.docsSide .doc.on .docname{outline:2px solid #2b6cb0}
.docsSide .docname{flex:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.docViewer{flex:1;min-width:0;border:1px solid var(--line,#c8ccd2);border-radius:8px;overflow:auto;background:#6b6f76;display:flex}
.docFrame{flex:1;border:0;width:100%;height:100%;background:#fff}
.docImg{max-width:100%;margin:auto;display:block}
.docEmpty{margin:auto;color:#fff;padding:20px;text-align:center}
@media(max-width:800px){.docsLayout{flex-direction:column;height:auto}.docsSide{width:auto}.docViewer{height:70vh}}

/* ===== Nuvem / login / modo cliente ===== */
.cl-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: var(--bg, #f4f6f8); }
.cl-card { display: flex; flex-direction: column; gap: 10px; width: min(380px, 92vw); padding: 26px; background: var(--panel, #fff); border: 1px solid var(--line, #ccd); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.cl-card input, .cl-panel input { padding: 10px; border: 1px solid var(--line, #ccd); border-radius: 8px; font: inherit; background: var(--bg, #fff); color: inherit; }
.cl-brand { font-size: 1.25rem; font-weight: 700; }
.cl-sub { margin: 0; color: var(--muted, #667); font-size: .9rem; }
.cl-msg { margin: 0; min-height: 1.2em; color: #b3261e; font-size: .9rem; }
.cl-link { background: none; border: 0; color: var(--muted, #667); text-decoration: underline; cursor: pointer; font-size: .8rem; }
.cl-panel { position: fixed; top: 56px; right: 14px; z-index: 9000; width: min(360px, 94vw); display: flex; flex-direction: column; gap: 8px; padding: 14px; background: var(--panel, #fff); border: 1px solid var(--line, #ccd); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); }
.cl-panel > div:last-child { display: flex; flex-direction: column; gap: 8px; }
.cl-panel-h { display: flex; justify-content: space-between; align-items: center; }
body.cliente .projects-head, body.cliente #btnDemo, body.cliente #btnDupProject, body.cliente #btnRenameProject, body.cliente #btnDelProject, body.cliente #btnOpinion, body.cliente #btnImport, body.cliente #btnExport,
body.cliente #sideNav button[data-tab="docs"], body.cliente #sideNav button[data-tab="materiais"], body.cliente #sideNav button[data-tab="pendencias"] { display: none !important; }
