/* Extensões funcionais sobre os primitivos visuais canônicos. */
#nav { overflow-y: auto; }
.scope { position: static; }
.external-links { display: flex; flex-wrap: wrap; gap: 6px; }
.external-links a { color: var(--accent); font-size: 9px; font-weight: 700; text-decoration: none; }
.external-links a:hover { text-decoration: underline; }
.error-text { color: var(--bad); }
.rich-table { max-height: 650px; }
.rich-table table { min-width: 1450px; }

.drawer-back { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: flex-end; background: rgba(11, 15, 18, .34); backdrop-filter: blur(4px); }
.drawer { width: min(700px, 94vw); height: 100vh; overflow: auto; background: var(--bg); box-shadow: -20px 0 50px rgba(0, 0, 0, .14); }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: rgba(246, 247, 244, .95); backdrop-filter: blur(16px); }
.drawer-head h2 { margin: 3px 0 0; font-size: 24px; letter-spacing: -.04em; }
.drawer-body { padding: 18px 20px 40px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.detail { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.detail small { display: block; margin-bottom: 5px; color: var(--muted); font-size: 8px; text-transform: uppercase; }
.detail b { display: block; overflow-wrap: anywhere; font-size: 10px; }
.detail-section { margin-top: 15px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.detail-section h3 { margin: 0 0 10px; font-size: 11px; }
.record { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 9px; }
.record:last-child { border-bottom: 0; }
.record span { color: var(--muted); text-align: right; }

.metrics.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 15px 0 0; }
.metrics.compact .metric { min-height: 75px; }
.metrics.compact .metric-value { margin: 7px 0 2px; font-size: 20px; }
.inspection-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.inspection-grid span { padding: 7px; border-radius: 9px; background: #f7f8f5; }
.inspection-grid small, .inspection-grid b { display: block; font-size: 8px; }
.inspection-grid small { margin-bottom: 3px; color: var(--muted); }
.inspection-grid .wide { grid-column: span 2; }
.sync-actions { display: grid; gap: 6px; justify-items: end; }

.financial-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--muted); font-size: 9px; }
.financial-toolbar label { display: flex; align-items: center; gap: 8px; }
.financial-toolbar input { height: 34px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: #3f4642; font-size: 9px; }
.inline-form { padding: 15px; border-bottom: 1px solid var(--line); background: #fbfcfa; }
.inline-form .btn { margin-top: 12px; }
.compact-form .fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.status-select { min-width: 105px; height: 30px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: #4c534f; font-size: 9px; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.kanban-column { min-width: 220px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: #eef1ed; scroll-snap-align: start; }
.kanban-head { display: flex; justify-content: space-between; padding: 11px; border-bottom: 1px solid #dce1dc; color: #242a27; font-size: 9px; }
.kanban-head span { color: var(--muted); }
.kanban-list { display: grid; align-content: start; gap: 7px; min-height: 100px; padding: 7px; }
.kanban-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 9px; box-shadow: 0 3px 10px rgba(20, 27, 24, .03); }
.kanban-open { width: 100%; display: grid; gap: 5px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; font-size: 9px; text-align: left; }
.kanban-open b { color: #1f2522; }
.kanban-open span { color: var(--muted); }
.phase-action { display: flex; gap: 5px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.phase-action select { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 8px; }

.summary-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-chip { min-width: 130px; display: grid; gap: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 9px; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; margin-bottom: 16px; }
.kpi-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.kpi-card strong { display: block; margin: 15px 0 6px; overflow-wrap: anywhere; font-size: 23px; letter-spacing: -.04em; }
.kpi-card h3 { margin: 0 0 8px; font-size: 11px; }
.kpi-card p, .kpi-card small { color: var(--muted); font-size: 8.5px; line-height: 1.5; }
.company-grid { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 9px; overflow-x: auto; padding-bottom: 6px; }
.company-card { min-width: 210px; cursor: pointer; }
.company-card.selected { border-color: #809d91; box-shadow: 0 0 0 1px #809d91 inset; }
.document-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); background: #fbfcfa; }
.document-filters input, .document-filters select { min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: #454c48; font-size: 10px; }

@media (max-width: 1300px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compact-form .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .detail-grid, .kpi-grid, .metrics.compact, .document-filters, .compact-form .fields { grid-template-columns: minmax(0, 1fr); }
  .record { align-items: flex-start; flex-direction: column; }
  .record span { text-align: left; }
  .inspection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer { width: 100vw; }
  .drawer-body { padding-inline: 14px; }
}
