/* Orçamento Sintético — cores Amorim Coutinho */
body.orcamentos-page {
  overflow: hidden;
  height: 100vh;
  background: var(--bg);
}

body.orcamentos-page .topbar {
  border-bottom-color: var(--line);
}

.orc-app {
  display: grid;
  grid-template-columns: auto 1fr;
  height: calc(100vh - var(--header-h, 70px) - var(--nav-h, 0px));
  overflow: hidden;
}

.orc-slicers {
  width: 240px;
  position: relative;
  flex-shrink: 0;
}

/* —— Slicers —— */
.orc-slicers {
  background: var(--panel2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.orc-slicer-resize {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 5;
  touch-action: none;
}

.orc-slicer-resize:hover,
.orc-slicer-resize.dragging {
  background: var(--accent-border);
}

.orc-slicers-top {
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}

.orc-field span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.orc-field select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  background: var(--panel);
  color: var(--text);
}

.orc-field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.orc-btn-clear {
  width: 100%;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.orc-btn-clear:hover {
  background: #fbd5d6;
  border-color: var(--brand);
}

.orc-status {
  margin: 8px 0 0;
  font-size: 10px;
  color: var(--muted);
}

.orc-status.ok { color: var(--ok); }
.orc-status.error { color: var(--error); }

.orc-slicer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line);
}

.orc-slicer.has-active .orc-slicer-title {
  background: var(--accent-soft);
  color: var(--brand);
  border-bottom-color: var(--accent-border);
}

.orc-slicer-title {
  padding: 8px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.orc-slicer-badge {
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.orc-slicer.has-active .orc-slicer-badge {
  display: inline-block;
}

.orc-slicer-search {
  margin: 6px 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  width: calc(100% - 20px);
  background: var(--panel);
}

.orc-slicer-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  font-size: 11px;
}

.orc-slicer-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.35;
  color: var(--text);
  border: 1px solid transparent;
}

.orc-slicer-item:hover {
  background: var(--panel2);
}

.orc-slicer-item input {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--brand);
}

.orc-slicer-item.checked {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--brand);
  font-weight: 600;
}

/* —— Board —— */
.orc-board {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.orc-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.orc-board-head h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.orc-meta {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.orc-total-badge {
  text-align: right;
  padding: 8px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
}

.orc-total-badge span {
  display: block;
  font-size: 10px;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.orc-total-badge strong {
  font-size: 18px;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

/* —— Filtros ativos —— */
.orc-filtros-ativos {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 16px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.orc-filtros-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-top: 4px;
  flex-shrink: 0;
}

.orc-filtros-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.orc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--brand);
  font-size: 11px;
  font-weight: 600;
  max-width: 280px;
}

.orc-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orc-chip button {
  border: none;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.7;
}

.orc-chip button:hover {
  opacity: 1;
}

.orc-chip.drill {
  background: var(--panel);
  border-style: dashed;
}

/* —— Grid de tabelas —— */
.orc-tables {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  min-height: 0;
  overflow-y: auto;
}

.orc-row-split {
  display: flex;
  gap: 0;
  min-height: 0;
  align-items: flex-start;
  width: max-content;
  max-width: 100%;
}

.orc-split-v {
  width: 6px;
  flex-shrink: 0;
  cursor: ew-resize;
  background: transparent;
  touch-action: none;
}

.orc-split-v:hover,
.orc-split-v.dragging {
  background: var(--accent-border);
}

.orc-panel-etapa,
.orc-panel-sub {
  flex: 1 1 0;
  min-width: 0;
}

.orc-panel-resize {
  flex-shrink: 0;
  height: 10px;
  cursor: ns-resize;
  background: linear-gradient(to bottom, var(--line), #e8e8e8 40%, var(--line));
  touch-action: none;
  user-select: none;
}

.orc-panel-resize:hover,
.orc-panel-resize.dragging {
  background: linear-gradient(to bottom, var(--accent-border), var(--accent-soft) 40%, var(--accent-border));
}

.orc-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
  width: max-content;
  max-width: 100%;
  align-self: flex-start;
}

.orc-row-split .orc-panel {
  flex-shrink: 0;
}

.orc-panel-h {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--amorim-red-dark), var(--amorim-red));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.orc-panel-reset {
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 4px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.orc-panel-reset:hover {
  background: rgba(255,255,255,0.22);
}

.orc-panel-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
  height: 200px;
  min-width: 0;
}

.orc-panel-uc,
.orc-panel-celula {
  /* largura segue a tabela (max-content) */
}

.orc-panel-etapa,
.orc-panel-sub {
  min-width: 120px;
}

/* —— Tabelas —— */
.orc-tbl {
  width: max-content;
  max-width: none;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
}

.orc-tbl thead th {
  position: sticky;
  top: 0;
  background: var(--panel2);
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.orc-tbl thead th .orc-col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 3;
}

.orc-tbl thead th .orc-col-resize:hover,
.orc-tbl thead th .orc-col-resize.dragging {
  background: var(--accent-border);
}

.orc-tbl tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.orc-tbl tfoot th {
  position: sticky;
  bottom: 0;
  background: var(--accent-soft);
  color: var(--brand);
  font-weight: 700;
  padding: 7px 10px;
  border-top: 2px solid var(--accent-border);
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.orc-tbl tbody tr {
  cursor: pointer;
}

.orc-tbl tbody tr:hover td {
  background: var(--panel2);
}

.orc-tbl tbody tr.sel td {
  background: var(--accent-soft);
  color: var(--brand);
  font-weight: 600;
}

.orc-tbl tbody tr.grp td {
  background: var(--panel2);
  font-weight: 700;
  color: var(--text);
  border-top: 1px solid var(--line);
}

.orc-tbl tbody tr.item td:first-child {
  padding-left: 22px;
  font-weight: 400;
}

.orc-tbl .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 12px;
}

.orc-badge-ok {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--brand);
  font-size: 10px;
  font-weight: 700;
}

.orc-empty {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 16px;
}

@media (max-width: 1100px) {
  .orc-tables {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow-y: auto;
  }

  .orc-panel-uc,
  .orc-panel-celula,
  .orc-panel-etapa,
  .orc-panel-sub {
    grid-column: 1;
    grid-row: auto;
  }
}
