:root {
  --amorim-red: #94161A;
  --amorim-red-dark: #7a1215;
  --amorim-grey: #717172;
  --amorim-grey-light: #a8a8a9;
  --bg: #f4f2f2;
  --panel: #ffffff;
  --panel2: #faf9f9;
  --text: #2b2b2c;
  --muted: #717172;
  --line: #dddcdc;
  --brand: var(--amorim-red);
  --brand-dark: var(--amorim-red-dark);
  --ok: #047857;
  --warn: #b45309;
  --error: var(--amorim-red);
  --accent-soft: #fde8e9;
  --accent-border: #f0c4c6;
  --shadow: 0 12px 28px rgba(148, 22, 26, 0.08);
  --radius: 16px;
  --code-bg: #faf9f9;
  --header-h: 70px;
  --nav-h: 0px;
  --app-nav-collapsed: 76px;
  --app-nav-expanded: 268px;
  --app-nav-width: var(--app-nav-collapsed);
}

html.app-nav-pinned-boot,
html.app-nav-pinned-boot body,
body.app-nav-expanded {
  --app-nav-width: var(--app-nav-expanded);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 13px;
}

/* Offset da rail no wrapper — não pode ser anulado por margin dos filhos. */
.app-main {
  margin-left: var(--app-nav-width);
  width: calc(100% - var(--app-nav-width));
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
  transition: margin-left 0.22s ease, width 0.22s ease;
}

/* —— Shell lateral (padrão Medições Sienge) —— */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--app-nav-width);
  z-index: 100;
  background: linear-gradient(180deg, #261b1e 0%, #20242a 52%, #171a1f 100%);
  color: #fff;
  border-right: 1px solid #ffffff12;
  box-shadow: 12px 0 32px #1118271c;
  display: flex;
  flex-direction: column;
  transition: width 0.22s ease;
  overflow: hidden;
}
.app-sidebar-brand {
  height: 106px;
  flex: 0 0 106px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  background: #fff;
  border-bottom: 3px solid var(--amorim-red);
  overflow: hidden;
}
.app-sidebar-brand img {
  width: 226px;
  max-width: none;
  height: auto;
  display: block;
  transition: width 0.22s ease;
}
body:not(.app-nav-expanded) .app-sidebar-brand { display: none; }
body:not(.app-nav-expanded) .app-nav-scroll {
  padding: 6px 5px 20px;
  background: linear-gradient(180deg, #261b1e 0%, #20242a 52%, #171a1f 100%);
}
.app-nav-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 9px 20px;
  scrollbar-width: thin;
  scrollbar-color: #ffffff4d transparent;
}
.app-nav { display: block; }
.app-nav-section {
  margin: 10px 0 16px;
  padding-top: 4px;
}
.app-nav-section + .app-nav-section {
  border-top: 1px solid #ffffff14;
  padding-top: 12px;
}
.app-nav-label {
  min-height: 18px;
  margin: 0 10px 7px;
  color: #d7dbe3;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: margin 0.12s, font-size 0.12s, letter-spacing 0.12s, color 0.12s;
}
.app-nav-label-short { display: none; }
.app-nav-label-full { display: inline; }
/* Collapsed rail: section headers always visible (abbreviated) */
body:not(.app-nav-expanded) .app-nav-label {
  min-height: 16px;
  margin: 0 0 6px;
  padding: 0 2px;
  color: #e8ebf0;
  font-size: 8px;
  letter-spacing: 0.06em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: visible;
  text-align: center;
}
body:not(.app-nav-expanded) .app-nav-label-full { display: none; }
body:not(.app-nav-expanded) .app-nav-label-short { display: inline; }
body:not(.app-nav-expanded) .app-nav-section {
  margin: 8px 0 12px;
  padding-top: 0;
}
body:not(.app-nav-expanded) .app-nav-section + .app-nav-section {
  padding-top: 10px;
}
.app-nav-item {
  position: relative;
  width: 100%;
  min-height: 44px;
  margin: 3px 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: #eef0f3;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  text-decoration: none;
  box-shadow: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.app-nav-item:hover,
.app-nav-item:focus-visible {
  background: #ffffff12;
  border-color: #ffffff1f;
  color: #fff;
}
.app-nav-item.active {
  background: linear-gradient(135deg, #bd0f20, #94161a);
  border-color: #e7a61a;
  box-shadow: 0 0 0 2px #e7a61a55;
  color: #fff;
}
.app-nav-icon {
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  border-radius: 9px;
  background: #ffffff12;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: -0.03em;
}
.app-nav-item.active .app-nav-icon { background: #ffffff24; }
.app-nav-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  opacity: 1;
  transition: opacity 0.12s;
}
.app-nav-text strong { font-size: 12px; line-height: 1.2; font-weight: 800; }
.app-nav-text small {
  margin-top: 2px;
  color: #aab0ba;
  font-size: 9px;
  font-weight: 600;
}
body:not(.app-nav-expanded) .app-nav-item {
  justify-content: center;
  padding: 8px 5px;
  gap: 0;
}
body:not(.app-nav-expanded) .app-nav-text {
  display: none;
}
.app-nav-toggle {
  position: fixed;
  left: calc(var(--app-nav-width) - 14px);
  top: 116px;
  z-index: 105;
  width: 29px;
  height: 29px;
  min-height: 29px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--amorim-red);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 5px 16px #0004;
  transition: left 0.22s ease, transform 0.22s ease;
}
body.app-nav-expanded .app-nav-toggle { transform: rotate(180deg); }
.app-sidebar-backdrop { display: none; }
.app-mobile-menu { display: none; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  min-height: var(--header-h);
  background: #fff;
  color: var(--text);
  border-top: 3px solid var(--amorim-red);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 5px 18px #1f29370d;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: nowrap;
}

.header-context {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  flex: 0 1 auto;
}
.header-context-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #bd0f20, #94161a);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 5px 14px #94161a33;
}

.header-brand {
  display: none;
}

.header-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #20242a;
}

.header-text p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.link-doc,
.pill-brand {
  color: var(--amorim-red);
  text-decoration: none;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  background: #f2f3f5;
  transition: background 0.15s, border-color 0.15s;
}

.link-doc:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.pill-brand {
  cursor: default;
}

/* Legado — barra horizontal removida do shell */
.main-nav { display: none !important; }
.nav-link { display: none !important; }

/* Botão "Filtro" — abre/fecha a barra lateral de filtros (todas as abas com
   .cap-shell/.comercial-shell). Inserido via initSidebarDock() em app-utils.js.
   Com .cap-filter-slot na tools row, fica in-flow ao lado dos KPIs; senão, absolute. */
.cap-filter-toggle {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  transition: transform 0.22s ease, background 0.15s, box-shadow 0.15s;
}
.cap-filter-toggle:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.28);
}
.cap-filter-toggle svg { flex: 0 0 auto; }
/* Aberta: desloca o botão para a borda direita da sidebar, ainda clicável. */
.cap-shell.sidebar-open .cap-filter-toggle { transform: translateX(300px); }
.comercial-shell.sidebar-open .cap-filter-toggle { transform: translateX(260px); }

/* Filtro + KPIs na mesma linha (Fluxo / CAP / Caixas) */
.cap-filter-slot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  align-self: center;
  min-height: 32px;
}
.cap-filter-slot .cap-filter-toggle {
  position: static;
  top: auto;
  left: auto;
}

@media (max-width: 900px) {
  :root,
  html.app-nav-pinned-boot,
  html.app-nav-pinned-boot body,
  body.app-nav-expanded {
    --app-nav-width: 0px;
  }
  .app-sidebar {
    width: min(286px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }
  body.app-nav-mobile-open .app-sidebar { transform: translateX(0); }
  body:not(.app-nav-expanded) .app-sidebar-brand {
    display: flex;
    padding: 14px 12px;
    justify-content: flex-start;
  }
  body:not(.app-nav-expanded) .app-nav-label {
    min-height: 18px;
    margin: 0 10px 7px;
    padding: 0;
    color: #d7dbe3;
    font-size: 9px;
    letter-spacing: 0.16em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-align: left;
  }
  body:not(.app-nav-expanded) .app-nav-label-full { display: inline; }
  body:not(.app-nav-expanded) .app-nav-label-short { display: none; }
  body:not(.app-nav-expanded) .app-nav-item {
    justify-content: flex-start;
    padding: 8px 10px;
    gap: 11px;
  }
  body:not(.app-nav-expanded) .app-nav-text {
    display: flex;
  }
  body:not(.app-nav-expanded) .app-nav-section {
    margin: 10px 0 16px;
    padding-top: 4px;
  }
  body:not(.app-nav-expanded) .app-nav-section + .app-nav-section {
    padding-top: 12px;
  }
  .app-nav-toggle { display: none; }
  .app-mobile-menu {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f2f3f5;
    color: var(--amorim-red);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: #11182780;
    backdrop-filter: blur(2px);
    display: none;
  }
  body.app-nav-mobile-open .app-sidebar-backdrop {
    display: block;
  }
  .app-main {
    margin-left: 0;
    width: 100%;
  }
  .header-context { min-width: 0; flex: 1; }
  .header-context-mark { display: none; }
  .header-text h1 { font-size: 13px; }
  .header-text p { display: none; }
  .topbar { min-height: 64px; padding: 8px 10px; gap: 8px; }
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px;
  display: grid;
  gap: 14px;
}

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  overflow: hidden;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 14px;
  font-weight: 800;
  color: var(--amorim-red);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #fff, #fdf5f5);
  margin: -1.25rem -1.5rem 1rem;
  padding: 12px 1.5rem;
}

.panel h3 {
  font-size: 12px;
  color: var(--amorim-red);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1rem 0 0.5rem;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  color: var(--muted);
  font-weight: 800;
}

input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(148, 22, 26, 0.12);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

button {
  padding: 9px 12px;
  border-radius: 11px;
  border: 0;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

button:hover {
  background: var(--brand-dark);
}

button.primary {
  background: var(--brand);
}

button.secondary {
  background: #ececec;
  color: var(--text);
}

button.secondary:hover {
  background: #e0e0e0;
}

button.secondary-outline {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
}

button.secondary-outline:hover {
  background: var(--accent-soft);
}

.status {
  min-height: 1.25rem;
  font-size: 12px;
  margin-top: 0.75rem;
  border-radius: 12px;
  padding: 9px;
}

.status.ok {
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.status.error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: -0.25rem;
  margin-bottom: 0.75rem;
}

.hint code {
  background: var(--accent-soft);
  color: var(--amorim-red);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--accent-border);
}

.badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--amorim-red);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  border: 1px solid var(--accent-border);
}

.table-wrap {
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

/* Alça de altura dos quadros (CapPanelResize) */
.cap-wbs-resize {
  flex-shrink: 0;
  height: 10px;
  cursor: ns-resize;
  background: linear-gradient(to bottom, var(--line), #e8e8e8 40%, var(--line));
  border-top: 1px solid var(--line);
  touch-action: none;
  user-select: none;
}
.cap-wbs-resize::before {
  content: 'Arraste para ajustar a altura';
  display: block;
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  line-height: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}
.cap-wbs-resize:hover::before,
.cap-wbs-resize.dragging::before { opacity: 1; }
.cap-wbs-resize:hover,
.cap-wbs-resize.dragging {
  background: linear-gradient(to bottom, #c4c4c4, #f0f0f0 40%, #c4c4c4);
}
.cap-wbs-resize::after {
  content: '';
  display: block;
  width: 36px;
  height: 3px;
  margin: 3px auto 0;
  border-radius: 2px;
  background: var(--muted);
  opacity: 0.45;
}
body.cap-panel-resizing,
body.cap-panel-resizing * {
  cursor: ns-resize !important;
  user-select: none !important;
}
.cap-panel-reset-btn,
.cap-panel-reset-tab-btn {
  font-size: 11px !important;
  padding: 2px 8px !important;
  white-space: nowrap;
}
.pf-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.pf-table-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}
#pfTableWrap {
  min-height: 160px;
  max-height: none;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel2);
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}

tr:hover td {
  background: #faf9f9;
}

.kv-table th {
  width: 35%;
  color: var(--amorim-red);
  font-weight: 800;
  background: #fdf5f5;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
  max-height: 120px;
  overflow: auto;
  background: var(--code-bg);
  padding: 4px 6px;
  border-radius: 6px;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.errors { margin-bottom: 1rem; }

.error-item {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.dcd-block { margin-bottom: 1.5rem; }

.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-list li { margin-bottom: 0.35rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--amorim-red);
  padding: 0;
  text-decoration: underline;
  font-weight: 800;
  cursor: pointer;
}

.schema-page {
  padding: 14px;
  max-width: 960px;
  margin: 0 auto;
}

.schema-page h1,
.schema-page h2,
.schema-page h3 {
  color: var(--amorim-red);
}

.schema-page code {
  background: var(--accent-soft);
  color: var(--amorim-red);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.schema-page table {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin: 1rem 0;
}

.schema-page .mermaid {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1rem;
  border-radius: 12px;
  overflow-x: auto;
  margin: 1rem 0;
}

.schema-wrap {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
}

.painel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.painel-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-right: 8px;
}

.painel-table {
  width: max-content;
  max-width: none;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
}

.painel-table th,
.painel-table td {
  border-bottom: 1px solid var(--line);
  padding: 3px 4px;
  vertical-align: middle;
}

.painel-table th {
  background: var(--panel2);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.painel-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.painel-table th.sortable:hover {
  color: var(--amorim-red);
}

.sort-indicator {
  font-size: 10px;
  opacity: 0.75;
}

.painel-table tbody tr.row-pinned {
  background: #fde8e9;
  box-shadow: inset 0 -1px 0 var(--accent-border);
}

.painel-table-wrap {
  max-height: min(60vh, 520px);
  overflow: auto;
}

.painel-table tbody tr.selected {
  background: #fdf5f5;
}

.painel-table .col-check {
  width: 26px;
  text-align: center;
  padding-left: 2px;
  padding-right: 2px;
}

.painel-table .col-contrato {
  width: 1%;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 8px;
}

.painel-table .col-nome {
  width: auto;
  min-width: 140px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.painel-table .col-meta {
  width: 108px;
  max-width: 120px;
}

.inp-meta-obra {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 10px;
  background: #fff;
  box-sizing: border-box;
}

select.inp-meta-obra {
  cursor: pointer;
  appearance: auto;
}

.inp-meta-obra:focus {
  outline: none;
  border-color: var(--amorim-red);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.meta-filtros-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 16px;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.meta-filtros-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding-top: 4px;
}

.meta-filtro-grupo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.meta-filtro-titulo {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.meta-filtro-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.meta-chip {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.meta-chip:hover {
  border-color: var(--accent-border);
  background: var(--panel2);
  color: var(--text);
}

.meta-chip.active {
  background: var(--amorim-red);
  color: #fff;
  border-color: var(--amorim-red);
}

.vocab-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.vocab-modal[hidden] { display: none !important; }
.vocab-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.vocab-modal-box {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}
.vocab-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel2);
}
.vocab-modal-head h3 { margin: 0; font-size: 16px; }
.vocab-modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}
.vocab-modal-body {
  padding: 14px 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.vocab-modal-status {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
}
.vocab-modal-status.ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.vocab-modal-status.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.vocab-secao h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.vocab-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.vocab-inp {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
.vocab-lista {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
}
.vocab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}
.vocab-item-nome {
  font-weight: 700;
  font-size: 13px;
  flex: 1;
}
.vocab-modal-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

.painel-table .col-modulo {
  width: 86px;
  max-width: 86px;
  text-align: center;
  font-size: 10px;
  padding: 2px 3px;
}

.painel-table .col-saldo-pj,
.painel-table .col-valor-retido {
  width: 128px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 12px;
}

.status-cell {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  padding: 2px 5px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-cell.ok {
  background: #ecfdf5;
  color: var(--ok);
  border-color: #a7f3d0;
}

.status-cell.parcial {
  background: #fffbeb;
  color: var(--warn);
  border-color: #fde68a;
}

.status-cell.erro {
  background: #fef2f2;
  color: var(--error);
  border-color: #fecaca;
}

.status-cell.pendente {
  background: #f3f4f6;
  color: var(--muted);
  border-color: var(--line);
}

.status-cell:hover {
  filter: brightness(0.97);
}

.painel-progress {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.download-panel {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
}

.download-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.download-summary {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
}

.download-summary.running {
  color: #1d4ed8;
}

.download-summary.done {
  color: var(--ok);
}

.download-summary.partial {
  color: var(--warn);
}

.download-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.download-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  font-size: 12px;
}

.download-item-id {
  font-weight: 700;
  color: var(--muted);
}

.download-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-item-status {
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.download-item.queued .download-item-status {
  color: var(--muted);
}

.download-item.running {
  border-color: #fde68a;
  background: #fffbeb;
}

.download-item.running .download-item-status {
  color: #b45309;
}

.download-item.done {
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.download-item.done .download-item-status {
  color: var(--ok);
}

.download-item.error {
  border-color: #fecaca;
  background: #fef2f2;
}

.download-item.error .download-item-status {
  color: var(--error);
}

.comercial-toolbar {
  margin-bottom: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.kpi-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
}

.kpi-card .kpi-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.kpi-card strong {
  font-size: 20px;
}

.comercial-matrix-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.comercial-matrix {
  border-collapse: collapse;
  font-size: 12px;
  min-width: max-content;
}

.comercial-matrix th,
.comercial-matrix td {
  border: 1px solid var(--line);
  padding: 3px 3px;
  text-align: center;
  white-space: nowrap;
}

.painel-table .col-id-obra {
  width: 1%;
  white-space: nowrap;
}

.painel-table .col-etapa {
  width: 1%;
  text-align: center;
  white-space: nowrap;
}

.painel-table .inp-id-obra {
  width: 4.5em;
  padding: 4px 4px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.painel-table .inp-etapa {
  width: auto;
  min-width: 2.8em;
  padding: 4px 2px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.painel-table .inp-etapa:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f3f4f6;
}

.comercial-matrix .sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: left;
  min-width: 200px;
  font-weight: 600;
}

.comercial-matrix .row-label {
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
}

.comercial-matrix thead th {
  background: #f3f4f6;
  font-weight: 600;
}

.comercial-matrix .col-corte {
  background: #fef3c7;
}

.cell-realizado {
  background: #ecfdf5;
  color: #065f46;
  font-weight: 600;
}

.cell-planejado {
  background: #eff6ff;
  padding: 2px;
}

.cell-planejado input {
  width: 52px;
  padding: 4px;
  border: 1px solid #93c5fd;
  border-radius: 4px;
  text-align: center;
  font-size: 12px;
}

.cell-calculado {
  background: #f9fafb;
  font-weight: 600;
}

.legenda {
  font-size: 14px;
  margin-right: 2px;
}

.legenda.realizado { color: #059669; }
.legenda.planejado { color: #2563eb; }
.legenda.calculado { color: #6b7280; }

.versoes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.versao-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.versao-item .hint {
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.orcamento-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin: 12px 0 16px;
  font-size: 13px;
}

.orcamento-toolbar select {
  margin-left: 6px;
  min-width: 220px;
  padding: 4px 8px;
}

.orcamento-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.orcamento-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafafa;
}

.orcamento-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
}

.orcamento-card-meta {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--muted);
}

.orcamento-card dl {
  margin: 0;
  display: grid;
  gap: 6px;
}

.orcamento-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.orcamento-card dt {
  color: var(--muted);
}

.orcamento-card dd {
  margin: 0;
  font-weight: 600;
}

.orcamento-card-total dt,
.orcamento-card-total dd {
  font-weight: 700;
  color: var(--text);
}

.orcamento-matrix-table .num,
.orcamento-agrup-table .num {
  text-align: right;
  white-space: nowrap;
}

.orcamento-matrix-table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.orcamento-matrix-table tr.orc-row-agrup {
  background: #f8fafc;
  font-weight: 600;
}

.orcamento-matrix-table tr.orc-row-item td.orc-desc {
  font-weight: 400;
}

.orcamento-matrix {
  max-height: 70vh;
  overflow: auto;
}
