/* =====================================================================
   Financeiro CAIS — identidade clara e premium
   Marfim + branco, azul-marinho do logotipo na tipografia,
   dourado como acento fino. Títulos e números em serifa elegante.
   ===================================================================== */
:root {
  color-scheme: light;

  /* marca */
  --navy: #0e2230;
  --navy-2: #1b3547;
  --gold: #c9a043;
  --gold-ink: #8a6414;          /* dourado legível sobre branco */
  --gold-line: #e3cf9b;
  --gold-wash: #faf4e4;
  --gold-grad: linear-gradient(135deg, #f1d98b 0%, #d7ad4d 48%, #b8862a 100%);
  --champagne: linear-gradient(140deg, #fffdf8 0%, #fbf4e2 55%, #f4e6c3 100%);

  /* superfícies */
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --surface-3: #f4f1ea;
  --line: #ebe6da;
  --line-2: #f1ede4;

  /* texto */
  --text: #0e2230;
  --text-2: #56636e;
  --muted: #8b949b;

  /* estados */
  --good: #1f7a4d;
  --good-bg: #ecf6f0;
  --bad: #b23b2e;
  --bad-bg: #fbeeec;
  --warn: #8a6414;
  --warn-bg: #fbf3df;

  /* gráficos (paleta validada p/ daltonismo e contraste) */
  --series-1: #2a6fb0;
  --series-2: #b8800f;
  --grid: #efebe2;

  --serif: 'Cormorant Garamond', 'Cormorant', Georgia, serif;
  --sans: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 1px rgba(14, 34, 48, .03), 0 6px 24px -6px rgba(14, 34, 48, .07);
  --shadow-lg: 0 24px 64px -16px rgba(14, 34, 48, .22);
  --sidebar-w: 272px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: #f1e1b4; }
a { color: var(--gold-ink); text-decoration-color: var(--gold-line); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 600; }
h1 { font-family: var(--serif); font-size: 2rem; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: .98rem; letter-spacing: -.005em; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.hidden { display: none !important; }
.i { flex: none; display: block; }
.eyebrow { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-ink); font-weight: 600; }

/* ============================ Layout ============================ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .28s var(--ease);
  overflow-y: auto;
}
.sidebar .brand { padding: 26px 24px 18px; }
.sidebar .brand img { width: 148px; display: block; }

.mode-switch {
  margin: 4px 18px 10px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  display: grid; grid-template-columns: 1fr 1fr;
  position: relative;
}
.mode-switch button {
  position: relative; z-index: 1;
  border: 0; background: transparent; color: var(--text-2);
  padding: 7px 0; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .8rem; letter-spacing: .02em;
  transition: color .2s;
}
.mode-switch button.active { color: var(--navy); background: var(--surface); box-shadow: 0 1px 2px rgba(14,34,48,.08), 0 0 0 1px var(--gold-line); }

.nav { padding: 6px 12px 18px; flex: 1; }
.nav .group { font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 18px 12px 8px; font-weight: 600; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 11px;
  color: var(--text-2); text-decoration: none; font-size: .88rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a .i { color: var(--muted); transition: color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a:hover .i { color: var(--text-2); }
.nav a.active { background: var(--gold-wash); color: var(--navy); font-weight: 600; }
.nav a.active .i { color: var(--gold-ink); }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold-grad); }

.userbox { margin: 0 14px 14px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; display: flex; align-items: center; gap: 10px; font-size: .82rem; background: var(--surface-2); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; color: var(--navy);
  background: var(--champagne); border: 1px solid var(--gold-line);
  display: grid; place-items: center; font-weight: 600; flex: none; font-family: var(--serif); font-size: 1.05rem;
}
.userbox .who { flex: 1; min-width: 0; line-height: 1.3; }
.userbox .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.userbox .who span { color: var(--muted); font-size: .75rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(247, 245, 240, .82);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  display: flex; align-items: flex-end; gap: 16px;
  padding: 26px 40px 18px;
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title .crumb { margin-bottom: 4px; }
.hamburger { display: none; }
.month-picker { display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.month-picker button { border: 0; background: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--text-2); display: grid; place-items: center; transition: background .15s; }
.month-picker button:hover { background: var(--surface-3); color: var(--navy); }
.month-picker span { min-width: 132px; text-align: center; font-family: var(--serif); font-weight: 600; font-size: 1.12rem; text-transform: capitalize; cursor: default; }
.content { padding: 6px 40px 72px; max-width: 1320px; }
.backdrop { display: none; }

@media (max-width: 1000px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(14, 34, 48, .28); backdrop-filter: blur(2px); z-index: 35; }
  .main { margin-left: 0; }
  .hamburger { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--navy); align-self: center; }
  .topbar { padding: 14px 16px 12px; flex-wrap: wrap; align-items: center; }
  .topbar h1 { font-size: 1.55rem; }
  .content { padding: 4px 16px 88px; }
  .month-picker { width: 100%; justify-content: space-between; }
}

/* ============================ Componentes ============================ */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--text-2); font-size: .9rem; max-width: 640px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--navy);
  padding: 10px 18px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: .84rem; letter-spacing: .01em;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { border-color: var(--gold-line); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 6px 16px -6px rgba(14,34,48,.45); }
.btn.primary:hover { background: var(--navy-2); }
.btn.primary .i { color: #e9cf88; }
.btn.gold { background: var(--gold-grad); border-color: transparent; color: var(--navy); box-shadow: 0 6px 16px -8px rgba(184,134,42,.7); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 12px; font-size: .78rem; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: none; cursor: pointer; width: 34px; height: 34px; border-radius: 10px; color: var(--muted); display: inline-grid; place-items: center; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--navy); }
.icon-btn.del:hover { color: var(--bad); background: var(--bad-bg); }

.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid.cards3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.mt { margin-top: 18px; }
@media (max-width: 1000px) { .grid.two, .grid.halves { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; min-width: 0; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.card > header .sub { font-size: .76rem; color: var(--muted); }
.card.flush { padding: 0; overflow: hidden; }

/* KPIs */
.kpi { position: relative; overflow: hidden; padding: 20px 22px; display: flex; flex-direction: column; }
.kpi .label { font-size: .72rem; color: var(--text-2); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.kpi .label .i { color: var(--gold-ink); }
.kpi .value { font-family: var(--serif); font-size: 2.05rem; font-weight: 600; margin-top: 10px; letter-spacing: -.01em; line-height: 1.05; font-variant-numeric: lining-nums tabular-nums; }
.kpi .foot { font-size: .76rem; color: var(--muted); margin-top: auto; padding-top: 10px; }
.kpi.hero { background: var(--champagne); border-color: var(--gold-line); }
.kpi.hero::after {
  content: ''; position: absolute; right: -34px; top: -34px; width: 120px; height: 120px;
  border: 1.5px solid rgba(201, 160, 67, .45); transform: rotate(45deg); border-radius: 6px;
}
.kpi.hero::before {
  content: ''; position: absolute; right: -8px; top: -8px; width: 68px; height: 68px;
  border: 1.5px solid rgba(201, 160, 67, .3); transform: rotate(45deg); border-radius: 4px;
}
.pos { color: var(--good); }
.neg { color: var(--bad); }
.delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .68rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.neutral { background: var(--surface-3); color: var(--text-2); }
.badge.gold { background: var(--gold-wash); color: var(--gold-ink); border-color: var(--gold-line); }
button.badge { cursor: pointer; transition: filter .15s; }
button.badge:hover { filter: brightness(.96); }

/* listas */
.list { display: flex; flex-direction: column; }
.list .row { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--line-2); }
.list .row:last-child { border-bottom: 0; }
.ico-cat { width: 40px; height: 40px; border-radius: 12px; background: var(--gold-wash); border: 1px solid #f1e6c9; display: grid; place-items: center; flex: none; color: var(--gold-ink); }
.ico-cat.in { background: #eef4fa; border-color: #dce8f4; color: var(--series-1); }
.list .info { flex: 1; min-width: 0; }
.list .info b { display: block; font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .info span { font-size: .76rem; color: var(--muted); }
.list .amount { font-weight: 600; text-align: right; white-space: nowrap; font-size: .95rem; min-width: 96px; }
.list .actions { display: flex; gap: 2px; align-items: center; }
.row.inactive { opacity: .5; }
@media (max-width: 640px) {
  .list .row { flex-wrap: wrap; row-gap: 8px; }
  .list .info { flex-basis: calc(100% - 56px); }
  .list .row > .badge, .list .row > button.badge { margin-left: 54px; }
  .list .amount { margin-left: auto; min-width: 0; }
}
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: .88rem; }
.empty .glyph { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--gold-ink); }

/* tabela */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.t th, table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t th:first-child, table.t td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.t thead th { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; background: var(--surface); border-bottom: 1px solid var(--line); }
table.t tr.group td { font-weight: 600; }
table.t tr.sub td { color: var(--text-2); font-size: .8rem; }
table.t tr.sub td:first-child { padding-left: 32px; }
table.t tr.total td, table.t tr.total td:first-child { font-weight: 700; background: var(--surface-2); }
table.t tr.result td, table.t tr.result td:first-child { font-weight: 700; background: var(--gold-wash); border-top: 1px solid var(--gold-line); border-bottom: 1px solid var(--gold-line); }
table.t tr.result td:first-child { font-family: var(--serif); font-size: 1.05rem; }
table.t tr.margin td { color: var(--text-2); font-size: .78rem; }
table.t tbody tr:hover td { background: var(--surface-2); }

/* progresso */
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--gold-grad); border-radius: 999px; transition: width .6s var(--ease); }
.bar-rank .item { margin-bottom: 14px; }
.bar-rank .item:last-child { margin-bottom: 0; }
.bar-rank .lbl { display: flex; justify-content: space-between; align-items: center; font-size: .84rem; margin-bottom: 7px; gap: 8px; }
.bar-rank .lbl span { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.bar-rank .lbl .i { color: var(--gold-ink); }
.bar-rank .progress > i { background: var(--series-2); }

.goal-card { display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s; }
.goal-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.goal-card .top { display: flex; align-items: center; gap: 12px; }
.goal-card .big { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; line-height: 1; }

/* tabs */
.tabs { display: inline-flex; background: var(--surface-3); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .78rem; color: var(--text-2); transition: background .15s, color .15s; }
.tabs button.active { background: var(--surface); color: var(--navy); box-shadow: 0 1px 2px rgba(14,34,48,.08); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; margin-bottom: 18px; }
.summary-strip div { background: var(--surface-2); padding: 14px 16px; }
.summary-strip span { display: block; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.summary-strip b { display: block; font-family: var(--serif); font-size: 1.45rem; font-weight: 600; margin-top: 4px; font-variant-numeric: lining-nums tabular-nums; }

/* cartões de crédito */
.cc {
  border-radius: 20px; padding: 22px; position: relative; overflow: hidden; cursor: pointer;
  background: var(--champagne); border: 1px solid var(--gold-line); box-shadow: var(--shadow);
  transition: transform .2s var(--ease), box-shadow .2s; min-height: 200px; display: flex; flex-direction: column;
}
.cc:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.cc::after { content: ''; position: absolute; right: -50px; bottom: -50px; width: 160px; height: 160px; border: 1.5px solid rgba(201,160,67,.4); transform: rotate(45deg); border-radius: 8px; }
.cc .chip { width: 38px; height: 28px; border-radius: 7px; background: var(--gold-grad); opacity: .9; }
.cc .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cc .name { font-weight: 600; font-size: 1rem; }
.cc .bank { font-size: .74rem; color: var(--text-2); letter-spacing: .06em; text-transform: uppercase; }
.cc .inv { font-family: var(--serif); font-size: 2.1rem; font-weight: 600; margin: 18px 0 2px; line-height: 1; }
.cc .meta { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-2); gap: 8px; }
.cc .progress { background: rgba(14,34,48,.08); margin: 12px 0 8px; }

/* formulários */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: .72rem; font-weight: 600; color: var(--text-2); letter-spacing: .06em; text-transform: uppercase; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 11px 14px; width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s; font-size: .92rem;
}
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #ddd5c3; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201, 160, 67, .14); }
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: .74rem; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; gap: 0; } }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: .88rem; user-select: none; }
.switch input { appearance: none; width: 40px; height: 22px; background: #e2ddd1; border-radius: 999px; position: relative; cursor: pointer; transition: background .2s; margin: 0; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--navy); }
.switch input:checked::after { transform: translateX(18px); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-3); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg label { text-align: center; padding: 8px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .82rem; color: var(--text-2); text-transform: none; letter-spacing: 0; transition: background .15s; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--navy); box-shadow: 0 1px 2px rgba(14,34,48,.1), 0 0 0 1px var(--gold-line); }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.icon-picker label { display: grid; place-items: center; height: 40px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; color: var(--text-2); text-transform: none; }
.icon-picker input { display: none; }
.icon-picker label:has(input:checked) { border-color: var(--gold); background: var(--gold-wash); color: var(--gold-ink); }
.form-err, .auth .err { background: var(--bad-bg); color: var(--bad); padding: 11px 14px; border-radius: 12px; font-size: .84rem; margin-bottom: 14px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(14, 34, 48, .32); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s; }
.modal { background: var(--surface); border-radius: 22px; width: 100%; max-width: 540px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: var(--shadow-lg); animation: pop .28s var(--ease); border: 1px solid var(--line); }
.modal.wide { max-width: 780px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 24px 26px 6px; }
.modal header h2 { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; }
.modal .body { padding: 14px 26px 6px; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 26px 22px; position: sticky; bottom: 0; background: linear-gradient(to top, var(--surface) 75%, rgba(255,255,255,0)); }
@media (max-width: 600px) {
  .modal-back { align-items: flex-end; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; max-height: 92vh; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(14px) scale(.985); opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.content > * { animation: rise .4s var(--ease) both; }
.content > *:nth-child(2) { animation-delay: .04s; }
.content > *:nth-child(3) { animation-delay: .08s; }
.content > *:nth-child(4) { animation-delay: .12s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* toasts */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); color: var(--text); padding: 12px 16px 12px 14px; border-radius: 14px; font-size: .86rem; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .25s var(--ease); max-width: 360px; display: flex; gap: 10px; align-items: center; }
.toast .i { color: var(--good); }
.toast.error .i { color: var(--bad); }
@media (max-width: 600px) { #toasts { left: 16px; right: 16px; bottom: 16px; } }

/* gráficos */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--muted); font-family: var(--sans); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--text); padding: 10px 12px; border-radius: 12px;
  font-size: .78rem; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); opacity: 0; transition: opacity .12s; z-index: 5;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.chart .tip .t { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.chart .tip.show { opacity: 1; }
.chart .tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.legend { display: flex; gap: 18px; font-size: .78rem; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ============================ Autenticação ============================ */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth .art {
  position: relative; overflow: hidden; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--champagne); border-right: 1px solid var(--gold-line);
}
.auth .art .mark { position: absolute; right: -140px; bottom: -140px; width: 520px; height: 520px; border: 2px solid rgba(201,160,67,.35); transform: rotate(45deg); border-radius: 18px; }
.auth .art .mark.two { right: -40px; bottom: -40px; width: 300px; height: 300px; border-color: rgba(201,160,67,.25); }
.auth .art h2 { font-family: var(--serif); font-size: 3rem; font-weight: 600; max-width: 520px; line-height: 1.05; letter-spacing: -.015em; }
.auth .art h2 em { font-style: italic; color: var(--gold-ink); }
.auth .art p { color: var(--text-2); max-width: 440px; font-size: .98rem; }
.auth .art .feats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 26px; position: relative; z-index: 1; }
.auth .art .feats div { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-2); font-weight: 500; }
.auth .art .feats .i { color: var(--gold-ink); }
.auth .form-side { display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth .box { width: 100%; max-width: 380px; }
.auth .box .logo { width: 176px; margin-bottom: 36px; }
.auth .box h1 { font-size: 2.3rem; margin-bottom: 6px; }
.auth .box p.lead { color: var(--text-2); margin: 0 0 28px; }
.auth .switch-link { margin-top: 20px; font-size: .86rem; text-align: center; color: var(--text-2); }
.auth .legal { margin-top: 40px; font-size: .74rem; color: var(--muted); text-align: center; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth .art { display: none; } }

/* ============================ Vera ============================ */
.chat { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 440px; padding: 0; overflow: hidden; }
.chat .chat-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.vera-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--champagne); border: 1px solid var(--gold-line); display: grid; place-items: center; color: var(--gold-ink); flex: none; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; background: var(--surface-2); }
.chat .msg { max-width: 78%; padding: 12px 16px; border-radius: 18px; font-size: .9rem; white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; }
.chat .msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 6px; }
.chat .msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.chat .composer { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line-2); background: var(--surface); align-items: flex-end; }
.chat .composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px; background: var(--surface); min-height: 46px; max-height: 140px; outline: none; }
.chat .composer textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201,160,67,.14); }
.chat .suggest { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 22px 14px; background: var(--surface-2); }
.chip-btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 999px; font-size: .8rem; cursor: pointer; color: var(--text-2); transition: border-color .15s, color .15s; }
.chip-btn:hover { border-color: var(--gold-line); color: var(--navy); }
.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin-right: 3px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .25; } }

/* passo a passo / ajuda */
.steps .step { display: flex; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line-2); }
.steps .step:last-child { border-bottom: 0; }
.steps .dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; background: var(--surface); border: 1px solid var(--gold-line); color: var(--gold-ink); flex: none; }
.steps .step.done .dot { background: var(--navy); border-color: var(--navy); color: #fff; }
.steps .step .txt { flex: 1; }
.steps .step .txt p { margin: 3px 0 0; color: var(--text-2); font-size: .84rem; }
details.faq { border-bottom: 1px solid var(--line-2); padding: 16px 0; }
details.faq:last-child { border-bottom: 0; }
details.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: '+'; color: var(--gold-ink); font-size: 1.3rem; line-height: 1; font-weight: 400; }
details.faq[open] summary::after { content: '−'; }
details.faq p { color: var(--text-2); margin: 10px 0 0; font-size: .9rem; }

.banner { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 20px 22px; margin-bottom: 18px; background: var(--champagne); border-color: var(--gold-line); }
.banner .ttl { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }

.loading { display: grid; place-items: center; padding: 80px; }
.spinner { width: 26px; height: 26px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ Impressão (papel timbrado CAIS) ============================ */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 16mm 14mm 20mm; }
  body { background: #fff; font-size: 10.5px; }
  .sidebar, .topbar, .no-print, #toasts, .backdrop { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .content > * { animation: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .print-only { display: block; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 12px; margin-bottom: 18px; border-bottom: 1px solid #c9a043; }
  .print-head img { width: 150px; }
  .print-head .meta { text-align: right; font-size: 9.5px; color: #333; }
  .print-head .meta b { font-family: var(--serif); font-size: 17px; display: block; color: #0e2230; }
  .print-foot { position: fixed; bottom: 0; left: 0; right: 0; text-align: right; font-size: 9px; color: #0e2230; font-weight: 700; }
  table.t { font-size: 9px; }
  table.t th, table.t td { padding: 5px 6px; }
  table.t tr.result td, table.t tr.total td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chart, .grid.kpis, table.t tr { break-inside: avoid; }
}
@media (min-width: 901px) { .auth .box .logo { display: none; } }
.kpi .value.text { font-size: 1.45rem; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sidebar { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.range { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px 10px; }
.range input { border: 0; background: transparent; padding: 6px 2px; outline: none; font-size: .82rem; color: var(--text); }
.range span { font-size: .75rem; color: var(--muted); }
.badge.neutral::before { display: none; }
.field label.switch { text-transform: none; letter-spacing: 0; font-size: .88rem; font-weight: 500; color: var(--text); }

/* ===== ajustes finos para celular ===== */
@media (max-width: 640px) {
  .card { padding: 16px; border-radius: 16px; }
  .grid { gap: 12px; }
  .mt { margin-top: 12px; }
  .grid.kpis { grid-template-columns: 1fr 1fr; }
  .grid.kpis > .kpi.hero { grid-column: 1 / -1; }
  .kpi { padding: 14px 15px; }
  .kpi .label { font-size: .62rem; letter-spacing: .06em; }
  .kpi .label .i { display: none; }
  .kpi.hero .label .i { display: block; }
  .kpi .value { font-size: 1.32rem; margin-top: 8px; }
  .kpi.hero .value { font-size: 2rem; }
  .kpi .value.text { font-size: 1.1rem; }
  .kpi .foot { font-size: .7rem; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-strip div { padding: 11px 13px; }
  .summary-strip b { font-size: 1.15rem; }
  .page-head { margin-bottom: 14px; }
  .page-head .btn.primary { width: 100%; }
  .toolbar > * { max-width: 100%; }
  .range { width: 100%; }
  .range input { flex: 1; min-width: 0; }
  .toolbar .btn { width: 100%; }
}
@media (max-width: 640px) {
  .list .row { position: relative; }
  .list .row:has(> .actions .icon-btn):not(:has(> .actions .btn)) .info { padding-right: 64px; }
  .list .row > .actions:has(.icon-btn):not(:has(.btn)) { position: absolute; right: 0; top: 8px; }
  .list .row > .actions:has(.btn) { width: 100%; padding-left: 54px; }
  .summary-strip div:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
