:root {
  --bg: #0f172a; --panel: #1e293b; --panel2: #16213a; --border: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8;
  --good: #22c55e; --bad: #f87171; --warn: #fbbf24;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Segoe UI', Roboto, Arial, sans-serif; padding: 24px; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 14px; margin: 0 0 12px; color: var(--text); }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.top-selectors { display:flex; flex-wrap:wrap; gap:16px; align-items:flex-end; margin-bottom:16px; background:var(--panel); border:1px solid var(--border); border-radius:10px; padding:14px 16px; }
.selector-group { display: flex; flex-direction: column; gap: 4px; }
.selector-group label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
select, input.text-input {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; font-size: 13px; min-width: 160px;
}
select.table-select { min-width: 92px; padding: 3px 5px; font-size: 11px; border-radius: 4px; }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab-btn { background: transparent; border: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 10px 16px; cursor: pointer; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; }
.tab-btn:hover { color: var(--text); background: var(--panel); }
.tab-btn.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.kpi .value.bad { color: var(--bad); }
.kpi .value.good { color: var(--good); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 20px; }
.charts { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 20px; }
.chart-box { position: relative; height: 280px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; max-height: 640px; overflow-y: auto; }
table { border-collapse: collapse; font-size: 11.5px; white-space: nowrap; }
th, td { border: 1px solid var(--border); padding: 4px 6px; text-align: right; }
th { background: var(--panel2); position: sticky; top: 0; z-index: 2; font-weight: 600; }
td.date-col, th.date-col { position: sticky; left: 0; background: var(--panel2); z-index: 3; text-align: left; font-weight: 500; }
th.date-col { z-index: 4; }
input.cell-input { width: 60px; background: transparent; border: none; color: var(--text); text-align: right; font-size: 11.5px; font-family: inherit; }
input.cell-input:focus { background: #0b1220; outline: 1px solid var(--accent); border-radius: 3px; }
td.summary { background: #17233d; font-weight: 600; color: var(--accent); }
tr.total-row td { background: #0b1220; font-weight: 700; border-top: 2px solid var(--border); }
.legend-note { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.footer-note { font-size: 12px; color: var(--muted); margin-top: 24px; text-align: center; }
.action-btn { background: var(--accent); color: #05263a; border: none; border-radius: 6px; padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; }
.action-btn.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }

.selector-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin-bottom: 16px; }
td.fonte-cell { white-space: normal; min-width: 150px; vertical-align: top; }
.recommend-badge { margin-top: 4px; font-size: 10px; color: var(--warn); font-weight: 700; line-height: 1.3; }
.attention-row td { background: rgba(251,191,36,0.06); }
/* Etapa 5: indicador explicito de dado ausente (nunca 0) nas 4 fontes de
   irradiancia -- diferente visualmente de um simples "-", que poderia ser
   confundido com valor baixo/zero a um olhar rapido. */
td.missing-cell { background: rgba(248,113,113,0.12); color: var(--bad); font-style: italic; }
.total-inversor-box { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; }
.total-inversor-box .label { font-size: 11px; color: var(--muted); }
.total-inversor-box .value { font-size: 20px; font-weight: 700; color: var(--warn); }

.weights-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.weights-table th { background: var(--panel2); text-align: left; padding: 8px 10px; position: static; }
.weights-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.weights-table tr:last-child td { border-bottom: none; background: #10233a; font-weight: 700; }
.weight-input { width: 70px; background: var(--panel2); border: 1px solid var(--border); border-radius: 5px; color: var(--text); padding: 4px 6px; text-align: right; font-size: 13px; }
.weight-input:focus { outline: 1px solid var(--accent); }

.sum-banner { padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; margin-bottom: 12px; }
.sum-banner.ok { background: rgba(34,197,94,0.12); color: var(--good); border: 1px solid rgba(34,197,94,0.3); }
.sum-banner.error { background: rgba(248,113,113,0.12); color: var(--bad); border: 1px solid rgba(248,113,113,0.3); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; margin-bottom: 4px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; max-width: 560px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal-box h3 { margin-top: 0; }
.modal-box .btn-row { justify-content: flex-end; margin-top: 16px; }
.modal-summary-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 10px 0; }
.modal-summary-table th { background: var(--panel2); text-align: left; padding: 5px 8px; }
.modal-summary-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.undo-banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; margin-bottom: 12px; background: rgba(56,189,248,0.12); color: var(--accent); border: 1px solid rgba(56,189,248,0.3); }
.undo-banner button { flex-shrink: 0; }
.type-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.type-bar-label { width: 170px; flex-shrink: 0; color: var(--text); }
.type-bar-track { flex: 1; background: #0b1220; border-radius: 4px; height: 14px; overflow: hidden; }
.type-bar-fill { height: 100%; border-radius: 4px; }
.type-bar-value { width: 150px; flex-shrink: 0; text-align: right; color: var(--muted); }
.coverage-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.status-msg { padding: 10px 14px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--border); font-size: 13px; margin-bottom: 16px; }
.status-msg.error { color: var(--bad); border-color: rgba(248,113,113,0.4); }
