/* Componentes — Orçamento/DRE
 *
 * Valores visuais herdados da aplicação de IA; nomes trazidos para o domínio da
 * Controladoria. Herdar `teams-executive-panel` para exibir um Centro de Custo
 * carregaria vocabulário do chat para dentro do DRE. Mapa em docs/BRAND.md §8.
 *
 * Zero inline, zero CDN, zero webfont externa — verificado por
 * api/tests/python/test_pages_security.py.
 */

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark light; }

body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; }

/* ---------- Layout ---------- */

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px);
  padding-top: calc(clamp(16px, 3vw, 32px) + env(safe-area-inset-top));
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-main);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.brand-mark { width: 38px; height: 38px; border-radius: 8px; display: block; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.brand-subtitle { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .9px; }

.header-aside { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------- Card e painel ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card-title { font-size: 14.5px; font-weight: 700; margin: 0 0 4px; }
.card-description { font-size: 12.5px; color: var(--text-muted); margin: 0 0 14px; }

.panel { border-top: 1px solid var(--border-main); padding-top: 14px; margin-top: 14px; }
.panel-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .9px; color: var(--text-hint); margin-bottom: 8px;
}

/* ---------- Botões ---------- */

.btn-primary, .btn-secondary {
  font-family: inherit; font-size: 13px; font-weight: 700;
  border-radius: 9px; padding: 10px 16px; cursor: pointer; transition: .18s;
}
.btn-primary {
  border: none; color: #fff;
  background: linear-gradient(135deg, var(--accent-hex), var(--accent-hex-2));
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), .30);
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary {
  border: 1px solid var(--border-input);
  background: transparent; color: var(--accent-hex);
}
.btn-secondary:hover { background: rgba(var(--accent-rgb), .10); }
.btn-primary:focus-visible, .btn-secondary:focus-visible,
.tab:focus-visible, .input:focus-visible {
  outline: 2px solid var(--accent-hex); outline-offset: 2px;
}

/* ---------- Formulário ---------- */

.form { display: grid; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.input {
  font-family: inherit; font-size: 13px; padding: 9px 11px;
  border-radius: 8px; border: 1px solid var(--border-input);
  background: var(--bg-input); color: var(--text-main); outline: none;
}

/* ---------- Tabs ---------- */

.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border-main); flex-wrap: wrap; }
.tab {
  font-family: inherit; font-size: 12px; font-weight: 700;
  border: 0; background: transparent; color: var(--text-muted);
  padding: 9px 13px 11px; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab[aria-selected="true"] { color: var(--text-main); border-bottom-color: var(--accent-hex); }

/* ---------- Tabela ---------- */

/* Tabela financeira é larga por natureza: rola no próprio container,
 * nunca no body. */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-main); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border-msg, var(--border-main)); white-space: nowrap; }
th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-hint); font-weight: 700; }
/* Valor monetário: alinhado à direita e em fonte tabular, para as casas
 * decimais alinharem verticalmente numa DRE. */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty-state { padding: 22px; text-align: center; color: var(--text-muted); font-size: 12.5px; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .62);
  display: flex; align-items: center; justify-content: center;
  padding: 18px; z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bg-elevated); border: 1px solid var(--border-card);
  border-radius: 14px; box-shadow: var(--shadow-card);
  width: min(760px, 100%); max-height: 88vh; overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--border-main);
}
.modal-title { font-size: 14px; font-weight: 700; }
.modal-close {
  margin-left: auto; border: none; background: transparent;
  color: var(--text-muted); font-size: 16px; cursor: pointer;
  font-family: inherit; line-height: 1; padding: 4px 8px;
}
.confirm-modal .modal { width: min(420px, 100%); text-align: center; }

/* ---------- Estados ---------- */

.state-card { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 30px 20px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(var(--accent-rgb), .25);
  border-top-color: var(--accent-hex);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.status-line { display: flex; align-items: center; gap: 9px; font-size: 13px; min-height: 24px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-hint); flex-shrink: 0; }
.dot.is-ok { background: var(--ok); }
.dot.is-warn { background: var(--warn); }
.dot.is-error { background: var(--danger); }

.feedback { font-size: 12px; margin-top: 8px; min-height: 18px; }
.feedback.is-ok { color: var(--ok); }
.feedback.is-error { color: var(--danger); }

.mono { font-family: monospace; font-size: 11.5px; color: var(--text-sub); }

/* Variação: cor sempre acompanhada de sinal no texto, nunca cor sozinha. */
.delta-positive { color: var(--ok); }
.delta-negative { color: var(--danger); }

.app-footer {
  margin-top: 28px; padding-top: 16px;
  border-top: 1px solid var(--border-main);
  font-size: 11px; color: var(--text-hint);
  display: flex; gap: 12px; flex-wrap: wrap;
}

@media (max-width: 640px) {
  .app-header { gap: 10px; }
  .header-aside { margin-left: 0; width: 100%; }
  .card { padding: 15px 16px; }
}
