/* app/static/css/global.css
   Base global do sistema
   - Usa tokens do theme.css
   - Mantém padrões obrigatórios (ex: height 50px)
*/

* { box-sizing: border-box; }

html, body { height: 100%; }

html{
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--c-text);

  /* ✅ Backdrop “mesa” (full width). Cards/painéis continuam em --c-surface/panel-bg */
  background: var(--c-backdrop-grad, var(--c-backdrop, var(--c-bg)));

  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Links (ação / navegação) */
a {
  color: var(--c-accent);
  text-decoration: none;
}

/* ✅ remove underline global */
a:hover { text-decoration: none; }

a:focus-visible{
  outline: 3px solid color-mix(in srgb, var(--c-accent) 28%, transparent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Labels */
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--c-text);
}

/* Inputs / Selects / Buttons */
input, select, button {
  width: 100%;
  height: 50px;            /* OBRIGATÓRIO */
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  font-family: inherit;
}

/* Campos */
input, select {
  border: 1px solid var(--c-border-2);
  padding: 0 14px;
  background: var(--c-surface);
  color: var(--c-text);
}

select{
  appearance: none;
  -webkit-appearance: none;
}

/* Focus (usa o acento do tema) */
input:focus, select:focus{
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-accent) 18%, transparent);
}

input:focus-visible, select:focus-visible, button:focus-visible{
  outline: 3px solid color-mix(in srgb, var(--c-accent) 24%, transparent);
  outline-offset: 2px;
}

/* Botões (regra base — estilos específicos continuam nos CSS de cada página) */
button{
  border: none;
  cursor: pointer;
  font-weight: 700;
  color: inherit;
  background: transparent;
}

/* =========================================================
   PADRÃO GLOBAL — CARD DE GRÁFICO + RESUMO (tabela)
   ========================================================= */

.ui-chart{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 980px){
  .ui-chart{ grid-template-columns: 1fr; }
}

.ui-chart-card{
  border: 1px solid var(--c-border);
  border-radius: 14px;
  background: var(--surface-card, var(--c-surface));
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ui-chart-head{
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ui-chart-title{
  font-weight: 800;
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.2;
}
.ui-chart-sub{
  font-weight: 600;
  color: color-mix(in srgb, var(--c-text) 65%, transparent);
  font-size: 12px;
  line-height: 1.25;
}

.ui-chart-body{
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

/* Área do gráfico (neutra) */
.ui-chart-plot{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 4px;
  height: 280px;
  max-height: 280px;
  overflow: hidden;
}

.ui-chart-plot canvas,
.ui-chart-plot img,
.ui-chart-plot svg{
  width: 100%;
  height: 260px;
  max-height: 260px;
  display: block;
}

.ui-chart-plot.is-compact canvas,
.ui-chart-plot.is-compact img,
.ui-chart-plot.is-compact svg{
  width: 100%;
  max-width: 360px;
  height: 240px;
  max-height: 240px;
}

.ui-chart-divider{
  height: 1px;
  width: 100%;
  background: var(--c-border);
  opacity: .9;
}

/* Resumo (dados) */
.ui-chart-sum{
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
}

.ui-chart-sumtitle{
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--c-text) 60%, transparent);
  margin: 0 0 8px 0;
}

.ui-chart-grid{
  border: 1px solid var(--c-border);
  border-radius: 12px;
  overflow: hidden;
  /* background: color-mix(in srgb, var(--c-surface) 70%, var(--c-bg)); */
}

.ui-chart-row{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 76px;
  align-items: center;
  padding: 10px 10px;
  border-bottom: 1px solid var(--c-border);
}
.ui-chart-row:last-child{ border-bottom: none; }

.ui-chart-label{
  font-weight: 700;
  font-size: 12px;
  color: var(--c-text);
  padding-right: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-chart-val{
  font-weight: 800;
  font-size: 12px;
  color: var(--c-text);
  text-align: right;
  padding: 0 10px;
  border-left: 1px solid var(--c-border);
  white-space: nowrap;
}

.ui-chart-pct{
  font-weight: 800;
  font-size: 12px;
  color: color-mix(in srgb, var(--c-text) 60%, transparent);
  text-align: right;
  padding-left: 10px;
  border-left: 1px solid var(--c-border);
  white-space: nowrap;
}

.ui-chart-hint{
  color: color-mix(in srgb, var(--c-text) 60%, transparent);
  font-weight: 600;
  font-size: 12px;
  text-align: center;
  padding: 10px 0;
}

/* global.css */

/* Card do gráfico: precisa ter lift próprio */
.ui-chart-card{
  border: 1px solid var(--dash-stroke-soft, var(--c-border));
  border-radius: 14px;
  box-shadow: var(--dash-elev-1, var(--shadow-soft));
  transition:
    transform 160ms var(--dash-ease, cubic-bezier(.2,.8,.2,1)),
    box-shadow 180ms var(--dash-ease, cubic-bezier(.2,.8,.2,1)),
    border-color 160ms var(--dash-ease, cubic-bezier(.2,.8,.2,1));
}

/* Hover isolado do card */
.ui-chart-card:hover{
  transform: translateY(-1px);
  box-shadow: var(--dash-elev-2, var(--shadow-soft-2));
  border-color: color-mix(in srgb, var(--c-accent) 24%, var(--dash-stroke-soft, var(--c-border)));
}

@media (max-width: 560px){
  .ui-chart-plot{ height: 240px; max-height: 240px; }

  .ui-chart-plot canvas,
  .ui-chart-plot img,
  .ui-chart-plot svg{
    height: 220px;
    max-height: 220px;
  }

  .ui-chart-plot.is-compact canvas,
  .ui-chart-plot.is-compact img,
  .ui-chart-plot.is-compact svg{
    max-width: 320px;
    height: 210px;
    max-height: 210px;
  }

  .ui-chart-row{
    grid-template-columns: 1fr 140px 70px;
  }
}

/* =========================================================
   UI BASE — Module Page (reutilizável em todos os módulos)
   - Padrão para placeholders e telas reais
   ========================================================= */

.module-page{
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--sv-page-gutter, 20px);
}

.module-page.cad-embed-page{
  padding: 0;
}

.module-head h1{
  margin: 14px 0 10px;
  font-size: 22px;
  color: var(--c-text);
}
.module-head p{
  margin: 0;
  color: var(--c-muted);
  font-weight: 600;
}

/* Card base (transparente por padrão, seguindo seu novo conceito) */
.module-card{
  border: 1px solid color-mix(in srgb, var(--c-border) 70%, transparent);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
  background: transparent;

  transition:
    transform 160ms cubic-bezier(.2,.8,.2,1),
    box-shadow 180ms cubic-bezier(.2,.8,.2,1),
    border-color 160ms cubic-bezier(.2,.8,.2,1);
}

.module-card:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft-2);
  border-color: color-mix(in srgb, var(--c-accent) 22%, var(--c-border));
}

.module-card__title{
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  color: color-mix(in srgb, var(--c-text) 72%, transparent);
  margin-bottom: 6px;
}

.module-card__value{
  font-size: 14px;
  font-weight: 900;
  color: var(--c-text);
}

.module-card__hint{
  margin-top: 10px;
  font-size: 12px;
  color: var(--c-muted);
  font-weight: 600;
}

:root[data-theme="dark"] .is-overdue,
:root[data-theme="dark"] tr.is-overdue,
:root[data-theme="dark"] .fin-row--overdue{
  background: color-mix(in srgb, var(--c-danger) 18%, transparent) !important;
}
