/* ============================================================
   Maria Pudim — Painel. Identidade da marca (azul #476893 + Calgary).
   Paleta de dados (gráficos) validada pela dataviz skill.
   ============================================================ */
@font-face {
  font-family: "Calgary";
  src: url("fonts/Calgary.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* superfícies / tinta */
  --surface-1: #fdfcfb;
  --plane: #f1f3f7;
  --card: #ffffff;
  --ink: #1a2230;
  --ink-2: #55606f;
  --muted: #8a94a3;
  --grid: #e5e8ee;
  --line: #cfd6e0;
  --border: rgba(26, 34, 48, 0.10);
  /* marca (azul Maria Pudim) — cromo, nunca codifica dado */
  /* A marca da MAD, que não é a da Maria Pudim: é de quem assina o rodapé. */
  --mad-marinho: #0d2542;
  --brand: #476893;
  --brand-2: #35516f;
  --brand-3: #2c445e;
  --brand-soft: #eaeef5;
  --brand-tint: #c4cdde;
  --on-brand: #ffffff;
  /* categóricas (composição de custo) */
  --c1: #2a78d6; /* CMV insumos */
  --c2: #1baf7a; /* CIF */
  --c3: #eda100; /* MOD */
  --c4: #7a5cc8; /* DV */
  --c5: #008300; /* Lucro / MC */
  /* status (criticidade de margem) */
  --good: #0ca30c;
  --good-ink: #087a08;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(26,34,48,.06), 0 8px 24px rgba(26,34,48,.06);
  --radius: 14px;
}
:root[data-theme="dark"], html[data-theme="dark"] {
  --surface-1: #171b22;
  --plane: #0e1116;
  --card: #1e232c;
  --ink: #f2f4f8;
  --ink-2: #c2c9d4;
  --muted: #929bab;
  --grid: #2a303a;
  --line: #363d49;
  --border: rgba(255,255,255,0.10);
  --brand: #93aacb;
  --brand-2: #7f97ba;
  --brand-3: #b6c6de;
  --brand-soft: #232b38;
  --brand-tint: #3a465c;
  --on-brand: #ffffff;
  --c1: #3987e5; --c2: #199e70; --c3: #c98500; --c4: #9085e9; --c5: #2fa32f;
  --good: #0ca30c; --good-ink: #34c634; --warning: #fab219; --serious: #ec835a; --critical: #e05555;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-1: #171b22; --plane: #0e1116; --card: #1e232c;
    --ink: #f2f4f8; --ink-2: #c2c9d4; --muted: #929bab; --grid: #2a303a; --line: #363d49;
    --border: rgba(255,255,255,0.10);
    --brand: #93aacb; --brand-2: #7f97ba; --brand-3: #b6c6de; --brand-soft: #232b38;
    --c1:#3987e5; --c2:#199e70; --c3:#c98500; --c4:#9085e9; --c5:#2fa32f;
    --good-ink:#34c634; --critical:#e05555;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--plane);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
button { font-family: inherit; }

/* ---------------------------------------------------- topbar (azul marca) */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 22px;
  background: linear-gradient(120deg, var(--brand-2), var(--brand) 60%, #4f739f);
  border-bottom: 1px solid rgba(0,0,0,.15);
  box-shadow: 0 2px 14px rgba(26,34,48,.14);
}
.brand { display: flex; align-items: center; gap: 13px; cursor: pointer; }
.brand-badge { width: 42px; height: 42px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,.2)); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.05; }
.brand-txt strong {
  font-family: "Calgary", Georgia, serif; font-weight: 400;
  font-size: 25px; letter-spacing: .3px; color: #fff;
}
.brand-txt small { color: rgba(255,255,255,.82); font-size: 11px; letter-spacing: .3px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 13.5px;
  font-weight: 600; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); color: #fff; }
.btn.ghost { background: transparent; }
.btn.icon-only { padding: 8px 10px; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
/* botões do topo: contorno branco sobre o azul */
.topbar .btn { background: rgba(255,255,255,.10); color: #fff; border-color: rgba(255,255,255,.35); }
.topbar .btn:hover { background: rgba(255,255,255,.22); color: #fff; border-color: #fff; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 22px 60px; }
.loading { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------------------------------------------------- back nav */
.nav-back { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.btn.back { font-weight: 700; }
.btn.back:hover { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }

/* ---------------------------------------------------- breadcrumb */
.crumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 13.5px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); text-decoration: none; cursor: pointer; }
.crumbs a:hover { color: var(--brand); }
.crumbs .sep { color: var(--line); }
.crumbs .cur { color: var(--ink); font-weight: 600; }

.page-title { font-family: "Calgary", Georgia, serif; font-weight: 400; font-size: 30px; margin: 0 0 4px; letter-spacing: .2px; }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* ---------------------------------------------------- KPI row */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.kpi .val { font-size: 27px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.kpi .val small { font-size: 15px; font-weight: 600; color: var(--muted); }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------- category grid */
.grid-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.cat-card {
  position: relative; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; cursor: pointer; box-shadow: var(--shadow); overflow: hidden;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.cat-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--brand);
}
.cat-card:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: 0 8px 26px rgba(71,104,147,.18); }
.cat-card .cat-emoji { font-size: 30px; }
.cat-card h3 { margin: 8px 0 2px; font-size: 17px; }
.cat-card .cat-count { color: var(--muted); font-size: 13px; }
.cat-meta { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12.5px; }

/* ---------------------------------------------------- product list */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 200px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--ink); font-size: 14px;
}
.grid-prods { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.prod-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; cursor: pointer; box-shadow: var(--shadow); transition: .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.prod-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.prod-card .pc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.prod-card h4 { margin: 0; font-size: 15px; line-height: 1.25; }
.prod-card .pc-sub { color: var(--muted); font-size: 12px; }
.pc-metrics { display: flex; gap: 16px; margin-top: 2px; }
.pc-metric .m-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.pc-metric .m-val { font-size: 16px; font-weight: 700; }

/* ---------------------------------------------------- badges / status */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.badge.ok { color: var(--good-ink); background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.ok .dot { background: var(--good); }
.badge.low { color: #8a4b00; background: color-mix(in srgb, var(--serious) 20%, transparent); }
.badge.low .dot { background: var(--serious); }
.badge.crit { color: #7a1414; background: color-mix(in srgb, var(--critical) 18%, transparent); }
.badge.crit .dot { background: var(--critical); }
:root[data-theme="dark"] .badge.low, html[data-theme="dark"] .badge.low { color: #f6b98f; }
:root[data-theme="dark"] .badge.crit, html[data-theme="dark"] .badge.crit { color: #f0a1a1; }

/* meter (barra de margem) */
.meter { height: 8px; border-radius: 999px; background: var(--grid); overflow: hidden; position: relative; }
.meter > span { display: block; height: 100%; border-radius: 999px; }

/* ---------------------------------------------------- product detail */
.detail-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } .kpi .val { font-size: 24px; } }

.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.panel h3 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel h3 .tag { font-size: 11px; font-weight: 600; color: var(--muted); }

/* composição de custo */
.stackbar { display: flex; height: 30px; border-radius: 8px; overflow: hidden; background: var(--grid); }
.stackbar > span { height: 100%; border-right: 2px solid var(--card); transition: width .3s; }
.stackbar > span:last-child { border-right: none; }
.legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 12px; }
.legend .li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend .li b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* tabela de insumos */
table.ficha { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ficha th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .4px; padding: 6px 8px; border-bottom: 1px solid var(--line); font-weight: 600; }
table.ficha td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.ficha tr:last-child td { border-bottom: none; }
table.ficha td.num, table.ficha th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.ficha .ins-base { color: var(--brand); cursor: pointer; font-weight: 600; }
table.ficha .ins-base:hover { text-decoration: underline; }
table.ficha tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
table.ficha tfoot tr.ft-cif td { font-weight: 500; color: var(--muted); border-top: 1px dashed var(--grid); }
table.ficha tfoot tr.ft-fab td { border-top: 1px solid var(--line); }
.cat-pill { font-size: 10px; color: var(--muted); }

/* ficha comparativa por tamanho (bolos) */
.ficha-scroll { overflow-x: auto; }
table.ficha-bolos { min-width: 640px; }
table.ficha-bolos th.sz, table.ficha-bolos td.sz { min-width: 82px; text-align: right; }
table.ficha-bolos th.sz .sz-hint { display: block; font-size: 9.5px; font-weight: 400; color: var(--muted);
  text-transform: none; letter-spacing: 0; margin-top: 3px; }
.cell-legenda { font-size: 12px; color: var(--muted); background: var(--brand-soft); border: 1px dashed var(--line);
  padding: 8px 12px; border-radius: 9px; margin-bottom: 12px; }
.cell-legenda .lg-q { font-weight: 700; color: var(--ink); }
.cell-legenda .lg-s { color: var(--ink-2); }
table.ficha-bolos td.sz .cell-sub { display: block; font-size: 10px; color: var(--muted); font-weight: 400; margin-top: 1px; }
table.ficha-bolos tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
table.ficha-bolos tfoot tr.foot-preco td { border-top: 1px solid var(--grid); }
table.precos-bolo { min-width: 720px; }
table.precos-bolo th, table.precos-bolo td { white-space: nowrap; }
table.precos-bolo .pb-inp { width: 92px; margin: 0; font-size: 14px; padding: 5px 7px; }
table.precos-bolo .pb-markup, table.precos-bolo .pb-mc { font-weight: 700; }
table.precos-bolo .pb-chan { color: var(--brand); font-variant-numeric: tabular-nums; }
table.precos-bolo tbody tr:hover { background: color-mix(in srgb, var(--brand) 4%, transparent); }
table.precos-bolo th .sz-hint { display: block; font-size: 9.5px; font-weight: 400; color: var(--muted); text-transform: none; margin-top: 1px; }
table.precos-bolo th.pb-chead { text-align: center; }
table.precos-bolo th.pb-chead .chan-mark { display: inline-flex; justify-content: center; }
table.precos-bolo td.pb-chan { text-align: center; }
table.precos-bolo td.pb-precocell { text-align: center; }

/* formulário em modal (2 colunas) */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .field { min-width: 0; }
.form-grid .field input, .form-grid .field select { width: 100%; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* editor de produto (insumos da ficha) */
table.edit-ins { min-width: 620px; }
table.edit-ins select.ei-item { width: 100%; min-width: 230px; padding: 6px 9px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-1); color: var(--ink); font-size: 13px; }
table.edit-ins input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-1); color: var(--ink); font-size: 13px; }

/* tabela de insumos */
table.ins-table { min-width: 760px; }
table.ins-table th, table.ins-table td { padding: 8px 10px; }
table.ins-table .btn.sm { padding: 4px 8px; }

/* editor de embalagens por tamanho */
table.emb-table { min-width: 640px; }
table.emb-table td, table.emb-table th { vertical-align: middle; }
table.emb-table .emb-cell { min-width: 220px; }
table.emb-table select.emb-sel { width: 100%; max-width: 320px; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-1); color: var(--ink); font-size: 13px; }
table.emb-table .emb-cell .cell-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
table.emb-table tbody tr td:first-child { font-size: 15px; }

/* tabela de canais */
table.canais { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.canais th { text-align: right; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .3px; padding: 8px; border-bottom: 1px solid var(--line); }
table.canais th:first-child { text-align: left; }
table.canais td { padding: 9px 8px; border-bottom: 1px solid var(--grid); text-align: right; font-variant-numeric: tabular-nums; vertical-align: middle; }
table.canais td:first-child { text-align: left; font-weight: 600; }
table.canais td.taxa-td { text-align: right; white-space: nowrap; }
table.canais .preco-canal { font-size: 16px; font-weight: 700; }
table.canais .taxa-inp { width: 54px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface-1); color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.taxa-cell { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; justify-content: flex-end; }
.taxa-cell .pct { color: var(--muted); font-size: 13px; font-weight: 600; }
/* campo de preço único (visão "quanto sobra") */
.preco-unico-wrap { display: flex; flex-direction: column; gap: 5px; margin: 2px 0 14px; }
.preco-unico-wrap label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.pu-input { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink-2); }
.pu-input input { width: 118px; padding: 8px 11px; border: 1px solid var(--brand); border-radius: 9px;
  background: var(--surface-1); color: var(--ink); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.combo-pop { position: fixed; z-index: 1000; max-height: 260px; overflow-y: auto; padding: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 12px 30px rgba(0,0,0,.18); }
.combo-opt { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; white-space: nowrap; color: var(--ink); }
.combo-opt:hover, .combo-opt.hl { background: var(--brand-soft); }
.combo-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.bq-inp { width: 78px; text-align: right; padding: 5px 7px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface-1); color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.bq-inp:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.ficha-bolos td.sz { vertical-align: top; }
.chan-name { display: inline-flex; align-items: center; gap: 7px; }
.chan-name .cdot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
/* marca do canal (logo oficial se existir; senão a bolinha) */
.chan-mark { display: inline-flex; align-items: center; }
.chan-mark .cdot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
/* azulejo quadrado do canal: o selo preenche o quadro todo (cover) */
.chan-logo { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; vertical-align: middle; display: block; }
.c-nome-cell { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.c-nome-cell .chan-logo { flex: 0 0 auto; }
.c-nome-cell .c-nome { flex: 1 1 auto; min-width: 0; }
/* resumo de canais na Visão Geral */
.canais-strip { margin: 4px 0 22px; }
.canais-strip .cs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.canal-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.canal-chip { display: inline-flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--border);
  border-radius: 11px; background: var(--surface-1); min-width: 150px; }
.canal-chip .chan-logo { width: 42px; height: 42px; object-fit: cover; border-radius: 10px; }
.canal-chip .chan-mark .cdot { width: 11px; height: 11px; }
.canal-chip .cc-txt { display: flex; flex-direction: column; line-height: 1.25; }
.canal-chip .cc-nome { font-weight: 700; color: var(--ink); }
.canal-chip .cc-taxa { font-size: 12px; color: var(--muted); }

/* fracionamento */
.frac { border: 1.5px solid var(--brand); background: linear-gradient(180deg, var(--brand-soft), var(--card) 42%); }
.frac h3 { color: var(--brand); }
.frac-modes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.frac-modes .fm {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--card);
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.frac-modes .fm.active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.frac-controls { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.field input, .field select {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-1); color: var(--ink); font-size: 14px; min-width: 120px;
}
.frac-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 10px; margin: 14px 0; }
.frac-summary .fs { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.frac-summary .fs .l { font-size: 11px; color: var(--muted); font-weight: 600; }
.frac-summary .fs .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.frac-summary .fs .sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.frac-summary .fs.fs-preco { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--card)); }
.frac-summary .fs .preco-inp { width: 100%; margin-top: 4px; font-size: 18px; font-weight: 700; color: var(--brand);
  border: 1px solid var(--brand); border-radius: 8px; padding: 5px 8px; background: var(--card); text-align: right; }
.frac-summary .fs .preco-inp:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); }
.frac-scale-badge { font-size: 12px; color: var(--brand); font-weight: 700; margin-left: auto; }

/* custos fixos */
#custeio-tbl .cf-nome { width: 100%; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-1); color: var(--ink); font-size: 13.5px; }
.cf-money { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-weight: 600; }
.cf-money .cf-valor { width: 96px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-1); color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; font-size: 13.5px; }
#custeio-tbl tfoot td { font-size: 15px; }
#custeio-tbl .x.cf-del { font-size: 16px; }

/* modo preparo */
ol.modo { margin: 0; padding-left: 20px; }
ol.modo li { margin-bottom: 6px; color: var(--ink-2); }

/* ---------------------------------------------------- modal */
.modal-back { position: fixed; inset: 0; background: rgba(20,28,42,.5); z-index: 60;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.modal { background: var(--card); border-radius: 16px; max-width: 620px; width: 100%;
  box-shadow: var(--shadow); border: 1px solid var(--border); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px;
  border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.x { cursor: pointer; font-size: 22px; color: var(--muted); background: none; border: none; }

.canal-edit-head { display: grid; grid-template-columns: 1fr 116px 36px; gap: 10px; margin-bottom: 8px; padding: 0 2px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; }
.canal-edit-head span:nth-child(2) { text-align: left; }
.canal-edit-row { display: grid; grid-template-columns: 1fr 116px 36px; gap: 10px; align-items: center; margin-bottom: 10px; }
.canal-edit-row input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-1); color: var(--ink); font-size: 14px; width: 100%; }
.canal-edit-row .c-nome[readonly] { color: var(--ink-2); background: var(--brand-soft); }
.canal-edit-row .taxa-cell { justify-content: flex-start; }
.canal-edit-row .taxa-cell .c-taxa { width: 84px; }
.canal-edit-row .x.c-del { justify-self: center; }
.help-note { font-size: 12.5px; color: var(--muted); background: var(--brand-soft); border: 1px dashed var(--line);
  padding: 10px 12px; border-radius: 10px; margin-top: 14px; }

/* ---------------------------------------------------- footer + util */
.foot { max-width: 1180px; margin: 0 auto; padding: 14px 22px 30px; color: var(--muted); font-size: 12px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px; }
.foot .rod-cliente { color: var(--ink-2); font-size: 12.5px; }
.foot .rod-cliente b { color: var(--brand); }
.foot-ver { color: var(--brand); cursor: pointer; font-weight: 600; }
.foot-ver:hover { text-decoration: underline; }
.empty { color: var(--muted); text-align: center; padding: 40px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--brand-3); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 13.5px; z-index: 80; box-shadow: var(--shadow); opacity: 0; transition: .2s; }
.toast.show { opacity: 1; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-info { font-size: 12px; color: var(--muted); }
@media print {
  .topbar, .foot, .frac-modes, .top-actions, .btn, .crumbs { display: none !important; }
  .panel { break-inside: avoid; box-shadow: none; }
}

/* ============================================================
   LOGIN / SESSÃO / DEV / CRÉDITO MAD
   ============================================================ */
.hidden { display: none !important; }

/* Portão de acesso (login) */
.mp-gate { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px;
  background: linear-gradient(160deg, var(--brand), var(--brand-3)); }
.mp-gate-card { width: min(92vw, 350px); background: var(--card); color: var(--ink);
  border-radius: 18px; padding: 30px 26px 24px; box-shadow: 0 18px 50px rgba(0,0,0,.35); text-align: center; }
.mp-gate-badge { width: 82px; height: 82px; object-fit: contain; margin: 0 auto 8px; display: block; }
.mp-gate-card h1 { font-family: "Calgary", Georgia, serif; font-weight: 400; font-size: 30px; margin: 2px 0 0; color: var(--brand); }
.mp-gate-sub { font-size: 13px; color: var(--muted); margin: 2px 0 18px; }
.mp-gate-form { display: flex; flex-direction: column; gap: 10px; }
.mp-gate-form input { width: 100%; box-sizing: border-box; font-size: 16px; padding: 12px 12px;
  border: 1.5px solid var(--line); border-radius: 11px; background: var(--surface-1); color: var(--ink); outline: none; }
.mp-gate-form input:focus { border-color: var(--brand); }
.mp-gate-form .btn { justify-content: center; padding: 12px; font-size: 15px; }
.mp-gate-erro { color: var(--critical); font-size: 13px; margin: 2px 0 0; }
.mp-gate-info { color: var(--good-ink); font-size: 13px; margin: 2px 0 0; line-height: 1.4; }
.mp-gate-link { background: none; border: 0; padding: 4px; margin: 0 auto; cursor: pointer;
  color: var(--brand); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
.mp-gate-credito { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.9); font-size: 12.5px; }
.mp-gate-credito img { height: 22px; width: auto; flex: none; filter: brightness(0) invert(1); }

/* Chip do usuário logado na barra */
.user-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.30); border-radius: 999px; color: #fff; font-size: 13px; font-weight: 600; }
.user-chip .chip-x { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 26px; height: 26px;
  border-radius: 999px; cursor: pointer; font-size: 13px; line-height: 1; }
.user-chip .chip-x:hover { background: rgba(255,255,255,.34); }

/* Modal genérico (troca de senha) */
.mp-modal { position: fixed; inset: 0; z-index: 210; display: flex; align-items: center; justify-content: center;
  background: rgba(15,22,34,.55); padding: 16px; }
.mp-modal-box { width: min(92vw, 380px); background: var(--card); color: var(--ink); border-radius: 16px;
  padding: 22px 22px 18px; box-shadow: var(--shadow); }
.mp-modal-box h3 { margin: 0 0 4px; font-size: 19px; }
.mp-modal-box p { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.mp-modal-box input { width: 100%; box-sizing: border-box; font-size: 15px; padding: 11px; margin-bottom: 9px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-1); color: var(--ink); outline: none; }
.mp-modal-box input:focus { border-color: var(--brand); }
.mp-modal-acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Campos usados nas telas de usuários/histórico */
.inp, .sel { font-size: 14px; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface-1); color: var(--ink); outline: none; }
.inp:focus, .sel:focus { border-color: var(--brand); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.muted { color: var(--muted); }

/* Modo Dev */
.dev-info { font-size: 13.5px; color: var(--ink-2); line-height: 1.9; margin-top: 8px; }
.dev-info b { color: var(--ink); }

/* Crédito MAD no rodapé */
.foot-credito { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.foot-credito b { color: var(--mad-marinho); }
.foot-credito .cred-marca { height: 16px; width: auto; flex: none; }
/* Tema escuro: o nome em marinho clareado e o monograma em branco. O filtro
   preserva o alfa das bordas, então o mesmo arquivo serve aos dois temas. */
:root[data-theme="dark"] .foot-credito b { color: #9fb4d0; }
:root[data-theme="dark"] .foot-credito .cred-marca { filter: brightness(0) invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .foot-credito b { color: #9fb4d0; }
  :root:not([data-theme="light"]) .foot-credito .cred-marca { filter: brightness(0) invert(1); }
}

/* ============================================================
   BARRA DE ABAS (navegação) + RESPONSIVO MOBILE
   ============================================================ */
.mp-headwrap { position: sticky; top: 0; z-index: 40; }
.mp-headwrap .topbar { position: static; z-index: auto; box-shadow: none; }
.mp-tabs { display: flex; gap: 2px; overflow-x: auto; background: var(--card);
  border-bottom: 1px solid var(--grid); box-shadow: 0 3px 12px rgba(26,34,48,.12);
  -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.mp-tabs::-webkit-scrollbar { height: 4px; }
.mp-tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.mp-tab { flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  padding: 12px 15px; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  white-space: nowrap; border-bottom: 3px solid transparent; transition: color .12s; }
.mp-tab:hover { color: var(--brand); }
.mp-tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.mp-tab#btn-dev { color: var(--c3); }
body.deslogado .mp-tabs { display: none; }

/* Guard global: a PÁGINA nunca rola na horizontal. Conteúdo largo
   (tabelas) rola dentro do próprio painel. */
html, body { max-width: 100%; overflow-x: hidden; }
main { width: 100%; box-sizing: border-box; }
.panel { max-width: 100%; box-sizing: border-box; }
.ficha-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 760px) {
  main { padding: 14px 12px 48px; }
  .topbar { padding: 10px 12px; }
  .brand-txt small { display: none; }
  .brand-badge { width: 36px; height: 36px; }
  .brand-txt strong { font-size: 21px; }
  .mp-tab { padding: 11px 13px; font-size: 12.8px; }
  .page-title { font-size: 23px; }
  /* qualquer painel deixa a tabela larga rolar por dentro (não empurra a página) */
  .panel { overflow-x: auto; }
  .detail-grid { grid-template-columns: 1fr !important; }
  .kpi-row { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .kpi .val { font-size: 22px; }
}
@media (max-width: 420px) {
  .kpi-row { grid-template-columns: 1fr !important; }
}
