:root {
  --wine: #7a2e2e;
  --wine-dark: #5c2020;
  --wine-bg: #f6eaea;
  --gold: #b08a3e;
  --gold-bg: #f7f0e1;
  --green: #2f6b45;
  --green-bg: #e6f2ea;
  --amber: #8a5a10;
  --amber-bg: #fbf0dc;
  --red: #a32d2d;
  --ink: #2b2622;
  --ink-2: #5d564f;
  --ink-3: #8f877e;
  --line: #e6e0d6;
  --paper: #fbf9f5;
  --card: #ffffff;
  --radius: 8px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); font-size: 14px; line-height: 1.55; background: var(--paper); color: var(--ink); min-height: 100vh; }
a { color: var(--wine); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--ink); }
h1 { font-size: 26px; margin-bottom: 4px; }
h2 { font-size: 19px; margin-bottom: 12px; }
h3 { font-size: 16px; margin-bottom: 8px; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

/* Header / nav */
.topbar { background: var(--wine); color: #fff; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-size: 20px; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand small { font-family: var(--sans); font-size: 12px; opacity: .75; font-weight: 400; }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a { color: rgba(255,255,255,.82); text-decoration: none; padding: 7px 11px; border-radius: 6px; font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; }
.user-menu { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-menu a { color: rgba(255,255,255,.85); }
@media (max-width: 720px) {
  .topbar-inner { gap: 4px 12px; padding: 8px 16px; }
  .user-menu { margin-left: auto; }
  .nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -6px; }
  .nav a { flex: none; }
}
.acting-banner { background: var(--gold-bg); color: var(--amber); border-bottom: 1px solid #ecdcb8; font-size: 13px; }
.acting-banner .inner { max-width: 1180px; margin: 0 auto; padding: 7px 20px; display: flex; gap: 12px; align-items: center; }

main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-sidebar { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .grid-2, .grid-sidebar { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.stat .l { color: var(--ink-3); font-size: 12.5px; }

/* Forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d6cfc4; border-radius: 6px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(122,46,46,.25); border-color: var(--wine); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { font-weight: 400; display: flex; gap: 6px; align-items: center; color: var(--ink); font-size: 13.5px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--wine); color: #fff; }
.btn-primary:hover { background: var(--wine-dark); }
.btn-secondary { background: #fff; color: var(--ink); border-color: #d6cfc4; }
.btn-secondary:hover { background: #f4f0ea; }
.btn-ghost { background: none; color: var(--wine); padding: 4px 8px; }
.btn-ghost:hover { background: var(--wine-bg); }
.btn-danger { background: #fff; color: var(--red); border-color: #e7c4c4; }
.btn-danger:hover { background: #fbeeee; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid #f0ebe3; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* Pills / badges */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f0ebe3; color: var(--ink-2); }
.pill-wine { background: var(--wine-bg); color: var(--wine); }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-gold { background: var(--gold-bg); color: var(--amber); }

/* Lists */
.list { list-style: none; }
.list li { padding: 10px 0; border-bottom: 1px solid #f0ebe3; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.list li:last-child { border-bottom: none; }
.list-select li { padding: 9px 10px; border-radius: 6px; cursor: pointer; border-bottom: none; }
.list-select li:hover { background: #f6f2ec; }
.list-select li.selected { background: var(--wine-bg); }
.empty { color: var(--ink-3); padding: 18px 0; text-align: center; font-style: italic; }

/* Service cards on the schedule */
.service { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; background: #fff; }
.service-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #faf7f2; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; gap: 10px; flex-wrap: wrap; }
.service-head .date { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.slot-row { display: grid; grid-template-columns: 160px 1fr auto; gap: 10px; align-items: center; padding: 7px 14px; border-bottom: 1px solid #f3eee7; }
.slot-row:last-child { border-bottom: none; }
.slot-row .role { font-weight: 600; font-size: 13px; }
.slot-row select { padding: 5px 8px; }
.slot-row.is-requested { background: #fffaf0; }
@media (max-width: 640px) { .slot-row { grid-template-columns: 1fr; } }

/* Printable rota grid */
.rota-grid th, .rota-grid td { border: 1px solid var(--line); font-size: 13px; vertical-align: top; }
.rota-grid th { background: #faf7f2; }
.rota-grid .open { color: var(--amber); font-style: italic; }
.rota-grid .me { background: var(--wine-bg); font-weight: 600; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(30,20,15,.45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 520px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Toast */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 90vw; }
#toast.error { background: var(--red); }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(180deg, var(--wine) 0, var(--wine) 220px, var(--paper) 220px); }
.auth-card { background: #fff; border-radius: 12px; padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 12px 40px rgba(60,20,20,.15); }
.auth-card .brand-lg { font-family: var(--serif); font-size: 30px; color: var(--wine); text-align: center; }
.auth-card .tag { text-align: center; color: var(--ink-3); margin-bottom: 22px; font-size: 13px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
.msg { padding: 9px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.msg-error { background: #fbeeee; color: var(--red); }
.msg-ok { background: var(--green-bg); color: var(--green); }

@media print {
  .topbar, .acting-banner, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: none; padding: 0; }
}

/* Drag-to-reorder rows (Parish Settings → Ministries) */
.drag-handle { cursor: grab; color: var(--ink-3); font-size: 16px; letter-spacing: -2px; text-align: center; user-select: none; touch-action: none; }
.drag-handle:hover { color: var(--wine); }
.drag-ghost { background: var(--wine-bg); opacity: .7; }
