/* Pharmetria Nutri — mesmo visual do Painel de Gestão (DM Sans, faixa de KPIs, cartões e tabelas),
   com a cor verde para não confundir com o painel da farmácia. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f4f1; --surface: #fff; --surface2: #eeecea;
  --border: rgba(0,0,0,0.08); --border2: rgba(0,0,0,0.14);
  --text: #1a1917; --text2: #6b6a66; --text3: #a09f9b;
  --green: #0f6e56; --green-bg: #e1f5ee;
  --amber: #854f0b; --amber-bg: #faeeda;
  --red: #a32d2d; --red-bg: #fcebeb;
  --blue: #185fa5; --blue-bg: #e6f1fb;
  --marca: #0f6e56; --marca-hover: #0b5947; --side: #10231d; --side2: #1a3a30;
}
html, body { height: 100%; }
body { font-family: 'DM Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 13px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
.mono, .num { font-family: 'DM Mono', ui-monospace, monospace; }
.oculto { display: none !important; }

/* ── login ─────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: var(--surface); border: .5px solid var(--border2); border-radius: 14px; padding: 30px 28px; width: 100%; max-width: 360px; }
.login-box h1 { font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.login-box .sub { color: var(--text2); font-size: 12px; margin: 4px 0 20px; }
.login-box label { display: block; font-size: 11px; color: var(--text2); margin: 12px 0 4px; font-weight: 600; }
.login-box input { width: 100%; padding: 9px 11px; border: .5px solid var(--border2); border-radius: 8px; background: var(--bg); font-size: 14px; }
.login-box .btn { width: 100%; margin-top: 18px; padding: 10px; font-size: 14px; }
.marca-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--marca); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; margin-bottom: 14px; }

/* ── estrutura ─────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.side { width: 212px; flex-shrink: 0; background: var(--side); color: #cfe0d9; padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 16px; color: #fff; }
.side .brand .marca-ico { width: 30px; height: 30px; font-size: 14px; margin: 0; border-radius: 8px; background: #1d9e75; }
.side .brand b { display: block; font-size: 13.5px; line-height: 1.15; }
.side .brand span { display: block; font-size: 10.5px; color: #8fb3a6; }
.side .grupo { font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em; color: #6f9688; padding: 12px 10px 4px; font-weight: 700; }
.side a { display: flex; align-items: center; gap: 9px; color: #cfe0d9; padding: 7px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 500; }
.side a:hover { background: var(--side2); color: #fff; }
.side a.on { background: #1d9e75; color: #fff; font-weight: 600; }
.side a .ic { width: 16px; text-align: center; font-size: 13px; }
.main { flex: 1; min-width: 0; padding: 12px 20px 40px; }
.topo-mob { display: none; }

header.hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.hd-logo { font-size: 18px; font-weight: 700; }
.hd-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.hd-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── controles ─────────────────────────────────────────── */
.btn { background: var(--marca); border: none; color: #fff; border-radius: 6px; padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--marca-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.azul { background: var(--blue); } .btn.azul:hover { background: #12508a; }
.btn.verm { background: var(--red); } .btn.verm:hover { background: #8a2424; }
.btn-ghost { background: var(--surface); border: .5px solid var(--border2); color: var(--text2); border-radius: 6px; padding: 5px 12px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-mini { padding: 2px 8px; font-size: 11px; }
.btn-lg { padding: 9px 18px; font-size: 13.5px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { background: var(--surface); border: .5px solid var(--border2); border-radius: 99px; padding: 4px 12px; font-size: 11.5px; color: var(--text2); cursor: pointer; }
.chip:hover { border-color: var(--marca); color: var(--marca); }
.chip.on { background: var(--marca); border-color: var(--marca); color: #fff; font-weight: 600; }
.date-inputs { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); flex-wrap: wrap; }
input.campo, select.campo, textarea.campo, .date-inputs input, .date-inputs select {
  background: var(--surface); border: .5px solid var(--border2); border-radius: 6px; padding: 5px 9px; font-size: 12.5px; }
input.campo:focus, select.campo:focus, textarea.campo:focus { outline: 2px solid rgba(15,110,86,.25); border-color: var(--marca); }
.busca { background: var(--bg); border: .5px solid var(--border2); border-radius: 6px; padding: 5px 10px; font-size: 12px; min-width: 190px; }

/* ── KPIs ─────────────────────────────────────────────── */
.kpis { display: flex; flex-wrap: wrap; margin-bottom: 10px; background: var(--surface); border: .5px solid var(--border2); border-radius: 9px; padding: 7px 2px; }
.kpi { flex: 1 1 130px; padding: 1px 13px; border-left: .5px solid var(--border); min-width: 0; }
.kpi:first-child { border-left: none; }
.kpi .lb { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .vl { font-size: 17px; font-weight: 700; font-family: 'DM Mono', monospace; margin-top: 1px; letter-spacing: -.4px; white-space: nowrap; }
.kpi .ft { font-size: 9.5px; color: var(--text3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.ap .vl { color: var(--green); } .kpi.rj .vl { color: var(--red); } .kpi.az .vl { color: var(--blue); } .kpi.am .vl { color: var(--amber); }
.kpi.clica { cursor: pointer; } .kpi.clica:hover .lb { color: var(--marca); }

/* ── cartões e tabelas ─────────────────────────────────── */
.card { background: var(--surface); border: .5px solid var(--border2); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.card-hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 13px; border-bottom: .5px solid var(--border2); flex-wrap: wrap; }
.card-hd h2 { font-size: 12.5px; font-weight: 700; }
.card-hd .sub { font-size: 10px; color: var(--text3); }
.card-bd { padding: 12px 13px; }
.grade { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grade > .card { margin-bottom: 0; }
.tb-wrap { overflow: auto; max-height: calc(100vh - 230px); }
.tb-wrap.livre { max-height: none; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th { position: sticky; top: 0; z-index: 2; background: var(--surface2); text-align: right; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text2); padding: 8px 10px; font-weight: 600; white-space: nowrap; border-bottom: .5px solid var(--border2); }
thead th.l { text-align: left; } thead th.c { text-align: center; }
thead th.sort { cursor: pointer; user-select: none; } thead th.sort:hover { color: var(--marca); }
tbody td { padding: 7px 10px; text-align: right; border-bottom: .5px solid var(--border); font-family: 'DM Mono', monospace; white-space: nowrap; }
tbody td.l { text-align: left; font-family: 'DM Sans', sans-serif; } tbody td.c { text-align: center; }
tbody td.b { font-weight: 600; } tbody td.wrap { white-space: normal; min-width: 160px; }
tbody tr.clica { cursor: pointer; }
tbody tr:hover td { background: #faf9f7; }
tfoot td { background: var(--surface2); font-weight: 700; padding: 7px 10px; text-align: right; font-family: 'DM Mono', monospace; border-top: .5px solid var(--border2); white-space: nowrap; }
tfoot td.l { text-align: left; font-family: 'DM Sans', sans-serif; }
.vazio { text-align: center !important; color: var(--text3); padding: 26px !important; font-family: 'DM Sans', sans-serif !important; white-space: normal !important; }
.pill { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 11px; font-weight: 700; font-family: 'DM Sans', sans-serif; }
.pill.g { background: var(--green-bg); color: var(--green); } .pill.a { background: var(--amber-bg); color: var(--amber); }
.pill.r { background: var(--red-bg); color: var(--red); } .pill.b { background: var(--blue-bg); color: var(--blue); }
.pill.n { background: var(--surface2); color: var(--text2); }
.muted { color: var(--text3); } .txt2 { color: var(--text2); } .verde { color: var(--green); } .vermelho { color: var(--red); }
.barra { height: 6px; background: var(--surface2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.barra > i { display: block; height: 100%; background: var(--marca); border-radius: 99px; }

.aviso { padding: 9px 13px; border-radius: 8px; margin-bottom: 10px; font-size: 12.5px; }
.aviso.r { background: var(--red-bg); color: var(--red); } .aviso.a { background: var(--amber-bg); color: var(--amber); }
.aviso.g { background: var(--green-bg); color: var(--green); } .aviso.b { background: var(--blue-bg); color: var(--blue); }

/* ── formulários ───────────────────────────────────────── */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px; }
.form .f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form .f.w2 { grid-column: span 2; } .form .f.wt { grid-column: 1 / -1; }
.form label, .rot { font-size: 10.5px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.form .campo { width: 100%; }
.form .chk { flex-direction: row; align-items: center; gap: 7px; padding-top: 18px; }
.obrig::after { content: ' *'; color: var(--red); }

/* ── autocompletar ─────────────────────────────────────── */
.ac { position: relative; }
.ac .lista { position: absolute; left: 0; right: 0; top: 100%; margin-top: 2px; background: var(--surface); border: .5px solid var(--border2); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 50; max-height: 280px; overflow-y: auto; }
.ac .lista div { padding: 7px 10px; cursor: pointer; border-bottom: .5px solid var(--border); }
.ac .lista div:last-child { border-bottom: none; }
.ac .lista div:hover, .ac .lista div.sel { background: var(--green-bg); }
.ac .lista small { color: var(--text3); display: block; font-size: 10.5px; }
.escolhido { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border: .5px solid var(--marca); background: var(--green-bg);
  border-radius: 6px; min-height: 31px; }
.escolhido b { font-size: 12.5px; } .escolhido small { color: var(--text2); font-size: 10.5px; display: block; }
.escolhido .x { background: none; border: none; cursor: pointer; color: var(--text2); font-size: 16px; line-height: 1; }

/* ── editor de venda/orçamento ─────────────────────────── */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 10px; align-items: start; }
.totais { position: sticky; top: 12px; }
.totais .linha { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12.5px; }
.totais .linha.total { border-top: .5px solid var(--border2); margin-top: 6px; padding-top: 10px; font-size: 20px; font-weight: 700; }
.totais .linha span:last-child { font-family: 'DM Mono', monospace; }
.itens input.campo { width: 82px; text-align: right; font-family: 'DM Mono', monospace; padding: 4px 6px; }
.itens td { vertical-align: middle; }
.pag-linha { display: grid; grid-template-columns: 1fr 110px 70px 26px; gap: 6px; margin-bottom: 6px; align-items: center; }
.atalhos { display: flex; gap: 5px; flex-wrap: wrap; margin: 4px 0 10px; }

/* ── modal ─────────────────────────────────────────────── */
.fundo { position: fixed; inset: 0; background: rgba(20,24,22,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 14px 20px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.largo { max-width: 860px; }
.modal-hd { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: .5px solid var(--border2); }
.modal-hd h3 { font-size: 14px; }
.modal-hd .x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text2); }
.modal-bd { padding: 14px 16px; }
.modal-ft { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: .5px solid var(--border2); background: #fbfaf8; border-radius: 0 0 12px 12px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1a1917; color: #fff; padding: 9px 16px; border-radius: 8px; z-index: 200; font-size: 12.5px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.erro { background: var(--red); }
.carregando { padding: 30px; text-align: center; color: var(--text3); }

/* ── gráfico simples ───────────────────────────────────── */
.graf { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding: 10px 4px 0; }
.graf .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.graf .col i { display: block; width: 100%; max-width: 26px; background: var(--marca); border-radius: 3px 3px 0 0; }
.graf .col:hover i { background: #1d9e75; }
.graf .col span { font-size: 9px; color: var(--text3); margin-top: 3px; font-family: 'DM Mono', monospace; }

/* ── documento (impressão: orçamento, comprovante, relatório do prescritor) ── */
.doc { background: #fff; max-width: 820px; margin: 0 auto; padding: 28px 32px; border: .5px solid var(--border2); border-radius: 10px; color: #1a1917; }
.doc .doc-topo { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--marca); padding-bottom: 12px; margin-bottom: 14px; }
.doc h1 { font-size: 18px; } .doc h2 { font-size: 13px; margin: 16px 0 6px; color: var(--marca); text-transform: uppercase; letter-spacing: .04em; }
.doc .info { font-size: 12px; color: #555; line-height: 1.5; }
.doc table { font-size: 12px; } .doc thead th { position: static; background: #f1f5f3; }
.doc .rodape { margin-top: 22px; font-size: 11px; color: #777; border-top: .5px solid #ddd; padding-top: 10px; }
.doc .assin { margin-top: 40px; display: flex; justify-content: space-around; gap: 20px; font-size: 11px; color: #555; text-align: center; }
.doc .assin div { border-top: .5px solid #999; padding-top: 4px; min-width: 200px; }
.doc-acoes { display: flex; gap: 8px; justify-content: center; margin: 0 auto 10px; flex-wrap: wrap; }

@media print {
  body { background: #fff; }
  .side, .topo-mob, .nao-imprime, header.hd, .doc-acoes, .toast { display: none !important; }
  .main { padding: 0; }
  .doc { border: none; padding: 0; max-width: none; }
}

@media (max-width: 900px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .totais { position: static; }
}
@media (max-width: 760px) {
  .app { display: block; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 90; transform: translateX(-100%); transition: transform .2s; width: 240px; }
  .side.aberto { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .topo-mob { display: flex; align-items: center; gap: 10px; background: var(--side); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 80; }
  .topo-mob button { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
  .main { padding: 10px 12px 40px; }
  .form { grid-template-columns: minmax(0, 1fr); }
  .form .f.w2 { grid-column: auto; }
  .itens input.campo { width: 64px; }
  .busca { min-width: 0; flex: 1; }
  .doc { padding: 18px 14px; }
  .pag-linha { grid-template-columns: 1fr 90px 56px 26px; }
}
