/* PGD Gestão — visual de ferramenta de trabalho
   Regras: fonte do sistema (carrega na hora, mesmo sem internet), números alinhados,
   cinza para estrutura e cor só quando significa algo:
     azul  = ação principal / link        verde   = ok, pago, dinheiro entrando
     âmbar = atenção, em andamento        vermelho = atrasado, negativo, apagar
   O dourado da marca aparece só no logo e no item ativo do menu. */
:root {
  --ink: #18181b; --ink-2: #27272a; --ink-soft: #52525b; --ink-mute: #71717a;
  --bg: #f4f4f5; --card: #fff; --line: #e4e4e7; --line-2: #d4d4d8; --hover: #f7f7f8; --sub: #fafafa;
  --gold: #f2b705;
  --blue: #1d4ed8; --blue-bg: #eef3ff; --blue-line: #c7d6fb;
  --green: #15803d; --green-bg: #eaf6ee; --green-line: #bfe3cb;
  --red: #b91c1c; --red-bg: #fdeeee; --red-line: #f3c4c4;
  --orange: #b45309; --amber-bg: #fdf4dc; --amber-line: #f1dc9f;
  --radius: 6px;
  --display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --body: var(--display);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--body); font-size: 14px; color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 20px; font-weight: 650; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; margin-bottom: 10px; }
.muted { color: var(--ink-soft); }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
.right { text-align: right; } .nowrap { white-space: nowrap; }
.link { color: var(--blue); cursor: pointer; font-weight: 500; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
/* números sempre com a mesma largura, para as colunas baterem */
table, .kpi strong, .totals, .qitem__total, .bars, .cap, .mod__kpi, .mod__stats, .plan-row__val, .inst { font-variant-numeric: tabular-nums; }

/* ---------- Estrutura ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: 220px; background: var(--ink); color: #fff;
  display: flex; flex-direction: column; padding: 12px 8px 10px; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 2px 10px 12px; text-decoration: none !important; flex: none; }
.brand svg { width: 26px; height: 21px; color: var(--gold); }
.brand span { font-size: 15px; font-weight: 700; line-height: 1.1; }
.brand small { display: block; font-size: 11px; font-weight: 400; color: rgba(255,255,255,.5); }
/* o menu rola sozinho quando não cabe na altura da tela (marca e usuário ficam fixos) */
.side nav { display: flex; flex-direction: column; gap: 1px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px 8px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.22) transparent; }
.side nav::-webkit-scrollbar { width: 6px; }
.side nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 6px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 4px; color: rgba(255,255,255,.72); font-size: 13.5px; text-decoration: none; }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--gold); }
.side nav svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side__user { display: flex; align-items: center; gap: 8px; padding: 10px 6px 0; border-top: 1px solid rgba(255,255,255,.1); flex: none; }
.side__user div { flex: 1; min-width: 0; }
.side__user strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side__user small { color: rgba(255,255,255,.5); font-size: 11.5px; }
.side__user a { color: rgba(255,255,255,.6); font-size: 16px; text-decoration: none; padding: 2px 4px; }
.side__user a:hover { color: #fff; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--ink-soft); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.menu-toggle { display: none; }
.main { margin-left: 220px; padding: 20px clamp(14px, 2.4vw, 32px) 48px; max-width: 1440px; }
.main--full { margin: 0 auto; max-width: 440px; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head p { margin: 4px 0 0; color: var(--ink-soft); }
.head__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; align-items: start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid transparent; font: 500 13.5px var(--body);
  cursor: pointer; text-decoration: none !important; white-space: nowrap; line-height: 1;
}
.btn--gold, .btn--blue { background: var(--blue); color: #fff; }            /* ação principal da tela */
.btn--gold:hover, .btn--blue:hover { background: #1e40af; }
.btn--ink { background: var(--ink-2); color: #fff; }
.btn--ink:hover { background: #000; }
.btn--green { background: var(--green); color: #fff; }
.btn--green:hover { background: #166534; }
.btn--line { border-color: var(--line-2); color: var(--ink); background: #fff; }
.btn--line:hover { background: var(--hover); border-color: #a1a1aa; }
.btn--danger { background: #fff; color: var(--red); border-color: var(--red-line); }
.btn--danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.form { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 500; color: var(--ink-soft); }
input, select, textarea {
  font: 400 14px var(--body); color: var(--ink);
  width: 100%; height: 34px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 4px; background: #fff;
}
textarea { height: auto; resize: vertical; min-height: 72px; }
input[type=checkbox], input[type=radio] { height: auto; }
input[type=file] { height: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-bg); }
input[readonly] { background: var(--sub); color: var(--ink-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; color: var(--ink); }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--ink-soft); font-weight: 600; padding: 7px 10px; background: var(--sub); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--hover); }
.card > .table-wrap:only-child { margin: -16px; width: calc(100% + 32px); max-width: none; border-radius: 5px; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; color: var(--ink-mute); padding: 24px 10px; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 1.5; background: #f1f1f3; color: var(--ink-soft); border: 1px solid var(--line); white-space: nowrap; }
.badge--info { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-line); }
.badge--ok { background: var(--green-bg); color: var(--green); border-color: var(--green-line); }
.badge--bad { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.badge--prod, .badge--warn { background: var(--amber-bg); color: var(--orange); border-color: var(--amber-line); }

.flash { padding: 9px 12px; border-radius: var(--radius); margin-bottom: 14px; background: var(--green-bg); color: var(--green); border: 1px solid var(--green-line); }
.flash--bad { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.flash--warn { background: var(--amber-bg); color: var(--orange); border-color: var(--amber-line); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi small { display: block; font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.kpi strong { display: block; font-size: 22px; font-weight: 650; line-height: 1.2; margin-top: 2px; letter-spacing: -.01em; }
.kpi span { font-size: 12.5px; color: var(--ink-mute); }
.kpi--dark { border-color: var(--ink-2); box-shadow: inset 0 3px 0 var(--ink-2); }   /* o número principal da tela */
.kpi--bad { border-color: var(--red); box-shadow: inset 0 3px 0 var(--red); }
.kpi--bad strong { color: var(--red); }
.pos { color: var(--green); } .neg { color: var(--red); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 170px; }
.tabs { display: flex; gap: 0; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: #fff; width: fit-content; max-width: 100%; }
.tabs a { padding: 5px 12px; color: var(--ink-soft); font-size: 13px; text-decoration: none; border-right: 1px solid var(--line); }
.tabs a:last-child { border-right: 0; }
.tabs a:hover { background: var(--hover); color: var(--ink); }
.tabs a.on { background: var(--ink-2); color: #fff; }

dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.info dt { font-size: 12.5px; color: var(--ink-soft); }
dl.info dd { margin: 0; word-break: break-word; }

/* ---------- Etapas do pedido (stepper) ---------- */
.stepper { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; margin: 6px 0 4px; padding: 0; }
.stepper li { list-style: none; position: relative; padding-top: 10px; font-size: 11.5px; line-height: 1.25; color: var(--ink-mute); text-align: center; }
.stepper li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--line); }
.stepper li.done::before { background: var(--green); }
.stepper li.now::before { background: var(--blue); }
.stepper li.now { color: var(--ink); font-weight: 650; }

/* ---------- Quadro de produção ---------- */
.board { display: grid; grid-template-columns: repeat(6, minmax(210px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #ececee; border-radius: var(--radius); padding: 8px; min-height: 200px; }
.col h3 { font-size: 12.5px; font-weight: 650; color: var(--ink-soft); display: flex; justify-content: space-between; margin: 2px 2px 8px; }
.op { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; margin-bottom: 6px; border-left: 3px solid var(--line-2); }
.op.late { border-left-color: var(--red); }
.op strong { display: block; font-weight: 600; }
.op small { display: block; color: var(--ink-soft); font-size: 12px; }
.op__move { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; }
.op__move form { margin: 0; }

/* ---------- Itens do orçamento ---------- */
.items td { padding: 5px 4px; }
.items input, .items select { padding: 5px 7px; font-size: 13.5px; }
.items .qty { width: 80px; } .items .price { width: 110px; }
.totals { margin-left: auto; width: min(340px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { border-top: 1px solid var(--ink); margin-top: 4px; padding-top: 8px; font-size: 18px; font-weight: 650; }

/* ---------- Arrastar no quadro de produção ---------- */
.board-tip { font-size: 12.5px; margin: 0 0 8px; }
.op { position: relative; cursor: grab; user-select: none; }
.op__handle { position: absolute; top: 6px; right: 6px; color: var(--ink-mute); font-size: 14px; line-height: 1; touch-action: none; cursor: grab; padding: 4px; }
.op > a { padding-right: 22px; display: block; }
.op--ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: .95; }
.op--placeholder { opacity: .35; }
.op--saving { opacity: .6; }
.col.drop { background: var(--blue-bg); outline: 2px dashed var(--blue); outline-offset: -3px; }

/* ---------- Itens do orçamento (com grade) ---------- */
.qitem { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; display: grid; gap: 10px; background: var(--sub); }
.qitem__top { display: flex; gap: 10px; align-items: end; }
.qitem__prod { flex: 1.4; } .qitem__name { flex: 1; }
.qitem__del { flex: none; height: 34px; width: 34px; padding: 0; font-size: 16px; }
.qitem__grade { background: #fff; border: 1px dashed var(--line-2); border-radius: 4px; padding: 8px 10px; }
.qitem__grade > span { font-size: 12px; }
.sizes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sz { display: grid; gap: 2px; width: 54px; text-align: center; font-size: 12px; }
.sz input { padding: 5px 4px; text-align: center; }
.qitem__nums { display: grid; grid-template-columns: 90px 140px 200px 1fr; gap: 10px; align-items: end; }
.disc { display: flex; gap: 6px; } .disc input { min-width: 0; } .disc select { width: 96px; flex: none; }
.qitem__total { text-align: right; }
.qitem__total small { display: block; font-size: 12px; color: var(--ink-soft); }
.qitem__total strong { font-size: 18px; font-weight: 650; }
.gradeline { display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 4px; background: var(--amber-bg); color: var(--orange); font-size: 12px; }
.grade-box { border-left: 3px solid var(--orange); }
.grade-box--ok { border-left-color: var(--green); }
@media (max-width: 820px) {
  .qitem__nums { grid-template-columns: 1fr 1fr; }
  .qitem__total { grid-column: 1 / -1; }
  .qitem__top { flex-wrap: wrap; }
}

/* ---------- Tabela do orçamento (uma linha por tamanho) e fotos ---------- */
.qtable tr.cont td { border-top: 0; }
.qtable tr.first td { border-top: 1px solid var(--line-2); }
.qtable tbody tr:first-child td { border-top: 0; }
.qtable td[rowspan] { vertical-align: top; background: var(--sub); }
.size-tag { display: inline-block; min-width: 32px; text-align: center; padding: 0 6px; border-radius: 3px; background: #ececee; color: var(--ink); font-weight: 650; font-size: 12.5px; border: 1px solid var(--line-2); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo { position: relative; margin: 0; background: var(--sub); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.photo img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo__cap input { border: 0; border-top: 1px solid var(--line); border-radius: 0; font-size: 12.5px; padding: 5px 8px; }
.photo__del { position: absolute; top: 4px; right: 4px; margin: 0; }
.photo__del .btn { background: rgba(255,255,255,.95); height: 26px; width: 26px; padding: 0; }

/* ---------- Forma de pagamento (parcelas) ---------- */
.plan-row { display: grid; grid-template-columns: 100px 1fr 130px 34px; gap: 8px; align-items: end; margin-bottom: 6px; }
.plan-row__val { text-align: right; padding-bottom: 8px; font-size: 14px; font-weight: 600; }
.plan-row .btn { height: 34px; width: 34px; padding: 0; font-size: 16px; }
.inst { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 6px; }
.inst--paid { border-color: var(--green-line); background: var(--green-bg); }
.inst form { grid-column: 1 / -1; }
@media (max-width: 820px) { .plan-row { grid-template-columns: 80px 1fr; } .plan-row__val { text-align: left; padding: 0; } }

/* ---------- Janela flutuante (modal) ---------- */
dialog.modal { border: 1px solid var(--line-2); border-radius: 8px; padding: 0; width: min(600px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 12px 40px rgba(0,0,0,.22); }
dialog.modal::backdrop { background: rgba(24,24,27,.45); }
.modal__inner { padding: 18px; overflow: auto; max-height: calc(100vh - 40px); }
.modal__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.modal__x { border: 0; background: transparent; width: 30px; height: 30px; border-radius: 4px; font-size: 18px; cursor: pointer; flex: none; color: var(--ink-soft); }
.modal__x:hover { background: var(--hover); color: var(--ink); }

/* ---------- Plano de contas ---------- */
.acc-tree, .acc-tree ul { list-style: none; margin: 0; padding: 0; }
.acc { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; }
.acc ul { margin-top: 4px; }
.acc__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.acc ul .acc__row { padding-left: 14px; border-top: 1px solid var(--line); }
.acc__acts { margin-left: auto; display: inline-flex; gap: 6px; }
.acc--off { opacity: .5; }

/* ---------- Anexos ---------- */
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.files li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; border-radius: 4px; border: 1px solid var(--line); }
.files li > a { font-weight: 500; word-break: break-all; }
.files li form { margin-left: auto !important; }
.toolbar input[type=file] { min-width: 0; flex: 1 1 220px; padding: 5px; }

/* ---------- Login ---------- */
.auth { padding: 10vh 0; }
.auth__brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.auth__brand svg { width: 30px; height: 24px; color: var(--gold); }
.auth__brand span { color: var(--ink-soft); font-weight: 400; }
.auth h1 { margin-bottom: 6px; }
.auth .card { margin-top: 16px; }

/* ---------- Linha do tempo ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 10px 18px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-mute); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 17px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline small { display: block; color: var(--ink-mute); font-size: 12px; }

/* ---------- Responsivo (celular na fábrica) ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .side { transform: translateX(-100%); transition: transform .2s; width: 250px; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .side .brand { padding-left: 50px; }   /* o botão ☰ fica por cima do canto do menu */
  .menu-toggle {
    display: grid; place-items: center; position: fixed; top: 8px; left: 8px; z-index: 60;
    width: 40px; height: 40px; border-radius: var(--radius); border: 0; background: var(--ink); color: #fff; font-size: 20px;
  }
  .main { margin-left: 0; padding-top: 58px; }
  .main--full { padding-top: 24px; }
  .grid2 { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 10px; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 140px; }
  .table .hide-sm { display: none; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; }
  input, select, textarea, .btn { min-height: 38px; }   /* dedo na fábrica */
  .btn--sm { min-height: 32px; }
}

.crown-ico { width: 1.05em; height: .84em; color: var(--gold); vertical-align: -.06em; }


/* ===== Os 3 módulos ===== */
/* cada módulo tem uma cor só de marcação (quadradinho e filete), nunca de fundo */
:root { --crm: #3b82f6; --dre: #d4a106; --pcp: #a1a1aa; }
/* menu lateral agrupado */
.navmod { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 1px; }
.side nav .navmod__h { font-size: 11.5px; color: rgba(255,255,255,.5); padding: 6px 10px; gap: 8px; }
.navmod__h i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.navmod__h b { color: rgba(255,255,255,.9); font-weight: 650; }
.navmod--crm .navmod__h i { background: var(--crm); }
.navmod--dre .navmod__h i { background: var(--dre); }
.navmod--pcp .navmod__h i { background: var(--pcp); }
.side nav .navmod a:not(.navmod__h) { padding: 5px 10px 5px 16px; font-size: 13px; }
.side nav .navmod a:not(.navmod__h) svg { width: 15px; height: 15px; }
.side nav a, .side nav .navmod { flex: none; }
/* só o módulo da tela atual fica aberto; os outros mostram só o título (a setinha abre/fecha) */
.navmod { position: relative; }
.side nav .navmod__h { padding-right: 36px; }
.navmod:not(.open) > a:not(.navmod__h) { display: none; }
.navmod__t { position: absolute; right: 2px; top: 5px; width: 26px; height: 26px; border: 0; border-radius: 4px; background: transparent; color: rgba(255,255,255,.5);
  font-size: 13px; line-height: 1; cursor: pointer; transform: rotate(-90deg); }
.navmod.open > .navmod__t { transform: none; }
.navmod__t:hover { background: rgba(255,255,255,.08); color: #fff; }
.navmod.is-on .navmod__h { color: rgba(255,255,255,.8); }
/* faixa do módulo no topo de cada tela: abas simples, a ativa sublinhada */
.modbar { display: flex; align-items: stretch; gap: 16px; flex-wrap: nowrap; margin: -20px calc(-1 * clamp(14px, 2.4vw, 32px)) 18px; padding: 0 clamp(14px, 2.4vw, 32px); background: #fff; border-bottom: 1px solid var(--line); }
.modbar__name { color: var(--ink); text-decoration: none !important; font-weight: 500; font-size: 13px; display: flex; align-items: center; gap: 6px; white-space: nowrap; padding: 10px 0; }
.modbar__name::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--pcp); }
.modbar--crm .modbar__name::before { background: var(--crm); }
.modbar--dre .modbar__name::before { background: var(--dre); }
.modbar__name b { font-weight: 700; }
.modbar__tabs { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1; }
.modbar__tabs::-webkit-scrollbar { display: none; }
.modbar__tabs a { white-space: nowrap; }
.modbar__tabs a { color: var(--ink-soft); text-decoration: none; font-size: 13px; padding: 10px 10px 8px; border-bottom: 2px solid transparent; }
.modbar__tabs a:hover { color: var(--ink); background: var(--hover); }
.modbar__tabs a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
@media (max-width: 820px) {   /* no celular a faixa do módulo vira a barra do topo, ao lado do ☰; as abas rolam para o lado */
  .modbar { margin-top: -58px; margin-bottom: 14px; padding-left: 56px; min-height: 56px; gap: 10px; }
  .modbar__name { font-size: 0; gap: 0; } .modbar__name::before { margin-right: 6px; } .modbar__name b { font-size: 13px; }
}
/* tela inicial: três colunas de trabalho */
.mods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.mod { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--pcp); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.mod--crm { border-top-color: var(--crm); }
.mod--dre { border-top-color: var(--dre); }
.mod__head { display: flex; align-items: baseline; gap: 8px; color: var(--ink); text-decoration: none !important; }
.mod__tag { font-size: 15px; font-weight: 700; }
.mod__name { font-size: 13px; color: var(--ink-soft); }
.mod__go { margin-left: auto; font-size: 12.5px; color: var(--blue); white-space: nowrap; }
.mod__head:hover .mod__go { text-decoration: underline; }
.mod__kpi strong { display: block; font-size: 26px; font-weight: 650; line-height: 1.15; letter-spacing: -.01em; }
.mod__kpi span { font-size: 12.5px; color: var(--ink-soft); }
.mod__stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 4px; }
.mod__stats span { padding: 6px 8px; font-size: 11.5px; line-height: 1.3; color: var(--ink-soft); border-right: 1px solid var(--line); }
.mod__stats span:last-child { border-right: 0; }
.mod__stats b { display: block; font-size: 15px; color: var(--ink); font-weight: 650; }
.mod__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.mod__list a { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); text-decoration: none; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.mod__list a:hover { background: var(--hover); }
.mod__list .badge { flex: none; margin-top: 1px; }
.mod__list span { min-width: 0; }
.mod__list strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod__list small { display: block; font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod__more { font-size: 12.5px; }
.mod__empty { margin: 0; padding: 14px; text-align: center; color: var(--ink-mute); border: 1px dashed var(--line-2); border-radius: 4px; }
.mod__actions { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.btn--light { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn--light:hover { background: var(--hover); }
.mods__flow { margin: 12px 2px 0; font-size: 12.5px; color: var(--ink-mute); }
@media (max-width: 1100px) { .mods { grid-template-columns: 1fr; } }

.type-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.type-row .btn { min-width: 30px; }

/* PCP: capacidade, compras, fornecedores */
.cap { display: flex; flex-direction: column; gap: 8px; }
.cap__row { display: grid; grid-template-columns: 70px 1fr; gap: 4px 10px; align-items: center; }
.cap__wk strong { display: block; font-size: 13.5px; }
.cap__wk small { color: var(--ink-mute); font-size: 12px; }
.cap__bar { position: relative; height: 24px; background: #ececee; border-radius: 3px; overflow: hidden; }
.cap__fill { position: absolute; inset: 0 auto 0 0; }
.cap__fill--ok { background: #b7e2c6; } .cap__fill--full { background: #f3d77f; } .cap__fill--over { background: #f0a9a9; }
.cap__bar span { position: relative; z-index: 1; display: block; padding: 3px 8px; font-size: 12.5px; font-weight: 600; }
.cap__orders { grid-column: 2; display: flex; gap: 4px; flex-wrap: wrap; }
.cap__orders a { font-size: 12px; background: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 0 7px; text-decoration: none; color: var(--ink); }
.sim { background: var(--sub); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; line-height: 1.5; }
.sim .big { font-size: 18px; font-weight: 650; }
.sim small { display: block; margin-top: 4px; }
.cap-hint { background: var(--green-bg); border: 1px solid var(--green-line); border-radius: var(--radius); padding: 9px 12px; margin-bottom: 12px; }
.cap-hint--off { background: var(--sub); border-color: var(--line); }
.stars { color: #d49b00; letter-spacing: 1px; }
.stars span { color: var(--line-2); }
.buy { position: relative; }
.buy summary { list-style: none; cursor: pointer; }
.buy summary::-webkit-details-marker { display: none; }
.buy__form { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 10px; width: 230px; display: flex; flex-direction: column; gap: 8px; text-align: left; }

/* DRE: gráficos de barras, DRE comparativo, fluxo, sócios */
.head__actions select, .head__actions input[type="month"], .head__actions input[type="number"] { width: auto; }
form.head__actions { flex-wrap: wrap; }
.row-bad td { background: var(--red-bg); }
.bars { display: flex; gap: 8px; align-items: stretch; height: 200px; padding-top: 4px; overflow-x: auto; }
.bars__col { flex: 1; min-width: 60px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bars__v { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.bars__track { flex: 1; width: 60%; display: flex; align-items: flex-end; border-bottom: 1px solid var(--line-2); }
.bars__track i { display: block; width: 100%; border-radius: 2px 2px 0 0; }
.bars__pos { background: var(--green); }
.bars__neg { background: var(--red); }
.bars__col small { font-size: 12px; color: var(--ink-mute); }
.dre-table td small { display: block; font-size: 11.5px; }
.dre-table .dre-sub td { font-weight: 650; background: var(--sub); }
.dre-table .dre-ded td:first-child { padding-left: 22px; color: var(--ink-soft); }
.dre-table .dre-main td { background: #f1f1f3; font-size: 15px; font-weight: 650; border-top: 1px solid var(--ink); }
.fx-det { margin-top: 4px; font-size: 13px; }
.fx-det ul { margin: 4px 0 0; padding-left: 18px; }
.fx-det li { margin: 2px 0; }
.kpi.partner ul { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.kpi.partner li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-top: 1px solid var(--line); }

/* CRM: funil, eventos, menu de WhatsApp */
.funnel .col { min-height: 260px; }
.funnel__sum { margin: -2px 2px 8px; font-weight: 650; font-size: 13.5px; }
.funnel .col--ganho { background: var(--green-bg); }
.funnel .col--perdido { background: var(--red-bg); }
.funnel .op small .badge { vertical-align: middle; }
.wa-menu { position: relative; }
.wa-menu summary { list-style: none; cursor: pointer; }
.wa-menu summary::-webkit-details-marker { display: none; }
.wa-menu__list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; min-width: 260px; display: flex; flex-direction: column; }
.wa-menu__list a { padding: 7px 10px; border-radius: 4px; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.wa-menu__list a:hover { background: var(--hover); }
.wa-menu__edit { border-top: 1px solid var(--line); margin-top: 4px; color: var(--ink-soft) !important; font-size: 12.5px !important; }
.ev-form { display: grid; grid-template-columns: 1.4fr 1fr auto auto; gap: 8px; align-items: end; }
.ev-form .check { margin-bottom: 8px; }
@media (max-width: 700px) { .ev-form { grid-template-columns: 1fr 1fr; } }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; }

/* leads e retornos */
.lead { display: inline-block; font-family: var(--body); font-size: 12px; font-weight: 500; padding: 1px 7px; border-radius: 4px; vertical-align: middle; white-space: nowrap; border: 1px solid transparent; }
.lead--quente { background: #fdeee6; color: #b4400a; border-color: #f5cdb6; }
.lead--frio { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-line); }
h1 .lead { font-size: 12px; }
.lead-switch { display: flex; gap: 6px; margin-top: 6px; }
.lead-switch__b { border: 1px solid currentColor; background: #fff; border-radius: 4px; padding: 3px 10px; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; opacity: .55; }
.lead-switch__b:hover { opacity: .9; }
.lead-switch__b.on { opacity: 1; }
.lead-switch__b.lead--quente.on { background: #fdeee6; }
.lead-switch__b.lead--frio.on { background: var(--blue-bg); }
.side nav a .nav__n { margin-left: auto; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; }
.contact-card { margin-bottom: 12px; border-left: 3px solid var(--line-2); }
.contact-card--due { border-left-color: var(--red); }
.contact-card__head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.contact-form__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.contact-form__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.due-alert { display: inline-block; background: var(--red-bg); color: var(--red); border: 1px solid var(--red-line); font-weight: 500; padding: 6px 12px; border-radius: var(--radius); text-decoration: none; }

/* fluxo de produção */
.flow-row { display: grid; grid-template-columns: 26px 1fr 230px auto; gap: 8px; align-items: center; padding: 6px 0 4px; border-bottom: 1px solid var(--line); }
.flow-row__n { width: 22px; height: 22px; border-radius: 50%; background: #ececee; color: var(--ink); font-size: 12px; font-weight: 650; display: grid; place-items: center; }
.flow-row__btns { display: flex; gap: 4px; }
.flow-row__btns .btn { min-width: 30px; height: 30px; padding: 0 8px; font-size: 14px; }
.flow-row__count { grid-column: 2 / -1; font-size: 12px; }
.flow-new { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 10px 12px; margin-top: 12px; }
.flow-new legend { font-weight: 650; font-size: 13px; padding: 0 6px; }
@media (max-width: 640px) { .flow-row { grid-template-columns: 26px 1fr; } .flow-row select, .flow-row__btns { grid-column: 2; } }

/* abas do pedido */
.ptabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line-2); margin: 14px 0 14px; }
.ptabs button { background: none; border: 0; padding: 8px 12px; font: inherit; font-size: 13.5px; color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; }
.ptabs button:hover { color: var(--ink); background: var(--hover); }
.ptabs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.ptabs__n { background: #ececee; color: var(--ink-soft); border-radius: 9px; padding: 0 6px; font-size: 11px; font-weight: 600; }
.ppanel { display: none; max-width: 920px; }
.ppanel.on { display: block; }
.ppanel > .card + .card, .ppanel > form + form { margin-top: 12px; }

@media print {
  .ppanel { display: none !important; }
  .ppanel[data-panel="op"], .ppanel[data-panel="checklist"] { display: block !important; max-width: none; }
  .side, .menu-toggle, .modbar, .head__actions, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; }
  .card, .kpi { border-color: #999; }
}
