/* ============================================================================
   JNVKAA app UI — loaded by the console (/Admin, /BatchAdmin: _PortalLayout) and the
   member area (/Alumni: _MemberLayout). Mobile-first.
   1. Console shell: dark sidebar (off-canvas on phones), compact topbar.
   2. Profile / "More" dropdowns (shared by both shells, /js/menus.js).
   3. Compact component system on the "sm" tokens from site.css (body.app-ui).
   Rules use :where(.app-ui) so they sit at the specificity of the base rules they refine;
   feature stylesheets (events.css, gallery.css …) load later and can still override them.
   ========================================================================== */
:root { --side-w: 240px; --top-h: 52px; }

body.portal-body { background: var(--paper); }
body.app-ui { font-size: var(--fs-base); line-height: 1.5; --btn-h: var(--ctl-h); }

/* skip link (the console does not load public.css) */
.app-ui .skip-link { position: fixed; top: 8px; left: 8px; z-index: 300; padding: .5rem .9rem; border-radius: var(--ctl-radius); background: var(--ink); color: #fff; font-weight: 600; font-size: var(--fs-sm); transform: translateY(-150%); transition: transform .2s; }
.app-ui .skip-link:focus { transform: none; color: #fff; }
.app-ui main:focus { outline: none; }

/* ---- 1. console shell ------------------------------------------------------------------- */
/* Dark sidebar: fixed from 1000px, an off-canvas drawer below (portal.js handles focus).
   Topbar: menu button (phones/tablets), section crumb + page title, account menu. */
.portal-main { min-height: 100svh; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--gutter);
  background: rgba(255,255,255,.92); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .burger { width: var(--touch); height: var(--touch); flex: none; margin-left: -10px; border: 0; background: none; border-radius: var(--ctl-radius); font-size: 1.1rem; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.topbar .burger:hover { background: var(--paper); }
.topbar .burger:focus-visible { outline: none; box-shadow: var(--ring); }
.topbar-title { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 0 1 auto; }
.topbar-crumb { display: none; align-items: center; gap: 6px; flex: none; font-size: var(--fs-sm); color: var(--muted); }
.topbar-crumb a { color: var(--muted); font-weight: 500; text-decoration: none; border-radius: 4px; }
.topbar-crumb a:hover { color: var(--teal-700); }
.topbar-crumb a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.topbar-crumb i { font-size: .6rem; opacity: .7; }
@media (min-width: 600px) { .topbar-crumb { display: inline-flex; } }
.topbar .title { font-family: var(--font-head); font-weight: 600; font-size: var(--fs-md); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .spacer { flex: 1; }

.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); max-width: 86vw; z-index: 60;
  background: linear-gradient(180deg, #002229 0%, var(--ink) 40%, #001619 100%); color: rgba(255,255,255,.8);
  display: flex; flex-direction: column;
  transform: translateX(-100%); visibility: hidden;
  transition: transform .24s cubic-bezier(.2,.8,.2,1), visibility 0s linear .24s;
  overscroll-behavior: contain;
}
.side.open { transform: none; visibility: visible; transition: transform .24s cubic-bezier(.2,.8,.2,1), visibility 0s; box-shadow: 0 0 40px rgba(0,0,0,.35); }
.side-top { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-2) var(--sp-3) var(--sp-3); border-bottom: 1px solid rgba(255,255,255,.07); flex: none; }
.side .brand { display: flex; align-items: center; gap: .6rem; color: #fff; padding: var(--sp-1); flex: 1; min-width: 0; border-radius: var(--ctl-radius); text-decoration: none; }
.side .brand img { width: 30px; height: 30px; flex: none; filter: brightness(0) invert(1); }
.side .brand span { font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; letter-spacing: .03em; line-height: 1.1; display: grid; }
.side .brand small { font-family: var(--font-body); font-weight: 500; font-size: var(--fs-xs); letter-spacing: 0; color: var(--teal-300); }
.side .brand:focus-visible { outline: 2px solid var(--teal-300); outline-offset: 1px; }
.side-close { flex: none; width: var(--touch); height: var(--touch); display: grid; place-items: center; border: 0; border-radius: var(--ctl-radius);
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); font-size: 1rem; cursor: pointer; }
.side-close:hover { background: rgba(255,255,255,.12); color: #fff; }
.side-close:focus-visible { outline: 2px solid var(--teal-300); outline-offset: 1px; }

.side-nav { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-2) var(--sp-2) var(--sp-3);
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.side-group { display: flex; flex-direction: column; gap: 1px; }
.side-group + .side-group { margin-top: 6px; }
.side .side-cat { margin: 0; font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: rgba(255,255,255,.42); padding: 6px var(--sp-3) 2px; }
.side a { position: relative; display: flex; align-items: center; gap: .65rem; min-height: 32px; padding: .25rem .7rem; border-radius: var(--ctl-radius); color: rgba(255,255,255,.76); font-family: var(--font-body); font-weight: 500; font-size: var(--fs-sm); line-height: 1.3; text-decoration: none; transition: background-color .15s, color .15s; }
.side a i { width: 18px; flex: none; text-align: center; font-size: .875rem; opacity: .8; }
.side a .side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side a.active { background: rgba(18,146,152,.22); color: #fff; font-weight: 600; }
.side a.active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--teal-300); }
.side a.active i { opacity: 1; color: var(--teal-300); }
.side a:focus-visible { outline: 2px solid var(--teal-300); outline-offset: -2px; }
.side .nav-badge { margin-left: auto; }
.side-foot { flex: none; padding: var(--sp-2); border-top: 1px solid rgba(255,255,255,.07); }
.side-foot a { color: rgba(255,255,255,.6); font-size: var(--fs-xs); }
@media (pointer: coarse) { .side a { min-height: 42px; font-size: var(--fs-base); } }

.side-scrim { position: fixed; inset: 0; background: rgba(0,20,25,.5); z-index: 50; opacity: 0; transition: opacity .24s; }
.side-scrim[hidden] { display: block; pointer-events: none; }
.side-scrim.show { opacity: 1; pointer-events: auto; }
body.side-open { overflow: hidden; }

/* Full-width ("container-fluid") content with the shared breakpoint gutters. */
.portal-content { flex: 1; padding: var(--sp-4) var(--gutter) var(--sp-8); min-width: 0; }
.portal-content .wrap, .app-container { width: 100%; max-width: none; margin-inline: 0; min-width: 0; }
@media (min-width: 768px) { .portal-content { padding-top: var(--sp-5); } }

@media (min-width: 1000px) {
  .side { transform: none; visibility: visible; transition: none; max-width: none; }
  .side-close, .side-scrim { display: none !important; }
  body.side-open { overflow: auto; }
  .topbar .burger { display: none; }
  .portal-main { margin-left: var(--side-w); }
  .portal-content { padding-top: var(--sp-6); }
}
@media (min-width: 1536px) { :root { --side-w: 248px; } }

/* ---- 2. dropdown menus (profile, member "More") ----------------------------------------- */
.pmenu, .mnav-more { position: relative; }
.pmenu-btn { display: inline-flex; align-items: center; gap: .5rem; min-height: 36px; padding: 2px .55rem 2px 2px; border: 1px solid var(--line); border-radius: 100px; background: #fff; color: var(--ink); font: 500 var(--fs-sm)/1.2 var(--font-body); cursor: pointer; position: relative; max-width: 260px; }
.pmenu-btn:hover, .pmenu.open .pmenu-btn { border-color: var(--teal-300); background: #fbfefe; }
.pmenu-btn:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--teal); }
.pmenu-av { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--cream); color: var(--teal-700); display: grid; place-items: center; font: 700 var(--fs-xs)/1 var(--font-head); letter-spacing: .02em; }
.pmenu-av.lg { width: 38px; height: 38px; font-size: var(--fs-sm); }
.pmenu-name { display: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmenu-caret { font-size: .65rem; color: var(--muted); transition: transform .15s; }
.pmenu.open .pmenu-caret { transform: rotate(180deg); }
.pmenu-dot { position: absolute; top: 1px; left: 24px; width: 9px; height: 9px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 2px #fff; }
@media (min-width: 640px) { .pmenu-name { display: inline; } }
@media (pointer: coarse) { .pmenu-btn { min-height: var(--touch); padding-right: .7rem; } .pmenu-av { width: 36px; height: 36px; } }

.pmenu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 120; width: min(272px, calc(100vw - 24px)); padding: var(--sp-1); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px -12px rgba(0,29,35,.28), 0 2px 6px rgba(0,29,35,.06); }
.pmenu-panel[hidden] { display: none; }
.pmenu-head { display: flex; align-items: center; gap: .6rem; padding: var(--sp-2) var(--sp-2) var(--sp-3); margin-bottom: var(--sp-1); border-bottom: 1px solid var(--line); }
.pmenu-who { display: grid; min-width: 0; line-height: 1.3; }
.pmenu-who strong { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmenu-who small { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmenu-list { list-style: none; margin: 0; padding: 2px 0; }
.pmenu-list + .pmenu-list { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 4px; }
.pmenu-item { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 34px; padding: .3rem .6rem; border: 0; border-radius: 7px; background: none; color: var(--ink); font: 500 var(--fs-sm)/1.3 var(--font-body); text-align: left; cursor: pointer; }
.pmenu-item i { width: 16px; text-align: center; color: var(--muted); font-size: .85rem; }
.pmenu-item:hover, .pmenu-item:focus-visible, .pmenu-item.active { background: var(--cream); color: var(--teal-700); outline: none; }
.pmenu-item:hover i, .pmenu-item:focus-visible i, .pmenu-item.active i { color: var(--teal-700); }
.pmenu-item .nav-badge { margin-left: auto; }
.pmenu-foot { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 4px; }
.pmenu-foot .signout-form { display: block; }
.pmenu-signout { color: var(--danger); }
.pmenu-signout .signout-icon { width: 16px; color: var(--danger); }
.pmenu-signout:hover, .pmenu-signout:focus-visible { background: var(--danger-bg); color: var(--danger); }
@media (pointer: coarse) { .pmenu-item { min-height: var(--touch); font-size: var(--fs-base); } }

/* ---- 3. compact components (console + member area) -------------------------------------- */

/* page header: title + subtitle on the left, primary action on the right */
:where(.app-ui) .page-title { font-family: var(--font-head); font-weight: 700; font-size: var(--fs-title); line-height: 1.25; letter-spacing: -.005em; margin: 0 0 2px; }
:where(.app-ui) .page-sub { font-size: var(--fs-sm); color: var(--muted); line-height: 1.5; margin: 0 0 var(--sp-5); max-width: var(--measure); }
:where(.app-ui .portal-content) h1 { font-size: var(--fs-title); line-height: 1.25; }
:where(.app-ui .portal-content) h2 { font-size: var(--fs-lg); line-height: 1.3; }
:where(.app-ui .portal-content) h3 { font-size: var(--fs-md); line-height: 1.35; }
:where(.app-ui .portal-content) p { margin-bottom: var(--sp-3); }
:where(.app-ui) .lead { font-size: var(--fs-md); }
:where(.app-ui) .eyebrow { font-size: var(--fs-2xs); padding: .25rem .6rem; margin-bottom: var(--sp-2); }

/* buttons */
:where(.app-ui) .btn {
  min-height: var(--ctl-h); padding: var(--ctl-py) var(--ctl-px); gap: .4rem;
  font-family: var(--font-body); font-weight: 600; font-size: var(--fs-base); line-height: 1.2; letter-spacing: 0;
  border-radius: var(--ctl-radius); box-shadow: none; transition: background-color .15s, border-color .15s, color .15s, filter .15s;
  white-space: nowrap;
}
:where(.app-ui) .btn:hover { transform: none; box-shadow: none; color: var(--fg); filter: brightness(.95); }
:where(.app-ui) .btn:active { transform: none; filter: brightness(.9); }
:where(.app-ui) .btn:focus-visible { outline: none; box-shadow: var(--ring); }
:where(.app-ui) .btn i { font-size: .9em; }
:where(.app-ui) .btn-ghost { --bg: #fff; --fg: var(--ink); border-color: var(--line-strong); }
:where(.app-ui) .btn-ghost:hover { --fg: var(--teal-700); background: var(--cream); border-color: var(--teal-300); filter: none; }
:where(.app-ui) .btn-cream { --bg: var(--cream); --fg: var(--teal-700); }
:where(.app-ui) .btn-light { --bg: #fff; --fg: var(--teal-700); border-color: var(--line); }
:where(.app-ui) .btn-danger { --bg: var(--danger); --fg: #fff; }
:where(.app-ui) .btn-sm { min-height: var(--ctl-h-sm); padding: .25rem .6rem; font-size: var(--fs-sm); gap: .35rem; }
:where(.app-ui) .btn-lg { min-height: 40px; padding: .5rem 1.1rem; font-size: var(--fs-md); }
:where(.app-ui) .btn-block { width: 100%; }
:where(.app-ui) .icon-btn { width: var(--ctl-h); height: var(--ctl-h); flex: 0 0 var(--ctl-h); border-radius: var(--ctl-radius); border: 1px solid var(--line-strong); background: #fff; color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; }
:where(.app-ui) .icon-btn:hover { background: var(--cream); color: var(--teal-700); }

/* form controls outside .field (toolbars, filters, inline forms) */
:where(.app-ui) .toolbar :is(input, select),
:where(.app-ui) .ac-filters :is(input, select),
:where(.app-ui) .ac-filter-body :is(input, select),
:where(.app-ui) .ac-pop-body :is(input[type=text], textarea, select),
:where(.app-ui) .opt-list li input[type=text],
:where(.app-ui) .req .actions textarea {
  min-height: var(--ctl-h); padding: .375rem .7rem; font-family: var(--font-body); font-size: var(--ctl-fs); line-height: 1.4;
  border: 1px solid var(--line-strong); border-radius: var(--ctl-radius); background: #fff; color: var(--ink);
}
:where(.app-ui) :is(input, select, textarea):focus-visible { outline: none; border-color: var(--teal); box-shadow: var(--ring); }
:where(.app-ui) select { cursor: pointer; }
:where(.app-ui) .toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-4); }
:where(.app-ui) fieldset { min-width: 0; }

/* panels & cards */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--card-radius); padding: var(--card-pad); box-shadow: 0 1px 2px rgba(0,29,35,.04); margin-bottom: var(--sp-4); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2) var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.panel-head h2 { font-size: var(--fs-lg); margin: 0; display: flex; align-items: center; gap: .45rem; }
.panel-head h2 i { color: var(--teal); font-size: .9em; }
:where(.app-ui) .card { padding: var(--card-pad); border-radius: var(--card-radius); box-shadow: 0 1px 2px rgba(0,29,35,.04); }
:where(.app-ui) .card h3 { font-size: var(--fs-md); margin: 0 0 var(--sp-1); }
:where(.app-ui) .card p { font-size: var(--fs-sm); }
:where(.app-ui) .card .icon { width: 38px; height: 38px; border-radius: 10px; font-size: 1rem; margin-bottom: var(--sp-3); }
@media (hover: hover) { :where(.app-ui) .card:hover { transform: none; box-shadow: 0 6px 18px -10px rgba(0,29,35,.25); } }
:where(.app-ui) .grid { gap: var(--sp-3); }
@media (min-width: 620px) { :where(.app-ui) .grid { gap: var(--sp-4); } }
/* full-width content: card grids gain a column on wide screens instead of stretching cards */
@media (min-width: 1400px) { :where(.app-ui) .grid-3 { grid-template-columns: repeat(4, minmax(0, 1fr)); } :where(.app-ui) .grid-4 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
@media (min-width: 780px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1400px) { .kpis.wide, .kpis:has(> :nth-child(5)) { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--card-radius); padding: 14px var(--card-pad); box-shadow: 0 1px 2px rgba(0,29,35,.04); min-width: 0; }
.kpi .k-ico { width: 32px; height: 32px; border-radius: 8px; background: var(--cream); color: var(--teal-700); display: grid; place-items: center; margin-bottom: var(--sp-2); font-size: .85rem; }
.kpi .k-n { font-family: var(--font-head); font-weight: 700; font-size: 1.375rem; color: var(--ink); line-height: 1.1; }
.kpi .k-l { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }

/* badges, pills, chips */
.badge { display: inline-flex; justify-self: start; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 100px; font-family: var(--font-body); font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--danger-bg); color: var(--danger); } .badge.mut { background: #eef2f3; color: var(--muted); }
:where(.app-ui) .pill { font-family: var(--font-body); font-size: var(--fs-xs); padding: .15rem .55rem; }
.nav-badge { min-width: 18px; height: 18px; padding: 0 .35rem; border-radius: 100px; background: #ffb547; color: var(--ink); font-size: var(--fs-2xs); font-weight: 700; line-height: 1; display: inline-grid; place-items: center; }

/* tables: compact rows on desktop; admin.css collapses table.data.stack into cards on phones */
:where(.app-ui) .table-wrap { border-radius: var(--card-radius); }
:where(.app-ui) table.data td .btn-sm { margin-block: -2px; }

/* empty states */
:where(.app-ui) .empty { padding: var(--sp-8) var(--sp-4); font-size: var(--fs-sm); color: var(--muted); }
:where(.app-ui) .empty > i, :where(.app-ui) .empty .fa-2x { font-size: 1.6rem; color: var(--teal-300); display: block; margin: 0 auto var(--sp-2); }
:where(.app-ui) .empty p { margin: var(--sp-1) auto 0; max-width: 46ch; }
:where(.app-ui) .empty .btn { margin-top: var(--sp-3); }

/* dialogs (story editor and similar) */
:where(.app-ui) dialog { border: 1px solid var(--line); border-radius: 12px; padding: var(--sp-5); width: min(560px, calc(100vw - 24px)); box-shadow: 0 24px 60px -18px rgba(0,29,35,.4); color: var(--ink); }
:where(.app-ui) dialog::backdrop { background: rgba(0,20,25,.45); }
:where(.app-ui) dialog h2, :where(.app-ui) dialog h3 { font-size: var(--fs-lg); margin: 0 0 var(--sp-3); }

/* long-form readable text keeps a line length on very wide screens; forms/tables use the full width */
:where(.app-ui) :is(.prose, .story-body, .event-body, .a-quote) { max-width: var(--measure); }

.hide-sm { display: none; }
@media (min-width: 640px) { .hide-sm { display: inline; } }
@media (prefers-reduced-motion: reduce) { .side, .side-scrim, .pmenu-caret { transition: none; } }
