/* Assistente (estilo Gemini): uma coluna central; pergunta, resposta e o card da análise em sequência; barra embaixo */
.chat-page { --col: 780px; --pad: max(16px, calc((100% - var(--col)) / 2)); display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-col { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
/* barra do topo flutua sobre a conversa: vidro (transparência + desfoque leve), a conversa rola por baixo */
.chat-bar { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px var(--pad) 14px; }
/* o vidro fica numa camada por trás: backdrop-filter no próprio .chat-bar deslocaria as listas fixas (seletor) dentro dele */
.chat-bar::before { content: ''; position: absolute; inset: 0; z-index: -1; background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.chat-bar select { width: auto; max-width: 220px; height: 32px; font-size: 13px; }
.messages { flex: 1; overflow-y: auto; padding: 76px var(--pad) 24px; display: flex; flex-direction: column; gap: 26px; scroll-behavior: smooth; }
.empty { display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.empty h2 { font-size: clamp(30px, 4vw, 44px); line-height: 1.1; margin-bottom: 4px; } .empty p { margin: 0 0 10px; color: var(--text-2); }

.msg-user { align-self: flex-end; max-width: 75%; padding: 12px 20px; border-radius: 26px; background: var(--surface-2); color: var(--text); white-space: pre-wrap; animation: rise .16s ease; }
.msg-ai { display: flex; flex-direction: column; gap: 10px; animation: rise .18s ease; font-size: 15px; }
.msg-ai .text { white-space: pre-wrap; }
.msg-ai .card { margin-top: 4px; }
.msg-ai .foot { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 11.5px; color: var(--text-3); }
.pill { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 12px; }
.pill.ready { border-color: var(--accent); color: var(--accent); }
.pill.warn { border-color: var(--warning); color: var(--warning); } .pill.error { border-color: var(--danger); color: var(--danger); }
/* Carregando = a marca da Iris pulsando: a pupila laranja respira e um anel sai de dentro para fora */
.spin { position: relative; display: inline-block; flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--text); vertical-align: middle; }
.spin::before { content: ''; position: absolute; inset: 30%; border-radius: 50%; background: var(--accent); animation: iris-pupil 1.3s ease-in-out infinite; }
.spin::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--accent); animation: iris-ring 1.3s ease-out infinite; }
.empty-state .spin, .conv-empty .spin { width: 40px; height: 40px; }
.pill:has(.spin) { border: 0; background: none; padding: 0; gap: 10px; height: 28px; color: var(--text-2); font-weight: 500; font-size: 13.5px; }
@keyframes iris-pupil { 0%, 100% { transform: scale(.7); } 50% { transform: scale(1.3); } }
@keyframes iris-ring { from { transform: scale(1); opacity: .9; } to { transform: scale(2.2); opacity: 0; } }
.understood { font-size: 13px; color: var(--text-2); border-left: 2px solid var(--accent-2); padding: 2px 0 2px 10px; }
.note { font-size: 12.5px; color: var(--warning); border-left: 3px solid var(--warning); padding: 2px 0 2px 10px; }
.btn2 { align-self: flex-start; }
.group-title { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 30px; padding: 5px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px; text-align: left; cursor: pointer; }
.chip:hover { border-color: var(--text); color: var(--text); }
.fb { border: 0; background: transparent; cursor: pointer; padding: 0 2px; color: var(--text-2); font-size: 12px; }
.fb:hover { color: var(--accent); }

.composer { padding: 8px var(--pad) 16px; }
.composer .box { display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 4px 4px 18px; background: var(--raised); } /* fundo do campo sim; halo/sombra atrás dele não */
.composer .box:focus-within { border-color: var(--border-strong); }
.composer textarea { flex: 1; min-height: 36px; max-height: 160px; border: 0; box-shadow: none; resize: none; padding: 7px 4px; background: transparent; font-size: 16px; }
.composer textarea:focus { box-shadow: none; }
.send { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; cursor: pointer; }
.send:hover { background: var(--primary-hover); } .send:disabled { opacity: .45; cursor: default; }
.composer .hint { font-size: 11.5px; color: var(--text-3); margin-top: 8px; text-align: center; }

/* Início sem conversa: título acima, barra no centro, sugestões abaixo (ao perguntar, a barra desce) */
.starters { display: none; }
.chat-page.fresh #newChat { display: none; }
.chat-page.fresh .messages, .chat-page.fresh .starters { flex: 1 1 0; }
.chat-page.fresh .messages { justify-content: flex-end; overflow: visible; padding-bottom: 8px; }
.chat-page.fresh .empty { text-align: center; align-items: center; } .chat-page.fresh .empty .btn2 { align-self: center; }
.chat-page.fresh .starters { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px var(--pad); overflow-y: auto; }
.chat-page.fresh .starters .chips { justify-content: center; }
.chat-page:not(.fresh) .composer { animation: rise .25s ease; }
/* menos ruído: sugestões e ações só na última resposta */
.msg-ai:not(:last-child) .chips, .msg-ai:not(:last-child) .group-title, .msg-ai:not(:last-child) .foot { display: none; }
.msg-ai .text:empty { display: none; }

/* Conversas recentes (conversations.js) */
.conv-pop { position: fixed; z-index: 45; width: min(380px, calc(100vw - 16px)); max-height: min(520px, 70vh); display: flex; flex-direction: column; background: var(--raised); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg); animation: rise .14s ease; }
.conv-head { padding: 14px 20px 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.conv-list { overflow-y: auto; overflow-x: hidden; grid-template-columns: minmax(0, 1fr); padding: 0 8px 8px; display: grid; gap: 2px; }
.conv-empty { padding: 20px 14px; text-align: center; color: var(--text-2); font-size: 13px; display: grid; place-items: center; }
.conv-item { display: flex; align-items: center; gap: 2px; border-radius: 999px; }
.conv-item:hover, .conv-item.on { background: var(--hover); }
.conv-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 9px 6px 9px 14px; border: 0; background: none; color: var(--text); cursor: pointer; text-align: left; }
.conv-open span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-open small { color: var(--text-3); font-size: 11.5px; flex: none; }
.conv-open input { height: 30px; padding: 0 12px; }
.conv-act { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 6px 9px; border-radius: 999px; opacity: 0; font-size: 13px; }
.conv-item:hover .conv-act, .conv-act:focus-visible, .conv-act.confirm { opacity: 1; }
.conv-act:hover { color: var(--text); background: var(--surface-2); }
.conv-act.confirm { color: #fff; background: var(--danger); font-size: 12px; font-weight: 600; }

/* Cards de análise */
.card { background: var(--raised); border: 1px solid var(--border); border-radius: 32px; display: flex; flex-direction: column; min-width: 0; animation: rise .22s ease; transition: box-shadow .18s, border-color .18s; }
.card.flash { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--primary-soft); }
.card-head { display: flex; gap: 8px; align-items: flex-start; padding: 20px 22px 6px; }
.card-head h3 { font-size: 20px; line-height: 1.2; } .card-head small { display: block; color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.card-head .tools { margin-left: auto; display: flex; gap: 4px; }
.icon { height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--text-2); font-size: 11.5px; cursor: pointer; }
.icon:hover { color: var(--text); border-color: var(--border-strong); background: var(--hover); }
.card-body { padding: 8px 22px 14px; min-height: 0; }
.card-body canvas { width: 100% !important; height: 280px !important; }
.kpi-row { display: flex; flex-wrap: wrap; gap: 8px; }
.kpi-inline { min-width: 160px; padding: 14px 18px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface-2); }
.kpi-inline span { display: block; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi-inline b { font-size: 24px; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
/* Destaques do card: total, líder, variação */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; padding: 8px 22px 4px; }
.insight { padding: 12px 16px; border-radius: 20px; background: var(--surface-2); min-width: 0; }
.insight span { display: block; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insight b { display: block; font-size: 18px; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insight em { font-style: normal; font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.insight em.up { color: var(--success, #15803d); } .insight em.down { color: var(--danger); }
.card-body.is-kpi .kpi-inline b { font-size: 40px; }
.calc { margin: 0 22px 18px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; padding: 8px 16px; }
.calc summary { cursor: pointer; color: var(--text-2); }
.calc pre { white-space: pre-wrap; font: 12px/1.5 inherit; margin: 8px 0 2px; color: var(--text); }
.tbl { overflow: auto; max-height: 340px; border: 1px solid var(--border); border-radius: 20px; }
.tbl table { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th, .tbl td { padding: 8px 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.tbl th { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); position: sticky; top: 0; background: var(--surface-2); }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Painel de BI interativo */
.card.dash { grid-column: 1 / -1; }
.card.dash.loading .dash-grid, .card.dash.loading [data-kpis] { opacity: .55; transition: opacity .15s; }
.dash-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 22px; }
.dash-bar select { width: auto; height: 30px; }
.dash-year { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.dash-year input { width: 200px; accent-color: var(--accent); } .dash-year b { min-width: 34px; color: var(--text); font-variant-numeric: tabular-nums; }
.chip.on { border-color: var(--primary); color: var(--on-primary); background: var(--primary); } .chip.on .muted { color: inherit; opacity: .65; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; padding: 6px 22px 22px; }
.dash-panel { border-radius: 26px; background: var(--surface-2); padding: 16px 18px; min-width: 0; }
.dash-panel.wide { grid-column: 1 / -1; }
.dash-grid > .dash-panel:last-child:nth-child(even) { grid-column: 1 / -1; } /* painel que sobraria sozinho ocupa a linha */
.dash-panel h4 { margin: 0 0 8px; font-size: 16px; }
.dash-chart { height: 280px; position: relative; } .dash-panel.wide .dash-chart { height: 220px; }
.crumb-up { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }

