/* Alliance Management — calm dark admin layout: sidebar navigation, one card style,
   colour reserved for actions (blue) and status (green / amber / red). */
:root {
  --bg: #0e1218; --surface: #151a22; --surface-2: #1b212b; --raised: #202733;
  --line: #262e3a; --line-strong: #353f4d;
  --fg: #e6ebf2; --muted: #8b96a5; --faint: #5f6b7a;
  --primary: #3b7ddd; --primary-hi: #4b8cf0; --link: #7aa9f5;
  --good: #4cc38a; --info: #5ea8f5; --warn: #e0a84a; --bad: #ef6b6b; --violet: #a78bfa; --orange: #e8894a; --none: #4a5463;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 10px; --r-sm: 7px; --h: 38px; --side: 232px;
  color-scheme: dark;
}
* { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--bg); color: var(--fg); font: 14.5px/1.55 var(--sans); -webkit-font-smoothing: antialiased }
[hidden] { display: none !important }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; text-wrap: balance }
h1 { font-size: 22px } h2 { font-size: 17px } h3 { font-size: 15px }
p { margin: 0 }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .95em }
.muted { color: var(--muted) } .small { font-size: 13px }
.label { font-size: 12.5px; font-weight: 500; color: var(--muted) }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: calc(18px + env(safe-area-inset-top, 0px)) 14px 16px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px }
.side-brand b { display: block; font-size: 14px; font-weight: 600 }
.side-brand span:not(.logo) { font-size: 12px; color: var(--muted) }
.logo { width: 32px; height: 32px; border-radius: 8px; background: color-mix(in srgb, var(--primary) 22%, transparent); display: grid; place-items: center; flex: none }
.logo svg { width: 18px; height: 18px; fill: var(--primary-hi) }
.nav { display: grid; gap: 2px }
.nav button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: 500 14px var(--sans); text-align: left; cursor: pointer }
.nav button svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.nav button:hover { background: var(--surface-2); color: var(--fg) }
.nav button[aria-current="page"] { background: var(--raised); color: var(--fg) }
.nav .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; line-height: 18px }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 6px 0; display: grid; gap: 8px }
.me b { display: block; font-size: 13.5px } .me span { font-size: 12px; color: var(--muted) }
.me-links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px }
.mainwrap { min-width: 0 }
main { max-width: 1160px; margin: 0 auto; padding: 28px 32px 64px; display: grid; gap: 18px }
.mobilebar { display: none }
.scrim { display: none }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr }
  .side { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease }
  body.nav-open .side { transform: none }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / .5) }
  .mobilebar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--surface); border-bottom: 1px solid var(--line) }
  main { padding: 20px 16px 56px }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none } }

.iconbtn { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); cursor: pointer }
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: var(--fg); stroke-width: 1.8; stroke-linecap: round }

/* ---------- page header ---------- */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 4px }
.pagehead p { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 70ch }
.backlink { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font-size: 13px }
.sectiontitle { font-size: 17px; margin-top: 10px }

/* ---------- layout pieces ---------- */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center }
.between { justify-content: space-between }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 14px; align-content: start; min-width: 0 }
.panel > h3:first-child, .panel > .row:first-child h3 { font-size: 15px }
.notice { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 12px 14px; font-size: 14px }
.notice.err { border-left-color: var(--bad) } .notice.ok { border-left-color: var(--good) } .notice.info { border-left-color: var(--info) }
.field { display: grid; gap: 6px; align-content: start }
.formrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end }

/* ---------- controls ---------- */
button, .btn { font: 500 14px var(--sans); height: var(--h); padding: 0 14px; border-radius: var(--r-sm); cursor: pointer; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg); display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap }
button:hover, .btn:hover { background: var(--raised) }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff }
button.primary:hover { background: var(--primary-hi); border-color: var(--primary-hi) }
button.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent) }
button.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent) }
button.link { height: auto; padding: 0; border: 0; background: none; color: var(--link); font-weight: 500 }
button.link:hover { background: none; text-decoration: underline }
button:disabled { opacity: .5; cursor: default }
input, select, textarea { font: 14px var(--sans); color: var(--fg); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 11px; max-width: 100% }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select { height: var(--h) }
input:hover, select:hover, textarea:hover { border-color: #46505f }
input::placeholder, textarea::placeholder { color: var(--faint) }
textarea { width: 100%; min-height: 120px; padding: 10px 11px; line-height: 1.5 }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; accent-color: var(--primary); margin: 0 }
input.score { width: 140px; font-family: var(--mono) }
select.changed { border-color: var(--warn) }
.utcpick { display: inline-flex; align-items: center; gap: 6px }
.utcpick select { width: 70px; font-family: var(--mono) }
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm) }
.seg button { height: 32px; border: 0; background: transparent; color: var(--muted) }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--fg) }

/* ---------- auth ---------- */
.authwrap { max-width: 420px; margin: 10vh auto 0; padding: 0 16px; display: grid; gap: 18px }
.authwrap .panel { padding: 26px }
.authwrap input { width: 100% }
.auth { display: grid; gap: 18px }
.auth .seg { display: flex } .auth .seg button { flex: 1 }

/* ---------- summary tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 4px }
.stat .label { font-size: 12.5px }
.stat b { font: 600 24px var(--sans); font-variant-numeric: tabular-nums }
.tierbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-2); margin-top: 6px }
.tierbar i { display: block; height: 100% }

/* ---------- tables ---------- */
.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface) }
table { border-collapse: collapse; width: 100%; min-width: 820px; font-size: 14px }
th, td { padding: 10px 14px; text-align: left; vertical-align: middle }
th { font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap; border-bottom: 1px solid var(--line) }
th button.sort { height: auto; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer }
th button.sort:hover { color: var(--fg); background: none }
td { border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent) }
tr:last-child td { border-bottom: 0 }
tr.click { cursor: pointer } tr.click:hover td { background: var(--surface-2) }
td.r, th.r { text-align: right }
table.choices select { width: 100% }
table.choices td, table.choices th { white-space: nowrap }

/* ---------- pills, flags, chips ---------- */
.pill { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 8px; border-radius: 6px; font: 600 12px var(--sans) }
.t-A { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good) }
.t-B { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info) }
.t-C { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn) }
.t-D { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad) }
.t-New { background: var(--surface-2); color: var(--muted) }
.flag { display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 9px; border-radius: 999px; white-space: nowrap; background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); line-height: 20px }
.flag.ghost { background: color-mix(in srgb, var(--violet) 16%, transparent); color: var(--violet) }
.flag.quiet { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn) }
.flag.skip { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange) }
.flag.prev { background: var(--surface-2); color: var(--muted) }
.chip { display: inline-block; font-size: 12px; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 9px; margin: 2px 4px 2px 0; line-height: 20px }
.trend-up { color: var(--good) } .trend-down { color: var(--bad) }
.tag-ok { color: var(--good); font-size: 12.5px; font-weight: 500 } .tag-check { color: var(--warn); font-size: 12.5px; font-weight: 500 } .tag-no { color: var(--bad); font-size: 12.5px; font-weight: 500 }

/* ---------- score bar and event strip ---------- */
.scorebar { display: flex; align-items: center; gap: 10px; min-width: 140px }
.scorebar b { min-width: 24px; font-weight: 600; font-variant-numeric: tabular-nums }
.scorebar span:not(.num) { flex: 1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden }
.scorebar span:not(.num) i { display: block; height: 100%; background: var(--primary-hi) }
.strip { display: inline-flex; gap: 3px; align-items: center }
.strip i { width: 10px; height: 10px; border-radius: 3px; display: block }
.o-att { background: var(--good) } .o-walk { box-shadow: inset 0 0 0 2px var(--good) }
.o-ns { background: var(--bad) } .o-miss { background: var(--none) } .o-skip { box-shadow: inset 0 0 0 2px var(--orange) }
.o-none { box-shadow: inset 0 0 0 1px var(--line-strong) }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted) }
.legend span { display: inline-flex; gap: 6px; align-items: center }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 36px 20px; display: grid; gap: 12px; justify-items: center }
.steps { display: grid; gap: 8px; text-align: left; max-width: 560px; margin: 0; padding-left: 20px; color: var(--muted) }
.steps b { color: var(--fg) }

/* ---------- screenshots and reader ---------- */
.shots { display: flex; gap: 10px; flex-wrap: wrap }
.shots a, .shots div { width: 92px; height: 140px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); display: block; position: relative }
.shots img { width: 100%; height: 100%; object-fit: cover }
.shots em { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; font-style: normal; background: rgb(0 0 0 / .65); color: #fff; padding: 2px 6px }
.drop { border: 1.5px dashed var(--line-strong); border-radius: var(--r); padding: 18px; display: grid; gap: 12px; background: var(--surface) }
.drop.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)) }
.reader { display: grid }
.rrow { display: grid; grid-template-columns: minmax(0, 1.1fr) 130px minmax(0, 1.3fr) 140px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line) }
.rrow select, .rrow input { width: 100% }
@media (max-width: 600px) { .rrow { grid-template-columns: 1fr } }

/* ---------- misc ---------- */
.temp { font: 500 17px var(--mono); background: var(--bg); border: 1px solid var(--line-strong); padding: 10px 12px; border-radius: var(--r-sm); user-select: all }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: var(--r-sm); font-weight: 500; z-index: 40; max-width: calc(100% - 32px) }
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--line-strong); border-top-color: var(--primary-hi); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px }
@keyframes spin { to { transform: rotate(360deg) } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none } }

/* alignment fixes */
.nav button { justify-content: flex-start }
button.link { display: inline; text-align: left }
.stats { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)) }
.stat { align-content: start }
.scorebar .num { font-size: 12px; min-width: 30px }
table.slots { table-layout: fixed; min-width: 720px }
table.slots th:nth-child(1) { width: 24% } table.slots th:nth-child(2) { width: 12% } table.slots th:nth-child(3) { width: 11% }
table.slots th:nth-child(4) { width: 13% } table.slots th:nth-child(6) { width: 9% }
table.slots td:nth-child(1) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
table.choices td select { min-width: 170px }
table.choices td:nth-child(3) select { min-width: 110px }
.grid2 { align-items: start }
main > .seg, .panel > .seg { justify-self: start }
th.c, td.c { text-align: center; padding-left: 6px; padding-right: 6px }
table.history td.c .strip i { width: 14px; height: 14px; border-radius: 4px }
table.types { min-width: 760px }
table.types td:first-child { min-width: 220px }
table.types { table-layout: fixed; min-width: 860px }
table.types th:nth-child(1) { width: 26% }
table.types th:nth-child(2), table.types th:nth-child(3), table.types th:nth-child(4) { width: 14%; white-space: normal; text-align: center }
table.types td:nth-child(2), table.types td:nth-child(3), table.types td:nth-child(4) { text-align: center }
table.types th:nth-child(5) { width: 13% }
table.types td:nth-child(5) { white-space: nowrap }
table.types td:first-child { min-width: 0 }
table.types td .row button { height: 32px; padding: 0 11px; font-size: 13px }
