/* ChurchSuite Rota Tool v2 */
:root {
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #F7F9FD;
  --text: #16202F;
  --muted: #5B6679;
  --line: #DCE3EE;
  --line-strong: #B9CBEA;
  --accent: #0B57C2;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6EFFD;
  --date: #013AA3;
  --head-bg: #DEEFFF;
  --head-fg: #0B2A5B;
  --stripe: #F4F8FF;
  --ok: #0F7B3F;
  --ok-soft: #E4F5EA;
  --warn: #8A5A00;
  --warn-soft: #FFF4DA;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 var(--font); color: var(--text); background: var(--bg); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--accent); }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3em; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .25rem 0 .5rem; }
.ok { color: var(--ok); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  min-height: 38px; padding: .45rem .9rem; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; text-decoration: none;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--accent); }
.btn:focus-visible, input:focus-visible, select:focus-visible, .person:focus-visible, li[role=option]:focus-visible {
  outline: 3px solid rgba(11, 87, 194, .35); outline-offset: 1px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #0947A0; border-color: #0947A0; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(255, 255, 255, .15); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { min-height: 30px; padding: .2rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .45rem .55rem; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor;
  border-color: var(--muted) transparent var(--muted) transparent; border-radius: 50%; animation: spin .8s linear infinite;
}
.btn-primary.is-busy::after { border-color: #fff transparent #fff transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------ forms */
label { display: block; font-weight: 550; font-size: .9rem; margin: 0 0 .75rem; }
label > input:not([type=checkbox]):not([type=color]), label > select { display: block; width: 100%; margin-top: .3rem; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], select, .dialog-input {
  font: inherit; font-weight: 400; min-height: 38px; padding: .4rem .6rem; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface); color: var(--text); max-width: 100%;
}
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; vertical-align: middle; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
label.inline { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
label.inline select { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem .4rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .35rem; }
.grid-2, .grid-3, .grid-5 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.colours label { display: flex; flex-direction: column; gap: .3rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form input { flex: 1 1 200px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .75rem; }
.dirty-note { color: var(--warn); font-size: .85rem; }

/* ------------------------------------------------------------ alerts, toasts */
.alert { border-radius: 8px; padding: .7rem .9rem; margin: .75rem 0; border: 1px solid; }
.alert-error { background: var(--danger-soft); border-color: #F5B8B2; color: var(--danger); }
.alert-ok { background: var(--ok-soft); border-color: #B4E2C3; color: #0B5A2E; }
.alert-warn { background: var(--warn-soft); border-color: #F1D596; color: var(--warn); }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #1F2A3C; color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); transition: opacity .5s, transform .5s; }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 0 .4rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
.badge { font-size: .7rem; background: rgba(255, 255, 255, .2); padding: .1rem .45rem; border-radius: 99px; margin-left: .3rem; }

/* ------------------------------------------------------------ top bar */
.topbar { background: linear-gradient(90deg, #0A3F8F, #0B57C2); color: #fff; }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: .5rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.brand-mark { display: inline-block; width: 40px; height: 40px; border-radius: 10px; background: #fff;
  background-image: linear-gradient(#0B57C2, #0B57C2), linear-gradient(#0B57C2, #0B57C2), linear-gradient(#0B57C2, #0B57C2);
  background-size: 60% 12%, 60% 12%, 38% 12%; background-position: 50% 28%, 50% 50%, 29% 72%; background-repeat: no-repeat; }
.brand-mark.sm { width: 26px; height: 26px; border-radius: 7px; }
.topbar .btn-ghost { color: #fff; }
.topbar-actions { margin-left: auto; display: flex; gap: .25rem; }
.rota-tabs, .admin-tabs { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.rota-tab, .admin-tabs button {
  border: 0; background: transparent; color: rgba(255, 255, 255, .85); font: inherit; font-weight: 600;
  padding: .45rem .8rem; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.rota-tab:hover, .admin-tabs button:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.rota-tab.active, .admin-tabs button.active { background: #fff; color: var(--accent); }

.container { max-width: 1400px; margin: 0 auto; padding: 20px 16px 60px; }

/* ------------------------------------------------------------ auth */
.page-login, .page-setup, .page-error { background: radial-gradient(circle at 20% 0%, #DCE9FF, var(--bg) 60%); }
.auth-card { max-width: 400px; margin: 8vh auto 2rem; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 2rem 1.75rem; }
.auth-card.auth-wide { max-width: 520px; }
.auth-card .brand-mark { margin-bottom: .75rem; background-color: var(--accent);
  background-image: linear-gradient(#fff, #fff), linear-gradient(#fff, #fff), linear-gradient(#fff, #fff); }
.auth-switch { text-align: center; margin: 1rem 0 0; font-size: .9rem; }

/* ------------------------------------------------------------ viewer */
.viewer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.viewer-head h1 { margin-bottom: .15rem; }
.viewer-head p { margin: 0; }
.pdf-actions { position: relative; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin-bottom: .6rem; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; font: inherit; font-weight: 550; padding: .35rem .75rem; border-radius: 7px; cursor: pointer; color: var(--muted); min-height: 32px; }
.seg button:hover { color: var(--text); background: var(--surface-2); }
.seg button.active { background: var(--accent); color: #fff; }
.custom-range { display: flex; gap: .6rem; }
.custom-range label { margin: 0; display: flex; align-items: center; gap: .4rem; font-weight: 500; }
.custom-range input { margin: 0 !important; width: auto !important; display: inline-block !important; }
.toggle { margin: 0; }
.view-switch { margin: .25rem 0 .75rem; }

.people-picker { position: relative; }
.popover { position: absolute; z-index: 40; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 24, 40, .15); padding: .8rem; min-width: 260px; }
.pdf-actions .popover { right: 0; }
.people-panel { width: min(360px, calc(100vw - 32px)); }
.people-panel input[type=search] { width: 100%; margin-bottom: .5rem; }
#peopleList { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
#peopleList li { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; border-radius: 8px; cursor: pointer; }
#peopleList li:hover { background: var(--surface-2); }
#peopleList li[aria-selected=true] { background: var(--accent-soft); }
#peopleList .swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line-strong); flex: none; }
#peopleList .pname { flex: 1; display: flex; flex-direction: column; font-weight: 550; }
#peopleList .pname small { color: var(--muted); font-weight: 400; }
#peopleList .pcount { font-size: .8rem; color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 0 .45rem; }
#peopleList li.none { color: var(--muted); cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; min-height: 0; }
.chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 99px; padding: .15rem .25rem .15rem .25rem; font-weight: 550; font-size: .9rem; }
.chip.absent { opacity: .55; }
.chip-colour { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .25); cursor: pointer; padding: 0; }
.chip-remove { border: 0; background: transparent; font-size: 1.15rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 .35rem; border-radius: 50%; }
.chip-remove:hover { color: var(--danger); }
.chip-clear { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; }

.loading { color: var(--muted); padding: .5rem 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.rota { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.rota th, table.rota td { border: 1px solid #CCDDFE; padding: .45rem .6rem; text-align: left; vertical-align: top; }
table.rota thead th { background: var(--head-bg); color: var(--head-fg); font-weight: 700; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.rota tr.groups th { text-align: center; }
table.rota tbody tr:nth-child(even) td, table.rota tbody tr:nth-child(even) th { background: var(--stripe); }
table.rota th.date { color: var(--date); font-weight: 700; white-space: nowrap; }
table.rota th.date .t, table.rota th.date .n { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); white-space: normal; max-width: 12em; }
table.rota th.date .n { font-style: italic; }
table.rota td.none { text-align: center; color: var(--muted); padding: 1.5rem; }
.person { cursor: pointer; border-radius: 4px; padding: 0 .15em; margin: 0 -.15em; white-space: nowrap; }
.person:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.person.hl { font-weight: 700; color: #000; }
.person.dim { color: #9AA3B2; }
.person.un { text-decoration: line-through; color: #8A8A8A; }
.cl { color: #C00000; font-weight: 800; font-size: .8em; margin-left: .15em; }

.mine-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.mine-list li { display: grid; grid-template-columns: 11rem 1fr; gap: .75rem; padding: .65rem .9rem; border-top: 1px solid var(--line); }
.mine-list li:first-child { border-top: 0; }
.mine-date { font-weight: 700; color: var(--date); }
.mine-date .n { display: block; font-weight: 400; font-style: italic; color: var(--muted); font-size: .8rem; }
.mine-who .roles { color: var(--muted); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* Phone: rota rows become cards */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .topbar-inner { gap: .4rem; }
  .rota-tabs { order: 3; width: 100%; }
  .container { padding-top: 14px; }
  .viewer-head { flex-direction: column; }
  .pdf-actions .popover { left: 0; right: auto; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table.rota, table.rota tbody, table.rota tr, table.rota td, table.rota th { display: block; width: 100%; }
  table.rota thead { display: none; }
  table.rota tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; overflow: hidden; box-shadow: var(--shadow); }
  table.rota tbody tr:nth-child(even) td, table.rota tbody tr:nth-child(even) th { background: transparent; }
  table.rota th, table.rota td { border: 0; }
  table.rota th.date { background: var(--head-bg) !important; font-size: 1rem; }
  table.rota th.date .t, table.rota th.date .n { display: inline; margin-left: .5rem; }
  table.rota td { display: grid; grid-template-columns: 6.5rem 1fr; gap: .5rem; padding: .3rem .8rem; border-top: 1px solid var(--line); }
  table.rota td::before { content: attr(data-label); color: var(--gc, var(--muted)); font-size: .85rem; font-weight: 600; }
  table.rota td.empty { display: none; }
  table.rota td .sep { display: none; }
  table.rota td .names { display: flex; flex-wrap: wrap; gap: .2rem .5rem; align-items: baseline; }
  table.rota td .person { display: inline-block; margin: 0; padding: 0 .25em; }
  .mine-list li { grid-template-columns: 1fr; gap: .2rem; }
}

/* ------------------------------------------------------------ admin */
.admin .card, form.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1.25rem 1.25rem 1rem; margin-bottom: 1.25rem; }
.card.inset { box-shadow: none; background: var(--surface-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; border: 2px dashed var(--line-strong); border-radius: 12px; padding: 1.5rem 1rem; text-align: center; cursor: pointer; background: var(--surface-2); font-weight: 400; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dz-file { font-weight: 650; color: var(--ok); }

.rota-list { list-style: none; margin: 0; padding: 0; }
.rota-list li { display: flex; align-items: center; gap: .75rem; padding: .7rem .5rem; border-top: 1px solid var(--line); background: var(--surface); }
.rota-list li:first-child { border-top: 0; }
.rota-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--line-strong); flex: none; }
.rota-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.handle { cursor: grab; color: var(--muted); user-select: none; letter-spacing: -2px; padding: 0 .2rem; }

table.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.grid th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .45rem .5rem; border-bottom: 1px solid var(--line-strong); }
table.grid td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid input[type=text], table.grid input[type=number], table.grid select { width: 100%; min-height: 34px; }
table.grid .num { text-align: right; white-space: nowrap; }
.cols-table input.c-width, .cols-table input.d-width { width: 6.5rem; }
.cols-table tr.off td { color: var(--muted); }
.cols-table tr.off input[type=text], .cols-table tr.off select { opacity: .6; }
.cols-table tr.date-row td { background: var(--surface-2); }
.cols-table .auto-w { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.cols-layout { display: grid; grid-template-columns: 1fr 280px; gap: 1.25rem; align-items: start; }
.fit-panel { position: sticky; top: 16px; }
.fit-stats { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .5rem 0; }
.fit-stats dt { color: var(--muted); }
.fit-stats dd { margin: 0; font-weight: 650; }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: .4rem 0 .6rem; }
.meter span { display: block; height: 100%; background: var(--accent); }
.names-table tr.unused td { color: var(--muted); }
.shows-as { font-weight: 650; white-space: nowrap; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: .6rem 0; border-top: 1px solid var(--line); }
.palette-edit { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.pal-item { display: inline-flex; align-items: center; gap: .15rem; }
ul.history { list-style: none; padding: 0; margin: 0; }
ul.history li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 0; border-top: 1px solid var(--line); }

.dialog { border: 0; border-radius: 14px; padding: 1.25rem; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog .dialog-input { width: 100%; margin-top: .5rem; }
.dialog .actions { justify-content: flex-end; }

@media (max-width: 980px) {
  .cols-layout { grid-template-columns: 1fr; }
  .fit-panel { position: static; }
}
@media (max-width: 720px) {
  .admin-tabs { order: 3; width: 100%; }
  .rota-list li { flex-wrap: wrap; }
  .row-actions { width: 100%; justify-content: flex-start; }
  table.grid { font-size: .88rem; }
  .cols-table th:nth-child(5), .cols-table td:nth-child(5) { display: none; }
}

@media print {
  .topbar, .toolbar, .chips, .view-switch, .pdf-actions { display: none !important; }
  body { background: #fff; }
}

/* ------------------------------------------------------------ calendar view */
.cal { display: flex; flex-direction: column; gap: .75rem; }
.cal-month { display: grid; grid-template-columns: 5.5rem 1fr; gap: .5rem; align-items: stretch; }
.cal-mlabel { margin: 0; background: var(--head-bg); color: var(--head-fg); border-radius: var(--radius); padding: .6rem .7rem; font-size: 1rem; }
.cal-cards { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: .5rem; }
.cal-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .55rem .7rem; font-size: .9rem; min-width: 0; }
.cal-empty { background: transparent; border: 1px dashed var(--line); box-shadow: none; }
.cal-day { font-weight: 700; color: var(--date); margin-bottom: .2rem; }
.cal-t, .cal-n { font-size: .78rem; color: var(--muted); }
.cal-n { font-style: italic; }
.cal-line { line-height: 1.5; }
.cal-lb { font-weight: 650; color: #55627A; }

/* ------------------------------------------------------------ totals view */
.totals-wrap { overflow-x: auto; }
table.totals { border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: .92rem; min-width: 100%; }
table.totals th, table.totals td { border: 1px solid #CCDDFE; padding: .4rem .6rem; text-align: center; font-variant-numeric: tabular-nums; }
table.totals thead th { background: var(--head-bg); color: var(--head-fg); cursor: pointer; user-select: none; white-space: nowrap; position: sticky; top: 0; }
table.totals thead th:hover { background: #CFE3FA; }
table.totals .nm { text-align: left; }
table.totals .tt { font-weight: 700; background: #EEF3FB; }
table.totals thead th.tt { background: #CFE0F7; }
table.totals tbody tr:nth-child(even) td:not(.tt) { background: var(--stripe); }
table.totals tfoot td { font-weight: 700; background: #EEF3FB; border-top: 2px solid var(--line-strong); }
table.totals .z { color: #C3CAD5; }
.tname { border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; padding: 0 .2em; margin: 0 -.2em; border-radius: 4px; text-align: left; }
.tname:hover { text-decoration: underline; }
.tname.hl { font-weight: 700; }
tr.open .tname::after { content: " ▾"; color: var(--muted); }
tr.tdates td { text-align: left; background: var(--surface-2) !important; }
tr.tdates ul { margin: .2rem 0; padding-left: 1.2rem; columns: 2 16rem; }
tr.tdates li { break-inside: avoid; }

@media (max-width: 980px) {
  .cal-month { grid-template-columns: 1fr; }
  .cal-cards { grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
  .cal-empty { display: none; }
}

/* ------------------------------------------------------------ tabs: single vs combined, hidden */
.rota-tab { display: inline-flex; align-items: center; gap: .35rem; }
.tab-ico { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; opacity: .85; }
.rota-tab.is-hidden { font-style: italic; }
.rota-tab .tab-hidden { opacity: .7; }

/* ------------------------------------------------------------ combined views */
table.rota th.gstart, table.rota td.gstart { border-left: 3px solid var(--gl, var(--line-strong)); }
table.rota tr.groups th { color: #223; font-size: .85rem; }
.gk-mk, .cal-mk { font-size: .9em; }
table.totals tr.groups th { cursor: default; color: #223; font-size: .82rem; }
table.totals tr.groups th.blank { background: transparent; border-color: transparent; }
@media (max-width: 720px) {
  table.rota td.gstart { border-left: 0; }
}

/* ------------------------------------------------------------ admin: visibility switch + combined view editor */
.switch { display: inline-flex; align-items: center; gap: .4rem; margin: 0 .5rem 0 0; font-weight: 500; font-size: .85rem; white-space: nowrap; cursor: pointer; }
.switch input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.rota-list li .ico { color: var(--accent); }
.ve-visible { align-self: end; }
.ve-blocks { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1rem; }
.ve-block { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.ve-block.off { opacity: .75; border-style: dashed; }
.ve-head { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.ve-head label.inline { font-weight: 500; }
.ve-head .ve-count { margin-left: auto; }
.ve-cols { list-style: none; margin: 0; padding: .25rem .5rem; }
.ve-cols li { display: grid; grid-template-columns: auto auto 1fr minmax(8rem, 14rem); align-items: center; gap: .6rem; padding: .3rem .25rem; border-bottom: 1px solid var(--line); }
.ve-cols li:last-child { border-bottom: 0; }
.ve-cols li.off .ve-key, .ve-cols li.off .ve-label { opacity: .55; }
.ve-cols input.ve-pick { width: 18px; height: 18px; accent-color: var(--accent); }
.ve-cols input.ve-label { min-height: 32px; width: 100%; }
.btn.disabled { opacity: .5; pointer-events: none; }
@media (max-width: 720px) {
  .ve-cols li { grid-template-columns: auto auto 1fr; }
  .ve-cols input.ve-label { grid-column: 3; }
  .switch { order: 5; }
}

/* rota colour picker + collapsible blocks in the combined view editor */
input.rota-colour { width: 30px; height: 26px; padding: 1px; flex: none; cursor: pointer; }
.ve-tools { margin: 0 0 .6rem; }
.ve-toggle { display: inline-flex; align-items: center; gap: .45rem; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; padding: .15rem .25rem; border-radius: 6px; }
.ve-toggle:hover { background: rgba(11, 87, 194, .08); }
.ve-chev { display: inline-block; transition: transform .15s; color: var(--muted); }
.ve-block.collapsed .ve-chev { transform: rotate(-90deg); }
.ve-block.collapsed .ve-cols { display: none; }
.ve-block.collapsed .ve-head { border-bottom: 0; border-radius: var(--radius); }
.ve-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .2); flex: none; }

/* ------------------------------------------------------------ admin: update from ChurchSuite */
.ico-lg { width: 28px; height: 28px; color: var(--accent); }
.cs-card h2 { margin-bottom: .75rem; }
.cs-steps { margin: 0 0 .5rem; padding-left: 1.4rem; display: grid; gap: .9rem; }
.cs-steps > li { padding-left: .2rem; }
.cs-steps > li::marker { font-weight: 700; color: var(--accent); }
.cs-steps .dropzone { margin: .6rem 0 0; }
.cs-downloads { margin-top: .5rem; }
.cs-downloads .hint { margin-bottom: 0; }
.cs-dl-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.cs-dl { border-left: 6px solid var(--rota, var(--line-strong)); }
.cs-dl .ico, .cs-csv .ico { width: 16px; height: 16px; color: var(--accent); }
.cs-csv.is-unlinked { color: var(--muted); border-style: dashed; }
.cs-csv.is-unlinked .ico { color: var(--muted); }
.cs-link { display: block; }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.cs-table { margin-top: .5rem; }
.cs-table td { vertical-align: top; padding-top: .55rem; padding-bottom: .55rem; }
.cs-table .cs-inc { width: 4.5rem; text-align: center; }
.cs-table .cs-inc input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: .2rem; }
.cs-table .cs-fname { display: block; word-break: break-word; }
.cs-table select { min-width: 12rem; }
.cs-table .cs-status { font-size: .88rem; }
.cs-table tr.cs-ok .cs-status { color: var(--ok); }
.cs-table tr.cs-warn td { background: var(--warn-soft); }
.cs-table tr.cs-warn .cs-status { color: var(--warn); }
.cs-table tr.cs-bad td { background: var(--danger-soft); }
.cs-table tr.cs-bad .cs-status { color: var(--danger); }
.cs-table tr.cs-muted td { color: var(--muted); }
.cs-table tr.cs-muted .cs-fname { font-weight: 550; }
.cs-x { color: var(--danger); font-weight: 650; }
.cs-q { color: var(--warn); font-weight: 650; }
@media (max-width: 720px) {
  .cs-table thead { display: none; }
  .cs-table tr { display: grid; grid-template-columns: 2.5rem 1fr; border-bottom: 1px solid var(--line); }
  .cs-table td { border: 0; }
  .cs-table td.cs-inc { grid-row: span 3; width: auto; }
  .cs-table select { min-width: 0; width: 100%; }
}

/* ------------------------------------------------------------ top bar: admin area + rotas/admin switch */
.topbar-admin { background: #2C2C2A; }
.topbar-admin .rota-tab.active, .topbar-admin .admin-tabs button.active { color: #2C2C2A; }
.topbar-actions { align-items: center; }
.area-switch { display: inline-flex; border: 1px solid rgba(255, 255, 255, .55); border-radius: 99px; overflow: hidden; margin-right: .35rem; }
.area-switch a { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .9rem; color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.area-switch a:hover { background: rgba(255, 255, 255, .14); }
.area-switch a.on { background: #fff; color: var(--accent); cursor: default; }
.topbar-admin .area-switch a.on { color: #2C2C2A; }
.area-switch .ico { width: 16px; height: 16px; }
