:root {
  --pri: #0f766e; --pri-esc: #115e59; --pri-claro: #ccfbf1;
  --topo: #0b1f2a; --txt: #1e293b; --suave: #64748b; --borda: #e2e8f0; --fundo: #f8fafc;
  --perigo: #dc2626; --aviso: #b45309; --raio: 8px;
  --sombra: 0 10px 30px rgba(15, 23, 42, .18);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  font-size: 14px; color: var(--txt);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; background: var(--fundo); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
small { color: var(--suave); }
h4 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); }
code, .codigo { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.codigo { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: var(--raio); white-space: pre-wrap; word-break: break-all; }

/* Botões */
.btn { border: 1px solid var(--borda); background: #fff; color: var(--txt); padding: 7px 12px; border-radius: 6px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--pri); color: var(--pri); }
.btn.primario { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.primario:hover { background: var(--pri-esc); color: #fff; }
.btn.perigo { color: var(--perigo); }
.btn.perigo:hover { background: var(--perigo); color: #fff; border-color: var(--perigo); }
.btn.pequeno { padding: 4px 9px; font-size: 12.5px; }
.btn.largo { width: 100%; padding: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.icone { border: 0; background: none; padding: 4px 7px; border-radius: 5px; color: inherit; line-height: 1; }
.icone:hover { background: rgba(100, 116, 139, .15); }

/* Login */
.tela-login { align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, #134e4a, #0b1f2a 60%); }
.caixa-login { width: min(380px, 92vw); background: #fff; border-radius: 14px; padding: 32px; box-shadow: var(--sombra); display: flex; flex-direction: column; gap: 14px; }
.caixa-login .marca { font-size: 26px; color: var(--topo); }
.caixa-login .sub { margin: -10px 0 8px; color: var(--suave); }
.caixa-login label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; }
.caixa-login input { padding: 10px; border: 1px solid var(--borda); border-radius: 6px; }
.caixa-login .erro { color: var(--perigo); background: #fef2f2; padding: 8px 10px; border-radius: 6px; }
.caixa-login .rodape { font-size: 12px; color: var(--suave); text-align: center; margin: 4px 0 0; }
.marca { font-size: 18px; letter-spacing: .02em; white-space: nowrap; }
.marca-icone { color: #2dd4bf; }

/* Topo */
#topo { height: 52px; background: var(--topo); color: #e2e8f0; display: flex; align-items: center; gap: 12px; padding: 0 12px; flex: none; z-index: 1100; }
#topo .icone:hover { background: rgba(255,255,255,.1); }
.busca { position: relative; flex: 0 1 460px; }
.busca input { width: 100%; padding: 8px 12px; border-radius: 6px; border: 0; background: rgba(255,255,255,.1); color: #fff; }
.busca input::placeholder { color: #94a3b8; }
.busca input:focus { background: #fff; color: var(--txt); outline: none; }
.espaco { flex: 1; }
.usuario { position: relative; }
.usuario-btn { background: none; border: 0; color: #e2e8f0; padding: 6px 8px; border-radius: 6px; }
.usuario-btn:hover { background: rgba(255,255,255,.1); }
.usuario-btn small { color: #5eead4; margin-left: 4px; }
.lista-suspensa { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; color: var(--txt); border-radius: var(--raio); box-shadow: var(--sombra); max-height: 60vh; overflow: auto; z-index: 2000; min-width: 220px; padding: 4px; }
.lista-suspensa.direita { left: auto; right: 0; }
.lista-suspensa button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; }
.lista-suspensa button:hover { background: var(--fundo); }
.vazio { color: var(--suave); padding: 8px; margin: 0; font-style: italic; }

/* Corpo */
#corpo { flex: 1; display: flex; min-height: 0; }
#lateral { width: 320px; flex: none; background: #fff; border-right: 1px solid var(--borda); display: flex; flex-direction: column; transition: margin .2s; z-index: 900; }
.sem-lateral #lateral { margin-left: -320px; }
.abas { display: flex; border-bottom: 1px solid var(--borda); flex: none; }
.aba { flex: 1; border: 0; background: none; padding: 10px; color: var(--suave); border-bottom: 2px solid transparent; }
.aba.ativa { color: var(--pri); border-color: var(--pri); font-weight: 600; }
.modal .abas { margin-bottom: 14px; }
.modal .aba { flex: none; padding: 8px 14px; }
.aba-conteudo { flex: 1; overflow: auto; padding: 10px; }
.acoes-camadas { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
#filtro-camadas { width: 100%; padding: 6px 9px; border: 1px solid var(--borda); border-radius: 6px; margin-bottom: 8px; }
.grupo { margin-bottom: 6px; }
.grupo-topo { display: flex; align-items: center; gap: 4px; padding: 4px 2px; font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); }
.grupo-nome { flex: 1; }
.camada { border: 1px solid transparent; border-radius: 6px; padding: 4px 4px 4px 22px; margin: 1px 0; }
.camada:hover { background: var(--fundo); border-color: var(--borda); }
.camada.oculta .camada-nome { color: var(--suave); }
.camada.em-edicao { border-color: #fdba74; background: #fff7ed; }
.camada-linha { display: flex; align-items: center; gap: 6px; }
.camada-icone { width: 16px; text-align: center; font-size: 13px; }
.camada-txt { flex: 1; min-width: 0; cursor: default; }
.camada-nome { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camada-txt small { font-size: 11.5px; }
.camada-extra { padding: 2px 0 4px 44px; }
.camada-extra input[type=range] { width: 100%; height: 4px; accent-color: var(--pri); opacity: 0; transition: opacity .15s; margin: 2px 0; }
.camada:hover .camada-extra input[type=range], .camada-extra input[type=range]:focus { opacity: .8; }
.legenda div { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 1px 0; }
.amostra { width: 14px; height: 10px; border: 2px solid; border-radius: 2px; flex: none; }
.amostra.ponto { border-radius: 50%; width: 11px; height: 11px; }
.amostra.linha { height: 0; border-width: 2px 0 0; }
.proc { color: var(--aviso); }
.erro-txt { color: var(--perigo); }
.base { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; margin-bottom: 4px; border: 1px solid var(--borda); border-radius: var(--raio); background: #fff; text-align: left; }
.base:hover { border-color: var(--pri); }
.base.ativa { border-color: var(--pri); background: var(--pri-claro); font-weight: 600; }
.base-icone { font-size: 18px; width: 24px; text-align: center; }

#area-mapa { flex: 1; position: relative; display: flex; flex-direction: column; min-width: 0; }
#mapa { flex: 1; background: #dfe7ef; }
.leaflet-container { font: inherit; }

/* Barra de ferramentas */
#ferramentas { position: absolute; top: 10px; left: 56px; right: 10px; z-index: 800; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.grupo-ferr { display: flex; background: #fff; border-radius: var(--raio); box-shadow: 0 1px 5px rgba(0,0,0,.25); overflow: hidden; pointer-events: auto; }
.grupo-ferr button { border: 0; background: #fff; width: 36px; height: 34px; font-size: 15px; border-right: 1px solid var(--borda); }
.grupo-ferr button:last-child { border-right: 0; }
.grupo-ferr button:hover:not(:disabled) { background: var(--pri-claro); }
.grupo-ferr button.ativo { background: var(--pri); color: #fff; }
.grupo-ferr button:disabled { color: #cbd5e1; cursor: not-allowed; }
.grupo-ferr select { border: 0; padding: 0 10px; height: 34px; max-width: 260px; background: #fff; }
#aviso-mapa { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); z-index: 800; background: rgba(15,23,42,.88); color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; max-width: 80%; text-align: center; pointer-events: none; }
#rodape-mapa { position: absolute; bottom: 0; left: 0; z-index: 800; background: rgba(255,255,255,.85); padding: 3px 10px; font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; border-top-right-radius: 6px; pointer-events: none; }
.com-tabela #rodape-mapa { bottom: 38%; }
.leaflet-bottom.leaflet-right { margin-bottom: 0; }
.leaflet-control-attribution { max-width: 38vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaflet-control-attribution:hover { max-width: none; white-space: normal; }
.rotulo { background: rgba(255,255,255,.75); border: 0; box-shadow: none; padding: 0 3px; font-size: 11px; font-weight: 600; color: #0f172a; }
.rotulo::before { display: none; }
.rotulo-medida { background: #e11d48; color: #fff; border: 0; font-size: 12px; text-align: center; }
.rotulo-medida::before { display: none; }

/* Painel da feição */
#painel { width: 380px; flex: none; background: #fff; border-left: 1px solid var(--borda); display: flex; flex-direction: column; z-index: 900; }
.painel-topo { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--borda); font-size: 15px; }
#painel-corpo { flex: 1; overflow: auto; padding: 12px 14px 24px; }
.painel-camada { font-size: 12px; color: var(--suave); margin-bottom: 8px; }
table.medidas { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 13px; }
table.medidas th { text-align: left; color: var(--suave); font-weight: 500; padding: 3px 8px 3px 0; white-space: nowrap; vertical-align: top; }
table.medidas td { padding: 3px 0; word-break: break-word; }
.form-feicao { display: flex; flex-direction: column; gap: 8px; }
.campo { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.form-feicao .campo { margin: 0; }
.campo > span { font-size: 12.5px; font-weight: 500; color: #334155; }
.campo input:not([type=checkbox]):not([type=color]):not([type=range]), .campo select, .campo textarea, .barra input {
  padding: 7px 9px; border: 1px solid var(--borda); border-radius: 6px; background: #fff; width: 100%; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--pri-claro); border-color: var(--pri); }
.campo input:disabled, .campo select:disabled, .campo textarea:disabled { background: var(--fundo); color: var(--txt); }
.dica { font-size: 12px; color: var(--suave); }
.destacar { outline: 2px solid var(--aviso) !important; }
.botoes { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.barra-edicao { background: #fff7ed; border: 1px solid #fdba74; padding: 10px; border-radius: var(--raio); margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.barra-edicao span { flex-basis: 100%; font-weight: 600; font-size: 13px; }
.anexos .anexo { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--borda); }
.anexo img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; cursor: zoom-in; }
.anexo a { flex: 1; color: var(--pri); word-break: break-all; }
.anexo-ic { width: 48px; text-align: center; font-size: 22px; }
.anexos > .btn { margin-top: 8px; }
.meta { font-size: 11.5px; color: var(--suave); margin-top: 16px; }
details.extras summary { cursor: pointer; color: var(--suave); font-size: 12.5px; margin: 4px 0; }

/* Tabela de atributos */
#tabela { height: 38%; flex: none; background: #fff; border-top: 2px solid var(--pri); display: flex; flex-direction: column; z-index: 850; }
.tabela-topo { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--borda); flex-wrap: wrap; }
.tabela-topo input { padding: 4px 8px; border: 1px solid var(--borda); border-radius: 6px; width: 220px; }
#tabela-info { font-size: 12px; color: var(--suave); }
.tabela-corpo { flex: 1; overflow: auto; }
.tabela-corpo table, table.grade { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.tabela-corpo th, table.grade th { position: sticky; top: 0; background: #f1f5f9; text-align: left; padding: 6px 8px; font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--borda); }
.tabela-corpo td, table.grade td { padding: 5px 8px; border-bottom: 1px solid #f1f5f9; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabela-corpo tbody tr { cursor: pointer; }
.tabela-corpo tbody tr:hover { background: #f0fdfa; }
.tabela-corpo tr.sel { background: #fef9c3; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grade td.acoes { white-space: nowrap; text-align: right; }
table.grade td.acoes .btn { margin-left: 4px; }
table.grade tr.inativo td { color: var(--suave); text-decoration: line-through; }
table.grade.compacta td.det { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--suave); }

/* Menus, janelas, avisos */
.menu-flutuante { position: fixed; z-index: 3000; background: #fff; border-radius: var(--raio); box-shadow: var(--sombra); padding: 4px; min-width: 240px; }
.menu-flutuante button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; }
.menu-flutuante button:hover { background: var(--fundo); }
.menu-flutuante button.perigo { color: var(--perigo); }
.modal-fundo { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 2500; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 0 2vh; overflow: auto; }
.modal { background: #fff; border-radius: 12px; box-shadow: var(--sombra); display: flex; flex-direction: column; max-height: 90vh; }
.modal-topo { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--borda); font-size: 16px; }
.modal-corpo { padding: 16px 18px; overflow: auto; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--borda); }
.barra { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.barra input { max-width: 300px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin: 4px 12px 4px 0; font-size: 13px; }
.check.bloco { display: flex; }
.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.span-2 { grid-column: span 2; }
.editor-campos { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.linha-campo { display: grid; grid-template-columns: 1.4fr 1fr 130px auto auto auto; gap: 6px; align-items: center; background: var(--fundo); padding: 6px; border-radius: 6px; }
.linha-campo input, .linha-campo select, .linha-campo textarea { padding: 5px 7px; border: 1px solid var(--borda); border-radius: 5px; min-width: 0; background: #fff; }
.linha-campo .chave { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--suave); }
.linha-campo .opcoes { grid-column: 1 / -1; }
.lista-cores { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 240px; overflow: auto; }
.lista-cores div { display: flex; align-items: center; gap: 8px; }
.lista-cores input[type=color] { width: 34px; height: 24px; border: 0; padding: 0; background: none; }
.lista-cores span { flex: 1; }
.progresso { height: 8px; background: var(--borda); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progresso div { height: 100%; width: 0; background: var(--pri); transition: width .2s; }
.ok-box { background: #f0fdf4; border: 1px solid #86efac; padding: 10px 12px; border-radius: var(--raio); }
.ok-box ul { margin: 6px 0 0; padding-left: 18px; }
.erro-box { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; padding: 10px 12px; border-radius: var(--raio); }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 4000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--sombra); max-width: 90vw; transition: opacity .4s; border-left: 4px solid #2dd4bf; }
.toast.erro { border-left-color: #f87171; }
.toast.aviso { border-left-color: #fbbf24; }
.toast.sumindo { opacity: 0; }
.busca .lista-suspensa button small { display: block; color: var(--suave); }

/* Modo embutido (dentro do Kanban) */
.embed #topo, .embed #lateral { display: none; }
.embed #painel { width: 340px; }

/* Celular / tablet */
@media (max-width: 820px) {
  #lateral { position: absolute; top: 52px; bottom: 0; left: 0; box-shadow: var(--sombra); }
  body:not(.lateral-aberta) #lateral { margin-left: -320px; }
  .sem-lateral #lateral { margin-left: 0; }
  #painel { position: absolute; right: 0; top: 52px; bottom: 0; width: min(380px, 100vw); box-shadow: var(--sombra); }
  .marca { display: none; }
  .usuario-btn small { display: none; }
  #ferramentas { left: 50px; }
}
