/* JPO Dashboard — styles
   Palette: powder blue from the JPO logo, navy ink, pastel squad colours.
   Type: Fraunces (soft + wonky) for display, Nunito for reading. */

:root {
  --ink: #1F2B46;
  --ink-2: #4A5874;
  --ink-3: #75829A;
  --paper: #FFFFFF;
  --mist: #EEF4FA;
  --powder: #C5DFF0;
  --powder-2: #E2EEF8;
  --powder-3: #F4F9FD;
  --line: #D5E2EE;
  --line-2: #E6EEF6;
  --accent: #2F5E8E;
  --focus: #6FA0CF;

  --sky: #C5DFF0;     --sky-ink: #265079;
  --lilac: #DDD6F3;   --lilac-ink: #4B3F86;
  --blush: #F5D5DE;   --blush-ink: #8E3450;
  --mint: #CFECDF;    --mint-ink: #23694C;
  --butter: #F7E7B4;  --butter-ink: #7A5C0E;
  --peach: #F9DCC8;   --peach-ink: #8A4521;
  --sage: #DCE8C8;    --sage-ink: #4A6224;

  --display: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --body: 'Nunito', 'Avenir Next', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --r-xl: 28px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--safe-top) + 64px); }
body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.num, table { font-variant-numeric: tabular-nums lining-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.display, h1, h2, h3, .figure {
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-optical-sizing: auto;
  letter-spacing: -0.01em;
}
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.15; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: rgba(238, 244, 250, 0.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-2);
}
.topbar-brand img { border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.topbar-title { flex: 1; font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 1; font-size: 20px; font-weight: 600; }
.main { padding: 20px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px); max-width: 1240px; margin: 0 auto; outline: none; min-width: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(var(--safe-bottom) + 6px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border-radius: 14px; text-decoration: none;
  color: var(--ink-3); font-size: 11.5px; font-weight: 700;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--ink); background: var(--powder-2); }

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 22px;
    position: sticky; top: 0; height: 100vh;
    padding: 26px 18px 20px;
    border-right: 1px solid var(--line-2);
  }
  .main { padding: 36px 40px 64px; width: 100%; }
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); padding: 0 6px; }
.brand img { border-radius: 50%; box-shadow: 0 0 0 1px var(--line); background: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 1; font-weight: 600; font-size: 19px; }
.brand-sub { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 14px;
  color: var(--ink-2); text-decoration: none; font-weight: 700; font-size: 15.5px;
}
.side-link svg { width: 20px; height: 20px; }
.side-link:hover { background: var(--powder-3); color: var(--ink); }
.side-link[aria-current="page"] { background: var(--powder); color: var(--ink); }

.sync-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--paper); text-align: left; cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.sync-chip strong { display: block; color: var(--ink); font-size: 13.5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ink-3); }
.dot[data-s="synced"] { background: #4FAE84; }
.dot[data-s="syncing"], .dot[data-s="pending"] { background: #E0B84A; }
.dot[data-s="error"], .dot[data-s="offline"] { background: #D0708A; }
.dot[data-s="local"] { background: #A9B6C9; }
.dot[data-s="syncing"] { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.sync-dot { border: 0; background: transparent; padding: 8px; cursor: pointer; display: grid; place-items: center; }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; margin-bottom: 22px; }
.page-title { font-size: 32px; font-weight: 600; }
@media (min-width: 960px) { .page-title { font-size: 40px; } }
.page-sub { margin: 6px 0 0; color: var(--ink-2); }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); text-decoration: none; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.back-link svg { width: 18px; height: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 18px; border-radius: 999px;
  border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink);
  font-weight: 800; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--powder-3); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2C3B5C; }
.btn-soft { border-color: transparent; background: var(--powder-2); }
.btn-soft:hover { background: var(--powder); }
.btn-quiet { border-color: transparent; background: transparent; padding-inline: 12px; }
.btn-quiet:hover { background: var(--powder-2); }
.btn-danger { border-color: var(--blush-ink); color: var(--blush-ink); }
.btn-danger:hover { background: var(--blush); }
.btn-sm { min-height: 34px; padding: 4px 14px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; flex: none;
  border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--powder-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Surfaces ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-title { font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 1; font-size: 21px; font-weight: 600; margin: 0; }
.panel-note { color: var(--ink-3); font-size: 14px; margin: 0; }
.grid { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .grid-main { grid-template-columns: 1.35fr 1fr; } }
.stack > * + * { margin-top: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.tight { margin: 0; }

/* ---------- Hero (overview) ---------- */
.hero {
  position: relative; overflow: hidden;
  display: grid; gap: 18px;
  background: var(--powder); border-radius: var(--r-xl);
  padding: 24px 22px 18px; margin-bottom: 20px;
}
@media (min-width: 900px) { .hero { grid-template-columns: minmax(330px, 0.85fr) 1.6fr; align-items: end; padding: 32px 32px 24px; } }
.hero-label { margin: 0; font-weight: 700; color: var(--sky-ink); }
.hero-figure { margin: 2px 0 6px; font-size: clamp(40px, 9vw, 64px); line-height: 1; font-weight: 600; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 18px; color: var(--ink-2); font-weight: 700; }
.hero-meta .up { color: var(--mint-ink); }
.hero-chart { min-height: 200px; }
.hero-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.hero .btn-soft { background: rgba(255,255,255,.7); }
.hero .btn-soft:hover { background: #fff; }

.stair-step { transform-origin: bottom; transform-box: fill-box; }
.animate .stair-step { animation: rise .6s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ---------- Pennants, chips, pills ---------- */
.pennant {
  --c-bg: var(--sky); --c-ink: var(--sky-ink);
  display: inline-flex; align-items: center; height: 22px;
  padding: 0 13px 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .02em;
  background: var(--c-bg); color: var(--c-ink); white-space: nowrap;
  clip-path: polygon(0 0, 100% 0, calc(100% - 7px) 50%, 100% 100%, 0 100%);
  border-radius: 4px 0 0 4px;
}
.pennant-lg { height: 30px; font-size: 14px; padding: 0 18px 0 11px; clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 50%, 100% 100%, 0 100%); }
.chip {
  --c-bg: var(--powder-2); --c-ink: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px;
  border-radius: 999px; background: var(--c-bg); color: var(--c-ink);
  font-size: 13px; font-weight: 800; white-space: nowrap;
}
.chip-btn { border: 1.5px solid transparent; cursor: pointer; height: 34px; padding: 0 14px; font-size: 14px; }
.chip-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--paper); color: var(--ink); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.status-live { --c-bg: var(--mint); --c-ink: var(--mint-ink); }
.status-upcoming { --c-bg: var(--butter); --c-ink: var(--butter-ink); }
.status-ended { --c-bg: var(--powder-2); --c-ink: var(--ink-3); }

/* colour helpers used by pennants/chips/bars */
[data-c="sky"]    { --c-bg: var(--sky);    --c-ink: var(--sky-ink);    --c-solid: #7EAAD0; }
[data-c="lilac"]  { --c-bg: var(--lilac);  --c-ink: var(--lilac-ink);  --c-solid: #A597DD; }
[data-c="blush"]  { --c-bg: var(--blush);  --c-ink: var(--blush-ink);  --c-solid: #DF93A8; }
[data-c="mint"]   { --c-bg: var(--mint);   --c-ink: var(--mint-ink);   --c-solid: #7FC6A5; }
[data-c="butter"] { --c-bg: var(--butter); --c-ink: var(--butter-ink); --c-solid: #E2C15E; }
[data-c="peach"]  { --c-bg: var(--peach);  --c-ink: var(--peach-ink);  --c-solid: #EBA87E; }
[data-c="sage"]   { --c-bg: var(--sage);   --c-ink: var(--sage-ink);   --c-solid: #A6C07B; }

/* ---------- Bars ---------- */
.bar { position: relative; height: 10px; border-radius: 999px; background: var(--powder-2); overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--c-solid, var(--ink)); }
.bar-lg { height: 14px; }
.bar-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .35; }

/* ---------- Lists ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.rank-list li:first-child { border-top: 0; }
.rank-no { font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 1; font-weight: 600; color: var(--ink-3); font-size: 18px; text-align: center; }
.rank-name { min-width: 0; display: flex; align-items: center; gap: 8px; }
.rank-name .name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name .pennant { flex: none; }
.rank-val { font-weight: 800; text-align: right; }
.rank-val small { display: block; font-weight: 700; color: var(--mint-ink); font-size: 13px; }

.squad-rows { display: flex; flex-direction: column; gap: 14px; }
.squad-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.squad-row .val { font-weight: 800; text-align: right; min-width: 92px; }
.squad-row .val small { display: block; color: var(--ink-3); font-weight: 700; font-size: 12.5px; }

.link-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line-2); text-decoration: none; color: inherit; }
.link-row:first-child { border-top: 0; }
.link-row:hover { background: var(--powder-3); border-radius: 12px; }
.date-block { width: 48px; flex: none; text-align: center; border-radius: 12px; background: var(--powder-2); padding: 5px 0; line-height: 1.1; }
.date-block b { display: block; font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 1; font-size: 20px; }
.date-block span { font-size: 12px; font-weight: 800; color: var(--ink-2); }
.link-row .grow { flex: 1; min-width: 0; }
.link-row .title { font-weight: 800; display: block; }
.link-row .meta { font-size: 13.5px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }

/* ---------- Tables ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--powder-2); }
.seg button { border: 0; background: transparent; padding: 7px 16px; border-radius: 999px; font-weight: 800; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(31,43,70,.12); }
.field-inline { display: inline-flex; align-items: center; gap: 8px; }
.select, .input {
  min-height: 42px; padding: 8px 12px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--paper); font-size: 15px;
}
.select { padding-right: 32px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%234A5874' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(111,160,207,.25); }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--ink-3); }
.search .input { padding-left: 36px; width: 210px; }

.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); -webkit-overflow-scrolling: touch; }
.table-wrap.tall { max-height: 72vh; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14.5px; }
table.data th, table.data td { padding: 10px 12px; text-align: right; white-space: nowrap; }
table.data th { position: sticky; top: 0; z-index: 2; background: var(--powder-2); font-weight: 800; font-size: 13px; color: var(--ink-2); }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data th[aria-sort] { color: var(--ink); }
table.data td { border-top: 1px solid var(--line-2); }
table.data tbody tr:hover td { background: var(--powder-3); }
table.data .l { text-align: left; }
table.data .c { text-align: center; }
table.data .sticky { position: sticky; left: 0; z-index: 1; background: var(--paper); box-shadow: 1px 0 0 var(--line-2); }
table.data th.sticky { z-index: 3; background: var(--powder-2); }
table.data tbody tr:hover td.sticky { background: var(--powder-3); }
table.data tfoot td { font-weight: 800; background: var(--powder-3); border-top: 1.5px solid var(--line); position: sticky; bottom: 0; }
table.data tfoot td.sticky { background: var(--powder-3); z-index: 2; }
table.data .strong { font-weight: 800; }
table.data .dim { color: var(--ink-3); }
table.data .neg { color: var(--blush-ink); }
table.data .pos { color: var(--mint-ink); }
table.data .warn { background: var(--blush) !important; color: var(--blush-ink); font-weight: 800; }
table.data .col-sep { border-left: 1.5px solid var(--line); }
.name-btn { border: 0; background: transparent; padding: 0; font-weight: 800; cursor: pointer; text-align: left; color: var(--ink); }
@media (max-width: 700px) {
  table.data td.sticky { max-width: 150px; }
  table.data td.sticky .name-btn { display: block; max-width: 136px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.name-btn:hover { text-decoration: underline; text-decoration-color: var(--focus); text-underline-offset: 3px; }
.cell-name { display: flex; align-items: center; gap: 8px; }
.cell-name small { color: var(--ink-3); font-weight: 700; }
table.data input.input { min-height: 34px; width: 110px; text-align: right; padding: 4px 8px; }

/* ---------- Stats tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { border-radius: var(--r-md); padding: 14px 16px; background: var(--c-bg, var(--powder-2)); color: var(--ink); }
.tile .k { font-size: 13.5px; font-weight: 700; color: var(--c-ink, var(--ink-2)); }
.tile .v { font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 1; font-size: 26px; font-weight: 600; line-height: 1.2; }

/* ---------- Attendance marking ---------- */
.att-group + .att-group { margin-top: 18px; }
.att-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.att-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line-2); }
.att-row .who { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-set { display: inline-flex; gap: 6px; flex: none; }
.att-btn {
  min-width: 40px; height: 38px; padding: 0 10px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink-3);
  font-weight: 800; font-size: 14px;
}
.att-btn .long { display: none; }
@media (min-width: 700px) { .att-btn .long { display: inline; } .att-btn .short { display: none; } .att-btn { min-width: 84px; } }
.att-btn[aria-pressed="true"] { border-color: transparent; background: var(--c-bg); color: var(--c-ink); }
.att-summary { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Tier badges ---------- */
.tier-badge { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 13px; color: var(--lilac-ink); }
.tier-badge svg { width: 15px; height: 15px; }
.progress-cell { min-width: 150px; }
.progress-cell .bar { margin-top: 5px; }
.progress-cell .cap { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-3); font-weight: 700; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 14px; }
@media (min-width: 560px) { .form-row.two { grid-template-columns: 1fr 1fr; } .form-row.three { grid-template-columns: 1fr 1fr 1fr; } }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 800; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--ink-3); margin: 0; }
.field .input, .field .select, .field textarea { width: 100%; }
textarea.input { min-height: 140px; resize: vertical; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; line-height: 1.45; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px 14px; margin: 0; }
legend { font-weight: 800; font-size: 14px; padding: 0 6px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 2px solid transparent; background: var(--c-bg); cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 3px #fff; }
.tier-rows { display: grid; gap: 10px; }
.tier-row { display: grid; grid-template-columns: 1fr 1fr 1fr 40px; gap: 8px; align-items: center; }
.pick-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px 12px; }
.pick-group { padding: 8px 0; border-top: 1px solid var(--line-2); }
.pick-group:first-child { border-top: 0; }
.pick-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.pick-grid { display: grid; gap: 4px 16px; }
@media (min-width: 560px) { .pick-grid { grid-template-columns: 1fr 1fr; } }
.pick-grid .check { font-weight: 600; font-size: 14.5px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(31, 43, 70, 0.34);
  animation: fade .18s ease-out;
}
@media (min-width: 700px) { .modal-backdrop { align-items: center; padding: 24px; } }
.modal {
  width: 100%; max-height: calc(100dvh - var(--safe-top) - 16px);
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: 26px 26px 0 0;
  box-shadow: 0 20px 60px rgba(31, 43, 70, 0.25);
  animation: sheet .22s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 700px) { .modal { max-width: 640px; border-radius: 26px; max-height: calc(100dvh - 48px); } .modal.wide { max-width: 960px; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 18px 10px 22px; }
.modal-head h2 { flex: 1; font-size: 24px; }
.modal-body { padding: 6px 22px 18px; overflow: auto; flex: 1; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 22px calc(16px + var(--safe-bottom)); border-top: 1px solid var(--line-2); }
.modal-foot .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { transform: translateY(24px); opacity: .6; } }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); z-index: 80; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 960px) { #toast-root { bottom: 28px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  max-width: 520px; padding: 12px 16px; border-radius: 16px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 14.5px;
  box-shadow: 0 10px 30px rgba(31,43,70,.3); animation: sheet .2s ease-out;
}
.toast button { border: 0; background: rgba(255,255,255,.16); color: #fff; font-weight: 800; border-radius: 999px; padding: 6px 12px; cursor: pointer; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 36px 20px; }
.empty h3 { font-size: 24px; margin-bottom: 6px; }
.empty p { margin: 0 auto 18px; max-width: 46ch; color: var(--ink-2); }
.empty .actions { justify-content: center; }
.empty-mini { color: var(--ink-3); font-size: 14.5px; margin: 0; padding: 6px 0; }

/* ---------- Import ---------- */
.drop {
  display: grid; place-items: center; gap: 8px; text-align: center; cursor: pointer;
  padding: 26px 16px; border-radius: var(--r-lg); border: 2px dashed var(--powder);
  background: var(--powder-3); font-weight: 700;
}
.drop:hover, .drop.over { background: var(--powder-2); border-color: var(--focus); }
.drop svg { width: 30px; height: 30px; color: var(--accent); }
.helper { border-radius: var(--r-md); background: var(--lilac); color: var(--lilac-ink); padding: 14px 16px; }
.helper p { margin: 0 0 10px; }
.helper .btn { border-color: var(--lilac-ink); color: var(--lilac-ink); background: rgba(255,255,255,.6); }
.notice { border-radius: var(--r-md); padding: 12px 14px; background: var(--butter); color: var(--butter-ink); font-weight: 700; font-size: 14.5px; }
.notice.bad { background: var(--blush); color: var(--blush-ink); }
.notice.good { background: var(--mint); color: var(--mint-ink); }
.notice ul { margin: 6px 0 0; padding-left: 18px; font-weight: 600; }

/* ---------- Report preview ---------- */
.report-preview { border-radius: var(--r-md); border: 1px solid var(--line); background: var(--mist); padding: 10px; }
.report-preview img { width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 10px rgba(31,43,70,.1); }

/* ---------- Adviser drawer ---------- */
.profile-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.mini-chart svg { width: 100%; height: auto; display: block; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--ink-3); font-weight: 700; }
.kv dd { margin: 0; font-weight: 700; }

.settings-section + .settings-section { margin-top: 16px; }
.code-box { white-space: pre-wrap; background: var(--powder-3); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; font: 12.5px/1.5 ui-monospace, Menlo, monospace; max-height: 260px; overflow: auto; }
details summary { cursor: pointer; font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .tabbar, .actions, .toolbar { display: none !important; }
  body { background: #fff; }
}

/* ---------- Quarters ---------- */
.q-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .q-cards { grid-template-columns: repeat(4, 1fr); } }
.q-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; display: grid; gap: 4px; align-content: start; }
.q-card[data-st="current"] { background: var(--powder); border-color: transparent; }
.q-card[data-st="future"] { background: transparent; border-style: dashed; }
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.q-name, .q-label { font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 1; font-weight: 600; font-size: 24px; line-height: 1; }
.q-label { font-size: 22px; min-width: 40px; }
.q-fyc { margin: 8px 0 0; font-size: 28px; font-weight: 600; line-height: 1.1; }
.q-cc { font-size: 15px; }
.q-cmp .pos { color: var(--mint-ink); font-weight: 800; }
.q-cmp .neg { color: var(--blush-ink); font-weight: 800; }
table.data th.cur { background: var(--powder); }
table.data td.cur { background: var(--powder-3); }
table.data tbody tr:hover td.cur { background: var(--powder-2); }
.modal .seg button { padding: 5px 14px; }

/* ---------- Squad set-up in squad challenges ---------- */
.cs-row { display: grid; grid-template-columns: 1fr 120px auto 40px; gap: 8px; align-items: center; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line-2); }
.member-row:first-child { border-top: 0; }
.member-row .who { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .select { min-height: 36px; padding-top: 4px; padding-bottom: 4px; width: 190px; flex: none; }
@media (max-width: 520px) { .member-row .select { width: 150px; } .cs-row { grid-template-columns: 1fr 100px 40px; } .cs-row .muted { display: none; } }

/* ---------- Headings in capitals ---------- */
.page-title, .panel-title, .modal-head h2, .modal-body h3, .empty h3, .topbar-title {
  text-transform: uppercase;
}
.page-title { font-size: 26px; letter-spacing: 0.04em; }
@media (min-width: 960px) { .page-title { font-size: 33px; } }
.panel-title { font-size: 17px; letter-spacing: 0.07em; }
.modal-head h2 { font-size: 19px; letter-spacing: 0.06em; }
.modal-body h3 { font-size: 15.5px !important; letter-spacing: 0.07em; }
.empty h3 { font-size: 19px; letter-spacing: 0.06em; }
.topbar-title { font-size: 16px; letter-spacing: 0.07em; }
.panel-head { flex-wrap: wrap; row-gap: 8px; }
.panel-head > .panel-title, .panel-head > div:first-child { flex: 1 1 auto; }
.squad-row { grid-template-columns: 54px 1fr auto; }
.rank-val small.sub-muted { color: var(--ink-3); }

/* ---------- Sync screen (blocks the app until synced) ---------- */
.sync-gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  background: rgba(197, 223, 240, 0.88);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: fade .15s ease-out;
  transition: opacity .2s ease;
}
.sync-gate.leaving { opacity: 0; }
.gate-card {
  width: min(380px, 100%); text-align: center;
  background: var(--paper); border-radius: 28px; padding: 30px 26px 24px;
  box-shadow: 0 20px 60px rgba(31, 43, 70, 0.18);
}
.gate-card img { margin: 0 auto 14px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); background: #fff; }
.gate-title {
  margin: 0 0 6px; font-family: var(--display); font-variation-settings: "SOFT" 100, "WONK" 1;
  font-weight: 600; font-size: 19px; letter-spacing: 0.08em; text-transform: uppercase;
}
.gate-msg { margin: 0 0 18px; color: var(--ink-2); font-weight: 700; }
.gate-bar { position: relative; height: 8px; border-radius: 999px; background: var(--powder-2); overflow: hidden; }
.gate-bar i { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; border-radius: inherit; background: var(--ink); animation: gate-slide 1.1s ease-in-out infinite; }
@keyframes gate-slide { from { left: -40%; } to { left: 100%; } }
.sync-gate[data-s="done"] .gate-bar i { animation: none; left: 0; width: 100%; background: #4FAE84; }
.sync-gate[data-s="error"] .gate-bar i { animation: none; left: 0; width: 100%; background: #DF93A8; }
.gate-sub { margin: 12px 0 0; min-height: 1.4em; font-size: 13.5px; font-weight: 600; color: var(--ink-3); }
.gate-actions { display: grid; gap: 8px; margin-top: 18px; }
.gate-note { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
