:root {
  --bg: #eef4fb; --text: #1b2b4b; --muted: #55627a; --navy: #1d3a78;
  --yes: #1f8f55; --no: #c0392b; --border: #c9d3e3;
}
* { box-sizing: border-box; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 19px/1.35 system-ui, "Segoe UI", sans-serif; }
main { max-width: 900px; margin: 0 auto; padding: 14px; }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
h2 { color: var(--navy); margin: 16px 0 8px; font-size: 1.3rem; }
svg { display: block; }

/* cabeçalho */
.head { display: flex; gap: 14px; align-items: center; background: #fff; border-radius: 18px; padding: 12px 18px; border: 2px solid #dbe6f5; }
.head .rx { width: 56px; flex: none; }
.head h1 { margin: 0; font-size: 2.3rem; letter-spacing: 1px; color: var(--navy); }
.head em { color: #c0392b; font-size: .85rem; }
.head aside { margin-left: auto; max-width: 240px; font-size: .85rem; color: var(--muted); border-left: 2px solid var(--border); padding-left: 14px; }
.head aside b { color: var(--navy); font-style: italic; display: block; }
.logo { width: 112px; height: 108px; object-fit: contain; object-view-box: inset(19% 24% 19% 25%); flex: none; } /* corta a margem branca da imagem: o brasão fica maior e mais nítido */
.fill { display: none; margin: 8px 4px; font-size: 1.05rem; justify-content: space-between; gap: 12px; }

/* controles */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.bar strong { flex: 1; text-align: center; text-transform: capitalize; font-size: 1.15rem; min-width: 180px; }
.btn { padding: 10px 16px; border-radius: 12px; border: 2px solid var(--navy); background: var(--navy); color: #fff; }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.danger { background: #fff; color: var(--no); border-color: var(--no); }
.btn.del { border-color: var(--no); background: #fff; color: var(--no); padding: 4px 10px; font-size: .8rem; margin-top: 8px; }

/* cartão de medicamento (receita ilustrada) */
.med { --c1: #e6f1ff; --c2: #a9d0ff; --c3: #1d4ed8; background: var(--c1); border: 2px solid var(--c2);
  border-radius: 18px; padding: 12px; margin-bottom: 14px; display: grid; gap: 10px;
  grid-template-columns: minmax(176px, 1.2fr) 3.2fr minmax(150px, 1fr); align-items: stretch; break-inside: avoid; }
.med.t1 { --c1: #e8f7ec; --c2: #a6dfb8; --c3: #17753f; }
.med.t2 { --c1: #efebfc; --c2: #c4b8f2; --c3: #5a3fc0; }
.med.t3 { --c1: #fff3e2; --c2: #f7cf9b; --c3: #b4620a; }
.med.t4 { --c1: #fdeaf0; --c2: #f4b4c9; --c3: #b0254f; }
.name { background: var(--c2); border-radius: 12px; padding: 10px 12px; }
.name h2 { margin: 0; font-size: 1.15rem; overflow-wrap: normal; hyphens: none; text-transform: uppercase; color: var(--c3); line-height: 1.1; }
.name h2.n2 { font-size: 1rem; } .name h2.n3 { font-size: .88rem; } .name h2.n4 { font-size: .76rem; }
.name .mg { font-size: 1.3rem; font-weight: 800; color: var(--c3); }
.info { margin: 10px 4px 0; font-size: .98rem; }
.slots { display: flex; background: #fff; border-radius: 14px; overflow: hidden; }
.slot { flex: 1; min-width: 100px; padding: 8px 6px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.slot + .slot { border-left: 2px solid var(--c2); }
.slot .badge { height: 24px; } .slot .badge svg { height: 24px; width: auto; }
.slot .when { font-size: .72rem; font-weight: 800; letter-spacing: .4px; color: var(--navy); }
.slot .art { height: 84px; display: flex; align-items: center; justify-content: center; }
.slot .art svg { height: 84px; width: auto; max-width: 100%; }
.slot .art img { height: 88px; width: 88px; object-fit: cover; clip-path: circle(50%); } /* o círculo corta os selos dos cantos das imagens */
.slot .pillart svg { width: 46px; height: auto; }
.slot .dose { font-size: .78rem; color: var(--muted); }
.slot.yes { background: #e9fbef; } .slot.no { background: #fdecea; }
.sumbox { background: #fff; border: 2px solid var(--c2); border-radius: 12px; padding: 8px 10px; font-size: .85rem; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.sumbox b { color: var(--navy); overflow-wrap: normal; hyphens: none; } .sumbox b.n2 { font-size: .8rem; } .sumbox b.n3 { font-size: .7rem; } .sumbox b.n4 { font-size: .62rem; } .sumbox em { color: var(--muted); }

.tips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; background: #dff0fb; border-radius: 18px; padding: 12px; font-size: .82rem; margin-top: 14px; }
.tips div { text-align: center; } .tips span { display: flex; justify-content: center; margin-bottom: 4px; } .tips svg { width: 34px; height: 34px; }
.summary { text-align: center; font-weight: 700; margin: 6px 0 14px; }
.empty { background: #fff; border-radius: 16px; padding: 26px; text-align: center; color: var(--muted); margin-bottom: 14px; }
.hello { font-size: 1.5rem; font-weight: 800; color: var(--navy); margin: 14px 4px 0; }

/* paciente: botões de marcação */
.check { display: flex; gap: 6px; margin-top: 6px; width: 100%; }
.check button { flex: 1; padding: 8px 4px; border-radius: 10px; border: 2px solid var(--border); background: #fff; font-size: .9rem; font-weight: 700; color: var(--muted); }
.check .y.on { background: var(--yes); border-color: var(--yes); color: #fff; }
.check .n.on { background: var(--no); border-color: var(--no); color: #fff; }

/* painel */
.card { background: #fff; border-radius: 16px; padding: 16px; display: grid; gap: 12px; margin-top: 16px; }
.plist { display: grid; gap: 10px; }
.pitem { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: #fff; border: 2px solid var(--border); border-radius: 14px; padding: 12px 16px; color: var(--text); }
.pitem b { font-size: 1.15rem; } .pitem small { color: var(--muted); }
.err { color: var(--no); font-weight: 700; min-height: 1.4em; }
form label { display: grid; gap: 4px; font-weight: 700; font-size: .95rem; }
.row { display: grid; grid-template-columns: 2fr 1fr 1.4fr; gap: 10px; }
input[type=text], input[type=password], select { font: inherit; padding: 10px; border: 2px solid var(--border); border-radius: 8px; width: 100%; background-color: #fff; color: inherit; }
select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%231d3a78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; }
.times { display: flex; flex-wrap: wrap; gap: 8px; }
.times label { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 2px solid var(--border); border-radius: 10px; }
.times input { width: 22px; height: 22px; }

/* folha mensal (só na impressão) */
.weekly { display: none; }
.c { display: inline-block; width: 17px; height: 17px; border: 1.5px solid #000; border-radius: 3px; background: #fff; vertical-align: middle; }
.wlegend { margin: 2px 2px 4px; font-size: .75rem; }
.wlegend .c { width: 14px; height: 14px; }
.mtable { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; }
.mtable + .mtable { margin-top: 8px; }
.mcap { margin: 0 0 4px; font-size: .8rem; font-weight: 700; }
.mtable th, .mtable td { border: 1px solid #000; padding: 1px; text-align: center; font-size: .75rem; line-height: 1.15; }
.mtable tr { break-inside: avoid; }
.mtable thead th { background: #e9eef7; font-size: .8rem; }
.mtable thead th:nth-child(1) { width: 180px; } .mtable thead th:nth-child(2) { width: 150px; }
.mtable small { font-weight: 400; font-size: .85em; }
.mtable .we { background: #eee; }
.mtable td { height: var(--rh, 27px); }
.mtable .mname { text-align: left; padding: 2px 6px; font-size: .8rem; font-weight: 400; }
.mtable .mslot { text-align: left; padding-left: 4px; font-size: .72rem; white-space: nowrap; }
.mpic { display: inline-block; vertical-align: middle; } .mpic svg { width: 30px; height: 21px; } .mpic img { width: 24px; height: 24px; object-fit: cover; clip-path: circle(50%); }
.mtable .mfirst th, .mtable .mfirst td { border-top: 2.5px solid #000; }
.m0 { background: #a9d0ff; } .m1 { background: #a6dfb8; } .m2 { background: #c4b8f2; } .m3 { background: #f7cf9b; } .m4 { background: #f4b4c9; }

@media (max-width: 700px) {
  body { font-size: 17px; }
  .med { grid-template-columns: 1fr; } .slots { flex-wrap: wrap; }
  .head aside { display: none; } .head h1 { font-size: 1.8rem; }
  .row { grid-template-columns: 1fr; } .tips { grid-template-columns: 1fr 1fr; }
}

/* ---------- impressão ---------- */
/* sem classe = receita ilustrada (retrato); body.print-month = folha mensal (paisagem) */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  @page month { size: A4 landscape; margin: 8mm; }
  body.print-month main { page: month; }
  body { background: #fff; font-size: 14px; }
  main { padding: 0; max-width: none; }
  .bar, form, .btn, .summary, .check, #login, #listView, .hello, .noprint { display: none !important; }
  .fill { display: flex; }

  .head { padding: 6px 14px; border-radius: 12px; }
  .head h1 { font-size: 1.9rem; } .head .rx { width: 46px; } .logo { width: 96px; height: 92px; }
  .med { margin-bottom: 9px; padding: 8px; gap: 8px; }
  .slot { min-width: 88px; padding: 4px; }
  .slot .art, .slot .art svg { height: 74px; } .slot .art img { width: 76px; height: 76px; }
  .tips { font-size: .72rem; padding: 8px; margin-top: 6px; } .tips svg { width: 26px; height: 26px; }

  body.print-month #list { display: none !important; }
  body.print-month .weekly { display: block; }
  body.print-month .tips { display: none; }
  .mpage + .mpage { break-before: page; }
  body.print-month .head { padding: 3px 10px; gap: 10px; border-radius: 10px; }
  body.print-month .head h1 { font-size: 1.4rem; } body.print-month .head .rx { width: 34px; }
  body.print-month .head em { font-size: .72rem; } body.print-month .head aside { font-size: .68rem; padding-left: 10px; }
  body.print-month .logo { width: 74px; height: 62px; }
  body.print-month .fill { margin: 3px 2px; font-size: .9rem; }
}
