:root {
  --bg: #f4f3f1; --card: #fff; --text: #16181c; --muted: #6a707a;
  --red: #c8102e; --red-hi: #a50d26; --line: #e2e0dc; --ok: #1d7a46;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--red); }
h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: 400; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #16181c; color: #fff; position: sticky; top: 0; z-index: 5; }
.top .brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; margin-right: auto; }
.top .who { color: #b9bdc4; font-size: .85rem; }
.top .view { color: #fff; font-size: .9rem; }
.top form { margin: 0; }
.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; font-size: .9rem; padding: 0; }

.shell { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 52px); }
.side { background: #fff; border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.side a { padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--bg); }
.side a[aria-current="page"] { background: #fbe7ea; color: var(--red); font-weight: 600; }
.main { padding: 24px 28px 80px; max-width: 1100px; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .85rem; }
label.grow { flex: 1 1 220px; }
label.full { flex: 1 1 100%; margin-bottom: 12px; }
label.check { flex-direction: row; align-items: center; font-weight: 500; }
input, select, textarea { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid #cfccc6; border-radius: 8px; background: #fff; color: var(--text); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: transparent; }
input.narrow { width: 80px; }
textarea { resize: vertical; width: 100%; }
input[type=file] { padding: 6px; }
.actions { display: flex; gap: 8px; margin-left: auto; }

.btn { background: var(--red); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--red-hi); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn.danger:hover { background: #fbe7ea; }
.btn.small { padding: 6px 10px; font-size: .85rem; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: #e3f4ea; color: var(--ok); }
.flash.err { background: #fbe7ea; color: var(--red-hi); }

.pill { flex: 1 1 100%; font-size: .8rem; font-weight: 700; color: var(--muted); }
.pill.on { color: var(--ok); }
.pill.off { color: var(--muted); }
.section-row { padding: 10px 0; border-top: 1px solid var(--line); }
.group-head { margin: 26px 0 10px; color: var(--muted); text-transform: uppercase; font-size: .85rem; letter-spacing: .05em; }
.thumb { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tiles .tile { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--red); border-radius: 12px; padding: 18px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.tiles .tile b { font-size: 1.8rem; }
.tiles .tile span { color: var(--muted); overflow-wrap: anywhere; }

.sticky-save { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .8rem; color: var(--muted); text-transform: uppercase; }
form.inline { display: flex; gap: 6px; margin: 0; }
form.inline input { width: 190px; }

.login { min-height: 100vh; display: grid; place-content: center; padding: 16px; }
.login-card { width: min(380px, 100%); text-align: center; }
.login-card h1 { margin: 8px 0 0; }
.login-logo { width: 190px; height: auto; }
.link-dark { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; margin: 18px 0 12px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .side a { white-space: nowrap; }
  .main { padding: 18px 16px 80px; }
  .top .who { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table thead { display: none; }
  .table tr { border-bottom: 2px solid var(--line); padding: 6px 0; }
  .table td { border: 0; padding: 6px 12px; }
  form.inline input { width: 100%; }
}

/* Repeating matches */
.repeat-only { display: none; }
form.repeats .repeat-only { display: flex; }
.badge { display: inline-block; background: #fbe7ea; color: var(--red); border-radius: 999px; padding: 1px 8px; font-size: .75rem; }
fieldset.dates { flex: 1 1 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
fieldset.dates legend { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
.date-chip { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
input.type-in { width: 150px; }
