:root {
  --qg-sidebar: 232px;
  --qg-bg: #f4f6fb;
  --qg-panel: #ffffff;
  --qg-border: #e2e8f0;
  --qg-ink: #0f172a;
  --qg-muted: #64748b;
}

body { background: var(--qg-bg); color: var(--qg-ink); }

/* ---------- Shell ---------- */
.qg-shell { display: flex; min-height: 100vh; }

.qg-sidebar {
  width: var(--qg-sidebar); flex: 0 0 var(--qg-sidebar);
  background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; gap: .25rem;
  padding: 1rem .75rem; position: sticky; top: 0; height: 100vh;
}
.qg-brand {
  display: flex; align-items: center; gap: .6rem;
  color: #fff; text-decoration: none; font-weight: 600; padding: .35rem .5rem 1rem;
}
.qg-logo {
  width: 32px; height: 32px; border-radius: 9px; background: #2563eb;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700; letter-spacing: .5px;
}
.qg-nav { display: flex; flex-direction: column; gap: 2px; }
.qg-nav a {
  color: #cbd5e1; text-decoration: none; padding: .5rem .65rem; border-radius: 8px;
  font-size: .9rem; display: flex; align-items: center; gap: .6rem; transition: background .15s;
}
.qg-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.qg-nav a.active { background: #2563eb; color: #fff; }
.qg-nav-soon { margin-top: auto; padding-top: 1rem; display: flex; flex-direction: column; gap: 1px; }
.qg-nav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: #64748b; padding: 0 .65rem .35rem;
}
.qg-soon {
  font-size: .82rem; color: #64748b; padding: .3rem .65rem;
  display: flex; align-items: center; gap: .6rem;
}
.qg-user {
  display: flex; align-items: center; gap: .6rem;
  border-top: 1px solid rgba(255,255,255,.1); margin-top: .75rem; padding-top: .75rem;
}
.qg-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #334155; color: #fff;
  display: grid; place-items: center; font-size: .78rem; font-weight: 600; text-decoration: none;
  flex: 0 0 34px;
}
.qg-main { flex: 1; padding: 1.5rem 1.75rem; min-width: 0; }
.qg-messages { max-width: 720px; }

/* ---------- Cabeçalho de página ---------- */
.qg-page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.qg-page-head h1 { font-size: 1.35rem; font-weight: 650; margin: 0; }

/* ---------- Cartões de módulo ---------- */
.qg-module-card {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 14px;
  padding: 1.1rem; height: 100%; text-decoration: none; color: inherit; display: block;
  transition: transform .12s, box-shadow .12s;
}
a.qg-module-card:hover, .qg-board-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,.09); }
.qg-module-card.disabled { opacity: .55; }
.qg-module-icon {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; font-size: 1.15rem; margin-bottom: .7rem;
}

/* ---------- Kanban (Demandas) ---------- */
.qg-board {
  display: flex; gap: 1rem; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden; padding: .2rem .2rem 1.25rem;
  scroll-snap-type: x proximity; scroll-padding-left: .2rem;
  -webkit-overflow-scrolling: touch;
}
.qg-board::-webkit-scrollbar { height: 8px; }
.qg-board::-webkit-scrollbar-thumb { background: #c7d0de; border-radius: 8px; }
.qg-board::-webkit-scrollbar-track { background: transparent; }

.qg-column {
  background: #eceff5; border-radius: 14px; width: 288px; flex: 0 0 288px;
  display: flex; flex-direction: column; max-height: calc(100vh - 190px);
  scroll-snap-align: start; box-shadow: 0 1px 2px rgba(15,23,42,.05);
  transition: box-shadow .15s;
}
.qg-column-head {
  display: flex; align-items: center; gap: .4rem; padding: .7rem .8rem .5rem; cursor: grab;
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(#eceff5 65%, rgba(236,239,245,0));
}
.qg-column-head:active { cursor: grabbing; }
.qg-column-head h2 { font-size: .86rem; font-weight: 700; margin: 0; flex: 1; letter-spacing: .01em; }
.qg-count { font-size: .72rem; color: var(--qg-muted); background: #dbe2ec; border-radius: 20px; padding: .05rem .45rem; }
.qg-count.over { background: #fecaca; color: #991b1b; }
.qg-cards {
  padding: .1rem .6rem .3rem; overflow-y: auto; flex: 1; min-height: 16px;
  display: flex; flex-direction: column; gap: .5rem; scroll-behavior: smooth;
}
.qg-cards::-webkit-scrollbar { width: 6px; }
.qg-cards::-webkit-scrollbar-thumb { background: #c7d0de; border-radius: 8px; }
.qg-card {
  background: #fff; border-radius: 10px; padding: .65rem .7rem; cursor: pointer;
  box-shadow: 0 1px 2px rgba(15,23,42,.08); font-size: .87rem; border-left: 3px solid transparent;
  transition: box-shadow .15s ease, transform .15s ease, background .15s ease;
}
@media (hover: hover) and (pointer: fine) {
  .qg-card:hover { box-shadow: 0 4px 14px rgba(15,23,42,.14); transform: translateY(-1px); }
}
.qg-card:active { transform: scale(.99); }
.qg-card.done { background: #f8fafc; }
.qg-card.done .qg-card-title { text-decoration: line-through; color: var(--qg-muted); }
.qg-card-title { line-height: 1.35; font-weight: 500; }
.qg-card-cover {
  display: block; width: 100%; max-height: 130px; object-fit: cover;
  border-radius: 7px; margin-bottom: .5rem;
}
.qg-attachment-current { margin-bottom: .5rem; }
.qg-attachment-preview {
  display: block; max-height: 160px; border-radius: 10px; object-fit: cover; margin-bottom: .4rem;
}
.qg-attachment-file {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .87rem;
  text-decoration: none; color: var(--qg-ink); background: #f1f5f9;
  border-radius: 8px; padding: .35rem .6rem;
}
.qg-attachment-file:hover { background: #e2e8f0; }
.qg-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: .4rem; }
.qg-label-chip { height: 6px; width: 28px; border-radius: 6px; display: inline-block; }
.qg-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .45rem; font-size: .73rem; color: var(--qg-muted); }
.qg-badge-due { border-radius: 6px; padding: .1rem .4rem; font-weight: 600; }
.qg-badge-due.late { background: #fee2e2; color: #b91c1c; }
.qg-badge-due.today { background: #fef3c7; color: #92400e; }
.qg-column-foot { padding: .5rem .65rem .7rem; }
.qg-column-foot input {
  border-radius: 9px; border: 1px dashed #c7d0de; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.qg-column-foot input:focus {
  border-style: solid; border-color: #2563eb; box-shadow: 0 0 0 .15rem rgba(37,99,235,.15);
}
.qg-ghost { opacity: .45; }
.qg-card.qg-ghost { background: #e7ebf2; box-shadow: none; }
.qg-drag { transform: rotate(1.5deg); box-shadow: 0 14px 30px rgba(15,23,42,.22) !important; }
.qg-add-column {
  width: 288px; flex: 0 0 288px; background: rgba(255,255,255,.55);
  border: 1.5px dashed #cbd5e1; border-radius: 14px; padding: .8rem;
  scroll-snap-align: start; transition: background .15s, border-color .15s;
}
.qg-add-column:hover, .qg-add-column:focus-within { background: #fff; border-color: #94a3b8; }
.qg-prio { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* Cabeçalho da tela de demanda: busca flexível em vez de largura fixa */
.qg-board-search { width: 190px; max-width: 46vw; }

@media (max-width: 900px) {
  .qg-board-search { max-width: 40vw; }
}

/* Celular: uma lista quase em tela cheia por vez, com deslize suave e snap */
@media (max-width: 640px) {
  .qg-board { gap: .75rem; scroll-snap-type: x mandatory; padding-inline: .1rem; }
  .qg-column, .qg-add-column { width: 84vw; flex: 0 0 84vw; }
  .qg-column { max-height: calc(100vh - 232px); }
  .qg-page-head form[method="get"] { flex: 1 1 100%; order: 3; margin-left: 0 !important; }
  .qg-board-search { width: auto; max-width: none; flex: 1; }
}

/* Toque: aumenta a área clicável de botões só-ícone sem alterar o layout */
@media (pointer: coarse) {
  .qg-card-meta > form .btn { padding: .4rem; margin: -.4rem; }
  .qg-column-head .btn { padding: .5rem .4rem; margin: -.35rem -.15rem; }
}

/* ---------- Auth ---------- */
.qg-auth { min-height: 100vh; display: grid; place-items: center; background: #0f172a; padding: 1.5rem; }
.qg-auth-card { background: #fff; border-radius: 16px; padding: 2rem; width: 100%; max-width: 400px; }

@media (max-width: 900px) {
  .qg-shell { flex-direction: column; }
  .qg-sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .qg-nav { flex-direction: row; flex-wrap: wrap; }
  .qg-nav-soon { display: none; }
  .qg-brand { padding-bottom: 0; }
  .qg-user { border: 0; margin: 0 0 0 auto; padding: 0; }
  .qg-main { padding: 1rem; }
}

/* ---------- Hábitos ---------- */
.qg-habit-progress {
  border-left: 3px solid #e2e8f0; transition: border-color .2s;
}
.qg-habit-progress.is-complete { border-left-color: #16a34a; }
.qg-habit-progress.is-complete .progress-bar { background: #16a34a !important; }

.qg-habit-list { display: flex; flex-direction: column; gap: .6rem; }
.qg-habit-card {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-left: 3px solid var(--habit-color, var(--qg-border));
  border-radius: 14px; padding: .8rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  transition: box-shadow .15s, transform .15s;
}
@media (hover: hover) and (pointer: fine) {
  .qg-habit-card:hover { box-shadow: 0 6px 18px rgba(15,23,42,.08); transform: translateY(-1px); }
}
.qg-habit-main { display: flex; align-items: center; gap: .75rem; min-width: 220px; flex: 1 1 220px; }
.qg-habit-icon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; font-size: 1rem; flex: 0 0 38px; box-shadow: 0 2px 6px rgba(15,23,42,.15);
}
.qg-habit-strip { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; }
.qg-habit-strip::-webkit-scrollbar { display: none; }
.qg-habit-side { display: flex; align-items: center; gap: .75rem; margin-left: auto; }

.qg-dot {
  width: 34px; height: 38px; border-radius: 9px; border: 1.5px solid var(--qg-border);
  background: #fff; color: var(--qg-muted); font-size: .7rem; font-weight: 600; flex: none;
  display: grid; place-items: center; cursor: pointer; transition: transform .12s, background .12s, box-shadow .12s;
  padding: 0;
}
@media (hover: hover) and (pointer: fine) {
  .qg-dot:hover { transform: translateY(-2px); }
}
.qg-dot:active { transform: scale(.92); }
.qg-dot.done { color: #fff; }
.qg-dot.off { background: #f1f5f9; color: #cbd5e1; border-style: dashed; }
.qg-dot.now { box-shadow: 0 0 0 2px rgba(37,99,235,.35); }

@media (max-width: 640px) {
  .qg-habit-card { flex-direction: column; align-items: stretch; gap: .75rem; }
  .qg-habit-side { margin-left: 0; width: 100%; justify-content: space-between; }
}

/* Grade do mês */
.qg-grid-wrap { -webkit-overflow-scrolling: touch; }
.qg-grid { border-collapse: separate; border-spacing: 3px; font-size: .75rem; margin: .5rem; }
.qg-grid th { font-weight: 600; color: var(--qg-muted); text-align: center; padding: 0 1px; }
.qg-grid th.weekend { color: #94a3b8; }
.qg-grid-dow { font-size: .62rem; text-transform: uppercase; opacity: .7; }
.qg-grid-name {
  position: sticky; left: 0; background: var(--qg-panel); text-align: left !important;
  min-width: 150px; max-width: 150px; padding-right: .5rem !important; z-index: 1;
  box-shadow: 2px 0 4px -2px rgba(15,23,42,.12);
}
.qg-grid-chip { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.qg-grid-total { font-weight: 600; color: var(--qg-muted); text-align: center; padding-left: .4rem; }
.qg-grid tbody tr:hover td { background: #f4f6fb; }
.qg-grid tbody tr:hover td.qg-grid-name { background: #f4f6fb; }
.qg-grid td.weekend { background: rgba(15, 23, 42, .015); }
.qg-grid td.today .qg-grid-cell { box-shadow: 0 0 0 2px rgba(37,99,235,.4); }
.qg-grid-cell {
  width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--qg-border);
  background: #fff; display: block; cursor: pointer; padding: 0; transition: border-color .12s, transform .1s;
}
.qg-grid-cell:hover { border-color: #94a3b8; transform: scale(1.12); }
.qg-grid-cell.off { background: #f1f5f9; border-style: dashed; }
.qg-grid-cell.future { background: #f8fafc; border-style: dotted; cursor: default; }
.qg-grid-cell.future:hover { transform: none; }

/* Mapa de calor do detalhe */
.qg-heat { display: flex; flex-wrap: wrap; gap: 4px; }
.qg-heat-cell {
  width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--qg-border); background: #fff;
  transition: transform .1s, border-color .1s;
}
.qg-heat-cell.off { background: #f1f5f9; border-style: dashed; }
@media (hover: hover) and (pointer: fine) {
  .qg-heat-cell:hover { transform: scale(1.15); border-color: #94a3b8; }
}

/* ---------- Gastos ---------- */
/* Papéis de cor da visualização. Tons da paleta de referência validada:
   série sequencial azul (#2a78d6) e sua trilha clara (passo 100). */
:root {
  --viz-series-1: #2a78d6;
  --viz-track: #cde2fb;
  --viz-good: #0ca30c;
  --viz-warning: #fab219;
  --viz-critical: #d03b3b;
  --qg-hover: #f8fafc;
  --qg-ring: rgba(37, 99, 235, .18);
}

.qg-panel {
  background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 14px; padding: 1rem 1.1rem;
}
.qg-panel-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem;
  margin-bottom: .75rem; }
.qg-panel-head h2 { font-size: .95rem; font-weight: 650; margin: 0; flex: 1 0 auto; }
.qg-finance-icon { background: #ca8a04; }

/* Abas: rolam na horizontal no celular em vez de quebrar em duas linhas. */
.qg-subnav {
  display: flex; gap: .25rem; align-items: center; margin-bottom: 1rem;
  overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
}
.qg-subnav::-webkit-scrollbar { display: none; }
.qg-subnav a {
  font-size: .84rem; padding: .4rem .75rem; border-radius: 9px; white-space: nowrap;
  color: var(--qg-muted); text-decoration: none; border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.qg-subnav a:hover { background: #e8ecf3; color: var(--qg-ink); }
.qg-subnav a.active {
  background: var(--qg-panel); color: var(--qg-ink); font-weight: 600;
  border-color: var(--qg-border); box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.qg-subnav-sep { width: 1px; height: 18px; background: var(--qg-border); margin: 0 .35rem; flex: none; }

/* Navegação de mês: largura estável, "hoje" sempre no mesmo lugar. */
.qg-monthnav {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 10px; padding: 2px;
}
.qg-monthnav a, .qg-monthnav span {
  display: grid; place-items: center; min-width: 30px; height: 28px; padding: 0 .5rem;
  border-radius: 8px; color: var(--qg-muted); text-decoration: none; font-size: .82rem;
  transition: background .15s, color .15s;
}
.qg-monthnav a:hover { background: #eef2f7; color: var(--qg-ink); }
.qg-monthnav-now { font-weight: 600; }
.qg-monthnav .is-off { opacity: .4; cursor: default; }

/* Fichas de número (KPI). A do saldo é a resposta da tela e ganha destaque. */
.qg-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.qg-stat {
  background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 14px; padding: .9rem 1rem;
}
.qg-stat.is-hero { box-shadow: inset 3px 0 0 var(--viz-series-1); }
.qg-stat.is-hero .qg-stat-value { font-size: 1.9rem; }
.qg-stat-label { font-size: .78rem; color: var(--qg-muted); }
.qg-stat-value { font-size: 1.6rem; font-weight: 650; line-height: 1.2; }
.qg-stat-value.is-negative { color: var(--viz-critical); }
.qg-stat-delta { font-size: .76rem; margin-top: .15rem; color: var(--qg-muted); }
.qg-stat-delta.is-good { color: var(--viz-good); }
.qg-stat-delta.is-bad { color: var(--viz-critical); }
.qg-stat-period { color: var(--qg-muted); font-weight: 400; }

/* Faixa de totais do extrato: reflete o filtro em tela, não só o mês. */
.qg-tally {
  display: flex; flex-wrap: wrap; gap: .5rem 2rem;
  background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 14px; padding: .75rem 1.1rem;
}
.qg-tally > span { display: flex; flex-direction: column; }
.qg-tally small { font-size: .72rem; color: var(--qg-muted); }
.qg-tally strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

/* Aviso de topo (fixos pendentes). Tom de status + ícone, nunca cor sozinha. */
.qg-notice {
  display: flex; align-items: center; gap: .6rem; font-size: .85rem;
  background: #fdf6e3; border: 1px solid #f3e0ac; color: #7a5b04;
  border-radius: 12px; padding: .6rem .9rem;
}
.qg-notice.is-calm { background: var(--qg-panel); border-color: var(--qg-border); color: var(--qg-muted); }

/* Lista de barras: magnitude em um tom só, ponta arredondada, base reta. */
.qg-barlist { display: flex; flex-direction: column; gap: .15rem; }
.qg-bar-row {
  display: grid; grid-template-columns: 150px 1fr 130px; align-items: center; gap: .6rem;
  padding: .3rem .4rem; margin: 0 -.4rem; border-radius: 8px;
  color: inherit; text-decoration: none; transition: background .15s;
}
.qg-bar-row:hover { background: var(--qg-hover); }
.qg-bar-row:hover .qg-bar-fill { filter: brightness(.92); }
.qg-bar-label { display: flex; align-items: center; gap: .4rem; font-size: .84rem; min-width: 0; }
.qg-bar-track { display: block; background: #f1f5f9; border-radius: 4px; height: 14px; overflow: hidden; }
.qg-bar-fill {
  display: block; height: 100%; background: var(--viz-series-1);
  border-radius: 0 4px 4px 0; min-width: 3px; transition: filter .15s;
}
.qg-bar-value { text-align: right; font-size: .84rem; font-variant-numeric: tabular-nums; }
.qg-bar-share { color: var(--qg-muted); font-size: .74rem; margin-left: .3rem; }

/* Medidor de orçamento: trilha é um passo claro da própria rampa do estado. */
.qg-meter {
  display: block; margin: 0 -.4rem .35rem; padding: .35rem .4rem; border-radius: 8px;
  color: inherit; text-decoration: none; transition: background .15s;
}
.qg-meter:hover { background: var(--qg-hover); }
.qg-meter:last-child { margin-bottom: 0; }
.qg-meter-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .84rem; margin-bottom: .25rem; }
.qg-meter-state { font-size: .74rem; font-weight: 600; white-space: nowrap; }
.qg-meter-track { display: block; border-radius: 4px; height: 14px; overflow: hidden; }
.qg-meter-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 3px; }
/* A largura mínima acima existe para 0,5% não sumir. Zero é zero. */
.qg-meter-fill.is-empty { min-width: 0; }
.qg-meter-foot {
  display: flex; justify-content: space-between; font-size: .74rem;
  color: var(--qg-muted); margin-top: .2rem; font-variant-numeric: tabular-nums;
}

/* Linha de conta no resumo. */
.qg-accountrow {
  display: flex; align-items: center; gap: .5rem; font-size: .87rem;
  padding: .45rem .4rem; margin: 0 -.4rem; border-radius: 8px;
  color: inherit; text-decoration: none; border-bottom: 1px solid var(--qg-border);
  transition: background .15s;
}
.qg-accountrow:last-child { border-bottom: 0; }
.qg-accountrow:hover { background: var(--qg-hover); }
.qg-accountcard { position: relative; }
.qg-accountcard-link {
  display: inline-block; margin-top: .5rem; font-size: .78rem;
  text-decoration: none; color: var(--viz-series-1);
}

/* Extrato: um bloco por dia, cada linha com marcador da cor da categoria. */
.qg-statement { display: flex; flex-direction: column; }
.qg-day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
  color: var(--qg-muted); background: #f8fafc;
  padding: .4rem 1.1rem; border-block: 1px solid var(--qg-border);
}
.qg-day:first-child .qg-day-head { border-top: 0; }
.qg-entry {
  display: grid; grid-template-columns: 3px 1fr auto auto; align-items: center; gap: .75rem;
  padding: .45rem 1.1rem; border-bottom: 1px solid #f1f5f9;
  color: inherit; text-decoration: none; transition: background .15s;
}
.qg-entry:last-child { border-bottom: 0; }
.qg-entry:hover { background: var(--qg-hover); }
.qg-entry-mark { align-self: stretch; border-radius: 2px; min-height: 24px; }
.qg-entry-main { min-width: 0; display: flex; flex-direction: column; }
.qg-entry-desc {
  font-size: .89rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qg-entry-meta {
  font-size: .74rem; color: var(--qg-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qg-entry-value { font-size: .92rem; white-space: nowrap; }
.qg-entry-actions { display: flex; gap: 0; opacity: .35; transition: opacity .15s; }
.qg-entry-actions form { display: inline; }
.qg-entry:hover .qg-entry-actions,
.qg-entry-actions:focus-within { opacity: 1; }
.qg-statement.is-compact .qg-entry { padding: .5rem 1.1rem; grid-template-columns: 3px 1fr auto; }

.qg-pager {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  padding: .85rem; border-top: 1px solid var(--qg-border);
}

/* Estado vazio: diz o que falta e oferece o próximo passo. */
.qg-blank { text-align: center; padding: 2rem 1rem; color: var(--qg-muted); }
.qg-blank i { font-size: 1.6rem; opacity: .45; }
.qg-blank p { margin: .5rem 0 .75rem; font-size: .87rem; }

/* Primeiro acesso: roteiro curto no lugar de painéis zerados. */
.qg-start {
  background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 16px; padding: 1.75rem;
}
.qg-start h2 { font-size: 1.1rem; font-weight: 650; margin: 0; }
.qg-start > p { color: var(--qg-muted); font-size: .88rem; margin: .35rem 0 1.25rem; }
.qg-start-steps {
  list-style: none; counter-reset: passo; padding: 0; margin: 0 0 1.5rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem;
}
.qg-start-steps li {
  counter-increment: passo; background: #f8fafc; border: 1px solid var(--qg-border);
  border-radius: 12px; padding: .85rem 1rem .95rem 2.6rem; position: relative;
}
.qg-start-steps li::before {
  content: counter(passo); position: absolute; left: .85rem; top: .9rem;
  width: 20px; height: 20px; border-radius: 50%; background: var(--viz-series-1);
  color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center;
}
.qg-start-steps strong { display: block; font-size: .88rem; }
.qg-start-steps span { font-size: .78rem; color: var(--qg-muted); }
.qg-start-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* Painel de lançamento rápido. */
.qg-quickadd { width: 400px; }
.qg-quickadd .offcanvas-body { padding-top: .5rem; }
.qg-quickform { display: flex; flex-direction: column; min-height: 100%; }
.qg-quickform-foot { margin-top: auto; padding-top: 1.25rem; }
.qg-quickform kbd {
  background: #eef2f7; color: var(--qg-ink); border-radius: 4px;
  padding: 0 .3rem; font-size: .72rem;
}
.qg-kindswitch { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.qg-kindswitch input { position: absolute; opacity: 0; pointer-events: none; }
.qg-kindswitch label {
  border: 1px solid var(--qg-border); border-radius: 10px; padding: .5rem;
  text-align: center; font-size: .85rem; font-weight: 600; color: var(--qg-muted);
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.qg-kindswitch label:hover { background: var(--qg-hover); }
.qg-kindswitch input:checked + label.is-expense {
  border-color: var(--viz-critical); color: var(--viz-critical); background: #fdf1f1;
}
.qg-kindswitch input:checked + label.is-income {
  border-color: var(--viz-good); color: var(--viz-good); background: #eef8ee;
}
.qg-kindswitch input:focus-visible + label { outline: 2px solid var(--viz-series-1); outline-offset: 2px; }

/* Formulário que abre e fecha dentro do painel. */
.qg-formtoggle {
  background: none; border: 0; padding: 0; font-size: .9rem; font-weight: 600;
  color: var(--viz-series-1); display: flex; align-items: center; gap: .45rem;
}
.qg-formtoggle[aria-expanded="true"] i { transform: rotate(45deg); }
.qg-formtoggle i { transition: transform .2s; }

.qg-chip { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: 0 0 9px; }
.qg-num { font-variant-numeric: tabular-nums; }
.qg-income { color: var(--viz-good); font-weight: 600; }
.qg-expense { color: var(--viz-critical); font-weight: 600; }
.qg-state { font-weight: 600; white-space: nowrap; }
.qg-state.is-good { color: var(--viz-good); }
.qg-state.is-warn { color: #8a6100; }
.qg-state.is-off { color: var(--qg-muted); }

.qg-table thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--qg-muted); font-weight: 600; border-bottom: 1px solid var(--qg-border);
}
.qg-table td { font-size: .87rem; }
.qg-table tbody tr:hover { background: var(--qg-hover); }
.qg-table tbody tr.is-paused { opacity: .55; }
.qg-filterbar {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  padding: .75rem 1rem; border-bottom: 1px solid var(--qg-border);
}
.qg-filterbar .form-control, .qg-filterbar .form-select { width: auto; min-width: 140px; }

.qg-archive-title {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--qg-muted); margin: 1.75rem 0 .6rem;
}
.qg-archive-pill {
  display: flex; align-items: center; gap: .5rem; background: var(--qg-panel);
  border: 1px solid var(--qg-border); border-radius: 999px; padding: .2rem .3rem .2rem 1rem;
}

@media (max-width: 720px) {
  .qg-bar-row { grid-template-columns: 110px 1fr; }
  .qg-bar-value { grid-column: 2; text-align: left; }
  .qg-quickadd { width: 100%; }
  .qg-entry-actions { opacity: 1; }
  .qg-entry, .qg-day-head { padding-inline: .85rem; }
  .qg-tally { gap: .5rem 1.25rem; }
}

/* ---------- Academia ---------- */
.qg-setlist { display: flex; flex-wrap: wrap; gap: .4rem; }
.qg-set {
  display: inline-flex; align-items: center; gap: .4rem;
  background: #f1f5f9; border-radius: 8px; padding: .2rem .5rem; font-size: .82rem;
}
.qg-set-n {
  width: 18px; height: 18px; border-radius: 50%; background: #cbd5e1; color: #0f172a;
  font-size: .66rem; font-weight: 700; display: grid; place-items: center;
}

/* Gráfico de linha: uma série, sem caixa de legenda — o título nomeia a linha. */
.qg-chart {
  background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 14px; padding: 1rem 1.1rem; margin: 0 0 1rem; position: relative;
}
.qg-chart-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.qg-chart-head h2 { font-size: .95rem; font-weight: 650; margin: 0; }
.qg-chart-head p { font-size: .78rem; color: var(--qg-muted); margin: 0; }
.qg-chart-change { margin-left: auto; font-size: .82rem; font-weight: 600; text-align: right; }
.qg-chart-change span { display: block; font-weight: 400; font-size: .72rem; color: var(--qg-muted); }
.qg-chart-change.is-up { color: var(--viz-good); }
.qg-chart-change.is-down { color: var(--viz-critical); }
.qg-chart-change.is-flat { color: var(--qg-muted); }

.qg-chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.qg-grid-line { stroke: var(--qg-border); stroke-width: 1; }   /* fino e sólido, recessivo */
.qg-axis-text { fill: var(--qg-muted); font-size: 11px; }
.qg-line {
  fill: none; stroke: var(--viz-series-1); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round;
}
.qg-dot-mark {                                   /* 8px com anel da superfície */
  fill: var(--viz-series-1); stroke: var(--qg-panel); stroke-width: 2;
}
.qg-chart-label { fill: var(--qg-ink); font-size: 12px; font-weight: 650; }
.qg-crosshair { stroke: var(--qg-muted); stroke-width: 1; opacity: .45; }
.qg-hit { fill: transparent; cursor: pointer; }
.qg-hit:hover ~ .qg-dot-mark { stroke-width: 3; }

.qg-tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #0f172a; color: #fff; font-size: .74rem; line-height: 1.35;
  padding: .35rem .55rem; border-radius: 7px; max-width: 260px;
  transform: translate(-50%, -140%); white-space: nowrap;
}

/* ---------- Dieta ---------- */
.qg-hero-label { font-size: .78rem; color: var(--qg-muted); }
.qg-hero {                        /* figura principal: uma só por tela */
  font-size: 3rem; font-weight: 650; line-height: 1.05; letter-spacing: -.02em;
}
.qg-hero span { font-size: 1rem; font-weight: 500; color: var(--qg-muted); }
.qg-macro-tag {
  display: inline-grid; place-items: center; width: 18px; height: 18px;
  border-radius: 5px; background: #e2e8f0; color: #334155;
  font-size: .66rem; font-weight: 700;
}
.qg-meal-empty { border-style: dashed; background: rgba(255,255,255,.6); }

/* ---------- Agenda ---------- */
.qg-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: #db2777; color: #fff;
  font-size: .66rem; font-weight: 700; margin-left: auto;
}

.qg-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.qg-cal-head {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--qg-muted); text-align: center; padding: .25rem 0 .35rem;
}
.qg-cal-cell {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 8px;
  min-height: 104px; padding: .3rem; display: flex; flex-direction: column; gap: 2px;
  overflow: hidden;
}
.qg-cal-cell.is-out { background: #f8fafc; opacity: .6; }
.qg-cal-cell.is-weekend { background: #f9fafc; }
.qg-cal-cell.is-today { border-color: #7c3aed; box-shadow: inset 0 0 0 1px #7c3aed; }
.qg-cal-day { font-size: .74rem; font-weight: 600; color: var(--qg-muted); }
.qg-cal-cell.is-today .qg-cal-day { color: #7c3aed; }

.qg-chip-event {
  display: flex; align-items: center; gap: 4px; text-decoration: none;
  font-size: .72rem; line-height: 1.25; color: var(--qg-ink);
  background: color-mix(in srgb, var(--chip) 12%, #fff);
  border-left: 3px solid var(--chip);
  border-radius: 4px; padding: 2px 4px; min-width: 0;
}
.qg-chip-event:hover { background: color-mix(in srgb, var(--chip) 22%, #fff); }
.qg-chip-event.is-cont { opacity: .72; border-left-style: dashed; }
.qg-chip-time { font-variant-numeric: tabular-nums; color: var(--qg-muted); flex: none; }
.qg-chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chip); flex: none; }

.qg-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.qg-week-col {
  background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 12px; padding: .5rem; min-height: 180px;
}
.qg-week-col.is-weekend { background: #f9fafc; }
.qg-week-col.is-today { border-color: #7c3aed; box-shadow: inset 0 0 0 1px #7c3aed; }
.qg-week-head {
  display: flex; flex-direction: column; align-items: center;
  border-bottom: 1px solid var(--qg-border); padding-bottom: .35rem; margin-bottom: .4rem;
}
.qg-week-head span { font-size: .68rem; text-transform: uppercase; color: var(--qg-muted); }
.qg-week-head strong { font-size: .82rem; }
.qg-week-body { display: flex; flex-direction: column; gap: 3px; }

@media (max-width: 900px) {
  .qg-cal-cell { min-height: 74px; font-size: .7rem; }
  .qg-week { grid-template-columns: 1fr; }
  .qg-week-col { min-height: auto; }
  .qg-week-head { flex-direction: row; gap: .5rem; justify-content: flex-start; }
}

/* ---------- Conhecimento ---------- */
.qg-section {
  font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
  color: var(--qg-muted); margin: 1.5rem 0 .75rem;
}
.qg-searchbox {
  display: flex; align-items: center; gap: .5rem; background: var(--qg-panel);
  border: 1px solid var(--qg-border); border-radius: 12px; padding: .5rem .75rem;
}
.qg-searchbox > i { color: var(--qg-muted); }
.qg-searchbox .form-control { border: 0; box-shadow: none; padding-left: 0; }
.qg-searchbox .form-control:focus { box-shadow: none; }

.qg-cat-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: .5rem .6rem;
  align-items: center; background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 14px; padding: .85rem; text-decoration: none; color: inherit;
  transition: transform .12s, box-shadow .12s;
}
.qg-cat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,.09); }
.qg-cat-card.is-muted { opacity: .8; }
.qg-cat-icon {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  color: #fff; font-size: .95rem;
}
.qg-cat-name { font-weight: 600; font-size: .9rem; min-width: 0; }
.qg-cat-count {
  font-size: .72rem; color: var(--qg-muted); background: #eef2f7;
  border-radius: 20px; padding: .05rem .45rem;
}
.qg-cat-desc { grid-column: 1/-1; font-size: .76rem; color: var(--qg-muted); }

.qg-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .75rem; }
.qg-note {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 14px;
  padding: .85rem; text-decoration: none; color: inherit; display: flex;
  flex-direction: column; gap: .35rem; transition: transform .12s, box-shadow .12s;
}
.qg-note:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,.09); }
.qg-note-head { display: flex; align-items: center; gap: .4rem; }
.qg-note-cat { font-size: .72rem; color: var(--qg-muted); }
.qg-note-title { font-size: .95rem; line-height: 1.3; }
.qg-note-summary {
  font-size: .8rem; color: var(--qg-muted); margin: 0; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.qg-note-foot {
  display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
  font-size: .72rem; color: var(--qg-muted); margin-top: auto; padding-top: .35rem;
}
.qg-tag { background: #eef2f7; border-radius: 5px; padding: .05rem .35rem; }
.qg-tag-link {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 20px;
  padding: .2rem .6rem; font-size: .78rem; text-decoration: none; color: var(--qg-ink);
}
.qg-tag-link:hover { border-color: #94a3b8; }
.qg-tag-link span { color: var(--qg-muted); font-size: .7rem; }

/* Resultado de busca */
.qg-hit {
  display: block; background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 14px; padding: .85rem 1rem; margin-bottom: .6rem;
  text-decoration: none; color: inherit;
}
.qg-hit:hover { border-color: #94a3b8; }
.qg-hit-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .2rem; }
.qg-hit-where { display: flex; gap: .3rem; }
.qg-hit-where span {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .04em;
  background: #eef2f7; color: var(--qg-muted); border-radius: 4px; padding: .05rem .3rem;
}
.qg-hit-snippet { font-size: .84rem; color: var(--qg-muted); margin: .3rem 0 .2rem; line-height: 1.45; }
.qg-hit-snippet mark { background: #fef3c7; color: inherit; padding: 0 1px; border-radius: 2px; }

/* Leitura */
.qg-prose { line-height: 1.65; font-size: .95rem; }
.qg-prose h1, .qg-prose h2, .qg-prose h3, .qg-prose h4 { margin: 1.2rem 0 .5rem; font-weight: 650; }
.qg-prose h2 { font-size: 1.15rem; }
.qg-prose h3 { font-size: 1rem; }
.qg-prose h4 { font-size: .92rem; }
.qg-prose p { margin: 0 0 .8rem; }
.qg-prose ul, .qg-prose ol { margin: 0 0 .8rem; padding-left: 1.4rem; }
.qg-prose li { margin-bottom: .2rem; }
.qg-prose blockquote {
  border-left: 3px solid var(--qg-border); margin: 0 0 .8rem; padding: .2rem 0 .2rem .8rem;
  color: var(--qg-muted);
}
.qg-prose pre {
  background: #0f172a; color: #e2e8f0; padding: .75rem 1rem; border-radius: 8px;
  overflow-x: auto; font-size: .82rem; margin: 0 0 .8rem;
}
.qg-prose code { background: #eef2f7; border-radius: 4px; padding: .05rem .3rem; font-size: .86em; }
.qg-prose pre code { background: none; padding: 0; }
.qg-prose img { max-width: 100%; height: auto; border-radius: 8px; margin: .4rem 0; }
.qg-prose a { color: #2a78d6; }
.qg-prose table { width: 100%; border-collapse: collapse; margin: 0 0 .8rem; font-size: .88rem; }
.qg-prose th, .qg-prose td { border: 1px solid var(--qg-border); padding: .35rem .5rem; text-align: left; }

/* Galeria */
.qg-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; }
.qg-shot {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 12px;
  overflow: hidden; margin: 0;
}
.qg-shot img { width: 100%; height: 140px; object-fit: cover; display: block; }
.qg-shot figcaption {
  display: flex; align-items: center; gap: .3rem; padding: .35rem .5rem;
  font-size: .74rem; color: var(--qg-muted);
}

/* Editor */
#qg-editor { min-height: 420px; }
.ql-toolbar.ql-snow { border-radius: 8px 8px 0 0; border-color: var(--qg-border); }
.ql-container.ql-snow { border-radius: 0 0 8px 8px; border-color: var(--qg-border); font-size: .95rem; }
.ql-editor { min-height: 380px; line-height: 1.65; }
.ql-editor img { max-width: 100%; border-radius: 8px; }

/* ---------- Contexto compartilhado ---------- */
.qg-context-banner {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: #fef3c7; border: 1px solid #fcd34d; color: #78350f;
  border-radius: 10px; padding: .5rem .75rem; margin-bottom: .75rem;
  font-size: .86rem;
}
.qg-context-banner.is-readonly { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
.qg-context-switch {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  font-size: .78rem; color: var(--qg-muted); margin: -.4rem 0 .9rem;
}
.qg-context-link {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 20px;
  padding: .1rem .6rem; font-size: .78rem; color: var(--qg-ink); cursor: pointer;
}
.qg-context-link:hover { border-color: #94a3b8; }

/* ---------- Convite de instalação ---------- */
.qg-install {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
  z-index: 1080; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: var(--qg-panel); border: 1px solid var(--qg-border);
  border-radius: 12px; padding: .6rem .9rem; font-size: .86rem;
  box-shadow: 0 10px 30px rgba(15,23,42,.18);
  max-width: min(560px, calc(100vw - 2rem));
}
.qg-install > i:first-child { color: #2563eb; font-size: 1.1rem; }

/* Em modo aplicativo, respeita a área segura do aparelho (notch, barra do
   iPhone) — senão a barra lateral encosta na borda arredondada da tela. */
@media (display-mode: standalone) {
  .qg-install { display: none; }
  .qg-sidebar { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  .qg-main { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
  body { padding-top: env(safe-area-inset-top); }
}

/* Dieta — linha de registro rápido dentro de cada refeição. */
.qg-diet-add { display: flex; gap: .5rem; flex-wrap: wrap; max-width: 520px; }
.qg-diet-add [data-qg-food] { flex: 1 1 190px; min-width: 160px; }
.qg-diet-qtd { flex: 0 0 84px; max-width: 84px; }
/* Desabilitado quando o alimento não tem peso por unidade: o campo continua
   visível, para o lugar dele não mudar de posição a cada alimento escolhido. */
.qg-diet-add [data-qg-units]:disabled { background: var(--qg-border); opacity: .55; }

/* ── Quadro de demandas no celular ──────────────────────────────────────── */
/* Manter o dedo sobre um cartão inicia o arraste. Sem isto, o navegador
   entende o toque mantido como "selecionar texto" ou abre o menu de contexto
   no meio do gesto, e o arraste nasce brigando com o sistema. */
.qg-card {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
/* O texto volta a ser selecionável onde isso importa: dentro do cartão aberto. */
#qg-modal-content { -webkit-user-select: auto; user-select: auto; }

/* ── Academia · treino do dia ───────────────────────────────────────────── */
.qg-hoje { border-left: 4px solid transparent; }
.qg-hoje-marca {
  width: 10px; height: 44px; border-radius: 6px; flex: 0 0 10px;
}
.qg-hoje-label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--qg-muted); font-weight: 600;
}
.qg-hoje-nome { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
/* Descanso não é erro nem alerta: fica visualmente calmo, sem cor de aviso. */
.qg-hoje-descanso .qg-hoje-nome { color: var(--qg-muted); font-weight: 600; }

/* ── Academia · animação de execução ────────────────────────────────────── */
/* Duas fotos empilhadas, alternando. A segunda começa invisível e a animação
   troca as duas — o movimento aparece sem vídeo e sem biblioteca. */
.qg-demo {
  position: relative; width: 260px; max-width: 100%; margin: 0;
  border-radius: 12px; overflow: hidden; background: #f1f4f8;
  aspect-ratio: 4 / 3;
}
.qg-demo img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.qg-demo .qg-demo-b { opacity: 0; animation: qg-demo-troca 1.6s steps(1, end) infinite; }
@keyframes qg-demo-troca { 0%, 50% { opacity: 0; } 50.01%, 100% { opacity: 1; } }
/* Quem pediu menos animação no sistema vê a posição inicial, parada. Movimento
   piscando é justamente o que incomoda quem ativa essa preferência. */
@media (prefers-reduced-motion: reduce) {
  .qg-demo .qg-demo-b { animation: none; opacity: 0; }
}

/* ── Gabinete de Crise ──────────────────────────────────────────────────── */

/* O texto do PCS e as respostas do Gabinete chegam em Markdown com quebras
   que significam alguma coisa: título de seção, item de lista, parágrafo. Um
   <div> comum colapsaria tudo numa parede de texto, e <pre> jogaria para uma
   monoespaçada larga que obriga a rolar na horizontal no celular. */
.qg-crise-texto {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: .9rem;
  line-height: 1.55;
  max-height: 32rem;
  overflow-y: auto;
}

/* Resumo de uma cadeira: derivado do texto acima, não um bloco irmão dele.
   O recuo e a barra à esquerda dizem "isto vem daquilo" sem precisar de
   título explicando a relação. */
.qg-resumo {
  margin-top: .75rem;
  padding: .6rem .8rem;
  border-left: 3px solid var(--bs-danger, #b91c1c);
  background: rgba(185, 28, 28, .05);
  border-radius: 0 6px 6px 0;
}
.qg-resumo-head {
  display: flex; align-items: center; gap: .5rem;
  font-size: .78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; opacity: .75; margin-bottom: .35rem;
}
.qg-resumo-head > span:first-child { flex-grow: 1; }

/* ── Escalas ────────────────────────────────────────────────────────────── */

.esc-brasao { width: 44px; height: 44px; object-fit: contain; }

.esc-resumo {
  display: flex; flex-wrap: wrap; gap: .25rem 1.25rem;
  font-size: .88rem; color: #475569; margin-bottom: .75rem;
}
.esc-problemas {
  font-size: .85rem; padding: .6rem 1rem .6rem 1.6rem; margin-bottom: .75rem;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
}
.esc-problemas li.erro { color: #b91c1c; font-weight: 600; }

/* Grade à esquerda, painel à direita; no celular o painel desce. */
.esc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 991px) { .esc-layout { grid-template-columns: minmax(0, 1fr); } }

.esc-grade-wrap { overflow-x: auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; }
.esc-grade { border-collapse: collapse; width: 100%; font-size: .86rem; }
.esc-grade th {
  position: sticky; top: 0; z-index: 1; background: #f8fafc;
  font-weight: 600; text-align: left; padding: .45rem .5rem; border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.esc-grade td { border-bottom: 1px solid #f1f5f9; padding: .2rem .35rem; vertical-align: middle; }
.esc-grade .esc-data { width: 3rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: #b45309; }
.esc-grade .esc-dia { width: 3.2rem; font-weight: 700; color: #334155; white-space: nowrap; }
.esc-grade tr.esc-fds td { background: #fff7ed; }

.esc-cel { min-width: 10.5rem; }
.esc-celula { display: flex; align-items: center; gap: .25rem; }
.esc-slot {
  flex-grow: 1; min-height: 1.9rem; border-radius: 6px;
  border: 1px dashed #cbd5e1; display: flex; align-items: center; padding: 0 .2rem;
}
.esc-slot:has(.esc-chip) { border-style: solid; border-color: transparent; }
.esc-abrir {
  border: 0; background: transparent; color: #94a3b8; padding: .15rem .3rem; border-radius: 5px;
}
.esc-abrir:hover, .esc-abrir:focus-visible { background: #f1f5f9; color: #0f172a; }

.esc-fechada .esc-slot {
  background: repeating-linear-gradient(135deg, #f1f5f9 0 6px, #e2e8f0 6px 8px);
  border-color: #e2e8f0;
}
.esc-aviso .esc-slot { box-shadow: inset 0 0 0 2px #f59e0b; }
.esc-erro .esc-slot { box-shadow: inset 0 0 0 2px #dc2626; }

.esc-chip {
  display: inline-flex; align-items: center; padding: .15rem .55rem; border-radius: 999px;
  background: #ffedd5; color: #7c2d12; font-weight: 600; white-space: nowrap;
  cursor: grab; user-select: none; touch-action: none;
}
.esc-chip:active { cursor: grabbing; }

/* Painel de participantes */
.esc-painel {
  position: sticky; top: .75rem; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: .75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto;
}
@media (max-width: 991px) { .esc-painel { position: static; max-height: none; } }
.esc-pessoa {
  display: flex; align-items: center; gap: .4rem; padding: .3rem .2rem;
  border-bottom: 1px solid #f1f5f9; font-size: .85rem;
}
.esc-pessoa.completa .esc-chip { background: #dcfce7; color: #14532d; }
.esc-pessoa.acima .esc-chip { background: #fee2e2; color: #7f1d1d; }
.esc-cota { display: flex; align-items: center; font-variant-numeric: tabular-nums; color: #475569; }
.esc-cota input {
  width: 3rem; border: 1px solid #e2e8f0; border-radius: 5px; padding: 0 .25rem; font-size: .85rem;
}
.esc-fdsn { font-size: .75rem; color: #94a3b8; white-space: nowrap; }

/* O nome encolhe com reticências em vez de empurrar a cota e o × para fora
   do painel — "3º SGT Cavalcanti" com um ícone de aviso não cabia em 300px. */
.esc-pessoa > * { flex-shrink: 0; }
.esc-pessoa > .esc-chip { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* No celular as duas jornadas precisam caber lado a lado: o escalante compara
   A com B do mesmo dia o tempo todo, e uma delas escondida pela direita
   obriga a rolar a cada decisão. */
@media (max-width: 575px) {
  /* Largura fixa: a tabela ocupa o quadro e as colunas dividem o que sobra,
     em vez de crescer até caber o nome mais comprido. */
  .esc-grade { font-size: .78rem; table-layout: fixed; }
  .esc-celula { min-width: 0; }
  .esc-grade th, .esc-grade td { padding-left: .2rem; padding-right: .2rem; }
  .esc-grade .esc-data { width: 2.2rem; }
  .esc-grade .esc-dia { width: 2.2rem; }
  .esc-cel { min-width: 0; }
  .esc-chip { padding: .1rem .4rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .esc-slot { min-height: 1.7rem; min-width: 0; overflow: hidden; }
  .esc-abrir { padding: .1rem; }
}

/* Feriado: mesmo peso visual do fim de semana, e uma estrela para não
   confundir uma quarta-feira de feriado com uma quarta qualquer. */
.esc-grade tr.esc-feriado td { background: #fef2f2; }
.esc-feriado-marca { font-size: .55rem; color: #dc2626; margin-left: .2rem; vertical-align: super; }

/* Montagem no formulário: o formato da planilha que o escalante já usa —
   a grade à esquerda, quem participa e quantos plantões à direita. */
.esc-montagem { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 1rem; align-items: start; }
@media (max-width: 991px) { .esc-montagem { grid-template-columns: minmax(0, 1fr); } }
.esc-montagem .esc-grade-wrap { max-height: 70vh; overflow-y: auto; }
.esc-slot-previa { min-height: 1.4rem; }
.esc-pessoas-montagem { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: .25rem .5rem; overflow-x: auto; }
.esc-cota-input { width: 3.6rem; text-align: right; border: 1px solid #e2e8f0; border-radius: 5px; padding: 0 .3rem; }
.esc-fora td:nth-child(3) { text-decoration: line-through; }

.esc-cota-input.fixa { border-color: #c2410c; font-weight: 600; }
.esc-pessoas-montagem td:nth-child(3) { white-space: nowrap; }
.esc-cota-input.impossivel { border-color: #dc2626; color: #b91c1c; background: #fef2f2; }
.esc-acoes { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.esc-chip.travada { box-shadow: inset 0 0 0 1.5px #c2410c; }
.esc-chip .bi-pin-angle-fill { font-size: .7em; margin-right: .25rem; opacity: .7; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; gap: .3rem; align-items: center; }

/* ---------- Estudos ----------
   A planilha de planejamento em forma de tela. O desenho segue o dela: o que
   se digita tem fundo branco e borda; o que é calculado fica em fundo tingido,
   sem borda — de relance se vê o que é entrada e o que é resultado. */
.qg-es-abas .nav-link { color: var(--qg-muted); display: flex; align-items: center; gap: .4rem; }
.qg-es-abas .nav-link.active { color: #4338ca; font-weight: 600; }

.qg-es-card {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 14px;
  overflow: hidden;
}
.qg-es-card-head {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .7rem 1rem; border-bottom: 1px solid var(--qg-border);
}
.qg-es-nota { font-size: .78rem; color: var(--qg-muted); margin: 0; padding: .6rem 1rem .8rem; }

.qg-es-tabela { width: 100%; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
.qg-es-tabela th, .qg-es-tabela td { padding: .3rem .35rem; text-align: center; white-space: nowrap; }
.qg-es-tabela thead th {
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  color: var(--qg-muted); background: #f8fafc; border-bottom: 1px solid var(--qg-border);
  padding: .5rem .35rem; vertical-align: bottom;
  /* Cabeçalho pode quebrar em duas linhas ("Prioridade relativa"); é o que
     deixa as 14 colunas do Planejamento caberem sem rolagem lateral. */
  white-space: normal; line-height: 1.2;
}
.qg-es-tabela th:first-child, .qg-es-tabela td:first-child { padding-left: .9rem; }
.qg-es-tabela th:last-child, .qg-es-tabela td:last-child { padding-right: .7rem; }
.qg-es-tabela tbody tr + tr td, .qg-es-tabela tbody tr + tr th { border-top: 1px solid #f1f5f9; }
.qg-es-tabela .txt { text-align: left; }
.qg-es-tabela td.calc { background: #f5f6ff; color: #334155; }
.qg-es-tabela td.forte { font-weight: 600; color: var(--qg-ink); }
.qg-es-tabela .sep { border-left: 1px solid var(--qg-border); }
.qg-es-tabela .acao { width: 1%; padding-left: .25rem; }
.qg-es-tabela .acao .btn { opacity: .45; }
.qg-es-tabela tr:hover .acao .btn { opacity: 1; }
.qg-es-tabela .vazio { color: var(--qg-muted); padding: 1.25rem; white-space: normal; }
.qg-es-tabela tfoot td {
  font-weight: 600; background: #eef0fb; border-top: 1px solid #d9dcf5; padding: .5rem;
}

/* Célula editável */
.qg-es-in {
  width: 100%; min-width: 3.5rem; border: 1px solid transparent; border-radius: 6px;
  background: transparent; padding: .25rem .4rem; font: inherit; color: inherit;
  transition: border-color .12s, background .12s;
}
.qg-es-in:hover { border-color: var(--qg-border); background: #fff; }
.qg-es-in:focus { outline: none; border-color: #4338ca; background: #fff; box-shadow: 0 0 0 3px rgba(67,56,202,.15); }
.qg-es-in.htmx-request { border-color: #a5b4fc; }
.qg-es-in.num { text-align: center; width: 3.6rem; min-width: 0; }
.qg-es-in.sigla { width: 6rem; min-width: 0; text-transform: uppercase; font-weight: 600; }
.qg-es-in.largo { min-width: 11rem; }
select.qg-es-in.num { width: 4rem; }
.qg-es-in.qg-es-titulo { font-weight: 650; font-size: .95rem; flex: 1; min-width: 10rem; }
select.qg-es-in { cursor: pointer; }

.qg-es-sigla {
  display: inline-block; font-weight: 600; font-size: .78rem; letter-spacing: .02em;
  padding: .1rem .45rem; border-radius: 6px; background: #eef0fb; color: #3730a3;
}

/* Formulário de "nova linha" no pé de um cartão */
.qg-es-nova {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  padding: .7rem 1rem; border-top: 1px solid var(--qg-border); background: #fbfcfe;
}
.qg-es-nova.solta { border: 1px dashed var(--qg-border); border-radius: 14px; background: transparent; }
.qg-es-nova .form-control { flex: 1 1 14rem; }
.qg-es-nova .sigla { flex: 0 1 10rem; text-transform: uppercase; }
.qg-es-nova .bloco { flex: 0 1 16rem; }

/* Conteúdo — o nível em uma só matiz, do mais forte (nunca vi) ao neutro
   (tenho material de revisão), como a escala de cor da planilha. O rótulo
   por extenso está sempre junto: a cor reforça, não substitui. */
.qg-es-indice { display: flex; flex-wrap: wrap; gap: .35rem; }
.qg-es-indice a {
  font-size: .75rem; font-weight: 600; text-decoration: none; color: #3730a3;
  background: #eef0fb; border-radius: 999px; padding: .15rem .6rem;
}
.qg-es-indice a:hover { background: #dfe2f9; }
.qg-es-niveis { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.qg-es-nivel { font-size: .72rem; font-weight: 600; border-radius: 999px; padding: .1rem .55rem; border: 1px solid transparent; }
.qg-es-nivel[data-nivel="0"], .qg-es-nivel-sel[data-nivel="0"] { background: #b91c1c; color: #fff; }
.qg-es-nivel[data-nivel="1"], .qg-es-nivel-sel[data-nivel="1"] { background: #f4a3a3; color: #450a0a; }
.qg-es-nivel[data-nivel="2"], .qg-es-nivel-sel[data-nivel="2"] { background: #fde2e2; color: #450a0a; }
.qg-es-nivel[data-nivel="3"], .qg-es-nivel-sel[data-nivel="3"] { background: #fff; color: #334155; border-color: var(--qg-border); }
/* Largo o bastante para o rótulo mais comprido da planilha caber inteiro. */
.qg-es-nivel-sel { font-size: .8rem; font-weight: 600; width: 29rem; max-width: 46vw; border-radius: 999px; padding: .2rem .7rem; }
.qg-es-nivel-sel option { background: #fff; color: var(--qg-ink); font-weight: 400; }
.qg-es-tabela.conteudo td:first-child { width: 100%; }
.qg-es-tabela.conteudo .largo { min-width: 16rem; }
.qg-es-colar { padding: .6rem 1rem .9rem; border-top: 1px solid var(--qg-border); }
.qg-es-colar summary { cursor: pointer; font-size: .85rem; color: #4338ca; font-weight: 500; }
.qg-es-colar form { margin-top: .6rem; }

/* Ciclo */
.qg-es-dias { display: flex; flex-wrap: wrap; gap: .75rem; padding: .9rem 1rem .2rem; }
.qg-es-dias label { display: flex; flex-direction: column; align-items: center; gap: .2rem; font-size: .75rem; color: var(--qg-muted); font-weight: 600; }
.qg-es-dias .qg-es-in { border-color: var(--qg-border); background: #fff; width: 3.6rem; min-width: 0; font-size: .95rem; color: var(--qg-ink); }
.qg-es-tabela td.barra { min-width: 13rem; }
.qg-es-barra {
  display: inline-block; width: 9rem; height: 8px; border-radius: 4px;
  background: #e4e7f5; vertical-align: middle; overflow: hidden;
}
.qg-es-barra i { display: block; height: 100%; border-radius: 4px; background: #4338ca; }
.qg-es-barra-num { display: inline-block; width: 2.6rem; text-align: right; margin-left: .5rem; }
.qg-es-tabela.grade th[scope="row"] { font-weight: 600; color: var(--qg-ink); }
.qg-es-tabela.grade td { padding: .25rem; }
.qg-es-tabela.grade .slot { min-width: 5.5rem; border-color: var(--qg-border); background: #fff; font-weight: 600; text-align: center; }
.qg-es-tabela.grade .fora { color: #cbd5e1; }

/* Semana */
.qg-es-semana-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.qg-es-nova-semana { min-width: 17rem; }
.qg-es-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .75rem; }
.qg-es-tile {
  background: var(--qg-panel); border: 1px solid var(--qg-border); border-radius: 14px;
  padding: .75rem 1rem; display: flex; flex-direction: column;
}
.qg-es-tile > span { font-size: .75rem; color: var(--qg-muted); }
.qg-es-tile strong { font-size: 1.35rem; font-weight: 650; line-height: 1.3; }
.qg-es-tile small { font-size: .75rem; color: var(--qg-muted); }
.qg-es-tabela.semana .grupo th { background: #eef0fb; color: #3730a3; }
.qg-es-tabela.semana th.dia {
  vertical-align: middle; text-align: center; font-weight: 650; min-width: 4.2rem;
  border-top: 1px solid var(--qg-border); border-right: 1px solid var(--qg-border);
}
.qg-es-tabela.semana th.dia small { display: block; font-weight: 400; font-size: .7rem; color: var(--qg-muted); }
.qg-es-tabela.semana tbody.par { background: #f7f9fd; }
.qg-es-tabela.semana tbody.par td.calc { background: #eceefb; }
.qg-es-tabela.semana tbody.hoje th.dia { color: #4338ca; box-shadow: inset 3px 0 0 #4338ca; }
.qg-es-tabela.semana tbody + tbody tr:first-child td { border-top: 1px solid var(--qg-border); }
.qg-es-tabela.semana .mais td { text-align: left; padding: .15rem .5rem .35rem; }
.qg-es-tabela.semana .mais .btn { font-size: .78rem; color: var(--qg-muted); }
.qg-es-tabela.semana .mais .btn:hover { color: #4338ca; }
.qg-es-tabela.semana .largo { min-width: 9rem; }
.qg-es-tabela.semana td.txt:has(.largo) { width: 100%; }
.qg-es-tabela.semana tfoot .leitura td { background: #f8fafc; border-top: 0; font-weight: 500; color: #475569; }

/* O Planejamento é a tabela mais larga do módulo (14 colunas): letra e
   respiro um ponto menores para caber inteira ao lado do menu. */
.qg-es-tabela.planej { font-size: .82rem; }
.qg-es-tabela.planej th, .qg-es-tabela.planej td { padding-left: .2rem; padding-right: .2rem; }
.qg-es-tabela.planej thead th { font-size: .66rem; letter-spacing: 0; }
.qg-es-tabela.planej th:first-child, .qg-es-tabela.planej td:first-child { padding-left: .7rem; width: 100%; }
.qg-es-tabela.planej .largo { min-width: 8.2rem; }
.qg-es-tabela.planej .qg-es-in.num { width: 3.1rem; padding-left: .2rem; padding-right: .2rem; }
.qg-es-tabela.planej select.qg-es-in.num { width: 3.6rem; }
.qg-es-tabela.planej .qg-es-in.sigla { width: 5.6rem; }
