/* Tokens da interface atual do Construtec Orçamentos (src/index.css).
   Os aliases preservam os módulos financeiros existentes. */
:root {
  color-scheme: light;
  --navy: #122036;
  --navy-2: #1b2c45;
  --ink: #172033;
  --muted: #596579;
  --line: #e4e6ea;
  --control-border: #8b96a7;
  --canvas: #f7f8fa;
  --white: #fefefe;
  --surface-raised: var(--white);
  --surface-muted: #f7f8fa;
  --accent: #085ce5;
  --accent-dark: #064bbd;
  --blue: #085ce5;
  --green: #14783c;
  --red: #b62e38;
  --focus-ring: #085ce5;
  --text: var(--ink);
  --radius: 6px;
  --shadow: 0 1px 3px rgba(18,32,54,.05);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

.view { animation: cc-view-fade .16s ease; }
@keyframes cc-view-fade { from { opacity: .35; transform: translateY(3px); } }
html.dark {
  color-scheme: dark;
  --canvas: #101a2a;
  --white: #19263a;
  --surface-muted: #142033;
  --ink: #edf2fa;
  --muted: #b1bed0;
  --line: #33445d;
  --control-border: #71839b;
  --blue: #9bc1ff;
  --green: #75d89b;
  --red: #ff9ca5;
  --focus-ring: #9bc1ff;
  --text: var(--ink);
}
::selection { color: #fff; background: #145fd0; }
body { color: var(--ink); }
a { color: var(--blue); text-underline-offset: 3px; }
input, textarea { caret-color: var(--blue); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.hint, .empty, .login-foot, .kpi span { color: var(--muted); }
:is(button,a,input,select,textarea,[tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: 3px;
}
html.dark :focus-visible { border-width: 1px !important; box-shadow: none !important; }
.topbar :focus-visible, .sidebar :focus-visible { outline-color: #9bc1ff !important; outline-offset: -3px; }
.btn.primary, .btn.primary:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
  transform: none;
}
.btn.primary:hover { background: var(--accent-dark); }
.btn.secondary, html.dark .btn.secondary { background: var(--white); border-color: var(--control-border); color: var(--ink); }
.btn.secondary:hover, html.dark .btn.secondary:hover { background: var(--surface-muted); border-color: var(--blue); }
.text-btn, .row-actions button, .password-toggle { color: var(--blue); }
.row-actions button.danger { color: var(--red); }
.center-card-footer .text-btn.danger { color: var(--red); }
.center-card-footer .text-btn.danger:hover { text-decoration: underline; }
.row-actions button { min-height: 32px; padding: 4px 8px; font-size: 12px; }
.panel, .kpi, .center-card, .filter-bar, .table-card {
  background: var(--white);
  border-color: var(--line);
  border-radius: var(--radius);
  box-shadow: none;
}
html.dark :is(.panel,.kpi,.center-card,.filter-bar,.table-card) { box-shadow: none; }
.kpi::before { display: none; }
.kpi p { font-size: 12px; letter-spacing: .02em; text-transform: none; }
.kpi span { font-size: 12px; }
.kpi.revenue strong { color: var(--green); }
.kpi.expense strong, .kpi.overdue strong { color: var(--red); }
.panel h2, .center-card-title, .page-head h1 { color: var(--ink); }
/* CC-P3: pills de bug report (severidade/status) com classes proprias, mesma paleta de .pill.pendente/.vencido/.despesa/.ativo/.inativo/.projeto-execucao, sem reaproveitar o significado financeiro/orcamento. */
.pill.bug-baixa { background: #edf1f2; color: #5f6b70; }
.pill.bug-media, .pill.bug-aberto { background: #fff2d9; color: #8b5a00; }
.pill.bug-alta { background: #fae9e6; color: #a43c34; }
.pill.bug-critica { background: #f6c7c1; color: #7a1f1a; }
.pill.bug-andamento { background: #ddf3fa; color: #176d89; }
.pill.bug-resolvido { background: #e2f4ec; color: #177354; }
.pill.bug-fechado { background: #eceeed; color: #7d868a; }
.filter-bar { grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); }
/* CC-P0-07: regra base incondicional; antes so existia dentro de media queries e o grid nao renderizava acima de 1000px. */
.centers-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
/* CC-P2: cards de Centros de Custo sao clicaveis e agora tambem ativaveis via teclado (Enter/Espaco). */
.center-card { cursor: pointer; }
.center-card:focus-visible { outline: 3px solid rgba(8,92,229,.35); outline-offset: 2px; }
.center-card-icon svg { stroke: var(--navy); }
.head-filters, .page-head-actions { flex-wrap: wrap; min-width: 0; }
.filter-bar > *, .settings-grid > *, .dashboard-grid > * { min-width: 0; }
.table-scroll { max-width: 100%; overflow: auto; scrollbar-width: thin; }
th, html.dark th { color: var(--muted); background: var(--surface-muted); font-size: 11px; }
td { font-size: 12px; border-color: var(--line); }
td, .money, .kpi strong { font-variant-numeric: tabular-nums; }
tbody tr:hover, html.dark tbody tr:hover { background: var(--surface-muted); }
.pill { font-size: 10px; letter-spacing: .02em; }
.table-meta { gap: 12px; flex-wrap: wrap; font-size: 12px; }
.main { max-width: none; }
.sidebar { background: var(--navy) !important; }
.sidebar nav { scrollbar-width: thin; }
.sidebar nav .nav-item span { white-space: normal !important; overflow: visible !important; }
.sidebar nav .nav-item.ativo::before { background: var(--accent) !important; }
.topbar { background: var(--navy) !important; }
.topbar .brand { flex-shrink: 0; }
.topbar .brand-logo { display: block !important; }
.topbar .brand-symbol-mobile { display: none !important; }
.instance-name { min-width: 0; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.user-copy { min-width: 0; max-width: 140px; }
.topbar #topbar-theme-toggle {
  display: inline-flex !important; align-items: center; justify-content: center;
  width: 34px !important; min-width: 34px !important; height: 32px !important;
  min-height: 32px !important; padding: 4px !important; text-indent: 0 !important;
  color: #f8fafc !important; background: transparent !important;
  border: 1px solid #71839b !important; border-radius: 6px !important;
  box-shadow: none !important; line-height: normal !important;
}
.topbar #topbar-theme-toggle::before, .topbar #topbar-theme-toggle::after,
.topbar #mobile-menu::before { content: none !important; }
.topbar { height: 43px !important; min-height: 43px !important; max-height: 43px !important; padding: 0 16px !important; gap: 10px !important; }
.topbar .brand { gap: 10px !important; padding: 0 16px !important; }
.topbar .brand-logo { display: none !important; }
.topbar .brand-symbol-mobile { display: block !important; width: 22px !important; height: 22px !important; object-fit: contain !important; }
.topbar .brand span { font-size: 14px !important; font-weight: 700 !important; color: #f2f7fa !important; }
.topbar-actions { gap: 3px !important; }
.instance-name { display: none !important; }
.topbar-status { display: inline-flex !important; align-items: center; gap: 7px; margin-left: 0; padding: 0 16px; color: #eef2f7; font-size: 12px; white-space: nowrap; }
/* Cinza neutro: o indicador é permanentemente "Offline / Dados locais" (app local-first),
   não uma conexão ativa — verde sugeriria "conectado", o que contradiz o rótulo ao lado. */
.topbar-status .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #8fa2ad; }
.status-caret { font-size: 16px; line-height: 1; color: #dbe7ef; margin-left: -2px; }
.topbar-search { display: flex; align-items: center; gap: 9px; flex: 0 1 420px; height: 34px; margin: 0 auto; padding: 0 12px; border: 1px solid #3b475a; border-radius: 6px; background: #293242; color: #c9d1dc; }
.topbar-search input { width: 100%; border: 0; outline: 0; background: transparent; color: #dbe7ef; font: inherit; font-size: 12px; }
.topbar-search input, .topbar-search input::placeholder { text-shadow: none !important; }
.topbar-search, .topbar-search input { box-shadow: none !important; }
.topbar-search input { opacity: 1 !important; -webkit-appearance: none; }
.topbar-search input::placeholder { color: #62728a; }
.busca-resultados { position: fixed; z-index: 1000; max-height: 420px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; border: 1px solid #ccd6e2; border-radius: 10px; background: #fff; box-shadow: 0 16px 40px rgba(18,32,54,.2); }
.busca-resultado-grupo { display: flex; flex-direction: column; gap: 2px; }
.busca-resultado-titulo { padding: 6px 8px 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #718096; }
.busca-resultado-item { display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 0; border-radius: 7px; background: transparent; color: #172033; font: inherit; text-align: left; cursor: pointer; }
.busca-resultado-item:hover, .busca-resultado-item:focus-visible { background: #f6f9fc; outline: none; }
.busca-resultado-item strong { font-size: 13px; font-weight: 600; }
.busca-resultado-item span { font-size: 12px; color: #718096; }
.busca-resultado-vazio { padding: 10px 8px; font-size: 12px; color: #718096; cursor: default; }
html.dark .busca-resultados { background: var(--white); border-color: var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.35); }
html.dark .busca-resultado-titulo { color: var(--muted); }
html.dark .busca-resultado-item { color: var(--ink); }
html.dark .busca-resultado-item:hover, html.dark .busca-resultado-item:focus-visible { background: var(--surface-muted); }
html.dark .busca-resultado-item span { color: var(--muted); }
html.dark .busca-resultado-vazio { color: var(--muted); }
.topbar .icon-button { width: 34px !important; height: 34px !important; min-width: 34px !important; padding: 6px !important; border: 0 !important; border-radius: 6px !important; background: transparent !important; color: #e5eaf0 !important; }
.topbar .icon-button:hover { background: #233147 !important; }
/* Topbar actions share one hit area so mail and theme stay optically aligned. */
.topbar .icon-button, .topbar #topbar-theme-toggle {
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  margin: 0 !important;
  align-self: center !important;
}
.topbar #topbar-theme-toggle {
  display: grid !important;
  place-items: center !important;
  padding: 0 !important;
  line-height: 0 !important;
  text-indent: 0 !important;
  transform: none !important;
}
.topbar #topbar-theme-toggle span { display: none !important; }
.topbar #topbar-theme-toggle svg { display: block; width: 18px; height: 18px; margin: 0; }
button:not(:disabled):active { transform: translateY(1px) !important; }
.topbar #topbar-theme-toggle:not(:disabled):active { transform: translateY(1px) !important; }
.topbar .icon-button:hover, .topbar .icon-button:focus-visible {
  border: 1px solid rgba(255,255,255,.9) !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,.18) !important;
}
.topbar-profile { position: relative; border: 0 !important; padding: 0 !important; gap: 0 !important; }
.profile-trigger { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; color: #f2f7fa; padding: 4px 6px; cursor: pointer; }
.profile-trigger .user-copy { max-width: 90px; text-align: left; }
.profile-trigger .user-copy span { display: none !important; }
.profile-trigger .user-copy span { color: #8da4af; }
.profile-caret { color: #dbe7ef; font-size: 18px; }
.profile-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 1000; width: 270px; padding: 16px; display: flex; flex-direction: column; gap: 12px; border: 1px solid #ccd6e2; border-radius: 10px; background: #fff; box-shadow: 0 16px 40px rgba(18,32,54,.2); }
.profile-menu-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid #dce3eb; }
.profile-menu-avatar { width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 48px; overflow: hidden; border-radius: 50%; background: #122036; color: #fff; font-size: 22px; font-weight: 700; }
.profile-menu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-menu-head strong { display: block; color: #172033; font-size: 18px; }
.profile-menu-head span { display: block; color: #718096; font-size: 12px; }
.profile-menu-head em { display: inline-block; margin-top: 5px; padding: 3px 8px; border-radius: 5px; background: #ecfdf3; color: #15803d; font-size: 11px; font-style: normal; }
.profile-menu-info { display: grid; gap: 3px; padding: 12px; border-radius: 8px; background: #f6f9fc; color: #43536a; }
.profile-menu-info strong { font-size: 13px; margin-top: 3px; }
.profile-menu-info span { color: #718096; font-size: 11px; padding-left: 17px; }
.profile-menu button { min-height: 36px; border: 1px solid #fecaca; border-radius: 7px; background: #fff5f5; color: #dc2626; font-size: 14px; cursor: pointer; }
html.dark .profile-menu { background: var(--white); border-color: var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.35); }
html.dark .profile-menu-head { border-bottom-color: var(--line); }
html.dark .profile-menu-avatar { background: var(--navy-2); }
html.dark .profile-menu-head strong, html.dark .profile-menu-info { color: var(--ink); }
html.dark .profile-menu-head span, html.dark .profile-menu-info span { color: var(--muted); }
html.dark .profile-menu-info { background: var(--surface-muted); }
html.dark .profile-menu button { background: rgba(182,46,56,.12); border-color: rgba(255,156,165,.35); color: var(--red); }
@media (max-width: 900px) {
  .topbar-search { display: none !important; }
  .topbar-status { font-size: 12px; gap: 5px; }
}
.suite-dropdown-menu { left: auto !important; right: 0 !important; max-width: calc(100vw - 28px); }
.login-about { background: var(--navy); padding: clamp(32px,6vw,88px); }
.login-about::before, .login-about::after { display: none; }
.login-logo { width: min(300px,85%); margin-bottom: 36px; }
.login-about h1 { font-size: clamp(32px,4vw,52px); letter-spacing: -.03em; }
.login-panel, html.dark .login-panel { background: var(--canvas); }
.login-card, html.dark .login-card { border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.login-card label, .modal label, .settings-grid label { color: var(--muted); }
.login-card .btn, .login-card input { min-height: 44px !important; }
.mobile-brand { color: var(--ink); }
.modal { border-radius: 7px; }
.modal-head { position: sticky; top: 0; background: var(--white); z-index: 2; }
.modal-head .icon-btn { min-width: 44px; min-height: 44px; }

/* Construtec workbench: keep legacy modules on the shared flat visual system. */
.nav-item.ativo { background: var(--accent) !important; box-shadow: none !important; }
.trend-month .bar { border-radius: 3px 3px 0 0; }
.modal { border-radius: 7px !important; box-shadow: 0 14px 34px rgba(18,32,54,.18) !important; }
.login-about { background: var(--navy) !important; }
.btn.primary { background: var(--accent); }
.pill.success { background: #eaf7ef; color: var(--green); }
.pill.warning { background: #fff5d9; color: #9a5b00; }
.pill.danger { background: #fdeeee; color: var(--red); }

/* Impeccable Bolder: make the financial dashboard the visual anchor. */
.page-head h1 { font-size: 34px; letter-spacing: -0.05em; }
.kpi-grid { gap: 16px; }
.kpi { padding: 22px 21px; border-width: 2px; }
.kpi strong { font-size: 28px; }
.dashboard-grid { gap: 22px; }
.panel { padding: 24px; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav-item { transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease; }
  .btn:active { transform: translateY(1px); }
  .btn.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(8,92,229,.18); }
  .portfolio-risk-alert, .portfolio-risk-ok { animation: cockpit-alert-in .22s ease both; }
  @keyframes cockpit-alert-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } }
  .center-card, .portfolio-kpi-card, .sync-card { transition: border-color .16s ease; }
  /* CC-P1-03: Bolder vence o flat-by-default (68-74) de proposito, so no hover, para dar feedback sem reintroduzir sombra. */
  .center-card:hover, .portfolio-kpi-card:hover, .sync-card:hover { border-color: var(--line-strong); }
  .filter-bar:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8,92,229,.10); }
  tbody tr, tbody tr td { transition: background-color .16s ease; }
  tbody tr:hover td:first-child { box-shadow: inset 3px 0 var(--accent); }
  .trend-month .bar { transform-origin: bottom; animation: cc-bar-reveal .6s cubic-bezier(.22,1,.36,1) both; }
  .trend-month .bar:nth-child(2) { animation-delay: .08s; }
  .trend-month:nth-child(2) .bar { animation-delay: .12s; }
  .trend-month:nth-child(2) .bar:nth-child(2) { animation-delay: .2s; }
  .trend-month:nth-child(3) .bar { animation-delay: .2s; }
  .trend-month:nth-child(3) .bar:nth-child(2) { animation-delay: .28s; }
  @keyframes cc-bar-reveal { from { opacity: .25; transform: scaleY(0); } to { opacity: 1; transform: scaleY(1); } }
  .kpi strong, .portfolio-kpi-card strong { animation: cc-value-settle .35s cubic-bezier(.16,1,.3,1) both; }
  @keyframes cc-value-settle { from { opacity: .45; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-kpi-card { transition: none; }
  .portfolio-kpi-card:hover { transform: none; }
  .trend-month .bar { animation: none; }
  .kpi strong, .portfolio-kpi-card strong { animation: none; }
  .center-card { transition: none; }
  .center-card:hover { transform: none; }
  .sync-card { transition: none; }
  .sync-card:hover { transform: none; }
  .filter-bar:focus-within { box-shadow: none; }
  tbody tr, tbody tr td { transition: none; }
  .btn.primary:hover, .btn:active { transform: none; }
  .portfolio-risk-alert, .portfolio-risk-ok { animation: none; }
}
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 100; padding: 12px; background: var(--white); }
.skip-link:focus { top: 8px; }
.app-shell.menu-open .main { pointer-events: none; }
.trend-chart { overflow-x: auto; }
.trend-month .bar:focus-visible::after { content: attr(data-value); position: absolute; bottom: 100%; background: var(--navy); color: #fff; padding: 4px; white-space: nowrap; z-index: 3; }
@media(min-width:801px) {
  .topbar { padding-right: 16px !important; }
  html.desktop-app .topbar { padding-right: 150px !important; }
  .sidebar { height: calc(100dvh - 43px) !important; }
}
@media(max-width:1000px) {
  .instance-name { display: none !important; }
  .centers-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width:800px) {
  .topbar .brand-logo { display: none !important; }
  .topbar .brand-symbol-mobile { display: block !important; }
  .topbar #mobile-menu, .topbar #topbar-theme-toggle { min-width: 44px !important; min-height: 44px !important; height: 44px !important; }
  .topbar .btn-suite-topbar { min-height: 44px !important; }
  .sidebar { transition: none !important; }
  .sidebar:not(.open) { visibility: hidden; }
  .sidebar.open { visibility: visible; }
  .filter-bar { grid-template-columns: minmax(0,1fr); }
  .form-grid { grid-template-columns: minmax(0,1fr); }
  .btn, .text-btn, .row-actions button, input, select { min-height: 44px !important; }
  input, select, textarea { font-size: 16px; }
  .dashboard-actions .head-filters { grid-template-columns: minmax(0,1fr) !important; }
  .page-head > select { min-width: 0; }
  .kpi p, .kpi span { font-size: 12px; }
  .center-row .money { white-space: normal; overflow-wrap: anywhere; }
  .centers-grid { grid-template-columns: minmax(0,1fr); }
  .table-scroll { overscroll-behavior-x: contain; }
}
@media(prefers-reduced-motion:reduce) {
  .view, .suite-dropdown-menu { animation: none !important; }
  button, input, select, textarea, .sidebar, .center-progress-bar { transition: none !important; }
  button:not(:disabled):active { transform: none !important; }
  .topbar #topbar-theme-toggle:not(:disabled):active { transform: none !important; }
  .btn.primary:hover, .fab-bug:hover, .fab-theme:hover { transform: none; }
  /* Extensao do Modulo de Orcamento (budget-*), auditoria 2026-09-20 */
  .budget-curves-close, .curve-point, .measurements-toolbar .btn-close-measurements,
  .measurements-tab-btn, .budget-report-toolbar .icon-btn, .budget-kpi-card,
  .budget-burn-fill, .btn-budget-action, #modal-fechar { transition: none !important; }
}

/* O estado de autenticacao prevalece sobre as regras de layout. */
html body #app.app-shell.oculto,
html body #app.app-shell[hidden],
html body #tela-login.oculto,
html body #tela-login[hidden] { display: none !important; }

/* Mantem o formulario acessivel mesmo em janelas baixas. */
#tela-login:not(.oculto):not([hidden]) {
  height: 100dvh;
  overflow-y: auto;
}
.profile-trigger { display:inline-flex !important; align-items:center !important; gap:8px !important; border:1px solid transparent !important; border-radius:6px !important; background:transparent !important; color:#f2f7fa !important; padding:4px 8px !important; cursor:pointer !important; font:inherit !important; }
.profile-trigger:hover, .profile-trigger[aria-expanded="true"] { background:#233147 !important; border-color:#33445d !important; }
.profile-trigger > span:first-child { width:34px !important; height:34px !important; display:grid !important; place-items:center !important; border-radius:50% !important; background:#41516a !important; color:#fff !important; font-weight:700 !important; }
.profile-trigger b { font-size:14px !important; font-weight:700 !important; }

/* E-mails externos autorizados (tela Usuarios) */
#emails-autorizados-panel { margin-top: 20px; }
#email-autorizado-form { display: grid; gap: 6px; max-width: 480px; margin: 12px 0; }
#email-autorizado-form .btn { justify-self: start; margin-top: 6px; }
.authorized-emails { list-style: none; margin: 0; padding: 0; }
.authorized-email-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line, #e5e7eb); }
.authorized-email-row small { display: block; color: var(--muted, #6b7280); }
.authorized-email-empty { padding: 10px 0; color: var(--muted, #6b7280); }
