* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 var(--font-body); background: var(--bg); color: var(--text); }
header.top { display: flex; align-items: center; gap: var(--gap); padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
header.top h1 { font-size: 15px; margin: 0; font-weight: 600; }
header.top .grow { flex: 1; }
nav.tabs { display: flex; gap: 2px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
nav.tabs a { padding: 9px 12px; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs a.on { color: var(--text); border-color: var(--accent); }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
h2 { font-size: 16px; margin: 0 0 var(--gap); } h3 { font-size: 14px; margin: 18px 0 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: var(--gap); }
.row { display: flex; gap: var(--gap); flex-wrap: wrap; align-items: center; }
.muted { color: var(--text-muted); } .mono { font-family: var(--font-mono); font-size: 12.5px; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--text-muted); font-size: 12px; background: var(--surface-2); position: sticky; top: 0; }
.scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); }
button, select, input, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 10px; }
button { cursor: pointer; } button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--bad); } button:disabled { opacity: .5; cursor: default; }
textarea { width: 100%; min-height: 220px; font-family: var(--font-mono); font-size: 12.5px; }
label { display: grid; gap: 3px; font-size: 12px; color: var(--text-muted); }
label input, label select { color: var(--text); font-size: 14px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--accent-soft); }
.badge.optimal, .badge.succeeded, .badge.pass { color: var(--ok); } .badge.feasible { color: var(--info); }
.badge.infeasible, .badge.failed, .badge.error, .badge.FAIL { color: var(--bad); } .badge.unknown, .badge.queued, .badge.warning { color: var(--warn); }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--gap); }
.col { background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius); padding: 8px; min-height: 90px; }
.col.over { border-style: solid; border-color: var(--accent); }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 8px; margin: 4px 0; cursor: grab; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); width: min(720px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 20; }
.toast { background: var(--accent); color: var(--accent-text); padding: 8px 14px; border-radius: var(--radius); cursor: pointer; max-width: 340px; }
.bell { position: relative; } .bell .n { position: absolute; top: -6px; right: -6px; background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 5px; }
.panel { position: absolute; right: 16px; top: 46px; width: 360px; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; z-index: 10; }
.err { color: var(--bad); } .ok { color: var(--ok); }
@media (max-width: 640px) { main { padding: 12px; } th, td { padding: 6px; } }

.ref { cursor: help; border-bottom: 1px dotted var(--text-muted); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; margin: 8px 0; }
.fields .wide { grid-column: 1 / -1; }
.fields label { text-transform: capitalize; } .fields label .hint { text-transform: none; color: var(--text-muted); font-size: 11.5px; }
.fields select[multiple] { min-height: 96px; }
.weekgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.weekgrid label { text-transform: uppercase; }

/* ---- studio layout ------------------------------------------------------------------------------------------ */
header.top h1 a { color: inherit; text-decoration: none; }
header.top { flex-wrap: wrap; row-gap: 6px; }
.stats { display: inline-flex; gap: 6px; flex-wrap: wrap; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.small, .small button { padding: 2px 8px; font-size: 12px; }
button.x { padding: 0 6px; margin-left: 4px; border: none; background: transparent; color: var(--text-muted); }
.small { font-size: 12.5px; } .grow { flex: 1; } .pad { padding: 10px; } .wrap { flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }
.pill.rule { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 4px 2px 10px; }
.jobpill { display: inline-flex; align-items: center; gap: 8px; padding: 3px 6px 3px 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); font-size: 12.5px; }
.jobpill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
nav.tabs a.more { font-size: 12.5px; }
nav.tabs .grow { flex: 1; }
.hero { margin: 4px 0 14px; } .hero h2 { font-size: 20px; margin: 0 0 4px; } .hero p { margin: 0; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.grid { display: grid; gap: 12px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid.club-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.div-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: grid; gap: 6px; align-content: start; text-decoration: none; color: inherit; } .tile.big h3 { margin: 0; font-size: 15px; } a.tile:hover { border-color: var(--accent); }
.card-head h3 { margin: 0; font-size: 15px; } .card-head { margin-bottom: 8px; } .card-head p { margin: 2px 0 0; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.step { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: none; }
.step .mark { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; border: 1px solid var(--border); flex: none; }
.step.ok .mark { background: var(--ok); color: var(--bg); border-color: var(--ok); } .step.warn .mark { color: var(--warn); border-color: var(--warn); }
.step.bad .mark { color: var(--bad); border-color: var(--bad); } .step.todo .mark { color: var(--text-muted); }
.suggest { padding: 8px 10px; margin: 8px 0; background: var(--surface-2); border-radius: var(--radius); }
.why { margin: 4px 0 0; padding-left: 18px; color: var(--text-muted); font-size: 12.5px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.segs { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); }
.segs.wrap { display: flex; flex-wrap: wrap; width: 100%; margin-bottom: 14px; }
button.seg { border: none; background: transparent; padding: 4px 12px; } button.seg.on { background: var(--surface); box-shadow: 0 0 0 1px var(--border); font-weight: 600; }
input.search { min-width: 200px; }
.bulkbar { display: flex; gap: 10px; align-items: center; padding: 8px 12px; margin-bottom: 10px; background: var(--accent-soft); border-radius: var(--radius); }
.bulkbar[hidden] { display: none; }
.club { padding: 10px 12px; } .club-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; } .club-head strong { font-size: 15px; }
.club-fac { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.team-rows { display: grid; gap: 3px; margin-bottom: 6px; } .team-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.team-abbr { cursor: pointer; font-weight: 500; } select.mini { padding: 1px 4px; font-size: 12px; width: 84px; }
.col.card { min-height: 90px; padding: 10px; } .col.over { outline: 2px solid var(--accent); }
.chip-team { display: inline-block; margin: 3px 4px 0 0; padding: 2px 9px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); cursor: grab; font-size: 12.5px; }
.picklist { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-top: 8px; }
label.pick { flex-direction: row; display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 14px; cursor: pointer; }
label.pick:hover { background: var(--surface-2); } label.pick[hidden] { display: none; }
label.inline { display: inline-flex; flex-direction: row; gap: 6px; align-items: center; color: var(--text); font-size: 13px; }
label.chipbox { padding: 2px 10px; border: 1px solid var(--border); border-radius: 99px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.alert { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 8px; border: 1px solid var(--border); } .alert.ok { color: var(--ok); } .alert.bad { color: var(--bad); border-color: var(--bad); } .alert ul { margin: 4px 0 0; padding-left: 18px; color: var(--text); }
.bulkrow { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: start; margin: 8px 0; } .bulkrow .hint.warn { grid-column: 2; font-size: 12px; color: var(--warn); }
.fields .wide textarea { width: 100%; }
[hidden] { display: none !important; }

.default-row { display: grid; grid-template-columns: 220px 160px 1fr; gap: 14px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.default-row:last-child { border-bottom: none; }
@media (max-width: 800px) { .default-row { grid-template-columns: 1fr; } }
.pill.own { border: 1px solid var(--accent); background: transparent; }

.small.warn, p.warn { color: var(--warn); }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: " ↕"; opacity: .35; font-size: 11px; }
th[aria-sort="ascending"]::after { content: " ▲"; opacity: 1; }
th[aria-sort="descending"]::after { content: " ▼"; opacity: 1; }

/* ---- searchable list boxes (combo.js) --------------------------------------------------------------------------- */
.combo { position: relative; display: inline-block; min-width: 140px; vertical-align: middle; }
.combo > .combo-input { width: 100%; cursor: text; padding-right: 22px; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
.combo > .combo-input.mini { padding-right: 16px; min-width: 0; }
.combo:has(> .combo-input.mini) { min-width: 0; }
.combo-list { position: absolute; z-index: 40; left: 0; min-width: 100%; max-height: 260px; overflow: auto; margin: 2px 0 0; padding: 2px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.combo-list li { padding: 4px 10px; border-radius: 4px; cursor: pointer; white-space: nowrap; color: var(--text); font-size: 13px; }
.combo-list li.act { background: var(--accent-soft); } .combo-list li.sel { font-weight: 600; } .combo-list li.dis { opacity: .45; cursor: default; } .combo-list li.none { color: var(--text-muted); cursor: default; }
.combo.multi { display: block; width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 6px; }
.combo-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.combo-tools .combo-search { flex: 1; min-width: 140px; }
.combo-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; } .combo-chips:empty { display: none; }
.pill.chip { padding-right: 2px; }
.combo-checks { max-height: 180px; overflow: auto; margin-top: 6px; border-top: 1px solid var(--border); }
label.combo-row { flex-direction: row; display: flex; gap: 8px; align-items: center; padding: 3px 4px; color: var(--text); font-size: 13px; cursor: pointer; text-transform: none; }
label.combo-row:hover { background: var(--surface-2); }
.combo-list li, .combo-chips, .combo-tools { text-transform: none; }

/* ---- rules ------------------------------------------------------------------------------------------------------ */
.rule-card { display: grid; gap: 4px; align-content: start; } .rule-card p { margin: 0; }
.rule-fields { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.rule-field .help { font-size: 12px; color: var(--text-muted); text-transform: none; line-height: 1.35; }
.rule-field .hint.why { color: var(--warn); font-size: 12px; text-transform: none; }
.rule-field.off { opacity: .5; } .rule-field.off .help { font-style: italic; }
.rule-field.off input, .rule-field.off select, .rule-field.off textarea { cursor: not-allowed; background: var(--surface-2); }
.rules { display: grid; }
.rule-row { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-top: 1px solid var(--border); } .rule-row.disabled { opacity: .55; } .rule-row[hidden] { display: none; }
details.card > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; } details.card > summary .right { margin-left: auto; display: inline-flex; gap: 4px; }

a.rule-link { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; } a.rule-link:hover { color: var(--accent); text-decoration: underline; }
.review-card { border-color: var(--warn); } .review-card .rule-row.flagged { background: var(--accent-soft); border-radius: var(--radius); }
.reasons { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text-muted); } .reasons li { margin: 2px 0; }

.toast.action { cursor: pointer; text-decoration: none; } .toast .go { text-decoration: underline; }
.danger-zone { border-color: var(--bad); } .danger-zone h3 { color: var(--bad); }
.tile-actions { display: flex; gap: 6px; margin-top: 6px; }

pre.log { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius); max-height: 50vh; overflow: auto; font-size: 12px; }

/* ---- audit ------------------------------------------------------------------------------------------------------ */
.audit-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; } .audit-head h2 { margin: 0 0 4px; font-size: 20px; }
.verdict { font-size: 14px; } .verdict ul { margin: 6px 0 0; padding-left: 18px; }
.audit-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: flex-start; } .audit-card-head h3 { margin: 0; }
.audit-scroll { max-height: 520px; } .audit-scroll.tall { max-height: 640px; }
.audit-table { font-size: 12.5px; } .audit-table td, .audit-table th { white-space: nowrap; padding: 5px 9px; } .audit-table td.num, .audit-table th.num { text-align: center; }
.audit-table td.strong { font-weight: 700; } .audit-table tr.row-bad { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.audit-table thead th:first-child, .audit-table tbody td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 2; } .audit-table thead th:first-child { background: var(--surface-2); z-index: 3; }
td.cellday, .cellday { text-align: center; font-variant-numeric: tabular-nums; color: var(--text-muted); }
td.cellday.full, span.cellday.full { color: var(--info); font-weight: 700; background: color-mix(in srgb, var(--info) 14%, transparent); }
td.cellday.over, span.cellday.over { color: var(--bad); font-weight: 700; background: color-mix(in srgb, var(--bad) 16%, transparent); }
td.cellday.closed, span.cellday.closed { color: var(--text-muted); background: var(--surface-2); }
span.cellday { display: inline-block; min-width: 20px; padding: 0 4px; border-radius: 4px; }
.pill.info { color: var(--info); } .ok-text { color: var(--ok); font-weight: 600; } .legend { margin: 6px 0 0; }
@media print { header.top, nav.tabs, .toasts, .noprint, #panel { display: none !important; } .scroll { max-height: none !important; overflow: visible !important; } body { background: #fff; } .card { break-inside: avoid; } }

/* brand: logo swaps with the theme; headings use the heading face */
header.top h1 a { display: flex; align-items: center; }
img.logo { height: 28px; width: auto; }
img.logo-light { display: var(--logo-light); } img.logo-dark { display: var(--logo-dark); }
h2, h3, .hero h2, .card-head h3 { font-family: var(--font-heading); letter-spacing: -.01em; }
h2 { font-weight: 800; }

/* ---- Studio look (modelled on the League Scheduler Studio example): centred page, roomy header, tab underline,
   white rounded cards with a soft shadow, small semibold buttons, pill badges ---------------------------------- */
:root { --pad-x: max(16px, calc((100vw - var(--page-max)) / 2 + 24px)); }
header.top { padding: 10px var(--pad-x); min-height: 64px; box-shadow: var(--shadow); }
nav.tabs { padding: 0 var(--pad-x); gap: 28px; box-shadow: var(--shadow); }
nav.tabs a { padding: 12px 2px; font-weight: 500; border-bottom-width: 2px; margin-bottom: -1px; }
nav.tabs a:hover { color: var(--text); border-color: var(--border); }
nav.tabs a.on { color: var(--accent); font-weight: 600; border-color: var(--accent); }
main { max-width: var(--page-max); padding: 24px; }
.card { border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 16px; }
.hero h2 { font-size: 22px; } .hero p { font-size: 13px; }
button, select, input, textarea { border-radius: var(--radius); }
button { font-size: 12.5px; font-weight: 600; padding: 6px 12px; transition: background .12s, border-color .12s; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.small, .small button { font-size: 12px; padding: 3px 9px; }
button.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); } button.danger:hover { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
.stats { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 12px; gap: 14px; font-size: 12px; }
.badge, .pill { font-weight: 600; font-size: 11.5px; padding: 2px 9px; }
.scroll { border-radius: var(--radius-lg); box-shadow: var(--shadow); }
th { text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }
dialog { border-radius: 16px; box-shadow: var(--shadow-lg); padding: 20px; }
.toast { box-shadow: var(--shadow-lg); border-radius: var(--radius-lg); }
.panel { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.toolbar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 10px 14px; }
@media (max-width: 640px) { main { padding: 12px; } }
.stats .pill { background: none; padding: 0; font-weight: 500; color: var(--text-muted); } .stats .pill + .pill { border-left: 1px solid var(--border); padding-left: 14px; }

/* larger brand lockup in the header */
img.logo { height: 46px; }
header.top { min-height: 78px; row-gap: 8px; column-gap: 18px; }
header.top h1 { margin-right: 6px; }
@media (max-width: 640px) { img.logo { height: 36px; } header.top { min-height: 60px; } }

/* rule dialog: compact fields, collapsible strictness and scope */
.fields { align-items: start; }
.fields input[type="number"] { width: 110px; }
details.fold { border: 1px solid var(--border); border-radius: var(--radius); margin: 8px 0; background: var(--surface); }
details.fold > summary { cursor: pointer; padding: 8px 12px; list-style: none; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--text-muted); }
details.fold[open] > summary::before { content: "▾"; }
details.fold > :not(summary) { margin: 0 12px 12px; }
.rule-fields { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* list search boxes are type=search (password managers skip them) but should look like the other fields */
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* in-table edit mode */
.editbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 8px; background: var(--accent-soft); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.editbar[hidden] { display: none; }
td.cell-edit { padding: 3px 6px; }
td.cell-edit input, td.cell-edit select { width: 100%; min-width: 90px; padding: 3px 6px; font-size: 13px; }
td.cell-edit input.cell-num { width: 84px; min-width: 0; }
td.cell-edit.dirty input, td.cell-edit.dirty select { border-color: var(--accent); background: var(--accent-soft); }
button.small.on { background: var(--accent-soft); border-color: var(--accent); }
