/* ==========================================================================
   RARUS DC — sistema visual v3.1 aplicado ao sistema
   Fonte da verdade: site/idvisual/ (brand book) + home v2 (rarusdc.com.br)
   Mesma linha da home: papel quente, superficie branca, canto reto,
   laranja como acento (5%), tipografia Archivo + Newsreader + IBM Plex Mono.
   Cinco cores: carvao #161412 · laranja #FC7903 · papel #F5F1EA
                grafite #665D52 · linha #DFD7C9
   Tema padrao: PAPEL. Alternativa: CARVAO (botao no topo, lembrado por usuario)
   ========================================================================== */

/* ---------- TEMA PAPEL (padrao) ---------- */
:root {
  --bg: #F7F3EC;
  --surface: #FFFFFF;
  --surface-2: #F5F0E7;
  --surface-3: #EDE4D6;
  --border: #E4DACA;
  --border-soft: #F0E9DC;
  --text: #161412;
  --text-muted: #6B6154;
  --text-faint: #7C7263;

  --brand: #D65E02;
  --brand-dark: #B3350A;
  --brand-texto: #B3350A;
  --brand-vivo: #FC7903;
  --sobre-vivo: #161412;
  --brand-soft: #FFF3E4;
  --brand-linha: #FFE4C4;
  --brand-contraste: #F5F1EA;

  /* barra lateral em carvao — a faixa institucional da marca */
  --sidebar-bg: #17140F;
  --sidebar-text: #F5F1EA;
  --sidebar-muted: #A99D8B;
  --sidebar-faint: #7A7161;
  --sidebar-border: #2C2721;
  --sidebar-hover: #221E18;
  --sidebar-brand: #FC7903;

  --green: #2E7D32;
  --green-bg: #E1EFDC;
  --orange: #D65E02;
  --orange-bg: #FCE4C9;
  --red: #B3350A;
  --red-bg: #F7DDD2;
  --blue: #3C6E9F;
  --blue-bg: #DEE8F2;

  --r: 4px;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(90, 70, 40, 0.05);
  --shadow-lg: 0 20px 50px rgba(56, 44, 28, 0.14);

  --ui: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- TEMA CARVAO ---------- */
:root[data-tema="carvao"] {
  --bg: #100E0C;
  --surface: #1A1714;
  --surface-2: #221E19;
  --surface-3: #2B2620;
  --border: #332C24;
  --border-soft: #262019;
  --text: #F3EEE6;
  --text-muted: #A99D8B;
  --text-faint: #8C8272;

  --brand: #FC7903;
  --brand-dark: #D65E02;
  --brand-texto: #FC7903;
  --brand-vivo: #FC7903;
  --sobre-vivo: #161412;
  --brand-soft: rgba(252, 121, 3, 0.13);
  --brand-linha: rgba(252, 121, 3, 0.32);
  --brand-contraste: #161412;

  --sidebar-bg: #0B0A08;
  --sidebar-text: #F5F1EA;
  --sidebar-muted: #A99D8B;
  --sidebar-faint: #6E6656;
  --sidebar-border: #262019;
  --sidebar-hover: #1C1915;
  --sidebar-brand: #FC7903;

  --green: #6ECB7C;
  --green-bg: rgba(110, 203, 124, 0.13);
  --orange: #FC7903;
  --orange-bg: rgba(252, 121, 3, 0.14);
  --red: #EE7250;
  --red-bg: rgba(238, 114, 80, 0.14);
  --blue: #7DB0E2;
  --blue-bg: rgba(125, 176, 226, 0.14);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.62);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--ui);
  font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
/* Texto que se le, nao que se consulta: serifada, como na home. */
.leitura, .page-head p, .bloco-sub-nota, .empty-state, .meta-sub,
.config-item .desc .d, .relatorio-card .desc {
  font-family: var(--serif); font-weight: 400;
}
::selection { background: var(--brand); color: var(--brand-contraste); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
#app { min-height: 100vh; }
.ic { flex-shrink: 0; vertical-align: middle; }

/* ---------- Login ---------- */
/* A tela de entrada e o primeiro contato com a marca do cliente. Estava
   toda em hexadecimal — o carvao de UMA empresa servia de fundo para o
   login de todas. Agora sao tokens: cada cliente pinta a sua no tema. */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--login-bg, var(--sidebar-bg)); position: relative; overflow: hidden;
}
.login-screen::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .06;
  background-image:
    linear-gradient(to right, var(--login-grade, var(--sidebar-text)) 1px, transparent 1px),
    linear-gradient(to bottom, var(--login-grade, var(--sidebar-text)) 1px, transparent 1px);
  background-size: 74px 74px;
  -webkit-mask-image: radial-gradient(85% 70% at 50% 30%, #000 5%, transparent 70%);
  mask-image: radial-gradient(85% 70% at 50% 30%, #000 5%, transparent 70%);
}
.login-card {
  position: relative; width: 384px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 26px 64px rgba(0,0,0,.45);
  padding: 38px 36px; text-align: center; color: var(--text);
}
.login-card img.login-logo { width: 150px; margin: 0 auto 18px; display: block; }
.login-card p.sub {
  color: #6B6154; margin: 0 0 24px; font-family: var(--mono);
  font-size: 9.5px; letter-spacing: .11em; text-transform: uppercase; line-height: 1.55;
}
.login-card label {
  display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em;
  text-transform: uppercase; color: #8E8474; margin: 15px 0 6px; text-align: left;
}
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid #E4DACA; border-radius: var(--r);
  font-size: 14px; background: #FBF8F3; color: #161412; font-family: var(--ui);
}
.login-card input:focus { outline: none; border-color: #D65E02; box-shadow: 0 0 0 3px rgba(214,94,2,.1); }
.login-card button {
  width: 100%; margin-top: 24px; justify-content: center;
  background: #FC7903; color: #161412;
}
.login-card button:hover { background: #161412; color: #FC7903; }
/* A unica acao da tela de entrada, na cor viva da marca. Estava escrita
   em hexadecimal aqui — e o laranja de UMA empresa aparecia no login de
   todas as outras. Agora sao os tokens, que cada cliente troca no tema. */
.login-card button.primary { background: var(--brand-vivo); border-color: var(--brand-vivo); color: var(--sobre-vivo); }
.login-card button.primary:hover { background: var(--sobre-vivo); border-color: var(--sobre-vivo); color: var(--brand-vivo); }
.login-erro { color: var(--red); font-size: 12.5px; margin-top: 12px; min-height: 16px; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 218px; flex-shrink: 0; background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border); padding: 20px 12px;
  display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0; overflow-y: auto;
}
.sidebar .brand { padding: 2px 8px 18px; }
.sidebar .brand img { width: 100%; max-width: 130px; display: block; }
.modulo-atual {
  font-family: var(--mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--sidebar-brand); font-weight: 500;
  padding: 2px 10px 12px;
}
.nav-funcoes { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r);
  color: var(--sidebar-muted); font-size: 13.5px; cursor: pointer; user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav-item { transition: background .14s ease, color .14s ease; }
.nav-item.active {
  background: rgba(252,121,3,.10); color: var(--sidebar-brand); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--sidebar-brand);
}

.sidebar-method {
  margin: 22px 4px 0; padding: 15px 14px; border: 1px solid var(--sidebar-border);
  border-radius: var(--radius); background: rgba(252,121,3,.04);
}
.sidebar-method .celula {
  border: 2px solid var(--sidebar-brand); padding: 8px 9px 9px;
  display: flex; flex-direction: column; margin-bottom: 12px;
}
.sidebar-method .celula .no { font-family: var(--mono); font-size: 10px; color: var(--sidebar-brand); }
.sidebar-method .celula .sym {
  font-family: var(--ui); font-weight: 900; font-size: 30px; line-height: .9;
  letter-spacing: -.05em; color: var(--sidebar-text); margin-top: 8px;
}
.sidebar-method .celula .label {
  font-family: var(--mono); font-size: 7.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--sidebar-faint); margin-top: 7px; line-height: 1.6;
}
.sidebar-method p { font-size: 11.5px; color: var(--sidebar-muted); margin: 0; line-height: 1.55; }

.sidebar-footer {
  margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 10px; color: var(--sidebar-text);
}
.sidebar .who .cargo { color: var(--sidebar-faint); }
.sidebar .avatar { border-color: var(--sidebar-border); }
.sidebar .avatar.iniciais { background: rgba(252,121,3,.13); color: var(--sidebar-brand); }
.sidebar .nav-subs { border-left-color: var(--sidebar-border); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.avatar.iniciais { display: flex; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 12px; }
.who { flex: 1; min-width: 0; }
.who .nome { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .cargo { font-size: 11px; color: var(--text-faint); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar: linha de busca + abas de módulos ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-linha1 { display: flex; align-items: center; gap: 16px; padding: 12px 24px; }
.search {
  flex: 1; max-width: 560px; display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 0 13px;
  color: var(--text-faint); transition: border-color .16s ease, box-shadow .16s ease;
}
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search input {
  flex: 1; padding: 10px 0; border: none; background: transparent; color: var(--text); font-size: 13.5px;
}
.search input:focus { outline: none; }
.search input::placeholder { color: var(--text-faint); }

.topbar-direita { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.periodo-btn {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text); padding: 9px 13px; font-size: 13px; font-weight: 500;
}
.periodo-btn:hover { border-color: var(--brand); }
.sino-btn { position: relative; background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 8px 10px; }
.sino-btn:hover { color: var(--text); }
.sino-badge {
  position: absolute; top: -6px; right: -6px; background: var(--brand); color: var(--brand-contraste);
  font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.perfil {
  display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 10px 5px 5px;
  border-radius: var(--r); color: var(--text-muted); max-width: 210px;
}
.perfil:hover { background: var(--surface-2); }

.modulos-tabs { display: flex; gap: 4px; padding: 0 24px; }
.modulo-tab {
  display: flex; align-items: center; gap: 8px; padding: 11px 18px; cursor: pointer;
  color: var(--text-muted); font-size: 13.5px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none;
  transition: color .15s ease, border-color .15s ease;
}
.modulo-tab:hover { color: var(--text); }
.modulo-tab.active { color: var(--text); border-bottom-color: var(--brand-vivo); font-weight: 700; }

.content { padding: 34px 36px 56px; flex: 1; }
@media (max-width: 860px) { .content { padding: 20px 18px 32px; } }

/* ---------- Cabeçalho de página ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1 { font-size: 27px; margin: 0 0 5px; font-weight: 800; letter-spacing: -0.032em; line-height: 1.1; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 14.5px; max-width: 68ch; }
.page-acoes { display: flex; gap: 10px; flex-shrink: 0; }
.brand-word { color: var(--brand); }

/* ---------- Cards ---------- */
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.cards-row.compacto { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px 17px; position: relative; box-shadow: var(--shadow);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.stat-card::after {
  content: ""; position: absolute; top: 0; right: 0;
  border-top: 9px solid var(--brand); border-left: 9px solid transparent;
  opacity: 0; transition: opacity .16s ease;
}
.stat-card:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(90,70,40,.07); }
.stat-card:hover::after { opacity: 1; }
.stat-top { display: flex; align-items: center; gap: 8px; color: var(--text-faint); margin-bottom: 11px; }
.stat-card:hover .stat-top { color: var(--brand); }
.stat-card .label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .15em;
  text-transform: uppercase; color: var(--text-faint);
}
.stat-card .value { font-size: 25px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.08; margin-bottom: 7px; }
.stat-card .value.green { color: var(--green); }
.stat-card .value.orange { color: var(--orange); }
.stat-card .value.blue { color: var(--blue); }
.stat-card .value.vermelho { color: var(--red); }
.var { font-size: 11.5px; display: block; }
.var em { font-style: normal; color: var(--text-faint); }
.var.sobe { color: var(--green); }
.var.desce { color: var(--red); }
.var.neutro { color: var(--text-faint); }

/* ---------- Painéis ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 22px; overflow: hidden; box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.panel-header h3 { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; margin: 0; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: 1.45fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.sub-titulo { font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin: 20px 0 8px; }

.filters-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filters-bar select, .filters-bar input {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r); font-size: 13px;
  background: var(--surface); color: var(--text);
}
.filters-bar select:focus, .filters-bar input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-family: var(--mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 0.15em; color: var(--text-faint); font-weight: 500;
  padding: 12px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 13px 12px; border-bottom: 1px solid var(--border-soft); }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--text-muted); }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-card .value, .meta-num .v { font-variant-numeric: tabular-nums; }
.verde { color: var(--green); }
.vermelho { color: var(--red); }
.laranja { color: var(--brand-texto); }
.link { color: var(--text-muted); cursor: pointer; white-space: nowrap; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.link:hover { color: var(--brand-texto); text-decoration-color: currentColor; }
.toggle { cursor: pointer; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--r);
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent; line-height: 1.5;
}
.badge.green { background: transparent; color: var(--green); border-color: color-mix(in srgb, var(--green) 38%, transparent); }
.badge.orange { background: transparent; color: var(--orange); border-color: color-mix(in srgb, var(--orange) 38%, transparent); }
.badge.red { background: transparent; color: var(--red); border-color: color-mix(in srgb, var(--red) 38%, transparent); }
.badge.blue { background: transparent; color: var(--blue); border-color: color-mix(in srgb, var(--blue) 38%, transparent); }
.badge.gray { background: transparent; color: var(--text-muted); border-color: var(--border); }

button {
  font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: var(--r);
  padding: 9px 16px; font-weight: 600; font-size: 13px; letter-spacing: -0.005em;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
button.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #FFFFFF; }
/* onde o laranja precisa gritar (uma acao por tela, no maximo) */
button.acento { background: var(--brand-vivo); border-color: var(--brand-vivo); color: var(--sobre-vivo); }
button.acento:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #FFFFFF; }
button.ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
button.ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--brand); }
button.small { padding: 6px 11px; font-size: 12px; }
/* Link que age como botao (abrir a tela certa da integracao). Sem isto ele
   herdava so o estilo de link e destoava da fileira de botoes. */
a.btn-sec {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--r);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 13px; font-weight: 600; text-decoration: none;
}
a.btn-sec:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-faint); }

.empty-state { text-align: center; padding: 44px 20px; color: var(--text-muted); font-size: 14.5px; }
.loading { padding: 60px; text-align: center; color: var(--text-faint); font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }

/* ---------- Gráficos ---------- */
.legenda { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.leg { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); }
.leg i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.grafico-wrap { width: 100%; }
.grafico { width: 100%; height: auto; }
.grafico .grid { stroke: var(--border-soft); stroke-width: 1; }
.grafico .axis { fill: var(--text-faint); font-size: 9.5px; }

.donut-bloco { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut { width: 132px; height: 132px; flex-shrink: 0; }
.donut-legenda { flex: 1; min-width: 170px; display: flex; flex-direction: column; gap: 11px; }
.donut-item { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; }
.donut-item i { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.donut-item .nome { color: var(--text-muted); }
.donut-item .val { font-weight: 600; }

/* ---------- Resumo / ações rápidas ---------- */
.resumo-linha { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.resumo-linha:last-child { border-bottom: none; }
.resumo-linha span { color: var(--text-muted); }
.acoes-rapidas { display: flex; flex-direction: column; gap: 2px; }
.acao {
  display: flex; align-items: center; gap: 11px; padding: 11px 10px; border-radius: var(--r);
  cursor: pointer; font-size: 13px; color: var(--text-muted);
}
.acao:hover { background: var(--surface-2); color: var(--text); }
.acao > span { flex: 1; }
.acao .ic:first-child { color: var(--text-faint); }
.acao:hover .ic:first-child { color: var(--brand); }

.alert-box {
  border: 1px solid var(--border); border-radius: var(--r); padding: 13px 15px; margin-bottom: 10px;
  font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer;
  transition: border-color .16s ease;
}
.alert-box.red { background: var(--surface); border-color: var(--border); border-left: 2px solid var(--red); }
.alert-box.red:hover { border-color: var(--red); }
.alert-box.orange { background: var(--surface); border-color: var(--border); border-left: 2px solid var(--brand-vivo); }
.alert-box.orange:hover { border-color: var(--brand); }

.faixa-marca {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px;
  background: var(--surface); border-left: 3px solid var(--brand-vivo);
}
.faixa-marca .titulo {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand-texto);
}
.faixa-marca .sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.faixa-marca img { height: 42px; opacity: 0.85; }

/* ---------- Modal / Drawer / Popover ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(22, 20, 18, 0.55); backdrop-filter: blur(2px); display: flex;
  align-items: flex-start; justify-content: center; z-index: 50; padding: 40px 20px; overflow-y: auto;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 560px; max-width: 100%; padding: 26px 28px;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 16.5px; }
.modal-head p { margin: 3px 0 0; font-size: 12.5px; }
.fechar { font-size: 24px; line-height: 1; color: var(--text-faint); cursor: pointer; }
.fechar:hover { color: var(--text); }
/* Campo de formulário fora de modal.
   As regras de campo só existiam dentro de `.modal`, então toda tela que
   usa `.field` na página (Estratégia, por exemplo) ficava com o rótulo e o
   campo colados na mesma linha. Mesmo visual, sem depender do modal. */
.field { margin-bottom: 14px; position: relative; }
.field > label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.field > input, .field > select, .field > textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13.5px; font-family: inherit; background: var(--surface-2); color: var(--text);
}
.field > input:focus, .field > select:focus, .field > textarea:focus { outline: none; border-color: var(--brand); }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; min-width: 0; }

.modal .field { margin-bottom: 14px; position: relative; }
.modal .field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.modal .field input, .modal .field select, .modal .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13.5px; font-family: inherit; background: var(--surface-2); color: var(--text);
}
.modal .field input:focus, .modal .field select:focus, .modal .field textarea:focus { outline: none; border-color: var(--brand); }
.modal .field-row { display: flex; gap: 12px; }
.modal .field-row .field { flex: 1; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-erro { color: var(--red); font-size: 12.5px; margin-top: 10px; }

.sugestoes { margin-top: 4px; }
.sugestao { padding: 7px 10px; font-size: 12.5px; color: var(--brand); cursor: pointer; border-radius: var(--r); }
.sugestao:hover { background: var(--surface-2); }

.custo-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.custo-row select, .custo-row input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r); font-size: 12.5px;
  background: var(--surface-2); color: var(--text);
}
.custo-row .rm { color: var(--text-faint); cursor: pointer; padding: 4px 8px; font-size: 17px; }
.custo-row .rm:hover { color: var(--red); }

.drawer-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; justify-content: flex-end; z-index: 60; }
.drawer { width: 470px; max-width: 100%; background: var(--surface); border-left: 1px solid var(--border); height: 100%; padding: 24px; overflow-y: auto; }
.drawer h3 { margin: 0; font-size: 16px; }
.memoria-linha { border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; margin-top: 9px; font-size: 12.5px; }
.memoria-linha .row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.memoria-linha .row.destaque { color: var(--brand); font-weight: 700; padding-top: 7px; margin-top: 4px; border-top: 1px solid var(--border-soft); }
.memoria-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--border); }

.popover-overlay { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding-top: 76px; }
.popover-overlay.alinha-topo-direita { justify-content: flex-end; padding-right: 24px; }
.popover { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px; }
.periodo-pop h4 { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); font-weight: 600; }
.meses-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mes-btn, .ano-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); padding: 8px 12px; font-size: 12.5px; justify-content: center; }
.mes-btn:hover, .ano-btn:hover { color: var(--text); border-color: var(--text-faint); }
.mes-btn.active, .ano-btn.active { background: var(--brand); border-color: var(--brand); color: var(--brand-contraste); }
.anos-linha { display: flex; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.anos-linha button { flex: 1; }

.menu-perfil { padding: 7px; min-width: 210px; }
.menu-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r); font-size: 13px; color: var(--text-muted); cursor: pointer; }
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.sair:hover { color: var(--red); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ---------- Comissões ---------- */
.comissao-pessoa { border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; margin-bottom: 12px; background: var(--surface); }
.comissao-pessoa .head { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.comissao-pessoa .nome { font-weight: 600; font-size: 14px; }
.comissao-pessoa .cargo { font-size: 11.5px; color: var(--text-faint); }
.comissao-pessoa .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px; margin-top: 14px; }
.comissao-pessoa .grid .k { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.comissao-pessoa .grid .v { font-size: 14.5px; font-weight: 600; }
.rodape-total { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); }
.rodape-total .total { font-size: 16px; font-weight: 700; color: var(--brand-texto); }

/* ---------- Configurações ---------- */
.config-item { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.config-item:last-child { border-bottom: none; }
.config-item.salvo { background: var(--green-bg); border-radius: var(--r); padding-left: 10px; padding-right: 10px; }
.config-item .desc .t { font-size: 13.5px; font-weight: 500; }
.config-item .desc .d { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.config-item .edit { display: flex; gap: 9px; align-items: center; flex-shrink: 0; }
.config-item input { width: 120px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r); text-align: right; background: var(--surface); color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.config-item input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.cat-lista { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Relatórios / marketing ---------- */
.relatorios-lista { display: flex; flex-direction: column; gap: 10px; }
.relatorio-card { display: flex; align-items: center; gap: 15px; border: 1px solid var(--border); border-radius: var(--r); padding: 15px 17px; background: var(--surface); transition: border-color .16s ease; }
.relatorio-card:hover { border-color: var(--brand); }
.relatorio-card .ico { color: var(--text-faint); display: flex; }
.relatorio-card:hover .ico { color: var(--brand); }
.relatorio-card .txt { flex: 1; }
.relatorio-card .titulo { font-size: 13.5px; font-weight: 600; }
.relatorio-card .desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.bloqueio { border-left: 2px solid var(--brand-vivo); background: var(--surface); border-top: 1px solid var(--border); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 12px 15px; border-radius: 0 var(--r) var(--r) 0; margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }
.bloqueio b { color: var(--text); }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .modulos-tabs { overflow-x: auto; }
  .page-head { flex-direction: column; }
  /* Tela estreita: a barra de cima guarda o que e identificacao e mantem
     busca e acoes. Sem isto a linha empurrava a pagina para o lado. */
  .topbar-linha1 { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .topbar-direita { gap: 8px; }
  .perfil { padding: 4px; max-width: none; }
  .perfil .who { display: none; }
  .periodo-btn { padding: 8px 10px; font-size: 12.5px; }
  .modulos-tabs { padding: 0 16px; }
}


/* ---- gestor de resultado ---- */
.meta-recado .panel-body { font-size: 14px; line-height: 1.7; }
.meta-recado.destaque { border-color: var(--brand); background: var(--brand-soft); }

.meta-linha { display: flex; gap: 34px; flex-wrap: wrap; align-items: flex-end; }
.meta-num .v { font-size: 24px; font-weight: 800; letter-spacing: -.6px; line-height: 1.1; }
.meta-num .v.muted { color: var(--text-faint); font-weight: 700; }
.meta-num .r { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.meta-num.destaque-ritmo { margin-left: auto; text-align: right; }
.meta-num.destaque-ritmo .v { color: var(--brand); }

.meta-trilho {
  position: relative; height: 8px; background: var(--surface-3);
  border-radius: 0; margin: 18px 0 9px; overflow: visible;
}
.meta-trilho i { display: block; height: 100%; border-radius: 0; }
/* Onde deveria estar hoje: a barra sozinha nao diz se esta atrasado. */
.meta-marca {
  position: absolute; top: -3px; width: 2px; height: 14px;
  background: var(--text-muted); border-radius: 1px;
}
.meta-sub { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }


/* O logo leva para o inicio. */
.brand { cursor: pointer; }

/* ================================================================
   ASSINATURA DO CLIENTE
   Sem logo no cliente.json, a marca é a sigla num quadrado com a cor da
   marca. Com logo, o JS troca este bloco pela imagem. Nada aqui conhece
   o nome de nenhum cliente.
   ================================================================ */
.marca-cliente { display: flex; align-items: center; gap: 10px; }
.msym {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--s, 26px); height: var(--s, 26px);
  background: var(--marca, currentColor);
  color: var(--marca-texto, #fff);
  border-radius: 3px;
  font-family: var(--ui); font-weight: 800; letter-spacing: .02em;
  font-size: calc(var(--s, 26px) * .42);
}
.marca-logo { display: block; height: var(--s, 26px); width: auto; flex: none; }

.marca-cliente .wm { display: flex; flex-direction: column; line-height: 1; }
.marca-cliente .wm b {
  font-family: var(--ui); font-weight: 700; font-size: 15px;
  letter-spacing: .3em; text-indent: .3em;
}
.marca-cliente .wm span {
  font-family: var(--mono); font-size: 6.5px; letter-spacing: .19em;
  color: var(--sidebar-brand); margin-top: 4px;
}
.sidebar .marca-cliente { color: var(--sidebar-text); padding: 2px 6px 18px; }
.sidebar .marca-logo { margin: 2px 6px 18px; }
.login-card .marca-cliente { color: var(--text); justify-content: center; margin-bottom: 22px; }
.login-card .marca-cliente .wm b { font-size: 19px; }
.login-card .marca-cliente .wm span { color: var(--marca-destaque, var(--sidebar-brand)); font-size: 7px; }
.login-card .marca-logo { margin: 0 auto 22px; }

/* alternador de tema — papel / carvao */
.tema-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  padding: 8px 10px; border-radius: var(--r);
}
.tema-btn:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------------------------------------------------------------- submenu
   Função com subfunções. As subfunções só aparecem quando o grupo está em
   uso — abertas sempre, o menu volta a ser a lista comprida que a
   hierarquia veio resolver. */
.nav-item.tem-subs { position: relative; }
.nav-seta {
  margin-left: auto;
  font-size: 10px;
  font-style: normal;
  opacity: 0.55;
}
.nav-subs {
  margin: 2px 0 6px;
  border-left: 1px solid var(--border);
  margin-left: 18px;
  padding-left: 4px;
}
.nav-item.nav-sub {
  padding-left: 10px;
  font-size: 13px;
}
.nav-item.nav-sub span { opacity: 0.92; }

/* ================================================================
   Página de função — painel em cima, subfunções em blocos
   ================================================================
   A quebra entre blocos é visual de propósito: a pessoa precisa perceber
   que passou de assunto sem ter trocado de tela. O cabeçalho é o alvo do
   menu, então tem folga em cima para não colar no topo ao rolar. */
.bloco-sub {
  margin-top: 52px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  /* A barra do topo é fixa e tem 110px: sem esta folga, o título do bloco
     para atrás dela e a pessoa acha que caiu no lugar errado. */
  scroll-margin-top: 126px;
}
/* Folga no último bloco: sem ela a página acaba antes e o último título
   nunca chega ao topo — o link do menu parecia não funcionar só ali. */
.bloco-sub:last-of-type { padding-bottom: 45vh; }
.bloco-cabeca {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 18px;
}
.bloco-cabeca h2 {
  margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.2px;
  white-space: nowrap;
}
.bloco-marca {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--r);
  background: var(--surface-3); color: var(--brand);
}
.bloco-linha { flex: 1; height: 1px; background: var(--border-soft); }
.bloco-sub-nota {
  margin: -4px 0 14px; font-size: 12.5px; color: var(--text-muted);
}
