:root {
  --bg: #eef0ed;
  --bg-rgb: 238, 240, 237;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-solid: #fbfcfa;
  --surface-soft: #f1f3f0;
  --line: #e1e4df;
  --text: #1e211f;
  --muted: #71766f;
  --dark: #242725;
  /* Paleta do acento. Todos os tons abaixo saem da cor de destaque escolhida
     em Configurações > Aparência, e são recalculados pelo front-end. */
  --lime: #c8ff43;
  --lime-soft: #efffc5;
  --accent-tint: #edfad4;
  --accent-wash: #f8fbed;
  --accent-strong: #4d7817;
  --accent-line: rgba(159, 198, 69, .45);
  --accent-glow: rgba(160, 205, 48, .18);
  --accent-ink: #1d2314;
  --green: #5e9b1d;
  --red: #d94a4a;
  --amber: #d9a634;
  --blue: #4e78d7;
  --shadow: 0 18px 50px rgba(22, 27, 23, 0.07);
  --radius: 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% 0%, #fff 0, transparent 26%), linear-gradient(135deg, #f5f6f3, #e9ece7); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.6rem); line-height: .98; letter-spacing: -.055em; font-weight: 520; margin-bottom: 12px; }
h2 { font-size: 1.22rem; letter-spacing: -.025em; margin-bottom: 0; }
h3 { font-size: 1rem; margin-bottom: 8px; }
small { color: var(--muted); }
.muted { color: var(--muted); }
.positive { color: var(--green) !important; }
.align-right { text-align: right; }
.wide-cell { min-width: 260px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; padding: 14px; gap: 14px; }
.sidebar { position: sticky; top: 14px; height: calc(100vh - 28px); border: 1px solid rgba(255,255,255,.8); background: rgba(249,250,248,.83); backdrop-filter: blur(18px); border-radius: 30px; padding: 24px 18px 18px; display: flex; flex-direction: column; box-shadow: var(--shadow); z-index: 20; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 28px; }
.brand-mark { width: 38px; height: 38px; position: relative; display: grid; place-items: center; }
.brand-mark span { position: absolute; width: 7px; height: 7px; background: var(--dark); border-radius: 50%; }
.brand-mark span:nth-child(1) { transform: translate(-10px, 0); }
.brand-mark span:nth-child(2) { transform: translate(10px, 0); }
.brand-mark span:nth-child(3) { transform: translate(0, -10px); }
.brand-mark span:nth-child(4) { transform: translate(0, 10px); }
.brand-mark span:nth-child(5) { width: 10px; height: 10px; }
.brand-mark.large { width: 62px; height: 62px; transform: scale(1.25); margin: 0 auto 10px; }
.nav-list { display: flex; flex-direction: column; gap: 7px; }
.nav-item { border: 0; background: transparent; color: #454944; padding: 13px 14px; border-radius: 14px; text-align: left; display: flex; align-items: center; gap: 12px; transition: .2s ease; }
.nav-item span { width: 24px; font-size: 18px; text-align: center; }
.nav-item:hover { background: #eff1ed; }
.nav-item.active { background: var(--dark); color: #fff; box-shadow: 0 8px 24px rgba(25,29,26,.18); }
.profile-card { margin-top: auto; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.profile-card strong, .profile-card small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.profile-card strong { font-size: .87rem; }
.avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--dark); color: white; font-weight: 700; font-size: .75rem; }
.avatar.small { width: 32px; height: 32px; }
.mobile-menu { display: none; border: 0; background: var(--surface-soft); border-radius: 12px; padding: 9px 11px; }

.main-content { min-width: 0; padding: 6px 16px 34px; }
/* O topo funde com o fundo da página em vez de cortar numa linha dura. */
.topbar { display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr); gap: 18px; align-items: center;
  padding: 10px 4px 26px; position: sticky; top: 0; z-index: 10;
  background: linear-gradient(to bottom, rgba(var(--bg-rgb), .97) 0%, rgba(var(--bg-rgb), .92) 42%, rgba(var(--bg-rgb), .55) 74%, rgba(var(--bg-rgb), 0) 100%);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.project-picker { justify-self: start; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.65); border: 1px solid rgba(255,255,255,.9); border-radius: 999px; padding: 6px 12px 6px 7px; }
.project-picker label { display: grid; font-size: .65rem; color: var(--muted); }
.project-picker select { border: 0; padding: 0 22px 0 0; background: transparent; color: var(--text); font-weight: 650; outline: none; }
.period-tabs { display: flex; background: rgba(255,255,255,.65); padding: 5px; border-radius: 999px; border: 1px solid rgba(255,255,255,.9); }
.period-tabs button { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 10px 18px; font-size: .82rem; }
.period-tabs button.active { color: white; background: var(--dark); }
.top-actions { justify-self: end; display: flex; gap: 8px; align-items: center; }
.button { border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 650; transition: .2s ease; white-space: nowrap; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--lime); color: var(--accent-ink); box-shadow: 0 8px 20px var(--accent-glow); }
.button.dark { background: var(--dark); color: #fff; }
.button.ghost { background: var(--surface-soft); color: var(--text); border: 1px solid var(--line); }
.button.full { width: 100%; }
.button.small { padding: 8px 12px; font-size: .78rem; }
.icon-button { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 0; background: var(--surface-soft); border-radius: 50%; color: var(--text); }
.icon-button.tiny { width: 28px; height: 28px; font-size: .8rem; }
.text-button { border: 0; background: transparent; color: var(--text); font-weight: 650; }

.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 34px 8px 28px; }
.page-heading > div:first-child { max-width: 760px; min-width: 0; flex: 1 1 0; }
.page-heading .muted { max-width: 680px; margin-bottom: 0; }
.eyebrow { color: var(--muted); letter-spacing: .18em; font-size: .68rem; font-weight: 750; margin-bottom: 10px; }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; }

.dashboard-grid { display: grid; gap: 12px; }
.dashboard-grid.metrics { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.dashboard-grid.secondary-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(300px, 1.45fr); margin-top: 12px; }
.dashboard-grid.content-row { grid-template-columns: minmax(280px, .85fr) minmax(520px, 2.15fr); margin-top: 12px; }
.dashboard-grid.bottom-row { grid-template-columns: minmax(220px, .75fr) minmax(500px, 1.8fr) minmax(220px, .85fr); margin-top: 12px; }
.dashboard-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 12px; }
.metric-card, .panel, .ai-summary-card { background: var(--surface); border: 1px solid rgba(255,255,255,.9); border-radius: var(--radius); box-shadow: 0 10px 36px rgba(23,28,24,.04); backdrop-filter: blur(14px); }
.metric-card { min-height: 150px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-title { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .83rem; }
.metric-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-soft); color: var(--text); font-size: .72rem; }
.metric-card > strong { display: block; font-size: clamp(1.3rem, 2vw, 2.1rem); letter-spacing: -.055em; font-weight: 520; }
.metric-foot { display: flex; align-items: center; justify-content: space-between; font-size: .72rem; font-weight: 650; }
.spark { width: 75px; height: 24px; fill: none; stroke: var(--accent-strong); stroke-width: 2; opacity: .85; }
.panel, .ai-summary-card { padding: 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-title > div { display: flex; align-items: center; gap: 9px; }
.section-title > div:first-child:has(small) { display: block; }
.section-title small { display: block; margin-bottom: 4px; }
.ai-summary-card { background: linear-gradient(145deg, rgba(255,255,255,.94), var(--accent-wash)); }
.ai-star { width: 30px; height: 30px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--lime); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: rgba(255,255,255,.7); border-radius: 999px; padding: 7px 9px; font-size: .62rem; }
.ai-answer { margin-top: 12px; border: 1px solid var(--accent-line); background: var(--accent-wash); border-radius: 15px; padding: 13px; font-size: .78rem; line-height: 1.45; }
.finance-list { display: grid; gap: 0; }
.finance-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .82rem; }
.finance-list > div.emphasis strong { color: var(--green); }
/* Prejuízo em verde se lê como lucro. O sinal decide a cor. */
.finance-list > div.emphasis.negativo strong { color: var(--red); }
.distribution-highlight { margin-top: 12px; display: flex; justify-content: space-between; gap: 10px; padding: 12px; border-radius: 12px; background: var(--lime-soft); font-size: .75rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .74rem; }
th { text-align: left; color: var(--muted); font-weight: 550; padding: 10px 12px; white-space: nowrap; }
td { padding: 13px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.empty-cell { text-align: center; color: var(--muted); padding: 30px; }
.status-list { display: grid; gap: 13px; }
.status-list > div { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; font-size: .8rem; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.green { background: #76ba2c; }.dot.amber { background: var(--amber); }.dot.blue { background: var(--blue); }.dot.red { background: var(--red); }
.mini-kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-kanban > div { background: rgba(246,247,245,.95); border: 1px solid var(--line); border-radius: 13px; padding: 11px; display: grid; gap: 7px; }
.mini-kanban strong { font-size: .72rem; }
.mini-kanban span { background: white; border-radius: 8px; padding: 8px; font-size: .67rem; }
.lock-box { min-height: 150px; border-radius: 16px; background: linear-gradient(160deg, var(--accent-tint), var(--surface-soft)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; text-align: center; }
.lock-box span { font-size: 1.5rem; }

.ai-layout { display: grid; grid-template-columns: 1fr 320px; gap: 14px; }
.ai-chat-panel { min-height: 630px; display: flex; flex-direction: column; }
.ai-hero { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.ai-orb { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 18px; background: var(--lime); font-size: 1.35rem; }
.ai-hero p { color: var(--muted); margin: 4px 0 0; }
.chat-messages { display: flex; flex-direction: column; gap: 12px; padding: 24px 0; flex: 1; overflow-y: auto; }
.message { max-width: 78%; padding: 14px 16px; border-radius: 18px; line-height: 1.55; font-size: .9rem; }
.message.assistant { align-self: flex-start; background: var(--surface-soft); border-bottom-left-radius: 5px; }
.message.user { align-self: flex-end; background: var(--dark); color: white; border-bottom-right-radius: 5px; }
.message small { display: block; margin-top: 8px; }
.message.loading { opacity: .6; animation: pulse 1.2s infinite; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; border-top: 1px solid var(--line); padding-top: 16px; }
.chat-form textarea { min-height: 60px; resize: vertical; }
.prompt-panel { display: flex; flex-direction: column; gap: 9px; align-self: start; }
.prompt-panel h2 { margin-bottom: 10px; }
.prompt-chip { text-align: left; padding: 12px; border-radius: 13px; background: var(--surface-soft); border: 1px solid var(--line); }
.privacy-note { margin-top: 16px; padding: 14px; background: var(--lime-soft); border-radius: 14px; }
.privacy-note p { font-size: .78rem; color: var(--muted); margin: 5px 0 0; }

.finance-page-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 12px; }
.finance-main .section-title h2 { font-size: 2.1rem; letter-spacing: -.05em; }
.partner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 14px; }
.partner-grid > div { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 13px; padding: 12px; display: grid; gap: 5px; }
.partner-grid span, .partner-grid small { font-size: .72rem; }
.loan-list { display: grid; gap: 9px; }
.loan-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px; border-radius: 13px; background: var(--surface-soft); }
.loan-item strong, .loan-item small { display: block; }
.table-panel { margin-top: 12px; }
.settings-stack .table-panel { margin-top: 0; }
.badge { font-size: .72rem; padding: 7px 10px; border-radius: 999px; background: var(--lime-soft); }
.status { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: .65rem; font-weight: 700; background: #eee; }
.status.income, .status.paid, .status.livre { background: var(--accent-tint); color: var(--accent-strong); }
.status.expense, .status.banido { background: #ffe4e4; color: #a43a3a; }
.status.open, .status.aquecendo { background: #fff1c9; color: #9a741c; }
.status.partial, .status.em_uso { background: #e4edff; color: #3f62a7; }

.heat { display: inline-block; vertical-align: middle; width: 90px; height: 7px; background: #e8eae7; border-radius: 999px; overflow: hidden; margin-right: 7px; }
.heat span { display: block; height: 100%; background: linear-gradient(90deg, #e6c348, #a8dc31); border-radius: inherit; }
.suggestion-panel { margin-bottom: 12px; background: linear-gradient(145deg, rgba(248,255,226,.95), rgba(255,255,255,.92)); }
.suggestion-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.suggestion-grid > div { display: grid; gap: 4px; background: rgba(255,255,255,.8); border: 1px solid var(--accent-line); padding: 12px; border-radius: 13px; }
.suggestion-grid span { color: var(--green); font-size: .72rem; font-weight: 700; }

.kanban { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; padding-bottom: 12px; }
.kanban-column { min-height: 520px; background: rgba(244,246,242,.78); border: 1px solid rgba(255,255,255,.9); border-radius: var(--radius); padding: 12px; }
.kanban-title { display: flex; justify-content: space-between; align-items: center; padding: 8px 6px 14px; }
.kanban-title span { background: #fff; min-width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: .72rem; }
.kanban-items { display: grid; gap: 9px; }
.task-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: 0 8px 22px rgba(20,25,21,.035); }
.task-card-top { display: flex; justify-content: space-between; align-items: center; }
.task-card p { color: var(--muted); font-size: .78rem; line-height: 1.5; }
.task-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .68rem; }
.priority { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: .58rem; font-weight: 800; }
.priority.alta { background: #ffe1e1; color: #ab3e3e; }.priority.media { background: #fff1c9; color: #8d6b1a; }.priority.baixa { background: var(--accent-tint); color: var(--accent-strong); }
.empty-card, .empty-compact { padding: 20px; color: var(--muted); text-align: center; font-size: .8rem; }

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.note-card { min-height: 230px; padding: 20px; border-radius: var(--radius); background: rgba(255,255,255,.85); border: 1px solid rgba(255,255,255,.95); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.note-card.pinned { background: linear-gradient(155deg, var(--accent-tint), #fff); }
.note-card-head { display: flex; justify-content: space-between; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; }
.note-card h2 { margin-top: 18px; }
.note-card p { color: var(--muted); line-height: 1.6; font-size: .85rem; }
.note-actions { margin-top: auto; }
.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
/* Cada seção de configurações fica num bloco próprio, com respiro entre elas. */
.settings-stack { display: flex; flex-direction: column; gap: 18px; margin-top: 18px; }
.settings-linha { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.settings-info p { margin-top: 8px; font-size: .82rem; line-height: 1.5; }
.settings-inline { display: flex; gap: 8px; align-items: center; }
.settings-inline input { flex: 1; }
@media (max-width: 760px) { .settings-linha { grid-template-columns: 1fr; } }
.settings-stack .settings-block { margin: 0; }
.settings-block > .section-title { margin-bottom: 14px; }
.settings-block > .section-title + .muted { margin-top: -4px; }
.settings-card { display: grid; grid-template-columns: 52px 1fr auto; gap: 16px; align-items: center; }
.settings-card p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.settings-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 17px; background: var(--lime-soft); font-weight: 800; }
.security-panel { margin-top: 12px; }
.settings-stack .security-panel { margin-top: 0; }
.check-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.check-grid span { padding: 12px; border-radius: 12px; background: var(--surface-soft); font-size: .8rem; }

label { display: grid; gap: 7px; color: #565b55; font-size: .78rem; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: #f8faf7; border-radius: 13px; padding: 12px 13px; outline: none; color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: #aed04e; box-shadow: 0 0 0 3px rgba(200,255,67,.24); }
label small { font-weight: 400; }
.stack-lg { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.check-label { display: flex; align-items: center; gap: 8px; }
.check-label input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
legend { padding: 0 8px; color: var(--muted); font-size: .75rem; }
.project-checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #fff, transparent 42%); }
.login-card { width: min(460px, 100%); background: rgba(255,255,255,.88); border: 1px solid rgba(255,255,255,.95); padding: 42px; border-radius: 34px; box-shadow: 0 30px 90px rgba(26,32,27,.12); backdrop-filter: blur(18px); text-align: center; }
.login-card h1 { font-size: 2.6rem; }
.login-card .muted { line-height: 1.6; margin-bottom: 28px; }
.login-card form { text-align: left; }
.login-hint { margin: 18px 0 0; color: var(--muted); font-size: .7rem; }

.modal { border: 0; padding: 0; background: transparent; width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 30px); }
.modal::backdrop { background: rgba(25,29,26,.45); backdrop-filter: blur(8px); }
.modal-card { background: var(--surface-solid); border-radius: 28px; padding: 24px; box-shadow: 0 30px 90px rgba(17,21,18,.25); }
.modal-header { display: flex; align-items: start; justify-content: space-between; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 1.65rem; }
.modal-body { padding: 20px 0; display: grid; gap: 14px; max-height: 62vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 16px; border-top: 1px solid var(--line); }
.partners-builder { padding: 14px; background: var(--surface-soft); border-radius: 16px; }
.partner-row { display: grid; grid-template-columns: 1fr 120px; gap: 8px; margin-bottom: 8px; }
.suggestion-text { color: var(--green); font-size: .78rem; line-height: 1.45; }

.toast-root { position: fixed; right: 20px; top: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: 380px; color: white; background: var(--dark); padding: 13px 16px; border-radius: 14px; box-shadow: 0 14px 38px rgba(20,24,21,.22); animation: slideIn .25s ease; }
.toast.error { background: #9d3333; }
.empty-state { min-height: 360px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.skeleton-page { padding-top: 80px; }
.skeleton { background: linear-gradient(90deg, #e5e8e3, #f3f5f1, #e5e8e3); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 18px; }
.skeleton.title { height: 70px; width: 45%; margin-bottom: 30px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.skeleton.card { height: 170px; }

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1220px) {
  .dashboard-grid.metrics { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid.secondary-metrics { grid-template-columns: repeat(2, 1fr); }
  .ai-summary-card { grid-column: span 2; }
  .dashboard-grid.bottom-row { grid-template-columns: 1fr 2fr; }
  .note-lock { grid-column: span 2; }
  .suggestion-grid { grid-template-columns: repeat(3, 1fr); }
  .topbar { grid-template-columns: 1fr auto; }
  .period-tabs { order: 3; grid-column: 1 / -1; justify-self: center; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; padding: 8px; }
  .sidebar { position: fixed; left: 8px; top: 8px; bottom: 8px; width: min(280px, calc(100vw - 40px)); height: auto; transform: translateX(-115%); transition: .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: block; position: fixed; left: 14px; top: 14px; z-index: 21; }
  .sidebar .mobile-menu { position: static; }
  .main-content { padding: 6px 4px 24px; }
  .topbar { padding-left: 52px; }
  .button.dark#export-button { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; padding-top: 22px; }
  .heading-actions { justify-content: flex-start; }
  .dashboard-grid.metrics, .dashboard-grid.secondary-metrics, .dashboard-grid.content-row, .dashboard-grid.bottom-row, .dashboard-grid.compact, .finance-page-grid, .settings-grid, .ai-layout { grid-template-columns: 1fr 1fr; }
  .dispatch-table-panel, .task-preview, .ai-chat-panel, .security-panel { grid-column: span 2; }
  .kanban { grid-template-columns: repeat(4, 280px); }
  .check-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .topbar { grid-template-columns: 1fr auto; gap: 8px; }
  .project-picker { max-width: 220px; }
  .period-tabs { width: 100%; overflow-x: auto; justify-content: flex-start; }
  .period-tabs button { padding: 9px 14px; }
  .page-heading h1 { font-size: 2.3rem; }
  .dashboard-grid.metrics, .dashboard-grid.secondary-metrics, .dashboard-grid.content-row, .dashboard-grid.bottom-row, .dashboard-grid.compact, .finance-page-grid, .settings-grid, .ai-layout { grid-template-columns: 1fr; }
  .dispatch-table-panel, .task-preview, .ai-chat-panel, .note-lock, .security-panel, .ai-summary-card { grid-column: auto; }
  .metric-card { min-height: 130px; }
  .mini-kanban { grid-template-columns: 1fr; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .form-grid, .project-checks { grid-template-columns: 1fr; }
  .settings-card { grid-template-columns: 48px 1fr; }
  .settings-card .button { grid-column: 1 / -1; }
  .check-grid { grid-template-columns: 1fr; }
  .chat-form { grid-template-columns: 1fr; }
  .message { max-width: 90%; }
  .login-card { padding: 30px 22px; }
  .modal-card { padding: 18px; }
}

/* Métricas e análise individual de disparos */
.dispatch-metrics-grid { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
.formula-note { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; padding: 15px 20px; background: linear-gradient(145deg, rgba(249,255,231,.94), rgba(255,255,255,.92)); }
.formula-note strong { margin-right: auto; }
.formula-note span { color: var(--muted); font-size: .76rem; }
.dispatch-metrics-table td { vertical-align: middle; }
.cell-note { display: block; margin-top: 5px; color: var(--muted); font-size: .62rem; font-weight: 500; }
.metric-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 74px; padding: 7px 9px; border-radius: 999px; font-weight: 760; font-size: .7rem; }
.metric-badge.positive { background: var(--accent-tint); color: var(--accent-strong); }
.metric-badge.negative { background: #ffe3e3; color: #9b3939; }
.estimated-value { display: grid; gap: 2px; }
.estimated-value small { color: var(--muted); font-size: .6rem; }
.ai-button { border: 1px solid var(--accent-line); background: linear-gradient(135deg, var(--accent-wash), #fff); color: var(--accent-strong); }
.ai-button:disabled { opacity: .55; cursor: wait; transform: none; }
.dispatch-metric-preview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px; border-radius: 16px; background: var(--surface-soft); border: 1px solid var(--line); }
.dispatch-metric-preview > div { display: grid; gap: 5px; padding: 11px; border-radius: 12px; background: rgba(255,255,255,.9); }
.dispatch-metric-preview span { color: var(--muted); font-size: .7rem; }
.dispatch-metric-preview strong { font-size: .92rem; }
.analysis-score-row { display: flex; align-items: center; gap: 18px; padding: 16px; border-radius: 18px; background: linear-gradient(140deg, var(--accent-tint), #fff); border: 1px solid var(--accent-line); }
.analysis-score { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; align-content: center; background: var(--dark); color: white; flex: 0 0 auto; }
.analysis-score strong { font-size: 1.8rem; line-height: 1; }
.analysis-score span { margin-top: 5px; font-size: .58rem; opacity: .7; }
.analysis-verdict { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: var(--lime); font-size: .72rem; font-weight: 800; }
.analysis-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.analysis-metrics > div { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.analysis-metrics span, .analysis-metrics small { color: var(--muted); font-size: .68rem; }
.analysis-metrics strong { font-size: 1.05rem; }
.ai-analysis-comment { padding: 17px; border-radius: 17px; background: var(--accent-wash); border: 1px solid var(--accent-line); }
.ai-analysis-comment p { margin: 0; line-height: 1.65; font-size: .85rem; color: #454b42; }
.analysis-warning { display: grid; gap: 5px; padding: 13px 15px; border-radius: 14px; background: #fff4d6; color: #765b16; font-size: .75rem; }

@media (max-width: 1220px) {
  .dispatch-metrics-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

@media (max-width: 620px) {
  .dispatch-metrics-grid { grid-template-columns: 1fr 1fr !important; }
  .dispatch-metric-preview, .analysis-metrics { grid-template-columns: 1fr 1fr; }
  .analysis-score-row { align-items: flex-start; }
}


/* Marca ------------------------------------------------------------ */
.brand-logo { width: 36px !important; height: 36px !important; max-width: 36px; object-fit: contain; display: block; flex: 0 0 auto; }
.brand-logo.large { width: 60px !important; height: 60px !important; max-width: 60px; margin: 0 auto 18px; }
.sidebar-top .brand-logo { margin: 0; }
.login-card .eyebrow { margin-bottom: 6px; }
.avatar img, .project-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
button.avatar { border: 0; padding: 0; overflow: hidden; }
button.avatar:hover { outline: 2px solid var(--lime); outline-offset: 2px; }

/* Aparência -------------------------------------------------------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.color-field { display: flex; align-items: center; gap: 12px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.color-field input[type="color"] { width: 42px; height: 42px; padding: 0; border: 0; background: none; border-radius: 12px; cursor: pointer; }
.color-field div { display: flex; flex-direction: column; }
.color-field strong { font-size: .88rem; font-weight: 560; }
.color-field small { font-size: .75rem; }
.theme-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 18px; border-radius: var(--radius); background: var(--surface-solid); border: 1px solid var(--line); }
.theme-preview .chip-demo { padding: 8px 16px; border-radius: 999px; background: var(--lime); font-weight: 560; }
.theme-preview .chip-dark { padding: 8px 16px; border-radius: 999px; background: var(--dark); color: #fff; }
.upload-slot { display: flex; align-items: center; gap: 14px; }
.upload-slot img { width: 56px; height: 56px; object-fit: contain; background: var(--surface-soft); border-radius: 14px; padding: 6px; }

/* Ações em linha nas tabelas e cartões ------------------------------ */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.button.tiny { padding: 5px 10px; font-size: .74rem; border-radius: 10px; }
.button.danger { background: #fbe9e9; color: var(--red); }
.button.danger:hover { background: #f6d9d9; }
.project-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: middle; }


/* Correção de estouro horizontal no celular ------------------------- */
/* Itens de grid não encolhem abaixo do próprio conteúdo por padrão, então uma
   tabela larga empurrava o painel inteiro e criava rolagem lateral na página. */
.app-shell > *, .main-content, .dashboard-grid > *, .finance-page-grid > *,
.ai-layout > *, .settings-grid > *, .panel, .metric-card { min-width: 0; }
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.kanban, .chat-messages, .notes-grid { max-width: 100%; }
.finance-list div { gap: 12px; }
.finance-list strong { white-space: nowrap; }


/* Recorte de foto --------------------------------------------------- */
.cropper-dialog { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; overflow: visible; }
.cropper-dialog::backdrop { background: rgba(22, 27, 23, .55); backdrop-filter: blur(6px); }
.cropper-card { background: var(--surface-solid); border-radius: 26px; padding: 24px; width: min(400px, 100%);
  box-shadow: 0 30px 90px rgba(26, 32, 27, .28); text-align: center; }
.cropper-card h2 { margin-bottom: 4px; }
.cropper-card > p { font-size: .8rem; margin-bottom: 16px; }
.cropper-stage { position: relative; width: 320px; max-width: 100%; aspect-ratio: 1; margin: 0 auto;
  border-radius: 18px; overflow: hidden; background: var(--surface-soft); touch-action: none; }
.cropper-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.cropper-stage canvas:active { cursor: grabbing; }
.cropper-mask { position: absolute; inset: 0; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(255, 255, 255, .0) inset; border: 2px solid rgba(255, 255, 255, .9); border-radius: 18px; }
.cropper-stage.redondo .cropper-mask { border-radius: 50%; box-shadow: 0 0 0 999px rgba(28, 33, 28, .38); }
.cropper-zoom { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; font-size: .8rem; color: var(--muted); }
.cropper-zoom input { flex: 1; accent-color: var(--lime); }
.cropper-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
@media (max-width: 420px) { .cropper-stage { width: 260px; } }


/* Menu lateral minimizado ------------------------------------------- */
.sidebar-toggle { margin-left: auto; width: 30px; height: 30px; border: 0; border-radius: 10px;
  background: var(--surface-soft); color: var(--muted); cursor: pointer; font-size: .9rem; line-height: 1; }
.sidebar-toggle:hover { background: var(--surface-strong, var(--surface-soft)); color: var(--text); }

.app-shell.menu-compacto { grid-template-columns: 84px 1fr; }
.app-shell.menu-compacto .sidebar { padding-left: 12px; padding-right: 12px; }
.app-shell.menu-compacto .sidebar-top { justify-content: center; flex-wrap: wrap; gap: 8px; }
.app-shell.menu-compacto .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
.app-shell.menu-compacto .nav-label,
.app-shell.menu-compacto .profile-card div,
.app-shell.menu-compacto #logout-button { display: none; }
.app-shell.menu-compacto .nav-icon { font-size: 1.05rem; }
.app-shell.menu-compacto .profile-card { justify-content: center; flex-wrap: wrap; gap: 8px; }
.app-shell.menu-compacto .sidebar-toggle { transform: rotate(180deg); }
@media (max-width: 900px) { .sidebar-toggle { display: none; } .app-shell.menu-compacto { grid-template-columns: 1fr; } }

.nav-icon { display: inline-flex; width: 20px; justify-content: center; flex: 0 0 auto; }
.loan-tag { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-tint); color: var(--accent-strong); font-style: normal; font-size: .68rem; font-weight: 560; white-space: nowrap; }
.finance-tabs { margin-bottom: 14px; flex-wrap: wrap; }
.finance-tabs button span { margin-left: 7px; opacity: .55; font-size: .72rem; }

.legacy-box { margin-top: 18px; border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; }
.legacy-box legend { padding: 0 8px; font-size: .82rem; font-weight: 620; }
.legacy-box .muted { font-size: .76rem; line-height: 1.45; }

tr.linha-fora td { opacity: .55; }
tr.linha-fora td:first-child { position: relative; }
tr.linha-fora td:first-child::before { content: ''; position: absolute; left: -2px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--line); }

.field-label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 8px; font-weight: 560; }
.kind-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.kind-picker button { padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-solid); color: var(--muted); cursor: pointer; font-size: .82rem; font-weight: 560; transition: all .16s; }
.kind-picker button:hover { border-color: var(--accent-line); color: var(--text); }
.kind-picker button.ativo { background: var(--lime); border-color: var(--lime); color: var(--accent-ink); }

.barra-investimento { height: 8px; border-radius: 999px; background: var(--surface-soft); overflow: hidden; margin-bottom: 10px; }
.barra-investimento > i { display: block; height: 100%; background: var(--lime); border-radius: 999px; transition: width .3s; }

/* Lucro da i4t: selo no cabeçalho, só para administradores. */
/* O selo segue o mesmo formato dos botões: mesma altura, mesmo arredondamento,
   na mesma linha. Só o conteúdo muda — rótulo pequeno e valor. */
.i4t-selo { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto;
  background: var(--lime); color: var(--accent-ink); border-radius: 999px;
  padding: 12px 18px; line-height: 1.35; white-space: nowrap; box-shadow: 0 8px 20px var(--accent-glow); }
.i4t-selo span { font-size: .6rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; opacity: .62; }
.i4t-selo strong { font-size: .9rem; font-weight: 680; letter-spacing: -.01em; }
.heading-actions { align-items: center; }

/* ========================================================================== */
/* i4t DIGITAL — PREMIUM UI REDESIGN v2.0                                    */
/* Camada exclusivamente visual. Nenhuma regra de negócio/API é alterada.    */
/* ========================================================================== */

:root {
  --premium-bg: #f5f6f4;
  --premium-surface: #ffffff;
  --premium-surface-2: #f8f9f7;
  --premium-border: #e7e9e5;
  --premium-border-strong: #dfe3dc;
  --premium-ink: #161916;
  --premium-muted: #737a72;
  --premium-sidebar: #101311;
  --premium-sidebar-soft: #181c19;
  --premium-shadow-sm: 0 1px 2px rgba(18, 24, 20, .03), 0 8px 24px rgba(18, 24, 20, .035);
  --premium-shadow-md: 0 12px 36px rgba(16, 22, 18, .065);
  --premium-ring: 0 0 0 4px var(--accent-glow);
}

html { scroll-behavior: smooth; }
body {
  color: var(--premium-ink);
  background: var(--premium-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--lime); color: var(--accent-ink); }

h1, h2, h3, strong { color: var(--premium-ink); }
h1 {
  font-size: clamp(2rem, 3.35vw, 3.25rem);
  line-height: 1.02;
  letter-spacing: -.052em;
  font-weight: 650;
}
h2 { font-weight: 650; letter-spacing: -.032em; }
h3 { font-weight: 650; letter-spacing: -.02em; }
.muted, small { color: var(--premium-muted); }

/* SHELL ------------------------------------------------------------------- */
.app-shell {
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 0;
  padding: 0;
  background: var(--premium-bg);
}

.sidebar {
  top: 0;
  height: 100vh;
  padding: 24px 16px 18px;
  border: 0;
  border-radius: 0;
  background: var(--premium-sidebar);
  box-shadow: 12px 0 38px rgba(15, 20, 16, .08);
  backdrop-filter: none;
}
.sidebar-top {
  min-height: 72px;
  padding: 4px 8px 25px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  margin-bottom: 14px;
}
.brand-logo { object-fit: contain; max-width: 100%; }
.sidebar .brand-logo {
  padding: 4px;
  border-radius: 10px;
  background: rgba(255,255,255,.96);
}
.sidebar-toggle {
  color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.08);
}
.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,.12); }
.nav-list { gap: 5px; }
.nav-item {
  min-height: 45px;
  padding: 11px 13px;
  color: rgba(255,255,255,.68);
  border-radius: 12px;
  font-weight: 580;
  font-size: .88rem;
}
.nav-item span { font-size: 16px; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active {
  color: var(--accent-ink);
  background: var(--lime);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.profile-card {
  padding: 16px 8px 0;
  border-top-color: rgba(255,255,255,.08);
  color: #fff;
}
.profile-card strong { color: #fff; }
.profile-card small { color: rgba(255,255,255,.48); }
.profile-card .avatar { color: var(--accent-ink); background: var(--lime); }
.profile-card .icon-button { color: rgba(255,255,255,.72); background: rgba(255,255,255,.07); }

.main-content {
  padding: 0 32px 48px;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}
.topbar {
  min-height: 82px;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  gap: 16px;
  padding: 14px 0 12px;
  border-bottom: 1px solid rgba(222,225,220,.72);
  background: rgba(245,246,244,.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.project-picker {
  padding: 5px 12px 5px 6px;
  background: #fff;
  border: 1px solid var(--premium-border);
  box-shadow: var(--premium-shadow-sm);
}
.project-picker .avatar.small { color: var(--accent-ink); background: var(--lime); }
.project-picker select { font-weight: 680; }
.period-tabs {
  padding: 4px;
  background: #fff;
  border: 1px solid var(--premium-border);
  box-shadow: var(--premium-shadow-sm);
}
.period-tabs button { color: #686f68; font-weight: 570; }
.period-tabs button:hover { color: var(--premium-ink); background: var(--premium-surface-2); }
.period-tabs button.active { background: var(--premium-sidebar); color: #fff; }
.top-actions { justify-self: end; }

/* PAGE HEADINGS ------------------------------------------------------------ */
.page-heading {
  padding: 38px 2px 26px;
  align-items: center;
}
.page-heading .eyebrow {
  color: var(--accent-strong);
  letter-spacing: .14em;
  font-size: .64rem;
}
.page-heading .muted {
  max-width: 720px;
  line-height: 1.55;
  font-size: .9rem;
}
.heading-actions { align-items: center; }

/* CONTROLS ---------------------------------------------------------------- */
.button {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 11px;
  font-weight: 680;
  letter-spacing: -.01em;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button.primary {
  color: var(--accent-ink);
  background: var(--lime);
  border-color: var(--lime);
  box-shadow: 0 7px 18px var(--accent-glow);
}
.button.primary:hover:not(:disabled) { filter: brightness(.97); box-shadow: 0 10px 22px var(--accent-glow); }
.button.dark { background: var(--premium-sidebar); color: #fff; box-shadow: 0 7px 18px rgba(14,19,15,.12); }
.button.ghost { background: #fff; border-color: var(--premium-border-strong); color: #343a34; }
.button.ghost:hover:not(:disabled) { background: var(--premium-surface-2); border-color: #d4d9d2; }
.button.danger { background: #fff4f4; border-color: #ffdcdc; color: #bc4141; }
.icon-button {
  background: #fff;
  border: 1px solid var(--premium-border);
  box-shadow: var(--premium-shadow-sm);
  transition: .16s ease;
}
.icon-button:hover { transform: translateY(-1px); background: var(--premium-surface-2); }
.text-button { color: #343a34; }
.text-button:hover { color: var(--accent-strong); }

label { color: #596059; font-size: .75rem; }
input, select, textarea {
  min-height: 44px;
  border-radius: 10px;
  border-color: var(--premium-border-strong);
  background: #fff;
  color: var(--premium-ink);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: #cfd4cd; }
input:focus, select:focus, textarea:focus {
  border-color: var(--lime);
  box-shadow: var(--premium-ring);
  background: #fff;
}
fieldset { border-color: var(--premium-border); background: var(--premium-surface-2); }

/* SURFACES ---------------------------------------------------------------- */
.metric-card, .panel, .ai-summary-card {
  border: 1px solid var(--premium-border);
  border-radius: 16px;
  background: var(--premium-surface);
  box-shadow: var(--premium-shadow-sm);
  backdrop-filter: none;
}
.panel, .ai-summary-card { padding: 22px; }
.dashboard-grid { gap: 14px; }
.dashboard-grid.metrics { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.dashboard-grid.secondary-metrics,
.dashboard-grid.content-row,
.dashboard-grid.bottom-row { margin-top: 14px; }
.metric-card {
  min-height: 148px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  /* O valor se mede pela largura do proprio cartao. Preso ao vw, um numero
     grande vazava assim que cabiam mais cartoes na linha. */
  container-type: inline-size;
}
.metric-card::before {
  content: '';
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--lime), transparent 72%);
  opacity: .8;
}
.metric-title { font-size: .77rem; font-weight: 590; }
.metric-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  color: var(--accent-strong);
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
}
.metric-card > strong {
  font-size: clamp(1.15rem, 13cqi, 2.15rem);
  font-weight: 690;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
  /* Ultima garantia: se ainda assim faltar um fio de espaco, encolhe em vez
     de cortar o final do numero. */
  white-space: nowrap;
  max-width: 100%;
}
.metric-foot { font-size: .69rem; }
.ai-summary-card {
  background: linear-gradient(145deg, #fff 35%, var(--accent-wash));
  border-color: var(--accent-line);
}
.ai-star { color: var(--accent-ink); background: var(--lime); border-radius: 9px; }
.ai-answer { background: rgba(255,255,255,.72); border-color: var(--accent-line); }

.section-title { margin-bottom: 18px; }
.section-title h2 { font-size: 1.12rem; }
.section-title small { color: var(--premium-muted); }

/* FINANCE ----------------------------------------------------------------- */
.finance-page-grid { gap: 16px; }
.finance-main .section-title h2 { font-size: 2.2rem; font-weight: 690; }
.finance-list > div { padding: 12px 0; border-bottom-color: var(--premium-border); }
.finance-list > div:last-child { border-bottom: 0; }
.distribution-highlight {
  padding: 14px;
  border: 1px solid var(--accent-line);
  background: var(--accent-wash);
}
.partner-grid { gap: 10px; }
.partner-grid > div { background: var(--premium-surface-2); border-color: var(--premium-border); }

/* TABLES ------------------------------------------------------------------ */
.table-panel { overflow: hidden; }
.table-panel > .table-scroll { margin: 0 -22px -22px; }
.table-panel > .section-title + .table-scroll table { border-top: 1px solid var(--premium-border); }
table { font-size: .75rem; font-variant-numeric: tabular-nums; }
th {
  padding: 13px 14px;
  color: #777e77;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .055em;
  text-transform: uppercase;
  background: #fafbf9;
}
td {
  padding: 15px 14px;
  border-top-color: var(--premium-border);
  background: #fff;
}
tbody tr { transition: background .14s ease; }
tbody tr:hover td { background: #fbfcfa; }
.row-actions { gap: 6px; }
.status, .badge, .metric-badge {
  font-weight: 720;
  border: 1px solid transparent;
}
.status.income, .status.paid, .status.livre,
.metric-badge.positive { border-color: var(--accent-line); }

/* DISPATCH ---------------------------------------------------------------- */
.formula-note {
  border-color: var(--accent-line);
  background: linear-gradient(90deg, var(--accent-wash), #fff 72%);
}
.dispatch-metrics-table td:nth-child(7),
.dispatch-metrics-table td:nth-child(8),
.dispatch-metrics-table td:nth-child(9) { font-weight: 700; }
.ai-button { background: var(--accent-wash); }
.analysis-score-row { background: var(--accent-wash); border-color: var(--accent-line); }
.analysis-score { background: var(--premium-sidebar); }
.analysis-verdict { color: var(--accent-ink); }

/* NUMBERS ----------------------------------------------------------------- */
.heat { background: #ecefec; }
.heat span { background: linear-gradient(90deg, var(--lime), var(--accent-strong)); }
.suggestion-panel { background: linear-gradient(135deg, var(--accent-wash), #fff 60%); }

/* KANBAN / TASKS ---------------------------------------------------------- */
.kanban { gap: 14px; }
.kanban-column {
  min-height: 540px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--premium-border);
  background: #eef1ed;
}
.kanban-title { padding: 10px 7px 14px; }
.kanban-title strong { font-size: .86rem; }
.task-card {
  border-radius: 13px;
  border-color: var(--premium-border);
  box-shadow: 0 4px 16px rgba(20,25,21,.03);
}
.task-card:hover { border-color: var(--accent-line); box-shadow: var(--premium-shadow-sm); }
.mini-kanban > div { background: var(--premium-surface-2); border-color: var(--premium-border); }

/* AI ---------------------------------------------------------------------- */
.ai-layout { gap: 16px; }
.ai-chat-panel { min-height: 650px; }
.ai-orb { color: var(--accent-ink); border-radius: 14px; }
.message.assistant { background: #f1f3f0; }
.message.user { background: var(--premium-sidebar); }
.prompt-chip { background: #fff; border-color: var(--premium-border); transition: .15s ease; }
.prompt-chip:hover { border-color: var(--accent-line); background: var(--accent-wash); }
.privacy-note { background: var(--accent-wash); border: 1px solid var(--accent-line); }

/* SETTINGS / NOTES -------------------------------------------------------- */
.settings-card, .note-card, .security-panel { border-color: var(--premium-border); }
.settings-icon { color: var(--accent-strong); background: var(--accent-wash); }
.lock-box { background: linear-gradient(145deg, var(--accent-wash), #f5f7f3); border: 1px solid var(--accent-line); }

/* MODAL ------------------------------------------------------------------- */
.modal::backdrop { background: rgba(8, 12, 9, .56); backdrop-filter: blur(5px); }
.modal-card {
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.75);
  background: #fff;
  box-shadow: 0 32px 100px rgba(7,12,8,.28);
}
.modal-header { border-bottom-color: var(--premium-border); }
.modal-header h2 { font-size: 1.55rem; font-weight: 680; }
.modal-actions { border-top-color: var(--premium-border); }

/* LOGIN ------------------------------------------------------------------- */
.login-view {
  background: radial-gradient(circle at 72% 20%, var(--accent-glow), transparent 28%), #0d100e;
}
.login-card {
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.98);
  box-shadow: 0 36px 100px rgba(0,0,0,.36);
}
.login-card h1 { font-size: 2.45rem; font-weight: 690; }

/* ACCESSIBILITY / FEEDBACK ------------------------------------------------ */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.toast { border-radius: 11px; background: var(--premium-sidebar); }
.skeleton { border-radius: 12px; }

/* COLLAPSED SIDEBAR ------------------------------------------------------- */
.app-shell.sidebar-collapsed { grid-template-columns: 82px minmax(0, 1fr); }
.app-shell.sidebar-collapsed .sidebar { padding-inline: 13px; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; padding-inline: 10px; }
.app-shell.sidebar-collapsed .nav-item span { width: auto; }

/* RESPONSIVE -------------------------------------------------------------- */
@media (max-width: 1220px) {
  .main-content { padding-inline: 24px; }
  .topbar { grid-template-columns: 1fr auto; }
  .period-tabs { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  body { padding-bottom: 76px; }
  .app-shell { display: block; }
  .main-content { padding: 0 16px 30px; }

  /* No mobile a navegação vira barra inferior — sem alterar eventos/rotas. */
  .sidebar {
    position: fixed;
    inset: auto 8px 8px 8px;
    width: auto;
    height: 64px;
    padding: 6px 8px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    transform: none !important;
    background: rgba(15,18,16,.96);
    box-shadow: 0 18px 50px rgba(10,14,11,.24);
    backdrop-filter: blur(18px);
    z-index: 50;
  }
  .sidebar-top, .profile-card, .mobile-menu { display: none !important; }
  .nav-list {
    height: 100%;
    flex-direction: row;
    gap: 4px;
    align-items: center;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item {
    flex: 1 0 68px;
    height: 52px;
    min-height: 52px;
    padding: 6px 7px;
    border-radius: 12px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    font-size: .58rem;
  }
  .nav-item span { width: auto; font-size: 14px; line-height: 1; }
  .nav-label { display: block !important; }

  .topbar {
    min-height: 70px;
    padding: 10px 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  .project-picker { max-width: min(240px, calc(100vw - 90px)); }
  .project-picker label { min-width: 0; }
  .project-picker select { max-width: 160px; text-overflow: ellipsis; }
  .top-actions .icon-button { display: inline-grid; }
  .period-tabs {
    order: 3;
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
  }
  .period-tabs button { flex: 1 0 auto; }

  .page-heading { padding: 28px 0 20px; }
  .page-heading h1 { font-size: 2.15rem; }
  .page-heading .muted { font-size: .84rem; }

  .dashboard-grid.metrics,
  .dashboard-grid.secondary-metrics,
  .dashboard-grid.content-row,
  .dashboard-grid.bottom-row,
  .dashboard-grid.compact,
  .finance-page-grid,
  .settings-grid,
  .ai-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .dispatch-table-panel, .task-preview, .ai-chat-panel, .security-panel { grid-column: 1 / -1; }
  .metric-card { min-height: 132px; }
  .table-panel > .table-scroll { margin-inline: -22px; }
}

@media (max-width: 620px) {
  .main-content { padding-inline: 12px; }
  .top-actions { gap: 4px; }
  .top-actions .icon-button { width: 38px; height: 38px; }
  .project-picker { padding-right: 8px; }
  .project-picker .avatar.small { width: 30px; height: 30px; }
  .project-picker select { max-width: 120px; }

  .page-heading {
    align-items: stretch;
    gap: 16px;
    padding-top: 24px;
  }
  .page-heading h1 { font-size: 2rem; }
  .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1 1 auto; }

  .dashboard-grid.metrics,
  .dashboard-grid.secondary-metrics,
  .dashboard-grid.content-row,
  .dashboard-grid.bottom-row,
  .dashboard-grid.compact,
  .finance-page-grid,
  .settings-grid,
  .ai-layout { grid-template-columns: 1fr; }

  .dispatch-table-panel, .task-preview, .ai-chat-panel, .note-lock,
  .security-panel, .ai-summary-card { grid-column: auto; }

  .metric-card { min-height: 122px; }
  .metric-card > strong { font-size: 1.7rem; }
  .panel, .ai-summary-card { padding: 17px; }
  .table-panel > .table-scroll { margin: 0 -17px -17px; }

  /* Em telas pequenas as tabelas preservam dados completos com scroll seguro. */
  .table-scroll {
    margin-inline: -2px;
    padding-bottom: 3px;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }
  table { min-width: 760px; }
  .dispatch-metrics-table { min-width: 1180px; }
  th:first-child, td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 1px 0 0 var(--premium-border);
  }
  th:first-child { z-index: 3; background: #fafbf9; }
  td:first-child { background: #fff; }
  tbody tr:hover td:first-child { background: #fbfcfa; }

  .form-grid, .project-checks, .check-grid { grid-template-columns: 1fr; }
  .modal { width: calc(100% - 12px); max-height: calc(100dvh - 16px); }
  .modal-card { border-radius: 16px; padding: 17px; }
  .modal-body { max-height: 64dvh; }
  .modal-actions .button { flex: 1; }
  .analysis-score-row { flex-direction: column; }
  .analysis-score { width: 78px; height: 78px; }

  .kanban {
    grid-template-columns: repeat(4, min(82vw, 310px));
    scroll-snap-type: x mandatory;
  }
  .kanban-column { min-height: 430px; scroll-snap-align: start; }

  .login-view { padding: 14px; }
  .login-card { padding: 30px 20px; }
  .login-card h1 { font-size: 2.15rem; }
}

@media (max-width: 390px) {
  .main-content { padding-inline: 10px; }
  .nav-item { flex-basis: 62px; }
  .nav-item .nav-label { font-size: .54rem; }
  .period-tabs button { padding-inline: 12px; }
  .project-picker select { max-width: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

/* ---- contestações (MED) ---- */
.med-destaques { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.med-destaques > div { display: flex; flex-direction: column; gap: 3px; padding: 18px; background: var(--surface-soft); border-radius: 12px; }
.med-destaques > div > span { font-size: .74rem; color: var(--muted); }
.med-destaques > div > strong { font-size: 1.6rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.05; }
.med-destaques > div > small { font-size: .7rem; color: var(--muted); }
.med-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap-sm); margin-bottom: var(--gap); }
.med-card { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; border-left-width: 3px; }
.med-card > span { font-size: .72rem; color: var(--muted); }
.med-card > strong { font-size: 1.05rem; font-weight: 600; }
.med-card > small { font-size: .68rem; color: var(--muted); }
.med-card.aberto { border-left-color: var(--amber); }
.med-card.ganha { border-left-color: var(--green); }
.med-card.perdida, .med-card.aceita { border-left-color: var(--red); }
.med-tag { font-size: .68rem; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--surface-soft); color: var(--muted); }
.med-tag.aberto { background: #fdf3e2; color: #b45309; }
.med-tag.ganha { background: #e7f7ee; color: #15803d; }
.med-tag.perdida { background: #fdeaea; color: #b91c1c; }
.med-tag.aceita { background: var(--surface-soft); color: var(--muted); }

/* ---- chave de fase (sociedades) ---- */
/* Sem fases, o seletor nem ocupa espaco na barra. */
.phase-switch:empty { display: none; }
.phase-switch { display: inline-flex; gap: 4px; background: var(--surface-soft); border-radius: 999px; padding: 4px; }
.phase-tab {
  border: 0; background: transparent; cursor: pointer; font-family: inherit;
  font-size: .8rem; font-weight: 500; color: var(--muted);
  padding: 7px 15px; border-radius: 999px; white-space: nowrap; transition: background .14s, color .14s;
}
.phase-tab:hover { color: var(--text); }
.phase-tab.active { background: var(--dark); color: #fff; }
.phase-tab.congelada.active { background: var(--muted); }
.phase-tab span { font-size: .72rem; opacity: .8; }
.phase-aviso {
  display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-radius: 12px;
  background: #fff4d6; color: #765b16; font-size: .82rem; margin-bottom: 14px;
}
@media (max-width: 900px) { .phase-tab { padding: 7px 11px; font-size: .74rem; } }

/* ---- topo: identidade | período | ações ----
   A chave de fase e o seletor de projeto dizem O QUE está em tela, então
   andam juntos à esquerda. O período fica centralizado e as ações à direita.
   Antes o seletor flutuava sozinho no meio da barra, sem relação com nada. */
.topbar-identidade { justify-self: start; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-identidade .project-picker { justify-self: auto; margin: 0; }
.topbar-identidade .phase-switch { flex-shrink: 0; }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr auto; row-gap: 12px; }
  .topbar-identidade { grid-column: 1; }
  .period-tabs { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .top-actions { grid-column: 2; grid-row: 1; }
}
@media (max-width: 620px) {
  .topbar-identidade { flex-wrap: wrap; gap: 8px; }
  .period-tabs { overflow-x: auto; max-width: 100%; }
}

/* ---- linha de totais da tabela ---- */
tfoot .linha-total td { border-top: 2px solid var(--text); padding-top: 16px; font-size: .84rem; background: var(--surface-soft); }
tfoot .linha-total td:first-child { border-top-left-radius: 8px; }
tfoot .linha-total td:last-child { border-top-right-radius: 8px; }

/* ================================================================ *
   Consolidado — todos os experts na mesma tela
   Segue a mesma escala do resto do sistema: nada de tamanho novo,
   nada de cor nova fora da paleta e da cor própria de cada projeto.
 * ================================================================ */

.panel + .panel,
.dashboard-grid + .panel { margin-top: 14px; }

.phase-aviso.alerta { background: #fdecea; color: #8a2f28; }

/* Barras comparativas: sem biblioteca, largura proporcional ao maior. */
.barras { display: grid; gap: 12px; }
.barra-linha {
  display: grid; grid-template-columns: minmax(110px, 170px) 1fr minmax(110px, auto);
  align-items: center; gap: 14px;
}
.barra-nome { display: flex; align-items: center; gap: 8px; font-size: .84rem; min-width: 0; }
.barra-nome, .barra-numero { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-ponto { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.barra-trilho { display: block; height: 11px; border-radius: 999px; background: var(--surface-soft); overflow: hidden; }
.barra-valor { display: block; height: 100%; border-radius: 999px; transition: width .3s ease; }
.barra-valor.negativa { opacity: .45; }
.barra-numero { text-align: right; font-size: .86rem; font-weight: 600; }

/* Tabelas do consolidado: números à direita, nome do expert à esquerda. */
.tabela-consolidada .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela-consolidada th.num { text-align: right; }
.tabela-consolidada .forte { font-weight: 600; }
.tabela-consolidada .negativo, .socio-total.negativo { color: var(--red); }
.expert-nome { display: inline-flex; align-items: center; gap: 8px; }
.nota-rodape { font-size: .76rem; margin: 14px 0 0; }

/* Lucro por pessoa, somando os projetos em que ela é sócia. */
.socios-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.socio-card {
  border: 1px solid var(--line); border-radius: 18px; padding: 18px;
  background: var(--surface-soft); display: grid; gap: 12px; align-content: start;
}
.socio-topo { display: flex; align-items: center; gap: 10px; }
.socio-total { margin: 0; font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; }
.socio-detalhe { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.socio-detalhe li {
  display: grid; grid-template-columns: 9px 1fr auto auto; align-items: center;
  gap: 8px; font-size: .78rem; color: var(--muted);
}
.socio-detalhe li strong { color: var(--text); font-weight: 600; }
.socio-detalhe li em { font-style: normal; opacity: .7; }
.socio-detalhe li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Custos da empresa e o resumo do rateio. */
.custos-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.custos-lista li {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line); font-size: .84rem;
}
.custos-lista li:last-child { border-bottom: 0; }
.custos-lista li.muted { display: block; padding: 22px 0; text-align: center; }
.custos-lista small { display: block; margin-top: 3px; font-size: .74rem; }
.custo-valor { font-weight: 600; font-variant-numeric: tabular-nums; }
.rateio-resumo {
  display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted);
}
.rateio-resumo span { display: inline-flex; align-items: center; gap: 7px; }
.rateio-resumo strong { color: var(--text); }

/* Escolha de quem participa do custo. */
.escolha-projetos { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 14px 0; }
.escolha-projetos legend { padding: 0 6px; font-size: .78rem; font-weight: 600; }
.escolha-projetos .muted { font-size: .75rem; margin: 0 0 10px; }
.escolha-projetos .checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; }
.check input { width: auto; margin: 0; }

@media (max-width: 760px) {
  .barra-linha { grid-template-columns: 1fr auto; row-gap: 6px; }
  .barra-trilho { grid-column: 1 / -1; grid-row: 2; }
  .custos-lista li { grid-template-columns: 1fr auto; row-gap: 8px; }
}


/* ---- correções da revisão ---- */

/* Selo de ROI sem base de cálculo: nem verde nem vermelho. Antes um ROI que
   não dava para calcular aparecia com fundo vermelho, como se fosse ruim. */
.metric-badge.neutro { background: var(--surface-soft); color: var(--muted); }

/* O rodapé do cartão perdeu o mini-gráfico sempre em alta e o percentual
   inventado; agora leva um dado do próprio cartão. */
.metric-foot span { color: var(--muted); font-size: .72rem; }
.metric-foot:empty { min-height: 0; }

/* Primeiros passos, na tela de sistema sem projeto. */
.passos { margin: 14px 0 20px; padding-left: 20px; display: grid; gap: 9px; color: var(--muted); font-size: .86rem; }
.passos li { padding-left: 4px; }
.passos li::marker { color: var(--text); font-weight: 600; }

/* Lista simples de projetos, para quem não enxerga valores. */
.lista-simples { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lista-simples li { display: flex; align-items: center; gap: 9px; font-size: .88rem; }
