:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde3ea;
  --text: #1a2332;
  --text-muted: #5c6b7a;
  --primary: #005686;
  --success: #2e7d32;
  --warning: #ed6c02;
  --danger: #c62828;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 40, 80, 0.08);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
body { overflow: hidden; }
.bom-widget-body { height: 100%; min-height: 100%; overflow: hidden; background: #eceff1; }
.hidden, .bom-hidden, .ui-hidden { display: none !important; }

/* MVP 17d functional layout restored. Scope: visual CSS only. */
.bom-root,
.bom-dashboard {
  --bom-primary: #1565c0;
  --bom-good: #2e7d32;
  --bom-moderate: #f57c00;
  --bom-bad: #c62828;
  --bom-bg: #eceff1;
  --bom-card: #ffffff;
  --bom-border: #b0bec5;
  --bom-text: #263238;
  --bom-muted: #607d8b;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--bom-bg);
  color: var(--bom-text);
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
}

.bom-layout-page {
  display: grid;
  grid-template-columns: 60% 40%;
  grid-template-rows: 38px minmax(120px, 30%) minmax(0, 1fr);
  grid-template-areas:
    "top  top"
    "filt graf"
    "ebom prev";
  gap: 4px;
  padding: 4px;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.bom-zone-1 { grid-column: 1 / -1; grid-row: 1; min-height: 0; }
.bom-zone-2 { grid-column: 1 / 6; grid-row: 2; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.bom-zone-3 { grid-column: 6 / 11; grid-row: 2; min-height: 0; overflow: hidden; }
.bom-zone-4 { grid-column: 1 / 7; grid-row: 3; min-height: 0; overflow: hidden; }
.bom-zone-5 { grid-column: 7 / 11; grid-row: 3; min-height: 0; overflow: hidden; }

.bom-quad,
.bom-ebom-block,
.bom-part-preview,
.bom-chart-panel {
  background: var(--bom-card);
  border: 1px solid var(--bom-border);
  border-radius: 9px;
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
}

.bom-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bom-card);
  border: 1px solid var(--bom-border);
  border-radius: 9px;
  min-height: 38px;
  overflow: hidden;
}
.bom-topbar-left,
.bom-topbar-center,
.bom-topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bom-topbar-left { flex: 0 1 auto; }
.bom-topbar-center { flex: 1 1 auto; justify-content: center; }
.bom-topbar-actions { flex: 0 1 auto; justify-content: flex-end; }
.bom-topbar-brand { color: var(--bom-primary); font-weight: 700; font-size: .95rem; white-space: nowrap; }
.bom-explorer-context-status,
.bom-topbar-product { color: var(--bom-text); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.bom-source-badge,
.bom-build-pill,
.bom-topbar-clock { display: inline-flex; align-items: center; border: 1px solid var(--bom-border); border-radius: 999px; padding: 2px 7px; color: var(--bom-muted); background: #f8fafc; font-size: .7rem; white-space: nowrap; }
.bom-topbar-more { font-size: .74rem; color: var(--bom-muted); max-width: 90px; }
.bom-topbar-more summary { cursor: pointer; }
.bom-topbar-more[open] { position: relative; z-index: 20; max-width: 320px; background: #fff; border: 1px solid var(--bom-border); border-radius: 8px; padding: 5px; }

.bom-btn,
.btn,
.btn-primary,
.btn-secondary,
.bom-btn-primary,
.bom-btn-secondary {
  border: 1px solid var(--bom-border);
  border-radius: 7px;
  background: #fff;
  color: #0b4070;
  padding: 6px 10px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.15;
  white-space: nowrap;
}
.bom-btn-primary,
.btn-primary { background: #2b67c8; color: #fff; border-color: #2b67c8; }
.bom-btn-secondary,
.btn-secondary { background: #f7fafc; color: #0b4070; }
.bom-btn:disabled { opacity: .55; cursor: not-allowed; }
.bom-btn-compact { padding: 5px 8px; font-size: .72rem; }
.bom-input,
.bom-paste { border: 1px solid var(--bom-border); border-radius: 7px; padding: 7px 8px; font-size: .78rem; width: 100%; background: #fff; color: var(--bom-text); }

.bom-zone-2-scroll,
.bom-charts-unified-scroll { height: 100%; overflow: auto; min-height: 0; }
.bom-sync-banner { margin: 6px; padding: 7px 10px; border-left: 4px solid #2b67c8; background: #f8fbff; color: #24445c; font-size: .77rem; border-radius: 6px; }
.bom-ska-diagnostics { margin: 0 6px 6px; padding: 6px 8px; background: #f8fafc; border: 1px solid #dbe4ec; border-radius: 6px; font-size: .74rem; color: #36526b; max-height: 52px; overflow: auto; }
.bom-filter-bar-quad { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr) auto; gap: 5px; padding: 6px; align-items: end; border-bottom: 1px solid #e1e8ef; }
.bom-filter-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: .65rem; color: #5a6d7f; font-weight: 600; }
.bom-filter-item select,
.bom-filter-item input { width: 100%; min-width: 0; padding: 6px; border: 1px solid #d4e0ea; border-radius: 7px; font-size: .74rem; background: #fff; }
.stat-markers-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 6px; }
.kpi-card,
.bom-dashboard .kpi-card { background: #fff; border: 1px solid #dbe4ec; border-radius: 8px; padding: 8px 10px; text-align: center; box-shadow: none; border-left: 4px solid var(--bom-primary); }
.kpi-value,
.bom-dashboard .kpi-value { display: block; font-size: 1.15rem; line-height: 1.1; font-weight: 700; color: var(--bom-text); }
.kpi-label,
.bom-dashboard .kpi-label { display: block; font-size: .68rem; color: var(--bom-muted); margin-top: 3px; }
.bom-st { margin: 0; padding: 5px 8px; font-size: .76rem; color: #36526b; border-top: 1px solid #e1e8ef; background: #f8fafc; }
.bom-st-err, .bom-st-error { color: #a42320; background: #ffebee; }
.bom-st-ok, .bom-st-success { color: #146b2e; background: #e8f5e9; }

.bom-charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; height: 100%; }
.bom-chart-panel { display: flex; flex-direction: column; min-height: 0; }
.bom-chart-heading { margin: 6px 6px 4px; text-align: center; font-size: .82rem; color: #263238; }
.bom-chart-canvas-box { flex: 1 1 auto; min-height: 88px; height: 105px; position: relative; }
.bom-chart-canvas-box canvas { width: 100% !important; height: 100% !important; max-height: 100% !important; }
.bom-chart-legend-list { font-size: .68rem; padding: 0 8px 6px; max-height: 40px; overflow: auto; color: var(--bom-muted); }

.bom-ebom-block { height: 100%; display: flex; flex-direction: column; }
.bom-ebom-head { padding: 8px 10px; border-bottom: 1px solid #e1e8ef; flex: 0 0 auto; }
.bom-ebom-head h2 { margin: 0; font-size: .9rem; color: #123f63; }
.bom-ebom-meta { margin: 3px 0 0; font-size: .72rem; color: #5a6d7f; }
.bom-ebom-list { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.bom-table-wrap { min-height: 0; flex: 1 1 auto; overflow: auto; margin: 0; border: 0; border-radius: 0; box-shadow: none; max-height: none; }
.bom-table,
table.bom-table { width: 100%; border-collapse: collapse; font-size: .78rem; color: var(--bom-text); }
.bom-table th,
.bom-table td { border-bottom: 1px solid #edf2f7; padding: 7px 8px; text-align: left; vertical-align: middle; }
.bom-table thead th,
.bom-table th { position: sticky; top: 0; background: #eef3f8; color: #3a5870; z-index: 1; font-weight: 700; }
.bom-table tbody tr { cursor: pointer; }
.bom-table tbody tr:hover td { background: #f7fbff; }
.bom-table tbody tr.is-selected td,
.bom-table tbody tr.selected td { background: #e8f2ff; }
.bom-table-pager { padding: 6px 8px; text-align: center; border-top: 1px solid #e1e8ef; font-size: .74rem; color: #3a5870; flex: 0 0 auto; background: #fff; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; background: #eceff1; color: #546e7a; }
.badge-released, .badge.good { background: #e8f5e9; color: var(--success); }
.badge-in_work, .badge.warn { background: #fff3e0; color: var(--warning); }
.badge-obsolete, .badge.bad { background: #ffebee; color: var(--danger); }
.badge-other, .badge.neutral { background: #eef1f4; color: var(--text-muted); }

.bom-preview-quad { height: 100%; padding: 10px; overflow: hidden; }
.bom-preview-body { height: 100%; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.bom-preview-hint { margin: 0; font-size: .8rem; color: #3a5870; }
.bom-preview-image { flex: 0 0 150px; min-height: 90px; border: 1px dashed #b8c7d6; border-radius: 9px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 10px; background: #fbfdff; overflow: hidden; }
.bom-preview-image { display: none; }
.bom-preview-placeholder { color: #4a6a83; font-size: .78rem; }
.bom-preview-meta { flex: 1 1 auto; min-height: 0; font-size: .76rem; color: #24445c; overflow: auto; }
.bom-preview-meta dl,
.bom-preview-dl { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 5px 10px; margin: 0; }
.bom-preview-meta dt { font-weight: 700; color: #47657d; }
.bom-preview-meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.bom-preview-id { font-size: .68rem; color: #38566b; }
.bom-maturity-actions { margin-top: 8px; padding: 8px; border: 1px solid #e1e8ef; border-radius: 8px; background: #f8fafc; }
.bom-maturity-hint { font-size: .72rem; color: #6b7f90; margin: 4px 0 0; }

.loading-overlay,
.bom-loading { position: fixed; inset: 0; background: rgba(255, 255, 255, .72); color: #005686; display: flex; align-items: center; justify-content: center; z-index: 9999; font-weight: 700; }
.loading-overlay.hidden,
.bom-loading.bom-hidden { display: none !important; }

/* Legacy/basic sections used by non-widget pages in this repo. */
.app-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; box-shadow: var(--shadow); }
.app-header h1 { margin: 0; font-size: 1.15rem; font-weight: 600; color: var(--primary); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.main-grid { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; max-width: 1600px; margin: 0 auto; }
.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel h2 { margin: 0; padding: 12px 16px; font-size: .95rem; border-bottom: 1px solid var(--border); background: #fafbfc; }
.table-wrap, .table-scroll { overflow: auto; max-height: 520px; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eef1f4; vertical-align: top; }
th { background: #f5f7fa; color: var(--text-muted); font-weight: 600; position: sticky; top: 0; z-index: 1; }
tr:hover td { background: #f7fbff; }

@media (max-width: 920px) {
  .bom-layout-page { grid-template-columns: 1fr; grid-template-rows: auto auto auto minmax(260px, 1fr) minmax(220px, 1fr); overflow: auto; }
  .bom-zone-1, .bom-zone-2, .bom-zone-3, .bom-zone-4, .bom-zone-5 { grid-column: 1; grid-row: auto; min-height: 180px; }
  .bom-topbar { flex-wrap: wrap; min-height: auto; }
  .bom-topbar-center { justify-content: flex-start; }
  .bom-charts-row { grid-template-columns: 1fr; }
  .bom-filter-bar-quad { grid-template-columns: 1fr 1fr; }
}

/* grid-area para cada zona */
.bom-zone-1 { grid-area: top; }
.bom-zone-2, .bom-quad.bom-zone-2 { grid-area: filt; display: flex; flex-direction: column; min-height: 0; }
.bom-zone-3, .bom-quad.bom-zone-3 { grid-area: graf; display: flex; flex-direction: column; min-height: 0; }
.bom-zone-4, .bom-quad.bom-zone-4 { grid-area: ebom; display: flex; flex-direction: column; min-height: 0; }
.bom-zone-5, .bom-quad.bom-zone-5 { grid-area: prev; display: flex; flex-direction: column; min-height: 0; }

/* pizza CSS conic-gradient — sem dependencia de CDN */
.cf-pie-quad-holder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 4px; gap: 8px; }
.cf-pie-quad { position: relative; width: min(100%, 110px); height: min(100%, 110px); border-radius: 50%; flex-shrink: 0; }
.cf-pie-hole-quad { position: absolute; inset: 25%; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; color: #263238; }
.cf-pie-legend { flex: 1 1 auto; min-width: 0; font-size: .62rem; color: #546e7a; overflow: hidden; }
.cf-pie-legend-item { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-pie-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Modal de maturidade */
.bom-maturity-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bomFadeIn 0.15s ease;
}
@keyframes bomFadeIn { from { opacity: 0; } to { opacity: 1; } }
.bom-maturity-modal-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  padding: 20px 24px;
  min-width: 340px;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  font-size: 13px;
  color: #263238;
}
.bom-maturity-modal-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #1565c0;
}
.bom-maturity-modal-card p {
  margin: 6px 0;
  line-height: 1.4;
}
.bom-maturity-modal-card select {
  width: 100%;
  padding: 6px 8px;
  margin: 6px 0 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
}
.bom-maturity-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.bom-maturity-modal-actions button {
  padding: 7px 16px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.bom-maturity-modal-actions .bom-btn-secondary {
  background: #e0e0e0;
  color: #333;
}
.bom-maturity-modal-actions .bom-btn-primary {
  background: #1565c0;
  color: #fff;
}
.bom-maturity-modal-actions .bom-btn-primary:disabled {
  background: #90a4ae;
  cursor: not-allowed;
}
.bom-maturity-warning {
  color: #e65100;
  font-size: 12px;
  font-style: italic;
}
.bom-maturity-modal-status {
  margin-top: 8px;
  font-size: 12px;
  color: #546e7a;
  min-height: 18px;
}

/* Zona 5 — ações no topo + viewer 3D + detalhes */
.bom-preview-actions {
  display: flex;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.bom-preview-actions .bom-btn {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  padding: 5px 8px;
  white-space: nowrap;
}
.bom-3d-viewer-container {
  width: 100%;
  min-height: 0;
  background: #1a1a1a;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 6px;
  overflow: hidden;
  position: relative;
}
.bom-3d-viewer-container:empty {
  display: none;
}
.bom-3d-viewer-container.bom-3d-viewer-active {
  display: flex;
  flex-direction: column;
  min-height: 220px;
}
.bom-3d-viewer-container iframe.bom-3d-viewer-iframe {
  width: 100%;
  height: 280px;
  min-height: 260px;
  border: 0;
  display: block;
  background: #1a1a1a;
}
.bom-3d-viewer-container canvas {
  width: 100% !important;
  height: 100% !important;
  min-height: 260px;
}
.bom-3d-preview-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 140px;
  background: #1a1a1a;
  border-radius: 6px 6px 0 0;
  overflow: hidden;
}
.bom-3d-preview-img {
  max-width: 100%;
  max-height: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.bom-3d-preview-img.bom-3d-preview-img-failed {
  display: none;
}
.bom-3d-preview-size {
  color: #90a4ae;
  font-size: 10px;
  text-align: center;
  padding: 6px 8px 0;
  margin: 0;
}
.bom-3d-msg {
  color: #90a4ae;
  font-size: 11px;
  text-align: center;
  padding: 16px 8px;
  margin: 0;
}
.bom-3d-geometry-hint {
  position: static;
  flex-shrink: 0;
  margin: 0;
  padding: 6px 8px 8px;
  font-size: 9px;
  line-height: 1.35;
  color: #78909c;
  text-align: left;
  pointer-events: auto;
  background: #f5f5f5;
  border-radius: 0 0 4px 4px;
  border-top: 1px solid #e0e0e0;
}

/* Esconder elementos legados do bundle na zona 5 */
.bom-3dplay-empty, .bom-preview-placeholder,
.bom-viewer-wrap, .bom-viewer-canvas, .bom-viewer-host { display: none !important; }
