.icon-btn {
  border: 1px solid var(--border);
  background: rgba(148,163,184,0.06);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 10px;
  cursor: pointer;
}
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #041018;
  font-weight: 600;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  cursor: pointer;
  font: inherit;
}
.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn.secondary {
  background: rgba(52,211,153,0.15);
  color: #a7f3d0;
  border-color: rgba(52,211,153,0.25);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(56,189,248,0.12);
  color: #bae6fd;
  font-size: 0.78rem;
  border: 1px solid rgba(56,189,248,0.2);
}

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.panel {
  background: rgba(18, 26, 43, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.panel h2, .panel h3 { margin: 0 0 0.75rem; font-size: 1rem; font-weight: 600; }
.kpi {
  display: flex; flex-direction: column; gap: 0.35rem;
  min-height: 110px;
}
.kpi .label { color: var(--muted); font-size: 0.82rem; }
.kpi .value {
  font-family: var(--display);
  font-size: 2.2rem;
  line-height: 1;
}
.kpi .hint { color: var(--muted); font-size: 0.78rem; }
.kpi.saudavel .value { color: var(--accent-2); }
.kpi.atencao .value { color: var(--warn); }
.kpi.risco .value, .kpi.critico .value { color: var(--danger); }

.bar-list { display: grid; gap: 0.7rem; }
.bar-row { display: grid; gap: 0.25rem; }
.bar-row header { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); }
.bar-track {
  height: 10px; border-radius: 999px;
  background: rgba(148,163,184,0.12);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0ea5e9, #34d399);
  transition: width .6s ease;
}
.bar-fill.critico { background: linear-gradient(90deg, #ef4444, #f97316); }
.bar-fill.atencao { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-fill.adequado { background: linear-gradient(90deg, #10b981, #34d399); }

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: rgba(148,163,184,0.12);
  color: var(--muted);
}
.tag.danger { background: rgba(248,113,113,0.15); color: #fecaca; }
tr.row-focus td { background: rgba(56,189,248,0.08); box-shadow: inset 3px 0 0 #38bdf8; }
.tag.warn { background: rgba(251,191,36,0.15); color: #fde68a; }
.tag.ok { background: rgba(52,211,153,0.15); color: #a7f3d0; }

.form-grid { display: grid; gap: 0.8rem; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .form-grid.two { grid-template-columns: 1fr; } }
label.field { display: grid; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(2, 8, 23, 0.45);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.4rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 1rem 0; }
.swot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
@media (max-width: 800px) { .swot-grid { grid-template-columns: 1fr; } }
.swot-box { border-radius: 12px; padding: 0.9rem; border: 1px solid var(--border); min-height: 120px; }
.swot-box h4 { margin: 0 0 0.5rem; }
.swot-box.f { background: rgba(52,211,153,0.08); }
.swot-box.w { background: rgba(251,191,36,0.08); }
.swot-box.o { background: rgba(56,189,248,0.08); }
.swot-box.t { background: rgba(248,113,113,0.08); }
.swot-box ul { margin: 0; padding-left: 1.1rem; color: var(--muted); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.8rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); }
.chart-legend i { width: 0.65rem; height: 0.65rem; border-radius: 50%; display: inline-block; }
.matrix-svg { width: 100%; height: auto; display: block; }
.timeline { display: flex; flex-direction: column; gap: 0.55rem; max-height: 320px; overflow: auto; }
.timeline-item {
  display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.75rem;
  padding: 0.55rem 0.7rem; border-radius: 10px;
  border: 1px solid var(--border); color: inherit; text-decoration: none;
  background: rgba(148,163,184,0.04);
}
.timeline-item.late { border-color: rgba(248,113,113,0.45); background: rgba(248,113,113,0.06); }
.timeline-date { font-size: 0.78rem; color: var(--muted); }
.timeline-body strong { display: block; font-size: 0.92rem; margin-bottom: 0.15rem; }
.status-pies {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.6rem;
}
.status-pie {
  text-align: center;
  padding: 0.7rem;
  border-radius: 12px;
  background: rgba(148,163,184,0.06);
}
.status-pie strong { display: block; font-size: 1.4rem; }

.toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 80;
  background: #122033; border: 1px solid var(--border);
  padding: 0.8rem 1rem; border-radius: 12px; box-shadow: var(--shadow);
  animation: fadeUp .25s ease;
}

.alerts-btn { position: relative; text-decoration: none; color: inherit; }
.alerts-count {
  position: absolute; top: -0.2rem; right: -0.25rem;
  min-width: 1.1rem; height: 1.1rem; padding: 0 0.25rem;
  border-radius: 999px; background: #f59e0b; color: #0f172a;
  font-size: 0.65rem; font-weight: 700; line-height: 1.1rem; text-align: center;
}
.alerts-count.sev-alta { background: #f87171; color: #0f172a; }
.alerts-list { display: flex; flex-direction: column; gap: 0.75rem; }
.alert-card {
  display: grid; grid-template-columns: 1fr auto; gap: 0.85rem;
  padding: 0.9rem 1rem; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(148,163,184,0.05);
}
.alert-card.sev-alta { border-color: rgba(248,113,113,0.45); background: rgba(248,113,113,0.06); }
.alert-card.sev-media { border-color: rgba(251,191,36,0.4); background: rgba(251,191,36,0.05); }
.alert-card .tag.sev { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.7rem; }
@media (max-width: 640px) {
  .alert-card { grid-template-columns: 1fr; }
}

.errorplot-wrap { position: relative; }
.errorplot-legend {
  display: flex; flex-wrap: wrap; gap: 1rem;
  font-size: 0.82rem; color: var(--muted); margin-bottom: 0.4rem;
}
.errorplot-legend .lg-mean { color: #7dd3fc; }
.errorplot-legend .lg-err { color: #38bdf8; }
.errorplot-legend .lg-atual { color: #6ee7b7; }
.errorplot-legend .lg-pi90 { color: rgba(251, 191, 36, 0.55); }
.errorplot-legend .lg-pi50 { color: rgba(251, 191, 36, 0.85); }
.errorplot-legend .lg-forecast { color: #fbbf24; }
.errorplot-legend .lg-struct { color: #a78bfa; }
.errorplot-svg { display: block; width: 100%; height: auto; }
.errorplot-svg .ep-pi-90 { fill: rgba(251, 191, 36, 0.14); stroke: none; }
.errorplot-svg .ep-pi-50 { fill: rgba(251, 191, 36, 0.28); stroke: none; }
.errorplot-tooltip {
  position: absolute;
  z-index: 5;
  max-width: 280px;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: rgba(8, 15, 28, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.45;
  pointer-events: none;
}
.errorplot-detail { margin-top: 0.75rem; font-size: 0.88rem; }

.module-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}
.module-subnav-item {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.22);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background .2s, color .2s, border-color .2s;
}
.module-subnav-item:hover { color: var(--text); border-color: rgba(125,211,252,0.45); }
.module-subnav-item.active {
  color: #e0f2fe;
  background: rgba(56,189,248,0.14);
  border-color: rgba(56,189,248,0.45);
}
.fat-module-card:hover { border-color: rgba(56,189,248,0.35); }

.sparkline { width: 120px; height: 28px; display: block; opacity: 0.9; }

.search-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(2, 8, 18, 0.72);
  display: flex; justify-content: center; padding-top: 12vh;
}
.search-overlay.hidden { display: none; }
.search-panel {
  width: min(640px, 92vw); max-height: 70vh;
  background: #0f172a; border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  padding: 0.85rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.search-panel input {
  width: 100%; padding: 0.75rem 0.85rem; border-radius: 10px;
  border: 1px solid var(--border); background: #0b1220; color: var(--text);
  font: inherit; font-size: 1rem;
}
.search-results { overflow: auto; max-height: 48vh; display: flex; flex-direction: column; gap: 0.35rem; }
.search-item {
  display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem;
  padding: 0.55rem 0.65rem; border-radius: 10px; text-decoration: none; color: inherit;
  border: 1px solid transparent;
}
.search-item:hover { background: rgba(56,189,248,0.08); border-color: rgba(56,189,248,0.25); }
.search-item .tag { grid-row: span 2; align-self: center; }
.search-item strong { font-size: 0.92rem; }
.search-hint { margin: 0; font-size: 0.75rem; }

.why-chain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.why-chain li {
  position: relative;
  padding: 0.7rem 0.85rem 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(56,189,248,0.05);
}
.why-chain li + li::before {
  content: "↓";
  position: absolute; top: -0.85rem; left: 1rem;
  color: #38bdf8; font-size: 0.9rem;
}
.why-n { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.2rem; }
.why-editor { display: flex; flex-direction: column; gap: 0.55rem; }
.why-step { margin: 0; }
.ishikawa-svg { width: 100%; height: auto; display: block; margin-top: 0.4rem; }
.ishikawa-editor { margin-top: 0.4rem; }
.rca-preview { padding: 0.8rem; border-radius: 12px; border: 1px solid var(--border); background: rgba(148,163,184,0.04); }
