/* === Shell === */
/* Admin shell: clean Inter throughout — no serif inside the workspace.
   Overrides --font-display (Cormorant) so every existing reference resolves to Inter. */
.app, .auth-shell { --font-display: var(--font-ui); }
.app h1, .app h2, .auth-shell h1, .auth-shell h2 { letter-spacing: -0.015em; font-weight: 600; }

.app {
  display: grid;
  /* minmax(0, 1fr) — NOT plain 1fr. A grid track defaults to min-width:auto,
     so it refuses to shrink below its content's intrinsic width; a wide table
     then pushes the whole main column past the viewport and clips on the right,
     because .table-wrap's overflow-x never gets room to scroll. minmax(0,1fr)
     (plus min-width:0 on .main/.content below) lets the column shrink so the
     table scrolls inside its wrapper instead. This is the root fix for the
     recurring "table cut off on the right" bug — applies to every table. */
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
}

/* === Sidebar === */
.sidebar {
  background: var(--ivory); border-right: var(--border-hair);
  padding: var(--s-5) var(--s-4); display: flex; flex-direction: column; gap: var(--s-5);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
@media (max-width: 880px) {
  .sidebar { display: none; position: fixed; inset: 0; height: 100vh; z-index: 200; width: 280px; box-shadow: var(--shadow-lifted); }
  .sidebar.open { display: flex; }
  body.drawer-open { overflow: hidden; }
}

.brand-mark {
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--s-2);
}
.brand-mark .accent { color: var(--gold-600); }
.brand-mark-svg { width: 48px; height: 48px; flex: none; }
/* Same lockup as the public site's header, same font too (Cormorant Garamond
   italic, loaded in header.php) — a deliberate, explicit exception to the
   admin shell's Inter-only rule for this one label, not an accidental leak
   of --font-display: confirmed side-by-side against landing.php's .lw-rsvp
   and this is the one the admin sidebar should match. */
.brand-mark-rsvp {
  font: italic 500 24px 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  color: var(--char-500); letter-spacing: 0.01em;
}
/* The brand WELL — C6, confirmed after a live C2 (maroon) trial, 2026-08-06:
   the well stays ivory and is FRAMED instead of filled — a 2px gold hairline
   crowning the sidebar's top edge, a bottom hairline that continues the
   topbar's in one unbroken line across the seam. Full-bleed, exactly
   --topbar-h tall; negative margins reach the sidebar's three edges while
   everything below stays inside the sidebar's own padding.
   Centered — the close button is desktop-hidden; the mobile drawer switches
   to space-between when it appears (same media query, further down). */
.sidebar-brand-row {
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  flex: none; height: var(--topbar-h);
  margin: calc(-1 * var(--s-5)) calc(-1 * var(--s-4)) 0;
  border-top: 2px solid var(--gold-600);
  border-bottom: var(--border-hair);
}
.sidebar-brand-row .brand-mark { min-width: 0; }
.sidebar-close {
  display: none; width: 34px; height: 34px; padding: 0;
  place-items: center; flex: 0 0 auto; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--char-500); cursor: pointer;
}
.sidebar-close:hover { background: var(--ink-50); color: var(--ink-800); }

.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section .label {
  font: 600 10px var(--font-ui); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--gold-700); padding: var(--s-2) var(--s-3);
}

/* Collapsible sections: the label is a real <button> where a data-key exists.
   Expanded stays exactly as before — the chevron only fades in once collapsed,
   as the one quiet hint that something is folded away. The height animation is
   the grid 0fr/1fr technique: .nav-links is a one-row grid whose row collapses,
   with the inner div doing overflow:hidden — no max-height guesswork. */
button.label {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  width: 100%; background: none; border: 0; text-align: left; cursor: pointer;
  border-radius: var(--r-sm); transition: color 0.15s ease;
}
button.label:hover { color: var(--gold-600); }
button.label:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 1px; }
.label .chev { flex: none; opacity: 0; transition: opacity 0.18s ease; }
.nav-section.collapsed .label .chev { opacity: 1; }
.nav-links { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.28s ease; }
.nav-links > div { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.nav-section.collapsed .nav-links { grid-template-rows: 0fr; }
@media (prefers-reduced-motion: reduce) {
  .nav-links { transition: none; }
}
.nav-section a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--char-700); font: 500 14px var(--font-ui);
  border-left: 3px solid transparent; margin-left: -3px;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-section a:hover { background: var(--ink-50); color: var(--ink-800); }
.nav-section a.active { background: var(--ink-100); color: var(--ink-800); border-left-color: var(--gold-600); font-weight: 600; }
.nav-section a .icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar .user-pill {
  margin-top: auto; padding: var(--s-3); border-radius: var(--r-md);
  background: var(--pearl); border: var(--border-hair);
  display: flex; align-items: center; gap: var(--s-3);
  position: relative;
}
.sidebar .user-pill .name { font: 500 13px var(--font-ui); color: var(--char-900); }
.sidebar .user-pill .role { font-size: 11px; color: var(--char-500); }
.sidebar .user-pill-copy { flex: 1; min-width: 0; }
.sidebar .user-pill-copy .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar .user-pill-toggle {
  background: transparent; border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--char-500);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar .user-pill-toggle:hover { background: var(--ink-50); color: var(--ink-800); }
.sidebar .user-pill-toggle[aria-expanded="true"] { background: var(--ink-100); color: var(--ink-800); }

.sidebar .user-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
  background: var(--pearl); border: 1px solid var(--line-200);
  border-radius: var(--r-md); box-shadow: var(--shadow-lifted);
  padding: var(--s-2);
  display: none; z-index: 250;
  animation: userMenuIn 140ms var(--ease);
}
.sidebar .user-menu.open { display: block; }
@keyframes userMenuIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sidebar .user-menu-head {
  padding: 8px 10px 10px; border-bottom: 1px solid var(--line-100); margin-bottom: 4px;
}
.sidebar .user-menu-name { font: 600 13px var(--font-ui); color: var(--char-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user-menu-email { color: var(--char-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar .user-menu a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--char-700); font: 500 13px var(--font-ui);
  text-decoration: none;
}
.sidebar .user-menu a:hover { background: var(--ink-50); color: var(--ink-800); }
.sidebar .user-menu a.user-menu-danger { color: var(--bad); }
.sidebar .user-menu a.user-menu-danger:hover { background: rgba(156,43,43,0.06); color: var(--bad); }
.sidebar .user-menu a svg { flex-shrink: 0; opacity: 0.75; }

/* === Top bar === */
.topbar {
  height: var(--topbar-h); background: var(--pearl); border-bottom: var(--border-hair);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s-6); position: sticky; top: 0; z-index: 100;
}
.topbar .left  { display: flex; align-items: center; gap: var(--s-4); min-width: 0; }
.topbar .right { display: flex; align-items: center; gap: var(--s-3); }
.topbar .left > div { min-width: 0; }
.topbar h1 {
  overflow: hidden; margin: 0; font-family: var(--font-display); font-weight: 500;
  font-size: 22px; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .crumb { font-size: var(--t-sm); color: var(--char-500); }
.topbar .menu-toggle { display: none; background: none; border: none; padding: 8px; cursor: pointer; color: var(--char-700); }
@media (max-width: 880px) { .topbar .menu-toggle { display: inline-flex; } .topbar { padding: 0 var(--s-4); } }

.topbar .search-bar {
  position: relative; width: 320px;
}
.topbar .search-bar .input { padding: 7px 12px 7px 36px; font-size: 14px; }
.topbar .search-bar .icon-left { left: 10px; }

.topbar-search-toggle {
  display: none; width: 36px; height: 36px; padding: 0; place-items: center;
  border: 0; border-radius: var(--r-md); background: transparent;
  color: var(--char-700); cursor: pointer;
}
.topbar-search-toggle:hover,
.topbar-search-toggle[aria-expanded="true"] { background: var(--ink-50); color: var(--ink-800); }

@media (max-width: 880px) {
  .sidebar-close { display: grid; margin-top: 0; }
  .sidebar-brand-row { justify-content: space-between; padding: 0 var(--s-3); }
}
@media (max-width: 720px) {
  .topbar { position: sticky; }
  .topbar h1 { max-width: 52vw; font-size: 18px; }
  .topbar-search-toggle { display: grid; }
  .topbar .search-bar {
    display: none; position: absolute; z-index: 120; top: calc(100% + 8px);
    right: 12px; left: 12px; width: auto; padding: 8px;
    border: 1px solid var(--line-200); border-radius: var(--r-lg);
    background: rgba(255,255,255,.98); box-shadow: var(--shadow-lifted);
  }
  .topbar .search-bar.open { display: block; animation: userMenuIn 140ms var(--ease); }
  .topbar .search-bar .input { min-height: 42px; padding-right: 12px; font-size: 16px; }
  .topbar .search-bar .kbd { display: none; }
}

/* === Main === */
/* min-width:0 lets the flex/grid item shrink below content width so wide tables
   scroll inside .table-wrap instead of stretching the layout (see .app note). */
.main { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
.content { padding: var(--s-6); max-width: var(--content-max); width: 100%; margin: 0 auto; min-width: 0; }
@media (max-width: 720px) { .content { padding: var(--s-4); } }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: var(--s-6); gap: var(--s-4); flex-wrap: wrap;
}
.page-header .title h1 { font-size: var(--t-2xl); margin: 0; }
.page-header .title p  { color: var(--char-500); margin: var(--s-2) 0 0; font-size: var(--t-sm); line-height: 1.55; }
.page-header .title { min-width: 0; flex: 1 1 480px; }
.page-header .title > p:not(.page-kicker) { max-width: 760px; }
.page-header .actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 720px) {
  .page-header { margin-bottom: var(--s-5); }
  .page-header .actions { width: 100%; justify-content: flex-start; }
}

.section { margin-bottom: var(--s-7); }

/* === Two-col layout for detail pages === */
.detail-layout { display: grid; grid-template-columns: 1fr 320px; gap: var(--s-6); }
@media (max-width: 1080px) { .detail-layout { grid-template-columns: 1fr; } }

/* === Login === */
.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(800px circle at 20% 0%, var(--ink-100), transparent 60%),
    radial-gradient(600px circle at 90% 100%, var(--gold-100), transparent 50%),
    var(--ivory);
  padding: var(--s-5);
}
.auth-card {
  width: min(440px, 100%); background: var(--pearl); border: 1px solid var(--line-200);
  border-radius: var(--r-xl); padding: var(--s-7); box-shadow: var(--shadow-card);
}
.auth-card .brand-mark { justify-content: center; padding: 0 0 var(--s-5); font-size: 32px; }
.auth-card h1 { font-size: var(--t-2xl); text-align: center; font-family: var(--font-display); font-weight: 500; }
.auth-card .sub { text-align: center; color: var(--char-500); margin-bottom: var(--s-6); font-size: var(--t-sm); }
.auth-foot { text-align: center; margin-top: var(--s-5); color: var(--char-500); font-size: var(--t-sm); }

/* === Utilities === */
.flex   { display: flex; }
.grid   { display: grid; }
.row    { display: flex; gap: var(--s-3); align-items: center; }
.col    { display: flex; flex-direction: column; gap: var(--s-3); }
.gap-1  { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4  { gap: var(--s-4); } .gap-5 { gap: var(--s-5); } .gap-6 { gap: var(--s-6); }
.between{ justify-content: space-between; }
.center { justify-content: center; align-items: center; }
.right  { margin-left: auto; }
.mt-1{margin-top:var(--s-1)}.mt-2{margin-top:var(--s-2)}.mt-3{margin-top:var(--s-3)}.mt-4{margin-top:var(--s-4)}.mt-5{margin-top:var(--s-5)}.mt-6{margin-top:var(--s-6)}
.mb-1{margin-bottom:var(--s-1)}.mb-2{margin-bottom:var(--s-2)}.mb-3{margin-bottom:var(--s-3)}.mb-4{margin-bottom:var(--s-4)}.mb-5{margin-bottom:var(--s-5)}.mb-6{margin-bottom:var(--s-6)}
.hidden { display: none; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.page-kicker,
.page-header .title .page-kicker {
  margin: 0 0 6px; color: var(--char-500);
  font: 600 10.5px var(--font-ui); letter-spacing: .10em; text-transform: uppercase;
}
.page-kicker a { color: inherit; text-decoration: none; }
.page-kicker a:hover { color: var(--ink-800); }

.kbd { padding: 2px 6px; border: 1px solid var(--line-200); border-radius: 4px; font: 500 11px ui-monospace, monospace; color: var(--char-500); background: var(--pearl); }

/* === Collapsible sidebar (desktop) ===
   The hamburger hides the nav to give wide tables the full viewport — the
   preference persists in localStorage and is applied on <html> before first
   paint (inline snippet in header.php) so there's no flash. Mobile keeps the
   drawer behaviour. */
html.nav-collapsed .app { grid-template-columns: 1fr; }
html.nav-collapsed .sidebar { display: none; }
@media (max-width: 880px) {
  /* Collapse state must never interfere with the mobile drawer. */
  html.nav-collapsed .app { grid-template-columns: 1fr; }
  html.nav-collapsed .sidebar.open { display: flex; }
}
.topbar .menu-toggle { display: inline-flex; border-radius: var(--r-sm); transition: background var(--dur-fast) var(--ease); }
.topbar .menu-toggle:hover { background: var(--ink-50); }
