/* ============================================================
   COMPONENTS.CSS — Reusable UI Components
   Think LAB — Laboratório Dinâmico de Empresas
   ============================================================ */

/* ── CARD ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary-light);
  flex-shrink: 0;
}

.card-body { padding: 1.25rem; }
.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
  font-size: 0.8rem;
  color: var(--muted);
}

.card-accent-top {
  border-top: 3px solid var(--primary);
}
.card-accent-accent { border-top: 3px solid var(--accent); }
.card-accent-success { border-top: 3px solid var(--success); }
.card-accent-danger  { border-top: 3px solid var(--danger); }
.card-accent-gold    { border-top: 3px solid var(--gold); }

/* ── KPI CARD ── */
.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
}
.kpi-card.kpi-accent::before { background: linear-gradient(90deg, var(--accent-dark), var(--accent)); }
.kpi-card.kpi-success::before { background: linear-gradient(90deg, var(--success), #4caf50); }
.kpi-card.kpi-danger::before  { background: linear-gradient(90deg, var(--danger), #ef5350); }
.kpi-card.kpi-gold::before    { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-delta {
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.kpi-delta.positive { color: var(--success); }
.kpi-delta.negative { color: var(--danger); }

/* Título de seção dos KPIs (ex.: relatório de resultados) */
.kpi-section-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin: 0 0 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* KPI clicável (ex.: "Unidades Vendidas" → Decomposição da Demanda) */
.kpi-card.kpi-clickable { cursor: pointer; }
.kpi-card.kpi-clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-card.kpi-clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.kpi-link-hint {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Destaque rápido ao saltar para um box via KPI clicável */
@keyframes box-flash-kf {
  0%   { box-shadow: 0 0 0 0 rgba(57, 73, 171, 0.0); }
  20%  { box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(57, 73, 171, 0.0); }
}
.box-flash { animation: box-flash-kf 1.5s ease-out; border-radius: var(--radius); }
.kpi-delta.neutral  { color: var(--muted); }

.kpi-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
  opacity: 0.7;
}
.kpi-icon svg { width: 18px; height: 18px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }

.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background: #1b5e20; border-color: #1b5e20; color: #fff; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #8b1a1a; border-color: #8b1a1a; color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); border-color: var(--border); }

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}
.btn-sm svg { width: 14px; height: 14px; }

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius);
}

.btn-xl {
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: var(--radius);
  letter-spacing: 0.02em;
}

.btn-full { width: 100%; }

.btn-process {
  background: linear-gradient(135deg, #1b5e20, #2e7d32, #388e3c);
  color: #fff;
  border: none;
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 800;
  border-radius: var(--radius);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 4px 15px rgba(46,125,50,0.35);
  transition: all 0.2s ease;
}
.btn-process:hover {
  background: linear-gradient(135deg, #388e3c, #43a047, #4caf50);
  box-shadow: 0 6px 20px rgba(46,125,50,0.5);
  transform: translateY(-1px);
  color: #fff;
}
.btn-process:active { transform: translateY(0); }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.03em;
}
.badge svg { width: 12px; height: 12px; }

.badge-default  { background: var(--bg-alt); color: var(--text-secondary); }
.badge-primary  { background: rgba(26,35,126,0.12); color: var(--primary); }
.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: #b45309; }
.badge-danger   { background: var(--danger-light); color: var(--danger); }
.badge-info     { background: var(--info-light); color: var(--info); }
.badge-gold     { background: rgba(201,162,39,0.15); color: var(--gold); }
.badge-muted    { background: var(--border); color: var(--muted); }

/* ── FORM COMPONENTS ── */
.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-label .hint {
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.75rem;
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(57,73,171,0.1);
}
.form-control:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(198,40,40,0.12); }

.form-select {
  display: block;
  width: 100%;
  padding: 0.55rem 2.2rem 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") right 0.75rem center no-repeat;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.form-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(57,73,171,0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.3rem;
}
.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 0.3rem;
  display: none;
}
.form-error.visible { display: block; }

/* Range Sliders */
.range-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-range {
  width: 100%;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  flex: 1;
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform var(--transition);
}
.form-range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}

.range-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 40px;
  text-align: right;
  flex-shrink: 0;
}

/* ── TABLE ── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -1px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--bg);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--card-hover); }

tfoot td {
  padding: 0.6rem 1rem;
  border-top: 2px solid var(--border);
  font-weight: 700;
  background: var(--bg);
}

.td-right { text-align: right; }
.td-center { text-align: center; }
.td-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.td-bold { font-weight: 700; }
.td-muted { color: var(--muted); font-size: 0.8rem; }
.td-nowrap { white-space: nowrap; }

/* ── DRE TABLE (Financial Statements) ── */
.dre-table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
.dre-table th {
  background: var(--primary);
  color: #fff;
  padding: 0.65rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dre-table td { padding: 0.55rem 1rem; border-bottom: 1px solid var(--border-light); }
.dre-table tr.total-row td { font-weight: 800; background: var(--bg); border-top: 2px solid var(--border); }
.dre-table tr.subtotal-row td { font-weight: 700; background: #f8fafc; color: var(--primary); }
.dre-table tr.section-header td {
  background: linear-gradient(90deg, rgba(57,73,171,0.07), transparent);
  font-weight: 700;
  color: var(--primary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 0.85rem;
}
.dre-table .indent-1 td:first-child { padding-left: 2rem; }
.dre-table .indent-2 td:first-child { padding-left: 3rem; }
.dre-table .td-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dre-table .positive { color: var(--success); font-weight: 600; }
.dre-table .negative { color: var(--danger); font-weight: 600; }
.dre-table .grand-total td {
  font-weight: 800;
  font-size: 1rem;
  background: linear-gradient(90deg, rgba(26,35,126,0.08), rgba(26,35,126,0.03));
  border-top: 2px solid var(--primary-light);
  color: var(--primary);
}

/* ── ALERTS ── */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  border: 1px solid transparent;
  line-height: 1.5;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 0.1rem; }

.alert-info    { background: var(--info-light);    color: #01579b; border-color: #b3e5fc; }
.alert-success { background: var(--success-light); color: #1b5e20; border-color: #c8e6c9; }
.alert-warning { background: var(--warning-light); color: #7c4700; border-color: #ffe0b2; }
.alert-danger  { background: var(--danger-light);  color: #6a0000; border-color: #ffcdd2; }

/* ── PROGRESS BAR ── */
.progress {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}
.progress-bar.bar-success { background: linear-gradient(90deg, var(--success), #4caf50); }
.progress-bar.bar-warning { background: linear-gradient(90deg, #b45309, var(--accent)); }
.progress-bar.bar-danger  { background: linear-gradient(90deg, var(--danger), #ef5350); }
.progress-bar.bar-gold    { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }

.progress-labeled {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.progress-labeled .progress { flex: 1; }
.progress-labeled .progress-label {
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 36px;
  text-align: right;
  color: var(--muted);
}

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.25s ease;
  overflow: hidden;
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close svg { width: 20px; height: 20px; }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── TAB BAR ── */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 0.7rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.tab-btn svg { width: 15px; height: 15px; }
.tab-btn:hover { color: var(--primary); background: var(--bg); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; padding: 1.5rem 0 0; }
.tab-content.active { display: block; }

/* Tab variant — inside card */
.card-tabs { border-radius: 0; border-left: none; border-right: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── SPINNER ── */
.spinner-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.8);
  z-index: 50;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  backdrop-filter: blur(2px);
}
.spinner-overlay.active { display: flex; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 20px; height: 20px; border-width: 2px; }
.spinner-lg { width: 52px; height: 52px; border-width: 4px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--muted);
}
.loading-state .spinner { margin: 0; }
.loading-state p { font-size: 0.875rem; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  gap: 0.75rem;
  color: var(--muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.35; }
.empty-state h4 { font-size: 1rem; font-weight: 700; color: var(--text-secondary); }
.empty-state p { font-size: 0.875rem; max-width: 300px; line-height: 1.6; }

/* ── RANKING ROW ── */
.ranking-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.ranking-row:last-child { border-bottom: none; }
.ranking-row:hover { background: var(--bg); }

.ranking-position {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
  background: var(--bg-alt);
  color: var(--muted);
}
.ranking-position.pos-1 { background: linear-gradient(135deg, #c9a227, #e6c84a); color: #1a1a1a; }
.ranking-position.pos-2 { background: linear-gradient(135deg, #9e9e9e, #bdbdbd); color: #fff; }
.ranking-position.pos-3 { background: linear-gradient(135deg, #a05c25, #cd7f32); color: #fff; }

.ranking-company {
  flex: 1;
  min-width: 0;
}
.ranking-company-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-company-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.ranking-value {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ranking-value.positive { color: var(--success); }
.ranking-value.negative { color: var(--danger); }

.ranking-bar-container {
  width: 120px;
  flex-shrink: 0;
}

/* ── DECISION FORM SECTION ── */
.decision-section {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.decision-section-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── ROUND TIMELINE ── */
.round-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 0.5rem 0;
}
.round-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  min-width: 60px;
  position: relative;
}
.round-step::after {
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.round-step:last-child::after { display: none; }
.round-step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  z-index: 1;
  position: relative;
  border: 2px solid var(--card);
}
.round-step.completed .round-step-dot { background: var(--success); color: #fff; }
.round-step.current .round-step-dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 3px rgba(57,73,171,0.25); }
.round-step-label { font-size: 0.65rem; color: var(--muted); font-weight: 600; }
.round-step.current .round-step-label { color: var(--primary); font-weight: 800; }

/* ── SCENARIO / PESTEL TABLE ── */
.pestel-table { border-collapse: collapse; width: 100%; }
.pestel-table th {
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: left;
}
.pestel-table td { padding: 0.6rem 1rem; border-bottom: 1px solid var(--border-light); font-size: 0.875rem; }
.pestel-table tr:hover td { background: var(--bg); }
.pestel-factor { font-weight: 700; color: var(--primary); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.pestel-item { line-height: 1.4; }
.pestel-item + .pestel-item { margin-top: 0.4rem; }

/* ── STATUS INDICATORS ── */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}
.status-chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-submitted { background: var(--success-light); color: var(--success); }
.status-pending   { background: var(--warning-light); color: var(--warning); }
.status-processing{ background: var(--info-light);    color: var(--info); }
.status-open      { background: var(--bg-alt);        color: var(--muted); }
.status-closed    { background: var(--danger-light);  color: var(--danger); }

/* ── CHART CONTAINER ── */
.chart-container {
  position: relative;
  height: 260px;
  width: 100%;
}
.chart-container-sm { height: 200px; }
.chart-container-lg { height: 360px; }

/* Aviso "sem dados" sobreposto a um gráfico (sem destruir o canvas) */
.chart-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  border-radius: var(--radius);
}

/* ── DASHBOARD EXECUTIVO ── */
.dash-company-picker {
  display: none;
  align-items: center;
  gap: 0.45rem;
}
.dash-company-picker label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.dash-map-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Mapa + ranking lateral */
.dash-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.dash-map-wrap {
  position: relative;
  min-height: 280px;
}
#brazil-map { width: 100%; }
.br-map-svg { display: block; width: 100%; height: auto; }

.br-region {
  stroke: #ffffff;
  stroke-width: 1px;
  cursor: pointer;
  transition: opacity var(--transition), filter var(--transition);
}
.br-region:hover {
  opacity: 0.9;
  filter: brightness(1.05);
  stroke: var(--primary);
  stroke-width: 1.5px;
}
.br-region-label {
  font-size: 11px;
  font-weight: 800;
  fill: #1f2533;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 2.5px;
  pointer-events: none;
}

.map-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Tooltip flutuante do mapa */
.map-tooltip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
  min-width: 150px;
}
.map-tooltip[hidden] { display: none; }
.map-tooltip strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--primary);
  font-size: 0.82rem;
}

/* Legenda de cor do mapa */
.map-legend {
  margin-top: 0.75rem;
  max-width: 320px;
}
.legend-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.legend-bar {
  height: 10px;
  border-radius: 5px;
  border: 1px solid var(--border-light);
}
.legend-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

/* Ranking lateral por região */
.dash-region-rank {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.dash-region-rank .rank-head {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.region-row { display: flex; flex-direction: column; gap: 0.25rem; }
.region-row-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.region-bar {
  height: 7px;
  border-radius: 4px;
  background: var(--bg-alt, #eef1f8);
  overflow: hidden;
}
.region-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  transition: width var(--transition);
}
.region-sub { font-size: 0.72rem; color: var(--muted); }

@media (max-width: 820px) {
  .dash-map-layout { grid-template-columns: 1fr; }
}

/* ── SECTION DIVIDER ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-divider span {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-light);
  white-space: nowrap;
}

/* ── METRIC COMPARISON ── */
.metric-vs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.metric-vs .arrow { font-size: 1rem; }
.metric-vs .improved { color: var(--success); font-weight: 700; }
.metric-vs .declined { color: var(--danger);  font-weight: 700; }

/* ── AVATAR INITIALS ── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.65rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }

/* ── COPY-TO-CLIPBOARD ── */
.copy-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
}
.copy-field .copy-val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.copy-btn:hover { color: var(--primary); background: var(--border); }
.copy-btn svg { width: 14px; height: 14px; display: block; }

/* ── PROJECTS ── */
.projects-section { margin-top: 1.5rem; }

.projects-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.projects-divider::before,
.projects-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.projects-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.project-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg);
}
.project-card:hover { border-color: var(--primary); background: var(--bg-secondary); }
.project-card:has(.project-check:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--bg));
}

.project-check {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.project-body { flex: 1; min-width: 0; }

.project-name {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.project-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.project-cost {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.project-effect {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

/* ── RESPONSIVE FORM GRID ── */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .tab-btn { padding: 0.6rem 0.9rem; font-size: 0.8rem; }
  .tab-btn svg { display: none; }
  .projects-grid { grid-template-columns: 1fr; }
}

/* ── PRINT MEDIA QUERY FOR REPORTS ── */
@media print {
  .tab-bar,
  .btn,
  .sidebar-link,
  #topbar,
  #sidebar,
  .page-actions,
  .no-print { display: none !important; }

  .panel { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .card-body { padding: 0.75rem; }
  .dre-table th { background: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; font-size: 12px; }
  h1, h2, h3 { color: #000; }
  .kpi-value { font-size: 1.2rem; }

  .charts-row,
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }

  @page {
    margin: 15mm 12mm;
    size: A4;
  }
}

/* ── DB EXPLORER ── */
.dbe-table-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.45rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.82rem;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  gap: 0.5rem;
}

.dbe-table-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.dbe-table-btn.active {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
  font-weight: 600;
}

.dbe-table-name {
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dbe-table-count {
  flex-shrink: 0;
  font-size: 0.72rem;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 0.1rem 0.45rem;
  font-family: monospace;
}

.dbe-table-btn.active .dbe-table-count {
  background: color-mix(in srgb, var(--color-primary) 20%, transparent);
  color: var(--color-primary);
}

.dbe-type-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: var(--bg-secondary);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.dbe-pk-badge {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  background: color-mix(in srgb, var(--color-warning, #f59e0b) 15%, transparent);
  color: var(--color-warning, #f59e0b);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .03em;
}

#dbe-data-table th.dbe-col-header:hover {
  background: var(--bg-secondary);
  color: var(--color-primary);
}

/* ── HELP TOOLTIP ── */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--primary-light);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 0.25rem;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  transition: background var(--transition), transform var(--transition);
}
.help-btn:hover,
.help-btn:focus-visible {
  background: var(--primary);
  transform: scale(1.2);
  outline: none;
}

.help-tooltip-popup {
  position: fixed;
  z-index: 9999;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0.55rem 0.75rem;
  border-radius: 7px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.28);
  max-width: 260px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.help-tooltip-popup.visible {
  opacity: 1;
}

/* ============================================================
   IMPACT PANEL — Efeitos estimados das decisões (painel do aluno)
   ============================================================ */
.decisions-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.25rem;
  align-items: start;
}
.impact-panel {
  position: sticky;
  top: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 4px 16px rgba(26, 35, 126, 0.06);
}
.impact-head { margin-bottom: 0.85rem; }
.impact-title { font-size: 0.95rem; font-weight: 700; color: var(--primary); }
.impact-sub { font-size: 0.72rem; color: var(--muted); }

.impact-kpi {
  padding: 0.65rem 0.75rem;
  border: 1.4px solid var(--border-light);
  border-radius: 10px;
  background: #fbfcfe;
  margin-bottom: 0.6rem;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.impact-kpi.flash { border-color: var(--primary-light); box-shadow: 0 3px 12px rgba(57, 73, 171, 0.16); }
.impact-kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.impact-kpi-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.impact-kpi-value.ok   { color: var(--success); }
.impact-kpi-value.warn { color: var(--accent-dark); }
.impact-kpi-value.bad  { color: var(--danger); }
.impact-kpi-sub { font-size: 0.72rem; color: var(--muted); line-height: 1.4; }

.impact-bar {
  height: 9px;
  background: var(--bg-alt);
  border-radius: 6px;
  overflow: hidden;
  margin: 0.35rem 0 0.3rem;
}
.impact-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.3s ease, background 0.3s;
}
.impact-bar-fill.warn { background: linear-gradient(90deg, var(--accent-dark), var(--accent-light)); }
.impact-bar-fill.bad  { background: linear-gradient(90deg, var(--danger), #ef5350); }

.impact-cohere {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1.4px solid var(--border-light);
  background: #fbfcfe;
  margin-bottom: 0.6rem;
}
.impact-cohere-list { list-style: none; margin: 0.45rem 0 0; padding: 0; }
.impact-cohere-list li {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-secondary);
  padding: 0.28rem 0;
}
.impact-cohere-list li .ci { flex: 0 0 auto; font-size: 0.85rem; line-height: 1.3; }
.impact-cohere-list li.ok   { color: var(--success); font-weight: 600; }
.impact-cohere-list li.warn { color: #b45309; }
.impact-cohere-list li.bad  { color: var(--danger); font-weight: 600; }

.impact-disclaimer {
  font-size: 0.68rem;
  color: var(--muted-light);
  line-height: 1.45;
  border-top: 1px dashed var(--border);
  padding-top: 0.6rem;
}

@media (max-width: 1100px) {
  .decisions-layout { grid-template-columns: 1fr; }
  .impact-panel { position: static; }
}
