:root {
  --bg: #f4f6f9; --card: #ffffff; --text: #182030; --muted: #667085; --line: #e1e5ec;
  --brand: #182030; --accent: #2ea078; --danger: #c0392b; --warn: #b7791f;
  --radius: 12px; --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1420; --card: #182030; --text: #eef1f6; --muted: #9aa5b8; --line: #2a3448; --brand: #0b0f18; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .center { text-align: center; } .small { font-size: .85rem; }
.hidden { display: none !important; }

header.top { background: var(--brand); color: #fff; padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5; }
header.top .title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.top a, header.top button.link { color: #fff; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
header.top a:hover, header.top button.link:hover { background: rgba(255,255,255,.12); }

main { max-width: 960px; margin: 0 auto; padding: var(--gutter); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--gutter); margin-bottom: var(--gutter); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--gutter); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 10px; padding: 9px 14px; cursor: pointer; min-height: 40px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
button.big { width: 100%; min-height: 72px; font-size: 1.3rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 40px; width: 100%; }
label { display: block; font-size: .9rem; margin: .6rem 0 .2rem; color: var(--muted); }
form .row input { width: auto; flex: 1; min-width: 120px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: var(--gutter); padding-bottom: 2px; }
.tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--text); border: 1px solid var(--line); background: var(--card); }
.tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.badge { display: inline-block; font-size: .78rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); }
.badge.ok { color: var(--accent); border-color: var(--accent); }
.badge.ko { color: var(--danger); border-color: var(--danger); }
.badge.warn { color: var(--warn); border-color: var(--warn); }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; color: var(--text); font-size: 1rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; min-height: 0; }
.switch .track { width: 44px; height: 26px; background: var(--line); border-radius: 999px; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 999px; max-width: 90vw; z-index: 20; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.toast.error { background: var(--danger); }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px dashed var(--accent); padding: 8px 10px; border-radius: 8px; word-break: break-all; }
.login { max-width: 380px; margin: 12vh auto 0; }

/* Filters of the access table */
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.filters .row { align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; white-space: nowrap; }
.check input { width: auto; margin: 0; }

/* Matrix "what to notify through each channel" */
.matrix { width: 100%; border-collapse: collapse; }
.matrix th, .matrix td { padding: 6px 4px; vertical-align: middle; }
.matrix th.group { text-align: left; background: var(--bg); font-size: .85rem; color: var(--muted); padding: 8px 6px; }
.matrix td.center, .matrix th.center { text-align: center; }
.matrix input[type=checkbox] { width: 20px; height: 20px; min-height: 0; padding: 0; }
.matrix .stack { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.matrix button.small { font-size: .72rem; padding: 3px 6px; min-height: 0; }

/* Sortable headers of the access table */
button.sort { all: unset; cursor: pointer; font-weight: 600; white-space: nowrap; }
button.sort:hover, button.sort:focus-visible { text-decoration: underline; }
