@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg-950: #0E0503;
  --bg-900: #130600;
  --bg-850: #1B0D06;
  --surface: #1D1C20;
  --surface-2: #26252A;
  --surface-warm: #2B1D15;
  --border: #36261F;
  --line: rgba(255, 255, 255, 0.08);
  --brand-300: #F8A060;
  --brand-400: #F08A3C;
  --brand-500: #E86A10;
  --brand-700: #8B461E;
  --glow: #BA531D;
  --cream: #EDD6AF;
  --text-strong: #F4F4F3;
  --text-headline: #DEE2E7;
  --text-2: #AEB3C1;
  --text-body: #B2AFAD;
  --text-muted: #8A7F78;
  --good: #3FB57A;
  --warn: #E8A23A;
  --bad: #E5484D;
  --grad-cta: linear-gradient(90deg, #8B461E 0%, #E86A10 55%, #F8A060 100%);
  --font-display: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(90% 60% at 100% 100%, rgba(186, 83, 29, 0.35) 0%, rgba(186, 83, 29, 0) 60%), var(--bg-900);
  background-attachment: fixed;
  color: var(--text-body);
  font: 14px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); color: var(--text-headline); letter-spacing: -0.02em; margin: 0; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03); color: var(--text-strong); cursor: pointer; white-space: nowrap;
  font-weight: 500; transition: background .15s, border-color .15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.07); border-color: #4a352b; }
.btn-cta { background: var(--grad-cta); border: 0; box-shadow: 0 0 0 1px rgba(248, 160, 96, .35), 0 8px 28px rgba(232, 106, 16, .3); }
.btn-cta:hover { filter: brightness(1.08); background: var(--grad-cta); }
.btn-light { background: #fff; color: #1B1B1F; border: 0; }
.btn-light:hover { background: #ececec; }
.btn-danger { color: #ff8a8d; border-color: rgba(229, 72, 77, .4); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 30px; height: 30px; padding: 0; border-radius: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.input {
  height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg-950); color: var(--text-strong); outline: none; width: 100%;
}
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(232, 106, 16, .2); }
select.input { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }

.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--text-strong); }
.eyebrow b { color: var(--brand-300); font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 400px; background: rgba(29, 28, 32, .85); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 36px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); backdrop-filter: blur(8px);
}
.login-card h1 { font-size: 32px; letter-spacing: -0.04em; margin: 14px 0 6px; line-height: 1.05; }
.login-card h1 span { color: var(--text-2); }
.login-card form { display: grid; gap: 14px; margin-top: 24px; }
.login-card .btn { height: 46px; width: 100%; margin-top: 6px; }
.msg-erro { color: #ff8a8d; font-size: 13px; min-height: 18px; }

/* ---------- Layout do app ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: rgba(19, 6, 0, .82); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--text-strong); letter-spacing: -0.02em; }
.logo i { width: 22px; height: 22px; border-radius: 6px; background: var(--grad-cta); display: inline-block; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.tab { height: 32px; padding: 0 16px; border-radius: 999px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-weight: 500; }
.tab:hover { color: var(--text-strong); }
.tab.ativo { background: #fff; color: #1B1B1F; }
.topbar .direita { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mes-select { width: auto; height: 34px; border-radius: 999px; padding-left: 14px; }
.usuario { font-size: 13px; color: var(--text-2); }

main { max-width: 1240px; transition: max-width .2s; margin: 0 auto; padding: 28px 24px 80px; }
main.largo { max-width: 1600px; }
.aviso {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 20px;
  border-radius: var(--r-md); background: rgba(232, 162, 58, .1); border: 1px solid rgba(232, 162, 58, .35); color: var(--cream);
}
.cabecalho { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.cabecalho h2 { font-size: 30px; letter-spacing: -0.035em; line-height: 1.1; margin-top: 8px; }
.cabecalho h2 span { color: var(--text-2); }

/* ---------- Painel ---------- */
.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; min-width: 0; }
.kpi .rotulo { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi .valor { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.03em; color: var(--text-strong); margin-top: 6px; }
.kpi .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi.hero { background: linear-gradient(135deg, rgba(232, 106, 16, .22), rgba(29, 28, 32, 1) 60%); border-color: rgba(248, 160, 96, .25); }
.kpi.hero .valor { font-size: 38px; }
.delta-pos { color: var(--good); }
.delta-neg { color: #ff8a8d; }

.progresso-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.prog-topo { display: flex; justify-content: space-between; align-items: baseline; }
.prog-topo b { font-family: var(--font-display); font-size: 22px; color: var(--text-strong); font-weight: 600; }
.barra { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .06); margin-top: 12px; overflow: hidden; }
.barra > div { height: 100%; border-radius: 999px; background: var(--brand-500); }

.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; margin-top: 14px; }
.card h3 { font-size: 16px; margin-bottom: 4px; }
.card .desc { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }

.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr; gap: 10px; align-items: center; margin-bottom: 10px; position: relative; }
.hbar .nome { font-size: 13px; color: var(--text-headline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .trilho { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar .fill { height: 18px; border-radius: 0 4px 4px 0; background: var(--brand-500); min-width: 3px; transition: filter .15s; }
.hbar .rot { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.hbar:hover .fill, .vbar:hover .col { filter: brightness(1.2); }

.vbars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 22px; border-bottom: 1px solid var(--line); }
.vbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; position: relative; }
.vbar .col { width: 100%; max-width: 46px; border-radius: 4px 4px 0 0; background: rgba(232, 106, 16, .45); min-height: 3px; }
.vbar.atual .col { background: var(--brand-500); }
.vbar .topo { font-size: 11px; color: var(--text-2); margin-bottom: 4px; white-space: nowrap; }
.vlabels { display: flex; gap: 10px; margin-top: 6px; }
.vlabels span { flex: 1; text-align: center; font-size: 11px; color: var(--text-muted); }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; padding: 8px 10px; border-radius: 8px;
  background: #0b0605; border: 1px solid var(--border); color: var(--text-strong); font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); max-width: 260px;
}
.tooltip small { display: block; color: var(--text-2); }

.lista { display: flex; flex-direction: column; }
.lista .item { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lista .item:last-child { border-bottom: 0; }
.lista .data { width: 62px; text-align: center; flex: none; border-radius: 10px; background: var(--surface-warm); padding: 6px 0; line-height: 1.1; }
.lista .data b { display: block; font-family: var(--font-display); font-size: 18px; color: var(--text-strong); }
.lista .data small { font-size: 10px; text-transform: uppercase; color: var(--brand-300); letter-spacing: .08em; }
.lista .info { flex: 1; min-width: 140px; }
.lista .info b { color: var(--text-strong); font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista .info small { color: var(--text-muted); }
.vazio { color: var(--text-muted); font-size: 13px; padding: 12px 0; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--good); background: rgba(63, 181, 122, .12); }
.chip.pend { color: var(--warn); background: rgba(232, 162, 58, .12); }
.chip.ruim { color: #ff8a8d; background: rgba(229, 72, 77, .12); }

/* ---------- Planilha ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .busca { max-width: 260px; height: 36px; border-radius: 999px; }
.filtros { display: flex; gap: 6px; flex-wrap: wrap; }
.filtro { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text-2); cursor: pointer; font-size: 12px; }
.filtro.ativo { border-color: var(--brand-400); color: var(--brand-300); background: rgba(232, 106, 16, .1); }
.toolbar .espaco { flex: 1; }

.planilha-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); max-height: calc(100vh - 230px); }
table.planilha { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1180px; font-size: 13px; table-layout: fixed; }
.planilha th {
  position: sticky; top: 0; z-index: 2; background: #232227; color: var(--text-2); font-weight: 600; font-size: 12px;
  text-align: left; padding: 0 10px; height: 38px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--line);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.planilha th.idx, .planilha td.idx { width: 40px; text-align: center; color: var(--text-muted); background: #1a191d; position: sticky; left: 0; z-index: 1; }
.planilha th.idx { z-index: 3; }
.planilha th .seta { color: var(--brand-300); margin-left: 4px; }
.planilha td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; height: 36px; color: var(--text-headline); }
.planilha tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.planilha td input[type=text], .planilha td input[type=date], .planilha td input[type=number] {
  width: 100%; height: 36px; border: 0; background: transparent; padding: 0 10px; outline: none; color: var(--text-headline);
}
.planilha td input:focus { background: rgba(232, 106, 16, .08); box-shadow: inset 0 0 0 1px var(--brand-400); }
.planilha td input.auto::placeholder { color: var(--text-2); }
.planilha td.centro { text-align: center; }
.planilha td.dir input { text-align: right; }
.planilha tfoot td { position: sticky; bottom: 0; background: #232227; font-weight: 600; color: var(--text-strong); padding: 0 10px; height: 40px; border-top: 1px solid var(--border); }
.planilha tfoot td.dir { text-align: right; }
.planilha .acoes { width: 44px; text-align: center; }
.check { width: 18px; height: 18px; accent-color: var(--brand-500); cursor: pointer; }
.salvo-flash { animation: flash .9s ease; }
@keyframes flash { 0% { background: rgba(63, 181, 122, .22); } 100% { background: transparent; } }

/* ---------- Clientes ---------- */
.clientes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.cliente-card { display: flex; flex-direction: column; gap: 10px; }
.cliente-card .topo { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.cliente-card h3 { font-size: 17px; }
.cliente-card dl { display: grid; grid-template-columns: 82px 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.cliente-card dt { color: var(--text-muted); }
.cliente-card dd { margin: 0; color: var(--text-headline); overflow-wrap: anywhere; }
.cliente-card .rodape { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal-fundo { position: fixed; inset: 0; z-index: 40; background: rgba(5, 2, 1, .7); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; }
.modal h3 { font-size: 20px; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.modal .acoes { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Configurações ---------- */
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cfg-grid .card form { display: grid; gap: 12px; }
.tabela-simples { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabela-simples td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.tabela-simples td:last-child { text-align: right; }
.token-box { font-family: ui-monospace, monospace; font-size: 12px; background: var(--bg-950); border: 1px dashed var(--brand-400); padding: 10px; border-radius: 8px; overflow-wrap: anywhere; color: var(--cream); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60; background: #fff; color: #1B1B1F; padding: 10px 18px; border-radius: 999px; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.toast.erro { background: #ffdcdc; color: #7a1215; }


/* ---------- Painel: novo layout ---------- */
.painel-topo { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 14px; }
.painel-topo .coluna { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.kpis-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.kpis-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 14px; }
.status-card { flex: 1; }
.status-linha { padding: 12px 0; border-bottom: 1px solid var(--line); }
.status-linha:last-child { border-bottom: 0; padding-bottom: 0; }
.status-linha .prog-topo span { font-size: 13px; color: var(--text-headline); }
.status-linha .prog-topo b { font-size: 18px; }
.status-linha .prog-topo small { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.status-linha .barra { margin-top: 8px; height: 6px; }

.grafico-card { flex: 1; }
.grafico-topo { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.legenda { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); padding-top: 2px; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.leg-barra { width: 10px; height: 10px; border-radius: 3px; background: var(--brand-500); display: inline-block; }
.leg-meta { width: 18px; border-top: 2px dashed var(--cream); display: inline-block; }
.grafico { width: 100%; overflow: hidden; }
.grafico svg { display: block; }
.g-grade { stroke: rgba(255, 255, 255, .06); stroke-width: 1; }
.g-base { stroke: rgba(255, 255, 255, .18); stroke-width: 1; }
.g-eixo { fill: var(--text-muted); font-size: 11px; font-family: var(--font-body); }
.g-eixo.atual { fill: var(--text-strong); font-weight: 600; }
.g-barra { fill: rgba(232, 106, 16, .5); transition: fill .15s; }
.g-barra.atual { fill: var(--brand-500); }
.g-valor { fill: var(--text-2); font-size: 12px; font-weight: 600; font-family: var(--font-display); }
.g-valor.atual { fill: var(--text-strong); }
.g-meta { stroke: var(--cream); stroke-width: 2; stroke-dasharray: 6 4; }
.g-meta-rot { fill: var(--cream); font-size: 11px; font-weight: 600; }
.g-alvo { fill: transparent; cursor: pointer; }
.g-alvo:hover { fill: rgba(255, 255, 255, .035); }

/* ---------- Desempenho ---------- */
.desemp-topo { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.meta-corpo { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.anel-fundo { fill: none; stroke: rgba(255, 255, 255, .07); stroke-width: 12; }
.anel-valor { fill: none; stroke: var(--brand-500); stroke-width: 12; stroke-linecap: round; }
.anel-texto { fill: var(--text-strong); font: 600 24px var(--font-display); letter-spacing: -0.02em; }
.meta-info { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.meta-num { display: flex; align-items: baseline; gap: 8px; }
.meta-num b { font: 600 40px/1 var(--font-display); color: var(--text-strong); letter-spacing: -0.03em; }
.meta-num span { color: var(--text-2); }
.meta-lista { list-style: none; padding: 0; margin: 4px 0 0; width: 100%; font-size: 13px; }
.meta-lista li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.meta-lista li:last-child { border-bottom: 0; }
.meta-lista li b { color: var(--text-strong); font-weight: 600; white-space: nowrap; }
.meta-lista li.total { border-top: 1px solid var(--border); border-bottom: 0; margin-top: 4px; padding-top: 12px; font-size: 14px; }
.alerta { margin-top: 14px; padding: 10px 12px; border-radius: 10px; font-size: 13px; background: rgba(232, 162, 58, .1); color: var(--cream); border: 1px solid rgba(232, 162, 58, .3); }
.alerta.ok { background: rgba(63, 181, 122, .1); border-color: rgba(63, 181, 122, .3); color: #b9ecd0; }

.tabela-comp, .tabela-mensal { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabela-comp th, .tabela-mensal th { text-align: right; color: var(--text-muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabela-comp th:first-child, .tabela-mensal th:first-child { text-align: left; padding-left: 0; }
.tabela-comp td, .tabela-mensal td { text-align: right; padding: 10px; border-bottom: 1px solid var(--line); color: var(--text-headline); white-space: nowrap; }
.tabela-comp td:first-child, .tabela-mensal td:first-child { text-align: left; padding-left: 0; color: var(--text-2); }
.tabela-mensal { min-width: 720px; }
.tabela-mensal tbody tr { cursor: pointer; }
.tabela-mensal tbody tr:hover td { background: rgba(255, 255, 255, .03); }
.tabela-mensal tr.sel td { background: rgba(232, 106, 16, .1); }
.tabela-mensal tr.sel td:first-child { color: var(--text-strong); font-weight: 600; }
.tabela-mensal tfoot td { font-weight: 600; color: var(--text-strong); border-top: 1px solid var(--border); border-bottom: 0; }

@media (max-width: 1100px) {
  .painel-topo { grid-template-columns: 1fr; }
  .kpis-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  .desemp-topo { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpis-3, .kpis-4 { grid-template-columns: 1fr; }
  .mes-select { padding-left: 10px; }
}

@media (max-width: 960px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid-2, .cfg-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 20px 16px 60px; }
  .kpis, .progresso-grid, .form-grid { grid-template-columns: 1fr; }
  .kpi.hero .valor { font-size: 32px; }
}
