/* Anything marked hidden stays hidden, even if a rule below gives it a display. */
[hidden] { display: none !important; }

:root {
  --bg: #15171c;
  --card: #1f2229;
  --edge: #343844;
  --text: #eceef3;
  --muted: #9aa0ad;
  --input: #2a2e37;
  --raised: #30343e;
  --raised-hover: #3a3f4b;
  --row: #262a32;
  --side: #1a1c22;
  --accent: #e74c3c;
  --blue: #3d8bd9;
  --warn: #e6a23c;
  --ok: #3fbf74;
  --radius: 10px;
  --side-w: 248px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f4f7;
  --card: #ffffff;
  --edge: #dde0e6;
  --text: #1d2129;
  --muted: #646b78;
  --input: #f6f7f9;
  --raised: #eef0f4;
  --raised-hover: #e3e6ec;
  --row: #f4f5f8;
  --side: #ffffff;
  --blue: #2f7ad0;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.1rem 0 .5rem; }
a { color: var(--blue); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; margin-top: .6rem; }
.small-line { font-size: .8rem; display: block; }
.error { color: #ff7b6e; min-height: 1.2em; margin: .5rem 0 0; }
kbd { background: var(--raised); border: 1px solid var(--edge); border-radius: 5px; padding: 0 .4rem; font-size: .85rem; }

input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--input); border: 1px solid var(--edge);
  border-radius: 8px; padding: .55rem .7rem;
}
input, textarea { width: 100%; }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
button { cursor: pointer; background: var(--raised); }
button:hover { background: var(--raised-hover); }
button:disabled { opacity: .5; cursor: wait; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.warn { border-color: var(--warn); }
button.danger { background: var(--accent); border-color: var(--accent); color: #fff; }
.small-btn { padding: .3rem .6rem; font-size: .85rem; }
.button-link { display: inline-block; margin-top: .8rem; }

/* ---------------- login ---------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card.login-card { width: min(400px, 100%); display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; padding: 0 1.2rem 1.2rem; overflow: hidden; }
.login-card .field { margin-top: .2rem; }
.login-card button[type=submit] { margin-top: .4rem; }
.login-photo { margin: 0 -1.2rem .4rem; min-height: 1.2rem; }
.login-photo img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.brand { display: flex; align-items: center; gap: .9rem; }
.brand h1, .brand h2 { margin: 0; }
.brand-icon { border-radius: 14px; flex: none; background: var(--input); }

/* ---------------- layout: sidebar + content ---------------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--side);
  border-right: 1px solid var(--edge); display: flex; flex-direction: column; padding: 1rem .8rem;
}
.side-brand { display: flex; align-items: center; gap: .7rem; padding: 0 .4rem .9rem; border-bottom: 1px solid var(--edge); margin-bottom: .6rem; }
.side-brand .brand-icon { border-radius: 10px; }
.side-brand strong { display: block; line-height: 1.2; }
.nav { display: grid; gap: .15rem; }
.nav-group { margin: .8rem .5rem .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.nav button {
  display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left; background: none;
  border: none; border-radius: 8px; padding: .5rem .6rem; color: var(--text);
}
.nav button:hover { background: var(--raised); }
.nav button.active { background: rgba(61, 139, 217, .18); color: var(--blue); font-weight: 600; }
.nav .ico { width: 1.2rem; text-align: center; opacity: .85; }
.side-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--edge); display: grid; gap: .5rem; }
.side-foot .me { margin: 0; font-size: .85rem; color: var(--muted); }

.content { min-width: 0; padding: 0 1.25rem 2rem; }
.topbar {
  position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: .75rem;
  padding: .8rem 0; background: var(--bg); border-bottom: 1px solid var(--edge); margin-bottom: 1rem;
}
.page-title { margin: 0; font-size: 1.25rem; flex: 1; }
.global-search { width: min(320px, 40vw); }
.icon-btn { display: none; font-size: 1.1rem; padding: .35rem .6rem; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 9; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); z-index: 10;
    transform: translateX(-102%); transition: transform .2s ease;
  }
  body.nav-open .sidebar { transform: none; }
  .icon-btn { display: inline-block; }
  .global-search { width: auto; flex: 1; }
  .page-title { display: none; }
  .content { padding: 0 .8rem 2rem; }
}

/* ---------------- overview ---------------- */
.hero { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; border: 1px solid var(--edge); background: var(--card); min-height: 220px; display: flex; align-items: flex-end; }
.hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(15, 17, 21, .92), rgba(15, 17, 21, .35) 70%, rgba(15, 17, 21, .15)); }
.hero-body { position: relative; width: 100%; padding: 1.1rem 1.2rem; display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; color: #eceef3; }
.hero .muted { color: #c9ced8; }
.hero-title { color: #fff; }
.auto { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: #dfe3ea; }
.me { margin: .2rem 0 0; font-size: .85rem; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); }
select { max-width: 100%; }
.field { min-width: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--edge); border-radius: var(--radius); padding: .75rem .95rem; display: grid; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.chart { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--blue); opacity: .75; }
.chart .bar.today { opacity: 1; }
.chart .grid-line { stroke: var(--edge); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .axis-y { text-anchor: end; }
.chart .axis-x { text-anchor: middle; }

.health { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.health li { display: flex; align-items: center; gap: .55rem; }
.health li::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; flex: none; }
.health li.good::before { background: var(--ok); }
.health li.bad::before { background: var(--warn); }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }

/* ---------------- cards and lists ---------------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--edge); border-radius: var(--radius); padding: 1.1rem; min-width: 0; }
.wide { grid-column: 1 / -1; }
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr; } }

.row { display: flex; gap: .5rem; }
.field { display: grid; gap: .3rem; margin-top: .8rem; color: var(--muted); font-size: .9rem; }
.buttons { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.buttons.tight { gap: .35rem; margin-top: .4rem; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

.player-top { display: flex; gap: 1.2rem; align-items: flex-start; margin-top: 1rem; }
.player-main { flex: 1; min-width: 0; }
.avatar-full { border-radius: 12px; background: var(--input); flex: none; }
.player-head { display: flex; gap: 1rem; align-items: center; }
.player-head img { border-radius: 50%; background: var(--input); }
.description { white-space: pre-wrap; color: var(--muted); font-size: .9rem; border-left: 3px solid var(--edge); padding-left: .7rem; margin: .8rem 0 0; max-height: 8rem; overflow: auto; }
.warn-note { color: #ffb4aa; background: rgba(231, 76, 60, .14); border-radius: 8px; padding: .4rem .6rem; margin: .6rem 0 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 1rem 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts.compact { margin-top: .5rem; font-size: .92rem; }

.chips-wrap { margin-top: .7rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: .2rem .7rem; font-size: .85rem; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.list li { background: var(--row); border-radius: 8px; padding: .5rem .7rem; display: flex; justify-content: space-between; gap: .75rem; align-items: center; flex-wrap: wrap; }
.list li.failed { border-left: 3px solid var(--accent); }
.list .when { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.list .seen { color: var(--muted); font-size: .85rem; }
.list-text { min-width: 0; overflow-wrap: anywhere; }
.row-buttons { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.row-buttons button { padding: .35rem .7rem; }
button.link { background: none; border: none; padding: 0; color: var(--blue); text-decoration: underline; }
.spaced { margin-top: .5rem; }
.list .empty { background: none; color: var(--muted); padding: 0; }
.plain { margin: 0; padding-left: 1.1rem; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: .4rem .5rem; border-bottom: 1px solid var(--edge); }
.table td { padding: .4rem .5rem; border-bottom: 1px solid var(--edge); }
.table td:first-child { font-variant-numeric: tabular-nums; width: 4rem; }
.table td:last-child { text-align: right; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.game-card { padding: 0; overflow: hidden; }
.game-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--input); }
.game-body { padding: 1rem 1.1rem; }
.game-body h3 { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }

@media (max-width: 600px) {
  .hero { min-height: 190px; }
  .row { flex-direction: column; }
  .buttons > * { flex: 1 1 auto; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: .4rem; }
  .player-top { flex-direction: column; }
  .avatar-full { width: 120px; height: 120px; }
  .quick { grid-template-columns: 1fr; }
}

.toast { position: sticky; top: 4.2rem; z-index: 5; padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
/* Solid backgrounds, so the message stays readable when it floats over the page. */
.toast.ok { background: linear-gradient(rgba(63, 191, 116, .16), rgba(63, 191, 116, .16)), var(--card); border-color: var(--ok); }
.toast.bad { background: linear-gradient(rgba(231, 76, 60, .16), rgba(231, 76, 60, .16)), var(--card); border-color: var(--accent); }

/* Staff accounts and their access */
.accounts li { align-items: flex-start; }
.accounts li.off .list-text strong { opacity: .6; }
.tag { display: inline-block; margin: 0 .35rem; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; background: var(--raised); color: var(--muted); vertical-align: 1px; font-weight: 600; }
.tag.owner, .tag.full { background: rgba(70, 140, 255, .18); color: #6ea6f5; }
.tag.moderator { background: rgba(60, 180, 120, .18); color: #4fbf85; }
.tag.helper, .tag.custom { background: rgba(240, 180, 60, .16); color: #d9a13b; }
.tag.off { background: rgba(230, 80, 70, .18); color: #ef7a70; }
.access-editor { flex-basis: 100%; margin-top: .6rem; padding: .8rem; border: 1px solid var(--edge); border-radius: 10px; background: rgba(127, 127, 127, .04); }
.switch-row { display: flex; align-items: center; gap: .55rem; font-weight: 600; margin-bottom: .6rem; }
.presets { align-items: center; margin-bottom: .6rem; }
.presets button { padding: .3rem .65rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .35rem .9rem; }
.perm { display: flex; align-items: flex-start; gap: .5rem; padding: .3rem 0; line-height: 1.3; }
.access-editor input[type=checkbox] { width: 1.1rem; height: 1.1rem; margin: .1rem 0 0; flex: none; accent-color: var(--blue); }

/* Discord invites and the setup page */
.setup-intro { margin: .3rem 0 0; line-height: 1.5; }
.invite-result { margin-top: .8rem; padding: .8rem; border: 1px solid var(--edge); border-radius: 10px; background: rgba(61, 139, 217, .08); }
.invite-result p { margin: 0 0 .5rem; }
.invite-result input { font-size: .85rem; }
.note-warn { color: var(--warn); }
.preview { margin: .7rem 0 0; padding: .6rem .75rem; border-left: 3px solid var(--warn); background: rgba(230, 162, 60, .08); border-radius: 0 8px 8px 0; font-size: .92rem; }
.preview:empty { display: none; }
.verify-box { margin-top: .4rem; padding: .8rem .9rem; border: 1px solid var(--warn); border-radius: 10px; background: rgba(230, 162, 60, .1); }
.verify-box ol { margin: .5rem 0 .8rem; padding-left: 1.2rem; display: grid; gap: .3rem; }
.verify-box code, .verified-line code { background: var(--raised); padding: 0 .3rem; border-radius: 4px; }
.verified-line { margin: .3rem 0 0; color: var(--ok); font-weight: 600; }

/* Shift and training slots */
.times { display: grid; gap: .4rem; margin-bottom: .4rem; }
.time-row { display: flex; gap: .4rem; align-items: center; }
.time-row input { flex: 1; min-width: 0; }
.time-row button { padding: .35rem .65rem; }
.list.slots li { display: block; }
.slot-top { display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; }
.team { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.spot { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .35rem .2rem .65rem; border-radius: 999px; background: var(--raised); font-size: .88rem; border: 1px solid transparent; }
.spot.open { border: 1px dashed var(--warn); color: var(--muted); }
.spot.mine { border-color: var(--ok); }
.spot .role { color: var(--muted); }
.spot button { padding: .12rem .55rem; font-size: .8rem; border-radius: 999px; }
.spot:not(:has(button)) { padding-right: .65rem; }
.list li.day-head { background: none; padding: .6rem 0 0; font-weight: 700; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.list li.day-head:first-child { padding-top: 0; }

/* Who's in game now */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.card-head h3 { margin: 0; }
#liveFilter { width: 100%; margin-top: .3rem; }
.live-games { display: grid; gap: 1rem; }
.live-game h4 { margin: 0 0 .4rem; display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.live-server { background: var(--raised); border-radius: 10px; padding: .6rem .75rem; margin-bottom: .5rem; }
.live-server-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.live-server-head strong { color: var(--text); }
.live-players { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.live-players button { padding: .2rem .6rem; border-radius: 999px; font-size: .85rem; }
.live-players button.match { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.live-players button .since { color: var(--muted); margin-left: .3rem; font-size: .78rem; }
.running-time { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Add-ons */
.grid.addons { align-items: start; }
.addon .addon-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.addon .addon-head h3 { margin: 0; }
.addon.on { border-color: var(--ok); }
.addon .switch { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; white-space: nowrap; cursor: pointer; }
.addon .switch input { width: 2.6rem; height: 1.4rem; appearance: none; -webkit-appearance: none; background: var(--raised); border: 1px solid var(--edge); border-radius: 999px; position: relative; cursor: pointer; transition: background .15s; flex: none; }
.addon .switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: var(--muted); transition: left .15s, background .15s; }
.addon .switch input:checked { background: var(--ok); border-color: var(--ok); }
.addon .switch input:checked::after { left: calc(100% - 1.05rem - 2px); background: #fff; }
.addon .needs { font-size: .85rem; color: var(--warn); margin: .4rem 0 0; }
.addon details { margin-top: .6rem; }
.addon details summary { cursor: pointer; font-weight: 600; }
.addon .rolemap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: .35rem .6rem; align-items: center; font-size: .9rem; }
.addon .roles-pick { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .9rem; }
.addon .roles-pick label { display: inline-flex; gap: .3rem; align-items: center; }
.addon .field-help { font-size: .8rem; color: var(--muted); margin-top: .15rem; display: block; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--edge); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.status-met { color: var(--ok); font-weight: 700; }
.status-short { color: var(--warn); font-weight: 700; }
.status-leave { color: var(--muted); font-weight: 700; }
.answers dt { font-weight: 600; margin-top: .4rem; }
.answers dd { margin: .1rem 0 0; white-space: pre-wrap; }
.addon .switch-row { flex-wrap: wrap; }
.addon .switch-row .field-help { flex-basis: 100%; font-weight: 400; margin-top: 0; }
.proof { border: 1px solid var(--edge); border-radius: 10px; padding: .8rem; }
.proof-code { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.proof-code code { font-size: 1.05rem; padding: .35rem .6rem; border-radius: 8px; background: var(--edge); user-select: all; word-break: break-word; }
