/* CMB Index: the redesigned look (dark, monochrome, hairlines). Used by pages on partials/site-head.ejs; the rest
   still use style.css until they are redesigned. Faction colour appears only as small squares. */
@font-face { font-family: Geist; src: url("/fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Combine Alphabet"; src: url("/fonts/combine.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #000;
  --surface: #0a0a0a;
  --raised: #111;
  --line: #1f1f1f;
  --line-soft: #161616;
  --line-strong: #2e2e2e;
  --fg: #ededed;
  --soft: #a1a1a1;
  --dim: #8f8f8f;
  --faint: #454545;
  --red: #ff8a8e;
  --red-line: rgb(255 97 102 / .42);
  --red-soft: rgb(255 97 102 / .1);
  --amber: #f5b54a;
  --amber-line: rgb(245 181 74 / .4);
  --amber-soft: rgb(245 181 74 / .08);
  --green: #45d483;
  --sans: Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --top-h: 64px;
  --pop-shadow: none; /* tooltips, menus, dropdowns: flat, the border alone sets them apart */
  --page: 1600px;
  color-scheme: dark;
  /* Thin dark scrollbars everywhere (Chrome, Edge and Firefox use these; Safari uses the ::-webkit rules below). */
  scrollbar-width: thin;
  scrollbar-color: #333 var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* the attribute wins over any component's display (closed popovers, empty states) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2e2e2e; border: 2px solid var(--bg); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #474747; }
::-webkit-scrollbar-corner { background: transparent; }
::selection { background: rgb(237 237 237 / .9); color: #000; }

html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--fg);
  font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
main { flex: 1 0 auto; }
a { color: var(--fg); text-decoration: none; }
a:hover { color: #fff; }
:focus-visible { outline: 2px solid #ededed; outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { margin: 0; }
.mono { font-family: var(--mono); }
.dim { color: var(--dim); }
.soft { color: var(--soft); }
.spacer { flex: 1 1 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--fg); color: #000; border-radius: 6px; }
.skip:focus { top: 12px; color: #000; }
.wrap { width: 100%; max-width: var(--page); margin: 0 auto; padding: 0 32px; }
.sq { display: inline-block; width: 8px; height: 8px; flex: none; }
/* Faction logos (views/partials/logo.ejs): one-colour logos are a mask tinted with the faction colour (--faction);
   multi-colour ones are shown as they are. */
.logo-mark {
  display: inline-block; flex: none; width: 18px; height: 18px; background: var(--faction, currentColor);
  -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat;
}
.logo-img { flex: none; width: 18px; height: 18px; object-fit: contain; }
.logo-lg { width: 60px; height: 60px; }

/* ---------- Buttons, chips, menus ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--fg);
  font: 500 14px/1 var(--sans); white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
/* An open menu summary uses that button's hover. Variant selectors follow the plain one so they win. */
.btn:hover,
.menu[open] > summary.btn { background: #141414; border-color: #474747; color: #fff; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--fg); border-color: var(--fg); color: #0a0a0a; }
.btn-primary:hover,
.menu[open] > summary.btn-primary { background: #fff; border-color: #fff; color: #000; }
.btn-icon { width: 36px; padding: 0; }
.btn-ghost { border-color: transparent; background: none; color: var(--soft); }
.btn-ghost:hover,
.menu[open] > summary.btn-ghost { background: #1a1a1a; border-color: transparent; color: var(--fg); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.link { color: var(--fg); }
.chip { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 4px; font: 12px/1 var(--mono); color: var(--soft); white-space: nowrap; }

.menu { position: relative; flex: none; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
/* A menu panel holds a small form (filters, Add manager); .menu-list makes it a list of links. */
.menu-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 240px; display: grid; gap: 14px; padding: 14px;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--pop-shadow);
}
.menu-end { left: auto; right: 0; }
.menu-list { gap: 2px; padding: 6px; max-height: min(60vh, 440px); overflow: auto; }
.menu-list a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 5px; color: var(--soft); white-space: nowrap; }
.menu-list a > span:first-of-type { flex: 1; }
.menu-list a:hover, .menu-list a:focus-visible { background: #1a1a1a; color: var(--fg); }
.menu-list a svg { width: 16px; height: 16px; flex: none; color: var(--dim); }
.menu-list .mono, .menu-list .num { font: 12px var(--mono); color: var(--dim); }
.form-panel { width: min(400px, calc(100vw - 32px)); }
.filter-grid { grid-template-columns: repeat(2, minmax(170px, 1fr)); min-width: min(400px, calc(100vw - 32px)); }
.menu-label { white-space: nowrap; }
.menu-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 4px; background: var(--fg); color: #000; font: 600 11px/1 var(--mono); }
.menu-count[hidden] { display: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--line);
  background: rgb(0 0 0 / .82); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.top-in { min-height: var(--top-h); display: flex; align-items: center; gap: 14px; flex-wrap: nowrap; }
html.combine {
  --sans: "Combine Alphabet", Geist, ui-sans-serif, system-ui, sans-serif;
  --mono: "Combine Alphabet", "Geist Mono", ui-monospace, monospace;
}
[data-combine-logo] { cursor: pointer; }
.combine-off { display: none; height: 22px; padding: 0 7px; font-family: Geist, sans-serif; }
html.combine .combine-off { display: inline-flex; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; font-weight: 600; font-size: 15px; letter-spacing: -.01em; color: var(--fg); white-space: nowrap; }
.brand svg { width: 22px; height: 22px; flex: none; }
.slash { color: #3a3a3a; font-weight: 300; font-size: 22px; line-height: 1; }
.crumb { display: flex; align-items: center; gap: 8px; color: var(--soft); font-weight: 500; }
.nav { display: flex; gap: 2px; margin-left: 16px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: inline-flex; align-items: center; gap: 7px; flex: none; padding: 6px 12px; border-radius: 6px; color: var(--soft); font: 500 12.5px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.nav a svg { width: 14px; height: 14px; flex: none; }
.nav a:hover { color: var(--fg); background: var(--raised); }
.nav a[aria-current="page"] { color: var(--fg); }
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { width: 24px; height: 24px; flex: none; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: #1f1f1f; color: var(--soft); font: 600 11px/1 var(--sans); }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.site-header form { margin: 0; }

/* ---------- Faction banner ---------- */
.hero { padding-top: 48px; padding-bottom: 40px; }
.frame { position: relative; border: 1px solid var(--line); }
.frame-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(#2a2a2a 1px, transparent 1px); background-size: 20px 20px;
  -webkit-mask-image: linear-gradient(90deg, transparent 35%, #000 100%); mask-image: linear-gradient(90deg, transparent 35%, #000 100%);
}
.cross { position: absolute; z-index: 1; width: 13px; height: 13px; }
.cross::before, .cross::after { content: ""; position: absolute; background: #6b6b6b; }
.cross::before { left: 6px; top: 0; width: 1px; height: 13px; }
.cross::after { left: 0; top: 6px; width: 13px; height: 1px; }
.cross.tl { top: -7px; left: -7px; }
.cross.tr { top: -7px; right: -7px; }
.cross.bl { bottom: -7px; left: -7px; }
.cross.br { bottom: -7px; right: -7px; }
.hero-main { position: relative; padding: 44px 40px 40px; display: flex; align-items: flex-end; gap: 32px; flex-wrap: wrap; }
.hero-copy { flex: 1 1 520px; min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font: 12px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.eyebrow b { font-weight: 500; color: var(--fg); }
.hero-title { display: flex; align-items: center; gap: 20px; min-width: 0; }
.hero h1 { font-size: 68px; line-height: 1; font-weight: 600; letter-spacing: -.05em; }
.lede { margin: 18px 0 0; max-width: 52ch; color: var(--soft); font-size: 16px; line-height: 1.55; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stats { position: relative; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border-top: 1px solid var(--line); }
.stat { padding: 20px 40px 22px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat dt { font: 12px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.stat dd { margin: 8px 0 0; display: flex; align-items: center; gap: 10px; font-size: 28px; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.region-counts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 16px 40px 18px; border-top: 1px solid var(--line); list-style: none; }
.region-count { display: inline-flex; align-items: baseline; gap: 8px; font: 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.region-count b { font-size: 16px; font-weight: 500; letter-spacing: -.02em; color: var(--fg); font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .stat { padding: 18px 24px; } .stat dd { font-size: 24px; white-space: nowrap; } } /* "10 min ago" stays on one line */
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgb(69 212 131 / .16); }
.live.stale { background: var(--amber); box-shadow: 0 0 0 3px rgb(245 181 74 / .16); }
.live.off { background: var(--red); box-shadow: 0 0 0 3px rgb(255 97 102 / .16); }
.btn .live { width: 7px; height: 7px; }

/* ---------- Faction tabs ---------- */
.tabs-bar { border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 12px 15px; color: var(--soft); white-space: nowrap;
  font: 500 12.5px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase;
}
.tab:hover { color: var(--fg); }
.tab[aria-current="page"] { color: var(--fg); }
.tab[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--fg); }
nav[aria-label="Management"] { flex-wrap: nowrap; }
nav[aria-label="Management"] .tab,
nav[aria-label="Management"] .menu { flex: none; }
nav[aria-label="Management"] .tab { gap: 7px; }
nav[aria-label="Management"] .tab svg { width: 14px; height: 14px; flex: none; }
nav[aria-label="Management"] .menu > summary { cursor: pointer; }
nav[aria-label="Management"] .tab-chevron { display: inline-flex; opacity: .65; }
nav[aria-label="Management"] .menu[open] > summary { color: var(--fg); }
nav[aria-label="Management"] .menu[open] .tab-chevron { transform: rotate(180deg); }
nav[aria-label="Management"] .menu-panel { top: calc(100% - 6px); }
nav[aria-label="Management"] .menu:last-child .menu-panel { left: auto; right: 0; }
nav[aria-label="Management"] .menu-list a[aria-current="page"] { color: var(--fg); background: #1a1a1a; }

/* Faction switch: a full-screen radar overlay. Colour comes from the faction accent.
   .out is the load; html.switching collapses it once the bar reaches the new page. */
.switch-loader { display: none; }
.switch-loader.out, html.switching .switch-loader {
  position: fixed; inset: 0; z-index: 80; display: block; overflow: hidden; background: #000; color: var(--accent);
}
.switch-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 13%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 13%, transparent) 1px, transparent 1px);
  background-size: 96px 96px;
}
.switch-bracket { position: absolute; z-index: 3; width: 22px; height: 22px; pointer-events: none; }
.switch-bracket::before, .switch-bracket::after { content: ""; position: absolute; background: var(--accent); }
.switch-bracket::before { width: 1.5px; height: 100%; }
.switch-bracket::after { height: 1.5px; width: 100%; }
.switch-bracket.tl { top: 26px; left: 26px; }
.switch-bracket.tl::before, .switch-bracket.tl::after { top: 0; left: 0; }
.switch-bracket.tr { top: 26px; right: 26px; }
.switch-bracket.tr::before, .switch-bracket.tr::after { top: 0; right: 0; }
.switch-bracket.bl { bottom: 26px; left: 26px; }
.switch-bracket.bl::before, .switch-bracket.bl::after { bottom: 0; left: 0; }
.switch-bracket.br { bottom: 26px; right: 26px; }
.switch-bracket.br::before, .switch-bracket.br::after { bottom: 0; right: 0; }
/* Ring centre matches the Airwatch comp (frame 512,191 of 1024×576). */
.switch-orbit {
  position: absolute; z-index: 1; left: 50%; top: 33.16%; width: 33.33vh; aspect-ratio: 1;
  transform: translate(-50%, -50%); pointer-events: none;
}
.switch-rings { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.switch-rings circle { fill: none; stroke: currentColor; }
.ring-dot { stroke-width: 0.55; stroke-linecap: round; stroke-dasharray: 0.01 5.4; }
.switch-orbit canvas {
  position: absolute; left: 50%; top: 50%; width: 78%; height: 78%; transform: translate(-50%, -50%); display: block;
}
.switch-copy {
  position: absolute; z-index: 2; left: 50%; top: calc(33.16% + 16.67vh + 4.6vh); transform: translateX(-50%);
  width: min(920px, calc(100% - 64px)); display: flex; flex-direction: column; align-items: center; text-align: center;
  pointer-events: none;
}
.switch-name {
  margin: 0; font: 600 clamp(32px, 5.1vh, 56px)/1 var(--sans); letter-spacing: -.045em; color: #fff; white-space: nowrap;
}
.switch-status {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 3.4vh 0 0;
  font: 500 11px/1 var(--mono); text-transform: uppercase; color: #f2f2f2;
}
.switch-status i { width: 6px; height: 6px; flex: none; background: var(--accent); }
.switch-status [data-switch-status] { letter-spacing: .2em; }
.switch-caret { letter-spacing: 0; margin-left: 1px; color: #fff; }
.switch-meter { position: relative; width: min(420px, 44vw); margin-top: 5vh; }
.switch-track { height: 2px; background: color-mix(in srgb, var(--accent) 32%, transparent); }
.switch-track i {
  display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left center; background: var(--accent);
}
.switch-pct {
  position: absolute; right: 0; bottom: 8px; font: 500 11px/1 var(--mono); letter-spacing: .04em; color: var(--accent);
}
.switch-loader.out { animation: switch-fade .18s ease-out both; }
html.switching .switch-loader { animation: switch-done .42s cubic-bezier(.7, 0, .84, 0) .12s forwards; }
@keyframes switch-fade { from { opacity: 0; } }
@keyframes switch-blink { 50% { opacity: 0; } }
@keyframes switch-done {
  0% { clip-path: inset(0 0 0 0); }
  60% { clip-path: inset(calc(50% - 1px) 0 calc(50% - 1px) 0); }
  100% { clip-path: inset(calc(50% - 1px) 50% calc(50% - 1px) 50%); visibility: hidden; }
}

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 20px 0; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 360px; max-width: 460px; }
.search > svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--dim); pointer-events: none; }
.search input {
  width: 100%; height: 36px; padding: 0 40px 0 38px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--fg); font: 14px var(--sans); outline: none;
}
.search input::placeholder { color: var(--dim); }
.search input:focus { border-color: #6b6b6b; box-shadow: 0 0 0 3px rgb(255 255 255 / .08); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { position: absolute; right: 8px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--raised); color: var(--soft); font: 11px/1 var(--mono); }
.result { font: 13px/1 var(--mono); color: var(--dim); }

/* Themed dropdowns (public/controls.js turns select.select into a button plus a listbox popover). */
select.select { height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--fg); font: 500 14px var(--sans); }
.dd { position: relative; display: inline-block; min-width: 0; }
.dd-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.select.dd-button {
  display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px 0 14px; max-width: 260px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--fg);
  font: 500 14px/1 var(--sans); text-align: left; cursor: pointer;
}
.select.dd-button:hover { background: #141414; border-color: #474747; }
.dd-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-button::after { content: ""; flex: none; width: 6px; height: 6px; border: solid var(--dim); border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.dd-button[aria-expanded="true"]::after { transform: translateY(2px) rotate(-135deg); }
.dd-list {
  position: fixed; z-index: 50; margin: 0; padding: 6px; list-style: none; max-width: min(440px, calc(100vw - 16px)); max-height: min(320px, 50vh);
  overflow: auto; overscroll-behavior: contain; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: var(--pop-shadow);
}
.dd-list li { padding: 8px 10px; border-radius: 5px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.dd-list li[aria-selected="true"] { color: var(--fg); font-weight: 500; }
.dd-list li:hover, .dd-list li.active { background: #1a1a1a; color: var(--fg); }

/* ---------- Roster ---------- */
.roster-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-bottom: 72px; } /* never wider than the page */
.empty { padding: 56px 20px; border: 1px solid var(--line); background: var(--surface); text-align: center; color: var(--soft); }
.rank { border: 1px solid var(--line); background: var(--surface); }
.rank-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--top-h) + 16px); }
.rank-head .idx { font: 12px/1 var(--mono); color: var(--dim); }
.rank-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.rank-stats { display: flex; gap: 20px; margin: 0; font: 12px/1.2 var(--mono); }
.rank-stats div { display: flex; gap: 6px; }
.rank-stats dt { color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.rank-stats dd { margin: 0; color: var(--fg); }
.rank.danger .idx, .rank.danger h2 { color: var(--red); }

.table-wrap { overflow: visible; } /* tables fit the page; narrow screens switch to cards (no sideways scrolling) */
.grid { width: 100%; border-collapse: collapse; }
.grid th {
  position: sticky; top: var(--top-h); z-index: 2; padding: 12px; background: var(--surface); border-bottom: 1px solid var(--line);
  text-align: left; font: 500 11px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--dim); white-space: nowrap;
}
.grid td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; vertical-align: middle; }
@media (min-width: 1200px) { /* table mode: line the first and last columns up with the rank header */
  .grid th:first-child, .grid td:first-child { padding-left: 20px; }
  .grid th:last-child, .grid td:last-child { padding-right: 20px; }
  .grid td.name, .grid:has(td.name) th:first-child { text-align: right; } /* designations right-aligned: unit numbers line up */
  .grid td.notes { max-width: 0; width: 24%; } /* long notes clip (full text on hover) instead of widening the table */
  .grid td.name { width: 1%; } /* the designation column hugs its content (the roster sets its own widths) */
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--raised); }
.grid .c { text-align: center; }
.grid th.dept, .grid td.dept, .grid th.notes, .grid td.notes { text-align: center; } /* Division and Notes, header and cells */
/* RC / DRC band: a crown-gold edge on their rows (an inset shadow, so no column shifts). Its last row keeps the usual
   row divider while rows below it are showing (filters). */
@media (min-width: 1200px) {
  .grid tr.lead td:first-child { box-shadow: inset 2px 0 0 #e8c15a; }
}
@media (max-width: 1199px) {
  .grid tr.lead { box-shadow: inset 2px 0 0 #e8c15a; }
}
@media (min-width: 1200px) { .grid td:empty::after { content: "—"; color: var(--faint); } } /* table mode: blank sheet cells */
.grid.aligned td { overflow: hidden; text-overflow: ellipsis; } /* only bites when a column had to give up room */
.grid.aligned td.dept,
.grid.aligned td:has(.pill) { overflow: visible; text-overflow: clip; } /* pills and division marks stay whole */
.grid td.mono { font: 13px var(--mono); color: var(--soft); }
.grid td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.grid td.strong { color: var(--fg); font-weight: 500; }
.grid td.muted { color: var(--dim); }
.callsign { font-weight: 500; color: var(--fg); text-transform: uppercase; letter-spacing: .03em; }
.grid td.name a { color: inherit; text-decoration: none; }
/* The unit number takes its faction's colour (--faction, set by the page or card holding the unit). */
.unit-no {
  margin-left: 8px; padding: 1px 5px; border: 1px solid var(--line-strong); border-radius: 4px; font: 12px var(--mono);
  color: var(--faction, var(--soft)); border-color: color-mix(in srgb, var(--faction, #a1a1a1) 38%, transparent);
  background: color-mix(in srgb, var(--faction, #a1a1a1) 7%, transparent);
}
.dash { color: var(--faint); }
.yes { color: var(--green); }
.no { color: var(--faint); }
.yes svg, .no svg { width: 16px; height: 16px; vertical-align: -3px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 4px;
  background: var(--raised); font: 500 11.5px/1 var(--mono); color: var(--soft); white-space: nowrap;
}
.badge-danger { border-color: var(--red-line); background: var(--red-soft); color: var(--red); }
.badge-leave { border-color: var(--amber-line); background: var(--amber-soft); color: var(--amber); }
.badge-accent { border-color: #474747; color: var(--fg); }
.badge.has-tip { cursor: help; } /* hover for the details */
.pill-row { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
td.c .pill-row { justify-content: center; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--raised); font: 12px/1 var(--mono); color: var(--fg); }
.pill-warn { border-color: var(--amber-line); background: var(--amber-soft); color: var(--amber); }
.pill-lead { gap: 5px; border-color: rgb(232 193 90 / .4); } /* RC / DRC: faction management */
.pill-lead svg { width: 12px; height: 12px; flex: none; color: #e8c15a; }
.div-mark { display: inline-flex; align-items: center; gap: 6px; line-height: 1; vertical-align: middle; }
.div-mark svg, .div-mark .div-ico { display: block; width: 16px; height: 16px; flex: none; color: var(--soft); }
.div-mark.div-color { gap: 5px; height: 22px; padding: 0 6px; border: 1px solid color-mix(in srgb, var(--div) 40%, transparent); border-radius: 4px; background: color-mix(in srgb, var(--div) 8%, transparent); font: 12px/1 var(--mono); color: var(--fg); }
.div-mark.div-color svg, .div-mark.div-color .div-ico { width: 12px; height: 12px; color: var(--div); }
.div-mark.div-color .logo-mark { background: var(--div); }
.div-ico { object-fit: contain; }

/* Long free text stays on one line; the full text opens in a popup on hover, focus or tap (see app.js). */
.clip { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--soft); }
.clip.is-clipped { cursor: help; }
.cell-tip {
  position: fixed; z-index: 70; max-width: min(380px, calc(100vw - 32px)); padding: 10px 12px; pointer-events: none;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: var(--pop-shadow);
  color: var(--fg); font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Narrow screens: every table row becomes a card of labelled fields, so nothing scrolls sideways.
   Labels come from each column's header (data-label, set in app.js). */
@media (max-width: 1199px) {
  .grid, .grid thead, .grid tbody, .grid tr, .grid th, .grid td { display: block; }
  .grid thead { display: none; }
  .grid tbody tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px 16px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
  .grid tbody tr:last-child { border-bottom: 0; }
  .grid tbody tr > td, .grid tbody tr:hover > td, .grid tbody td.c { padding: 0; border: 0; background: none; text-align: left; }
  .grid tbody td.dept, .grid tbody td.notes { text-align: center; } /* Division and Notes stay centred in the card */
  .grid tbody td { white-space: normal; overflow-wrap: anywhere; } /* long Discord names wrap inside the card */
  .grid tbody tr:hover { background: var(--raised); }
  .grid td::before { content: attr(data-label); display: block; margin-bottom: 4px; font: 500 10.5px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
  .grid td:empty, .grid td[data-label=""]::before { display: none; }
  .grid td.name, .grid td.notes { grid-column: 1 / -1; }
  .grid td.name::before { display: none; }
  .grid td.name .callsign { font-size: 16px; }
  .grid .clip { white-space: normal; }
}

/* ---------- Pages: head, cards, lists, notices (unit hub, apply) ---------- */
.page { padding-top: 44px; padding-bottom: 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { font-size: 44px; line-height: 1.05; font-weight: 600; letter-spacing: -.04em; }
.page-head p { margin: 12px 0 0; max-width: 62ch; color: var(--soft); font-size: 15px; }
.page-head p strong { color: var(--fg); font-weight: 500; }
.page-head .eyebrow { margin-bottom: 16px; }
.page-head h1 .callsign { font-size: inherit; font-weight: inherit; letter-spacing: -.02em; }
.page-head h1 .unit-no { margin-left: 12px; padding: 2px 8px; font-size: 22px; }
/* Large designations: the number tag centred on the callsign, not sitting on its baseline. */
.unit-title, .page-head h1:has(.unit-no) { display: flex; align-items: center; }
.unit-title .unit-no { margin-left: 10px; }
.eyebrow a { color: var(--dim); }
.eyebrow a:hover { color: var(--fg); }
.layout-split { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.layout-split > .span-all { grid-column: 1 / -1; }
.idea-log { border-top: 1px solid var(--line); }
.stack { display: grid; gap: 16px; align-content: start; }
.stack-lg { display: grid; gap: 20px; align-content: start; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card { min-width: 0; border: 1px solid var(--line); background: var(--surface); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card-desc { margin: 2px 0 0; font-size: 13px; color: var(--dim); }
.card-body { padding: 20px; }

/* CMB Manual. Headings are bars so a section is easy to spot. Green, amber, and red mark state, the way the old sheet used color, in this site's palette. */
.page[data-manual] .page-head { margin-bottom: 16px; }
.page[data-manual] .page-head h1 { font-size: 32px; }
.manual-bar {
  position: sticky; top: var(--top-h); z-index: 5; display: flex; align-items: center; gap: 16px;
  margin: 0 -32px 16px; padding: 12px 32px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.manual-layout { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 32px; align-items: start; }
.page[data-manual]:has([data-manual-empty]:not([hidden])) .manual-layout { display: none; }
.page[data-manual] .empty { margin-top: 8px; }
.manual-jumps {
  position: sticky; top: calc(var(--top-h) + 61px); display: flex; flex-direction: column; gap: 4px;
  max-height: calc(100dvh - var(--top-h) - 77px); overflow: auto;
}
.manual-jumps a { padding: 8px 10px; border-radius: 4px; font: 500 13px/1.3 var(--sans); color: var(--soft); }
.manual-jumps a:hover,
.manual-jumps a[aria-current="location"] { background: var(--raised); color: var(--fg); }
.manual-main { min-width: 0; display: grid; gap: 16px; }
.manual-pack { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.manual-pack.is-masonry { display: block; position: relative; }
.manual-pack.is-masonry > .manual-chapter { position: absolute; }
.manual-chapter { width: 100%; min-width: 0; margin: 0; scroll-margin-top: 140px; }
.manual-chapter:target { border-color: var(--line-strong); }
.manual-chapter .card-header { padding: 12px 16px; }
.manual-chapter .card-body { padding: 4px 16px 12px; }
.manual-block h3 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  margin: 8px -16px 0; padding: 7px 16px; font-size: 14px; font-weight: 600; letter-spacing: 0; line-height: 1.35;
  color: var(--fg); background: var(--raised);
}
.manual-block h3 > span:first-child { min-width: 0; }
.manual-block h3 .badge { height: auto; min-height: 20px; max-width: 100%; padding: 3px 6px; white-space: normal; line-height: 1.3; text-align: right; }
.manual-block > p:not(.manual-note) { margin: 6px 0 0; font-size: 14px; line-height: 1.4; }
.manual-block > ul { margin: 6px 0 0; padding: 0 0 0 18px; display: grid; gap: 3px; }
.manual-block li { font-size: 14px; line-height: 1.4; }
.manual-block.tone-ok h3,
.manual-block.heading-ok h3 { color: var(--green); background: rgb(69 212 131 / .1); }
.manual-block.tone-mid h3,
.manual-block.heading-mid h3 { color: var(--amber); background: var(--amber-soft); }
.manual-block.tone-stop h3,
.manual-block.heading-stop h3 { color: var(--red); background: var(--red-soft); }
.manual-matrix-wrap { overflow-x: auto; max-width: 100%; }
.manual-matrix { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
.manual-matrix th, .manual-matrix td { padding: 8px 10px; border: 1px solid var(--line-strong); text-align: center; vertical-align: middle; }
.manual-matrix thead th { color: var(--fg); font-weight: 600; background: var(--raised); }
.manual-matrix thead th.tone-ok { color: var(--green); }
.manual-matrix thead th.tone-mid { color: var(--amber); }
.manual-matrix thead th.tone-stop { color: var(--red); }
.manual-matrix tbody th { text-align: left; color: var(--fg); font-weight: 500; }
.tone-ok { color: var(--green); }
.tone-mid { color: var(--amber); }
.tone-stop { color: var(--red); }
.tone-info { color: #7eb6ff; }
.manual-tip {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; padding: 0;
  border: 0; background: none; color: var(--dim); cursor: help; vertical-align: -2px;
}
.manual-tip:hover, .manual-tip:focus-visible { color: var(--fg); }
.manual-tip svg { width: 14px; height: 14px; }
.manual-matrix .manual-tip { vertical-align: -3px; }
.manual-items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; padding: 4px 0 2px; }
.manual-items p { margin: 0; font-size: 14px; line-height: 1.4; }
@media (max-width: 700px) { .manual-items { grid-template-columns: 1fr; } }
.manual-block:first-child h3 { margin-top: 4px; }
.manual-note { margin: 6px 0 0; color: var(--soft); font-size: 13px; line-height: 1.4; }
.manual-rows { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 16px; }
.manual-row {
  display: grid; grid-column: 1 / -1; grid-template-columns: max-content minmax(0, 1fr); column-gap: 16px;
  align-items: baseline; margin: 0 -16px; padding: 8px 16px; border-bottom: 1px solid var(--line);
}
@supports (grid-template-columns: subgrid) {
  .manual-row { grid-template-columns: subgrid; column-gap: unset; }
}
.manual-row:hover { background: var(--raised); }
.manual-row .mono { color: var(--fg); font-size: 13px; font-weight: 500; white-space: nowrap; }
.manual-row .mono.tone-ok { color: var(--green); }
.manual-row .mono.tone-mid { color: var(--amber); }
.manual-row .mono.tone-stop { color: var(--red); }
.manual-row .mono.tone-info { color: #7eb6ff; }
.manual-row > span:last-child { color: var(--fg); font-size: 14px; line-height: 1.45; }
.manual-row .badge { margin-left: 8px; vertical-align: 1px; }
.manual-row[hidden], .manual-block[hidden], .manual-chapter[hidden], .manual-jumps a[hidden] { display: none; }
@media (max-width: 900px) {
  .manual-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .manual-jumps { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; gap: 4px 8px; }
  .manual-pack { grid-template-columns: 1fr; }
  .manual-pack.is-masonry { display: grid; height: auto !important; }
  .manual-pack.is-masonry > .manual-chapter { position: static; width: auto !important; }
}
.card-body .notice { margin: 0; }
.card-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.card .empty { border: 0; background: none; }
.empty p { margin: 0; }
.center-panel { max-width: 560px; margin: 14vh auto 0; padding: 0 16px 72px; text-align: center; }
.center-panel h1 { font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -.03em; }
.center-panel p { margin: 12px 0 24px; color: var(--soft); }
.list-item { display: block; padding: 14px 20px; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--raised); }
.list-item p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--dim); }
.meta strong { color: var(--fg); font-weight: 500; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.notice { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding: 12px 16px; border: 1px solid var(--line-strong); background: var(--raised); font-size: 14px; }
.notice svg { width: 16px; height: 16px; flex: none; }
.notice-ok { border-color: rgb(69 212 131 / .35); background: rgb(69 212 131 / .06); color: var(--green); }
.notice-warn { border-color: var(--amber-line); background: var(--amber-soft); color: var(--amber); }
.hint { font-size: 12.5px; color: var(--dim); }
.unit-title .callsign { font-size: 22px; letter-spacing: -.02em; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; }
.facts dt { font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.facts dd { margin: 6px 0 0; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 18px 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: grid; gap: 8px; min-width: 0; align-content: start; }
.label { font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.input, .textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); color: var(--fg);
  font: 14px var(--sans); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input { height: 40px; padding: 0 12px; }
.input.mono { font: 13px var(--mono); }
.textarea { min-height: 104px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.input:focus, .textarea:focus { border-color: #6b6b6b; box-shadow: 0 0 0 3px rgb(255 255 255 / .08); }
.input::placeholder, .textarea::placeholder { color: var(--dim); }
.input[readonly] { background: var(--surface); color: var(--soft); cursor: default; }
.field .dd { display: block; }
.field .select.dd-button { width: 100%; max-width: none; height: 40px; background: var(--bg); }
.field select.select { width: 100%; height: 40px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.question { display: grid; gap: 10px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.question .q { font-size: 15px; font-weight: 500; line-height: 1.5; color: var(--fg); }
input.tick, .check input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; display: inline-grid; place-content: center; flex: none; width: 16px; height: 16px; margin: 0;
  border: 1px solid #5a5a5a; border-radius: 4px; background: var(--bg); vertical-align: middle; cursor: pointer;
}
input.tick::before, .check input[type="checkbox"]::before { content: ""; width: 10px; height: 10px; background: #000; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%); transform: scale(0); }
input.tick:checked, .check input[type="checkbox"]:checked { border-color: var(--fg); background: var(--fg); }
input.tick:checked::before, .check input[type="checkbox"]:checked::before { transform: scale(1); }
input.tick:indeterminate { border-color: var(--fg); background: linear-gradient(var(--fg), var(--fg)) center / 8px 2px no-repeat, var(--bg); }
input.tick:disabled, .check input[type="checkbox"]:disabled { opacity: .4; cursor: not-allowed; }

/* Date field (public/controls.js): text in the column's own format plus a calendar popover. */
.date-field { position: relative; display: block; }
.date-field .input { padding-right: 46px; }
.date-btn {
  position: absolute; top: 1px; right: 1px; bottom: 1px; width: 40px; display: grid; place-items: center; padding: 0;
  border: 0; border-left: 1px solid var(--line); border-radius: 0 5px 5px 0; background: none; color: var(--soft); cursor: pointer;
}
.date-btn:hover { background: var(--raised); color: var(--fg); }
.date-btn svg { width: 16px; height: 16px; }
.cal {
  position: fixed; z-index: 50; width: 272px; display: grid; gap: 8px; padding: 10px; margin: 0;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--pop-shadow);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-title { font: 600 13px/1 var(--sans); }
.cal-nav { width: 28px; height: 28px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: none; color: var(--fg); font: 16px/1 var(--sans); cursor: pointer; }
.cal-nav:hover { background: #1a1a1a; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font: 500 10.5px/24px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.cal-day { height: 32px; padding: 0; border: 1px solid transparent; border-radius: 5px; background: none; color: var(--fg); font: 13px var(--mono); cursor: pointer; }
.cal-day.other { color: var(--faint); }
.cal-day:hover { background: #1a1a1a; }
.cal-day.today { border-color: var(--line-strong); }
.cal-day.picked { background: var(--fg); color: #000; font-weight: 600; }
.cal-foot { display: flex; justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--line); }

/* Shift patrol form: a unit's feedback box opens once the unit is ticked. */
.patrol-table td.feedback { width: 100%; min-width: 280px; white-space: normal; }
.patrol-table .feedback .textarea { min-height: 64px; }
.patrol-table tr:not(:has(input.tick:checked)) .feedback .textarea { display: none; }
.patrol-table td.name label { cursor: pointer; }
.patrol-table .pick { width: 48px; }
@media (max-width: 1199px) {
  .grid.patrol-table td.feedback { grid-column: 1 / -1; min-width: 0; }
  .patrol-table tr:not(:has(input.tick:checked)) td.feedback { display: none; }
}
@media (max-width: 1000px) { .layout-split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Staff pages (Manage) ---------- */
.admin { padding-top: 32px; }
.tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 4px; background: var(--amber); color: #1a1205; font: 600 11px/1 var(--mono); }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; font: 12px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.back:hover { color: var(--fg); }
.back svg { width: 14px; height: 14px; }
.muted { color: var(--dim); }
.cell-strong { font-weight: 500; color: var(--fg); }
.inline { display: inline; }
.row-link { color: inherit; }
.row-link:hover { color: var(--fg); }
.grid .right { text-align: right; }
.grid td .row { flex-wrap: nowrap; gap: 8px; } /* logo + faction name stay on one line in a cell */
.grid td.name > .logo-mark, .grid td.name > .logo-img { margin-right: 10px; vertical-align: -4px; } /* faction logo before a unit name */
.result-count { font: 13px/1 var(--mono); color: var(--dim); white-space: nowrap; }
a.notice:hover { border-color: #474747; color: var(--fg); }
.notice-warn:is(a):hover { color: var(--amber); border-color: var(--amber); }
.badge svg { width: 12px; height: 12px; flex: none; }
.badge-ok { border-color: rgb(69 212 131 / .35); background: rgb(69 212 131 / .07); color: var(--green); }
.badge-warn { border-color: var(--amber-line); background: var(--amber-soft); color: var(--amber); }
.badge-solid { border-color: var(--fg); background: var(--fg); color: #000; }
.btn-danger { border-color: var(--red-line); background: var(--red-soft); color: var(--red); }
.btn-danger:hover,
.menu[open] > summary.btn-danger { border-color: var(--red); background: rgb(255 97 102 / .18); color: #ffb3b5; }
.card-danger { border-color: var(--red-line); }
.card-danger .card-title { color: var(--red); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.span-all { grid-column: 1 / -1; }
.hint.edited { color: var(--amber); }
.diff-new { color: var(--green); }
.review + .review { margin-top: 20px; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); align-items: start; }
.section { margin-bottom: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.section-head h2 { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.qa { display: grid; gap: 8px; }
.qa .q { font-weight: 500; color: var(--fg); }
.qa .a { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--soft); }

/* Checkboxes with a label, toggle chips (unit certifications) and the faction switch on New unit. */
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; font-size: 14px; cursor: pointer; }
.checks { display: grid; gap: 2px; }
.checks legend { margin-bottom: 6px; padding: 0; }
.checks .check { min-height: 30px; }
.check .logo-mark, .check .logo-img { width: 16px; height: 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-row .chip { position: relative; height: auto; padding: 0; border: 0; cursor: pointer; }
.chip-row .chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip-row .chip span {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px;
  font: 500 13px/1 var(--sans); color: var(--soft);
}
.chip-row .chip span::before { content: ""; width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 2px; }
.chip-row .chip:hover span { border-color: #474747; color: var(--fg); }
.chip-row .chip input:checked + span { border-color: var(--fg); background: #141414; color: var(--fg); }
.chip-row .chip input:checked + span::before { border-color: var(--fg); background: var(--fg); }
.chip-row .chip input:focus-visible + span { outline: 2px solid var(--fg); outline-offset: 2px; }
.chip-row .chip input:disabled + span { opacity: .5; cursor: not-allowed; }
.chip-row .chip.warn span { border-color: var(--amber-line); }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 8px; }
.segmented a { padding: 6px 12px; border-radius: 5px; color: var(--soft); font-size: 13px; }
.segmented a:hover { color: var(--fg); }
.segmented a.active { background: #1a1a1a; color: var(--fg); }

/* Overview: totals, one tile per faction (owner: colour and logo), rank movement and sync history. */
.overview-stats { margin-bottom: 20px; }
.overview-stats .stats { border-top: 0; }
.overview-stats dd a { color: inherit; }
.division-tiles { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin-bottom: 20px; }
.division-tile { display: grid; gap: 12px; align-content: start; padding: 18px 20px; }
.division-tile-head { display: flex; align-items: center; gap: 12px; color: var(--fg); }
.division-tile-head .cell-strong { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.division-tile-count { margin-left: auto; font: 500 26px/1 var(--mono); color: var(--fg); }
.logo-md { width: 28px; height: 28px; }
.file-btn { position: relative; cursor: pointer; }
.file-btn input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn:focus-within { outline: 2px solid var(--fg); outline-offset: 2px; }
input[type="color"] { width: 36px; height: 30px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }

/* Units: ticked rows open a bar for moving them into a division. */
.grid .pick { width: 44px; text-align: center; }
.batch-bar {
  position: fixed; left: 50%; bottom: 20px; z-index: 40; transform: translateX(-50%); max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 10px;
}
.batch-bar[hidden] { display: none; }
.batch-bar .dd, .batch-bar select.select { min-width: 220px; }
.batch-count { font: 12px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
.batch-bar .btn-danger { margin-left: auto; }

/* Applications: one card per applicant (avatar, status, key facts); the whole card opens the application. */
.app-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.app-card { position: relative; display: grid; gap: 16px; align-content: start; padding: 18px 20px; color: var(--fg); transition: border-color .15s, background .15s; }
.app-card:hover { border-color: #3a3a3a; background: var(--raised); color: var(--fg); }
.app-open { display: grid; gap: inherit; align-content: start; color: inherit; }
.app-open::after { content: ""; position: absolute; inset: 0; }
.app-open:hover, .app-open:focus-visible { color: inherit; }
.app-delete { position: absolute; z-index: 1; top: 14px; right: 12px; }
.app-card:has(.app-delete) .app-head { padding-right: 40px; }
.app-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-avatar { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: #1f1f1f; color: var(--soft); font: 600 17px/1 var(--sans); }
.app-who { display: grid; gap: 6px; flex: 1; min-width: 0; }
.app-who .row { gap: 8px; }
.app-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.app-who .mono { font-size: 12px; }
.app-go { flex: none; width: 18px; height: 18px; color: var(--fg); opacity: 0; transition: opacity .15s, transform .15s; }
.app-card:hover .app-go, .app-card:focus-visible .app-go, .app-card:has(.app-open:focus-visible) .app-go { opacity: 1; transform: translateX(2px); }
.app-facts { display: grid; gap: 10px; margin: 0; }
.app-facts div { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; }
.app-facts dt { color: var(--dim); white-space: nowrap; }
.app-facts dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; text-align: right; }
.app-facts dd.mono { font: 12.5px var(--mono); }

/* Access: faction and permission ticks. Headers are two centered lines. Tick columns share the row. */
.grid .sep { border-left: 1px solid var(--line); }
.grid.access th { vertical-align: bottom; }
.grid.access th.c { line-height: 1.25; }
.grid.access th.c, .grid.access td.c { padding-left: 6px; padding-right: 6px; }
.th-lines { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; min-height: calc(1.25em * 2 + 2px); }
@media (min-width: 1200px) {
  .grid.access { table-layout: fixed; }
  .grid.access th:first-child { width: 240px; }
  .grid.access th:last-child { width: 118px; }
}
.acct { display: grid; gap: 7px; justify-items: start; }
.acct-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.acct-meta { display: grid; gap: 2px; font-size: 12px; line-height: 1.35; color: var(--dim); }
.acct-meta .mono { color: var(--soft); }
.acct-meta span { white-space: nowrap; }
@media (max-width: 1199px) { /* cards: the account and the Save / Remove buttons take full rows */
  .grid.access td.account, .grid.access td:last-child { grid-column: 1 / -1; }
  .grid.access td.account::before, .grid.access td:last-child::before { display: none; }
  .grid.access td.c { padding: 0; }
  .grid .sep { border-left: 0; }
}
.th-division { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.th-division .logo-mark, .th-division .logo-img { width: 14px; height: 14px; }

/* Site modal (public/app.js ask()), the "saved" toast, and the tag editor on the unit form. */
.modal { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--raised); color: var(--fg); outline: none; }
.modal::backdrop { background: rgb(0 0 0 / .7); }
.modal > form { display: grid; gap: 10px; padding: 20px 22px 18px; }
.modal-wide { width: min(680px, calc(100vw - 32px)); max-height: min(80vh, 760px); overflow: auto; }
.modal-wide .card-header { position: sticky; top: 0; z-index: 1; background: var(--raised); }
#shifts .new-shift { flex: 1; min-width: 140px; }

/* Applications list. The question bank opens in #questions so the rows can use the full width. */
.q-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 16px; }
.q-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 0; color: var(--soft); font-size: 13px; }
.q-meta strong { color: var(--fg); font-weight: 600; }
.apps-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.apps-filters { display: flex; align-items: center; gap: 2px; min-width: min(100%, max-content); overflow-x: auto; scrollbar-width: none; }
.apps-filters::-webkit-scrollbar { display: none; }
.apps-filters button { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--soft); font: 500 13px/1 var(--sans); cursor: pointer; }
.apps-filters button[aria-pressed="true"] { background: #1c1c1c; color: var(--fg); }
.apps-filters .n { color: var(--dim); font: 12px/1 var(--mono); }
.apps-filters button[aria-pressed="true"] .n { color: var(--soft); }
.apps-sort { flex: none; margin-left: auto; color: var(--dim); font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.apps-row { display: grid; grid-template-columns: 36px minmax(140px, 190px) minmax(0, 1fr) auto; gap: 8px 18px; align-items: center; padding: 16px 18px; border-top: 1px solid var(--line); }
.apps-row[hidden] { display: none; }
.apps-list .apps-row:first-child { border-top: 0; }
.apps-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #1c1c1c; color: var(--soft); font: 600 12px/1 var(--sans); letter-spacing: .02em; }
.apps-who { display: grid; gap: 2px; align-content: center; min-width: 0; }
.apps-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; letter-spacing: -.01em; }
.apps-who .badge { justify-self: start; margin-top: 4px; }
.apps-when { color: var(--dim); font-size: 12.5px; }
.apps-qa { min-width: 0; }
.apps-q, .apps-a { margin: 0; overflow-wrap: anywhere; }
.apps-q { color: var(--dim); font-size: 13px; }
.apps-a { margin-top: 3px; font-size: 14px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.apps-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.apps-status { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); font: 500 12px/1 var(--sans); white-space: nowrap; }
.apps-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.apps-status.is-pending { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.apps-status.is-accepted { color: var(--green); border-color: rgb(69 212 131 / .35); background: rgb(69 212 131 / .07); }
.apps-status.is-denied { color: var(--red); border-color: var(--red-line); background: var(--red-soft); }
dialog#questions.modal { width: min(640px, calc(100vw - 32px)); max-height: min(84vh, 760px); overflow: hidden; }
dialog#questions.modal[open] { display: flex; flex-direction: column; }
#questions .card-header { flex: none; background: var(--raised); }
#questions .q-body { min-height: 0; overflow: auto; scrollbar-gutter: stable; }
#questions .q-field { display: grid; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
#questions .q-line { display: flex; gap: 8px; align-items: center; }
#questions .q-line .input { flex: 1; min-width: 0; }
#questions .q-line .input[type="number"] { flex: none; width: 88px; }
#questions .q-list { display: grid; }
#questions .q-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 20px; border-bottom: 1px solid var(--line); }
#questions .q-row > form:first-child { display: grid; justify-items: center; gap: 4px; }
#questions .q-row p { margin: 2px 0 0; overflow-wrap: break-word; }
.switch { position: relative; width: 36px; height: 20px; padding: 0; border: 0; border-radius: 99px; background: #2a2a2a; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #8a8a8a; }
.switch.on { background: var(--fg); }
.switch.on::after { transform: translateX(16px); background: #111; }
.switch-state { color: var(--dim); font: 500 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.q-foot { display: flex; justify-content: flex-end; flex: none; padding: 14px 20px; border-top: 1px solid var(--line); }

/* Divisions: one card per faction. New division is a dialog, opened from the page or from a faction. */
.dept-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.dept-card { display: flex; flex-direction: column; gap: 16px; padding: 16px; }
.dept-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dept-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.dept-badge { display: grid; place-items: center; flex: none; }
.dept-badge .logo-mark, .dept-badge .logo-img { width: 28px; height: 28px; }
.dept-count { margin: 3px 0 0; color: var(--dim); font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.dept-empty { display: grid; align-content: center; justify-items: center; gap: 6px; flex: 1; min-height: 132px; margin: 0; padding: 24px 16px; border: 1px dashed #2e2e2e; border-radius: 10px; text-align: center; }
.dept-empty p { margin: 0; color: var(--dim); font-size: 13px; }
.dept-empty .dept-empty-title { color: var(--fg); font-size: 14px; font-weight: 600; }
.dept-list { display: grid; flex: 1; align-content: start; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.dept-item + .dept-item { border-top: 1px solid var(--line); }
.dept-color { display: contents; }
.dept-color input[type="color"] { width: 28px; height: 28px; padding: 3px; }
.dept-color input[type="color"]:not([data-set])::-webkit-color-swatch { background: transparent; border: 1px dashed var(--line-strong); }
.dept-row { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 8px 8px 14px; }
.dept-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
button.dept-name { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
#rename-division > form { padding: 0; gap: 0; }
.dept-units { margin-left: auto; color: var(--dim); font-size: 13px; white-space: nowrap; }
button.dept-units { display: inline-flex; align-items: center; gap: 4px; padding: 2px 0; border: 0; background: none; color: var(--fg); font: inherit; font-size: 13px; cursor: pointer; }
dialog.dept-units-modal[open] { display: flex; flex-direction: column; width: min(420px, calc(100vw - 32px)); max-height: min(80vh, 640px); overflow: hidden; }
dialog.dept-units-modal .card-header { flex: none; background: var(--raised); }
.dept-members { display: grid; align-content: start; min-height: 0; overflow: auto; padding: 6px 14px 10px; }
.dept-member { display: flex; align-items: center; gap: 10px; min-height: 34px; color: var(--soft); font-size: 14px; }
.dept-member .unit-no { display: inline-flex; align-items: center; margin-left: 0; padding: 2px 7px; line-height: 1; text-decoration: none; }
.dept-member .unit-no:hover { border-color: var(--fg); }
.dept-add { width: 100%; }
.dept-ico { display: grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #0c0c0c; color: var(--fg); }
button.dept-ico { cursor: pointer; }
button.dept-ico:hover, button.dept-ico:focus-visible { border-color: #6b6b6b; }
.dept-ico svg { width: 16px; height: 16px; }
.dept-ico-empty { width: 14px; height: 14px; border: 1px dashed #3a3a3a; border-radius: 3px; }
dialog#dept-icon.modal { width: min(520px, calc(100vw - 32px)); max-height: min(84vh, 720px); overflow: hidden; }
dialog#dept-icon.modal[open] { display: flex; flex-direction: column; }
#dept-icon > form { display: flex; flex-direction: column; min-height: 0; padding: 0; gap: 0; }
#dept-icon .card-header { flex: none; background: var(--raised); }
#dept-icon .icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; min-height: 0; overflow: auto; padding: 16px 20px; }
#dept-icon .nd-foot { flex: none; }
#dept-icon .icon-upload { display: flex; align-items: center; gap: 12px; flex: none; padding: 0 20px 12px; }
#dept-icon .icon-upload .hint { margin: 0; }
.dept-ico .div-ico { width: 16px; height: 16px; }
.icon-opt { display: grid; place-items: center; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: #0c0c0c; color: var(--soft); cursor: pointer; }
.icon-opt:has(input:checked) { border-color: #6b6b6b; background: #161616; color: var(--fg); }
.icon-opt input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon-opt svg { width: 20px; height: 20px; }
.icon-opt.icon-none { grid-column: 1 / -1; height: 36px; font-size: 13px; }
#new-division > form { padding: 0; gap: 0; }
#new-division .nd-body,
#rename-division .nd-body { display: grid; gap: 16px; padding: 16px 20px 18px; }
#new-division .nd-factions { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
#new-division .nd-factions .label { margin-bottom: 2px; }
.faction-pick { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: #0c0c0c; cursor: pointer; }
.faction-pick:has(input:checked) { border-color: #6b6b6b; background: #161616; }
.faction-pick input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.faction-pick input:focus, .faction-pick input:focus-visible, .faction-pick:focus-within { outline: none; }
.faction-logo { display: grid; place-items: center; flex: none; }
.faction-logo .logo-mark, .faction-logo .logo-img { width: 18px; height: 18px; }
.faction-tick { display: inline-flex; margin-left: auto; width: 16px; height: 16px; color: var(--fg); opacity: 0; }
.faction-pick:has(input:checked) .faction-tick { opacity: 1; }
.faction-tick svg { width: 16px; height: 16px; }
.nd-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.apps .empty { border: 0; background: transparent; padding: 40px 20px; }
#questions .empty { border: 0; background: transparent; padding: 28px 20px; }
@media (max-width: 860px) {
  .apps-row { grid-template-columns: 36px minmax(0, 1fr); }
  .apps-qa, .apps-actions { grid-column: 1 / -1; }
  .apps-actions { justify-content: flex-start; }
}
.modal-title { margin: 0; font-size: 15px; font-weight: 600; }
.modal.danger .modal-title { color: var(--red); }
.modal-msg { margin: 0 0 10px; color: var(--soft); line-height: 1.55; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: min(420px, calc(100vw - 40px)); margin: 0; transition: opacity .4s; }
.toast.out { opacity: 0; }
.tag-editor {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 5px 8px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg);
}
.tag-editor:focus-within { border-color: #6b6b6b; box-shadow: 0 0 0 3px rgb(255 255 255 / .08); }
.tag-add { flex: 1; min-width: 110px; height: 26px; padding: 0 4px; border: 0; outline: 0; background: none; color: var(--fg); font: 14px var(--sans); }
.tag-add::placeholder { color: var(--dim); }
.pill button { display: inline-grid; place-items: center; width: 14px; height: 14px; margin-right: -3px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; opacity: .7; }
.pill button:hover, .pill button:focus-visible { opacity: 1; }
.pill button svg { width: 12px; height: 12px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); }
.foot-in { display: flex; justify-content: center; padding-top: 24px; padding-bottom: 24px; font-size: 13px; color: var(--dim); }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .nav { margin-left: 8px; }
  .nav a { padding: 8px; font-size: 0; }
  .nav a svg { width: 18px; height: 18px; }
  .slash, .crumb, .user-name { display: none; } /* the page title names the faction */
  .hero { padding-top: 24px; padding-bottom: 28px; }
  .hero-main { padding: 28px 20px 24px; gap: 24px; }
  .hero h1 { font-size: 44px; }
  .hero-title { gap: 14px; }
  .hero-title .logo-lg { width: 40px; height: 40px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats:has(> :nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* staff also see Last sync */
  .stats:has(> :nth-child(4)) > .stat:nth-child(odd) { border-left: 0; }
  .stats:has(> :nth-child(4)) > .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stat { padding: 16px; }
  .stat dd { font-size: 22px; }
  .region-counts { padding: 14px 20px 16px; gap: 8px 16px; }
  .search { max-width: none; flex-basis: 100%; }
  .page { padding-top: 28px; }
  .page-head h1 { font-size: 34px; }
  .card-header, .card-body, .list-item { padding-left: 16px; padding-right: 16px; }
  .rank-head { padding: 14px 16px; }
  .rank-stats { width: 100%; gap: 14px; flex-wrap: wrap; }
  .grid tbody tr { padding: 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  @view-transition { navigation: none; }
}
