:root{--icm:#c1272d;--icm-dark:#8f1820;--ink:#202124;--muted:#6f7175;--paper:#f7f7f5;--line:#dedede;--ok:#eaf5ec;--empty:#fff1f2}
*{box-sizing:border-box}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:var(--paper);color:var(--ink)}
.brand{background:#fff;border-bottom:4px solid var(--icm);text-align:center;padding:18px 14px 20px}
.brand-logo{width:min(230px,72vw);height:auto;display:block;margin:0 auto 10px}
.church-name{font-size:13px;font-weight:800;letter-spacing:.08em;color:var(--icm);margin-bottom:8px}
.brand h1{margin:0;font-size:25px;line-height:1.15;color:#262626}
.brand p{margin:7px 0 0;color:var(--muted)}
main{max-width:900px;margin:auto;padding:14px 12px 42px}
.info{background:#fff;border:1px solid var(--line);border-left:4px solid var(--icm);border-radius:12px;padding:12px 13px;margin-bottom:12px;font-size:14px}
.viewbar{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:12px;position:sticky;top:0;z-index:10;padding:8px 0;background:linear-gradient(var(--paper) 70%,transparent)}
.viewbtn{font:inherit;padding:10px;border-radius:10px;border:1px solid #cfcfcf;background:#fff;font-weight:800}
.viewbtn.active{background:var(--icm);color:#fff;border-color:var(--icm)}
.summary{display:flex;gap:7px;overflow:auto;margin-bottom:16px;padding-bottom:2px}
.pill{white-space:nowrap;background:#fff;border:1px solid var(--line);padding:7px 10px;border-radius:999px;font-size:13px}
.period{margin:22px 0}.period h2{font-size:18px;margin:0 0 9px;color:#333}
.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.slot{background:#fff;border:1px solid var(--line);border-radius:12px;padding:11px}
.slot.empty{background:var(--empty);border-color:#efc2c5}.time{font-weight:800}.people{min-height:40px;color:var(--muted);font-size:13px;margin:6px 0}
.join{width:100%;background:var(--icm);color:#fff;border:0;border-radius:8px;padding:9px;font-weight:800}
.join:active,.quickcell:active{transform:scale(.98)}
.daywrap{background:#fff;border:1px solid var(--line);border-radius:14px;padding:8px;overflow:hidden}
.daylegend{display:flex;gap:12px;align-items:center;flex-wrap:wrap;font-size:12px;color:var(--muted);padding:4px 4px 10px}
.legenddot{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:4px;vertical-align:-1px}.legenddot.full{background:#eef5ef;border:1px solid #b9d2bd}.legenddot.open{background:#fff0f1;border:1px solid #e4a9ae}
.daytable{display:grid;grid-template-columns:42px repeat(4,minmax(0,1fr));gap:4px;width:100%}
.dayhead,.hour{font-size:11px;font-weight:800;text-align:center;color:#656565;padding:6px 1px}
.hour{display:flex;align-items:center;justify-content:center}
.quickcell{min-width:0;height:45px;border-radius:8px;border:1px solid #c8dbc9;background:#eef5ef;padding:2px;color:#233926;font-weight:800;display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1}
.quickcell.empty{background:#fff0f1;border-color:#e2a8ad;color:var(--icm-dark)}
.quickcell .min{font-size:11px}.quickcell .count{font-size:13px;margin-top:3px}.quickcell .count small{font-weight:600;font-size:9px}
.quickcell:focus{outline:2px solid var(--icm);outline-offset:1px}
dialog{border:0;border-radius:16px;width:min(420px,calc(100% - 24px));padding:18px;box-shadow:0 20px 70px #0005}
dialog::backdrop{background:#0008}dialog form{display:grid;gap:10px}dialog h2{margin:0;color:var(--icm)}
label{font-weight:700;display:grid;gap:5px}input,select,button{font:inherit;padding:10px;border-radius:8px;border:1px solid #bfc1c3}
.actions{display:flex;gap:8px}.actions button{flex:1}.actions button:last-child{background:var(--icm);color:#fff;border:0}
#when{margin:0;color:var(--muted)}#msg{min-height:20px;margin:0;color:#a32222;font-size:14px}
@media(max-width:560px){
  .brand{padding-top:14px}.brand-logo{width:min(205px,68vw)}.brand h1{font-size:22px}
  .grid{grid-template-columns:1fr}.slot{padding:10px}.people{min-height:30px}
  main{padding-left:9px;padding-right:9px}.daywrap{padding:6px}.daytable{grid-template-columns:38px repeat(4,minmax(0,1fr));gap:3px}.quickcell{height:42px}
}

.currentpeople{background:#f8f8f8;border:1px solid #e2e2e2;border-radius:9px;padding:8px 10px;font-size:13px;color:#555}.currentpeople:empty{display:none}.currentpeople b{color:#222}.quickhint{font-size:11px;color:#777;text-align:center;margin:8px 0 2px}

.period-label{display:inline-block;margin-top:8px;padding:5px 10px;border-radius:999px;background:#fff3f4;color:var(--icm-dark);font-size:13px;font-weight:800;border:1px solid #efc8cb}
.viewbar{grid-template-columns:1fr 1fr}
.printbtn{grid-column:1/-1;font:inherit;padding:10px;border-radius:10px;border:1px solid var(--icm);background:#fff;color:var(--icm);font-weight:800}
.printbtn:active{background:#fff3f4}
.print-only{position:fixed;left:-10000px;top:0;width:794px;height:1123px;display:block;pointer-events:none;z-index:-1}

@media print{
  @page{size:A4 landscape;margin:7mm}
  html,body{background:#fff!important}
  body>header,main>.info,main>.viewbar,main>#summary,main>#app,dialog{display:none!important}
  main{max-width:none!important;margin:0!important;padding:0!important}
  #printSheet{display:block!important}
  .print-header{display:flex;align-items:center;gap:12mm;border-bottom:2px solid #c1272d;padding-bottom:4mm;margin-bottom:4mm}
  .print-header img{width:48mm;height:auto}
  .print-header h1{font-size:15pt;margin:1mm 0;color:#222}
  .print-header p{margin:0;font-size:9pt;color:#555}
  .print-church{font-size:9pt;font-weight:800;letter-spacing:.08em;color:#c1272d}
  .print-table{width:100%;border-collapse:collapse;table-layout:fixed;font-size:7.2pt;line-height:1.15}
  .print-table thead{display:table-header-group}
  .print-table tr{break-inside:avoid;page-break-inside:avoid}
  .print-table th,.print-table td{border:.3mm solid #bcbcbc;vertical-align:top;padding:1.2mm}
  .print-table thead th{background:#c1272d!important;color:#fff!important;text-align:center;font-size:8pt;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .print-table th:first-child{width:11mm;text-align:center;vertical-align:middle}
  .print-table tbody th{background:#f1f1f1!important;font-size:8pt;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .print-slot-time{font-weight:800;font-size:6.8pt;color:#8f1820;margin-bottom:.8mm}
  .print-person{margin:.35mm 0;white-space:normal;overflow-wrap:anywhere}
  .print-empty{color:#999;font-style:italic}
}

/* PDF A4 retrato — geração por canvas */
.printbtn:disabled{opacity:.65;cursor:wait}
.pdf-page{width:794px;height:1123px;background:#fff;color:#222;padding:27px;overflow:hidden;font-family:Arial,Helvetica,sans-serif}
.pdf-header{display:flex;align-items:center;gap:24px;border-bottom:4px solid #c1272d;padding-bottom:11px;margin-bottom:9px}
.pdf-header img{width:182px;height:auto;display:block}
.pdf-header h1{font-size:22px;line-height:1.05;margin:3px 0 4px;color:#222}
.pdf-header p{font-size:11px;color:#666;margin:0}
.pdf-church{font-size:10px;font-weight:800;letter-spacing:.08em;color:#c1272d}
.pdf-summary{display:flex;gap:8px;margin:0 0 8px}
.pdf-summary span{font-size:9px;border:1px solid #ddd;border-radius:999px;padding:4px 7px;background:#f7f7f7}
.pdf-table{width:100%;border-collapse:separate;border-spacing:3px;table-layout:fixed}
.pdf-table thead th{background:#c1272d;color:#fff;font-size:9px;padding:4px 2px;text-align:center}
.pdf-table thead th:first-child{width:34px}
.pdf-table tbody th{width:34px;background:#f1f1f1;color:#555;border:1px solid #ddd;font-size:8px;text-align:center;vertical-align:middle;padding:2px}
.pdf-table td{vertical-align:top;background:#f5faf6;border:1px solid #d5e2d7;border-radius:5px;padding:3px 4px}
.pdf-table td.empty{background:#fff0f1;border-color:#e6b8bc}
.pdf-slot-time{font-size:6.4px;line-height:1;color:#8f1820;font-weight:800;margin-bottom:2px}
.pdf-people{font-size:6.8px;line-height:1.02}
.pdf-people.compact{font-size:6px;line-height:1}
.pdf-people.dense{font-size:5.2px;line-height:.98;columns:2;column-gap:5px}
.pdf-person{break-inside:avoid;white-space:normal;overflow-wrap:anywhere;padding:.25px 0;border-bottom:.5px dotted #e5e5e5}
.pdf-person:last-child{border-bottom:0}
.pdf-person span{font-size:.88em;color:#666;font-weight:700}
.pdf-empty{font-size:5.8px;line-height:1;color:#9c3b42;font-weight:800}
.pdf-footer{text-align:center;color:#999;font-size:7px;margin-top:5px}
