:root {
  --primary: #c1272d;      /* vermelho da logo Igreja Cristã Maranata */
  --primary-2: #a11f24;
  --primary-soft: #fbeceb;
  --blue: #2f6db5;         /* azul — status "agendada" */
  --blue-soft: #e6eef8;
  --sky: #7ab3d9;
  --green: #5a9e3a;        /* verde dos rótulos */
  --green-soft: #e8f3e1;
  --orange: #f0932b;       /* destaque (estrela) */
  --orange-soft: #fdf0e1;
  --red: #c94a3a;
  --red-soft: #fbe9e6;
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #22303f;
  --muted: #66768a;
  --line: #dde3ea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 70, .06), 0 2px 8px rgba(20, 40, 70, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; color: var(--primary); }
h2 { font-size: 1.1rem; color: var(--primary); }
h3 { font-size: 1rem; }
.splash { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.offline { position: sticky; top: 0; z-index: 50; background: var(--orange); color: #fff; padding: 6px 12px; text-align: center; font-size: .85rem; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: #fff; color: var(--text); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.brand img { width: 100%; max-height: 60px; object-fit: contain; display: block; margin-bottom: 10px; }
.brand b { display: block; font-size: .95rem; color: var(--primary); }
.brand span { font-size: .75rem; color: var(--muted); }
.nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; flex: 1; }
.nav a { color: var(--text); padding: 10px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav svg { width: 20px; height: 20px; flex-shrink: 0; }
.side-user { padding: 12px 16px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.side-user b { color: var(--text); }
.side-user b { display: block; }
main { flex: 1; min-width: 0; padding: 24px; max-width: 1200px; }
.topbar { display: none; }
.tabbar { display: none; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  main { padding: 16px 16px 90px; }
  .topbar { display: flex; align-items: center; gap: 10px; background: #fff; color: var(--primary); border-bottom: 3px solid var(--primary); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 20; }
  .topbar img { height: 30px; max-width: 45%; object-fit: contain; }
  .topbar b { font-size: .85rem; flex: 1; text-align: right; color: var(--muted); font-weight: 600; }
  .layout { flex-direction: column; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: .7rem; color: var(--muted); }
  .tabbar a.active { color: var(--primary); font-weight: 600; }
  .tabbar svg { width: 22px; height: 22px; }
}

/* Componentes */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-head p { margin: 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; border: 1px solid #e8edf3; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpi { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.kpi .v { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.kpi .l { font-size: .8rem; color: var(--muted); }
.kpi.green { border-left-color: var(--green); } .kpi.green .v { color: var(--green); }
.kpi.orange { border-left-color: var(--orange); } .kpi.orange .v { color: #c76f12; }
.kpi.sky { border-left-color: var(--blue); } .kpi.sky .v { color: var(--blue); }
.kpi.gray { border-left-color: #a7b1bd; } .kpi.gray .v { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--primary); color: #fff; min-height: 40px; }
.btn:hover { background: var(--primary-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--primary); border-color: var(--line); }
.btn.secondary:hover { background: var(--primary-soft); }
.btn.green { background: var(--green); } .btn.green:hover { background: #4b8a2f; }
.btn.orange { background: var(--orange); } .btn.orange:hover { background: #dc8020; }
.btn.danger { background: #fff; color: var(--red); border-color: #efc9c3; } .btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

label { display: block; font-size: .85rem; font-weight: 600; color: var(--green); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #ecb3b5; border-color: var(--primary); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); }
.check input { width: auto; min-height: 0; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.error { color: var(--red); background: var(--red-soft); padding: 8px 10px; border-radius: 8px; margin-top: 10px; font-size: .9rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: #3d7424; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.brand { background: var(--primary-soft); color: var(--primary); }
.badge.orange { background: var(--orange-soft); color: #a85c0c; }
.badge.gray { background: #edf0f4; color: var(--muted); }
.badge.red { background: var(--red-soft); color: var(--red); }

.progress { height: 10px; background: #e9eef4; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--green), #7cbf5a); border-radius: 99px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 2px solid var(--line); background: #f7f9fb; }
td { padding: 9px 8px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #eef1f5; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
a.list-item { color: inherit; }
a.list-item:hover .title { color: var(--primary-2); }

.date-chip { width: 52px; text-align: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); padding: 5px 0; flex-shrink: 0; }
.date-chip b { display: block; font-size: 1.2rem; line-height: 1; }
.date-chip span { font-size: .68rem; text-transform: uppercase; }
.date-chip.past { background: #edf0f4; color: var(--muted); }

.slot { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 8px; background: #fff; flex-wrap: wrap; }
.slot .time { font-weight: 700; color: var(--primary); width: 100px; flex-shrink: 0; }
.slot .info { flex: 1; min-width: 160px; }
.slot.free { border-style: dashed; background: #fbfcfe; }
.slot.mine { border-color: var(--blue); background: var(--blue-soft); }
.slot.done { border-color: #bfdcae; background: var(--green-soft); }

.notice { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: .9rem; }
.notice.blue { background: var(--blue-soft); color: #1f4f86; }
.notice.orange { background: var(--orange-soft); color: #8a4b09; }
.notice.green { background: var(--green-soft); color: #33621e; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters > * { width: auto; flex: 1 1 160px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .72rem; color: var(--muted); gap: 4px; }
.bars .bar div { width: 100%; max-width: 44px; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .bar b { color: var(--text); font-size: .78rem; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(165deg, #fff 0%, var(--primary-soft) 45%, #f3d3d4 100%); }
.auth .card { border-top: 4px solid var(--primary); }
.auth .card { width: 100%; max-width: 400px; padding: 24px; }
.auth .logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 14px; text-align: center; }
.auth .logo img { width: 100%; max-width: 280px; max-height: 90px; object-fit: contain; margin-bottom: 6px; }

/* Modal e toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 30, 55, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 100; }
.modal { background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 16px; } }
.modal h2 { margin-bottom: 4px; }
.modal .actions { margin-top: 16px; justify-content: flex-end; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #1f2d3d; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 200; max-width: 90vw; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.toast.err { background: var(--red); }
@media (min-width: 821px) { .toast { bottom: 24px; } }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 3px 10px; font-size: .8rem; display: inline-flex; gap: 6px; align-items: center; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 1rem; line-height: 1; }
.weekdays { display: flex; flex-wrap: wrap; gap: 6px; }
.weekdays label { margin: 0; display: flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-weight: 400; cursor: pointer; }
.weekdays input { width: auto; min-height: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; font: inherit; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--primary); color: #fff; }
.table-wrap table { min-width: 620px; }
.list-item > .actions { flex-shrink: 0; }
@media (max-width: 600px) {
  .list-item { flex-wrap: wrap; }
  .list-item > .actions { width: 100%; justify-content: flex-start !important; }
}
