/* ================================================================
   AYC PORTAL — SHARED STYLES  v12.0  (2026 restyle)
   Inter · light/dark themes · accent shades derived via color-mix
   ================================================================ */

/* Fonts are self-hosted (static/vendor/fonts.css, linked in base.html)
   so the strict same-origin CSP holds — no Google Fonts at runtime. */

:root {
  /* ── Typeface — Formal: Inter; Casual skin overrides to Nunito ── */
  --font: 'Inter', system-ui, sans-serif;

  /* ── Per-org accent — overridden via inline <style> in base.html ── */
  --accent: #0096b4;

  /* Derived accent shades — never hand-pick these again */
  --accent-strong: color-mix(in srgb, var(--accent) 85%, black);
  --accent-soft:   color-mix(in srgb, var(--accent) 10%, var(--surface));
  --accent-ring:   color-mix(in srgb, var(--accent) 30%, transparent);

  /* ── Core palette (light) ── */
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #fbfcfd;
  --text:      #16213a;
  --muted:     #65718a;
  --border:    #e6eaf1;

  /* ── Status colours ── */
  --green:    #1d8a55;  --green-bg:  color-mix(in srgb, #1d8a55 10%, var(--surface));
  --amber:    #b45309;  --amber-bg:  color-mix(in srgb, #f59e0b 12%, var(--surface));
  --red:      #c4344b;  --red-bg:    color-mix(in srgb, #c4344b 10%, var(--surface));
  --violet:   #7c3aed;  --violet-bg: color-mix(in srgb, #7c3aed 10%, var(--surface));

  /* ── Effects ── */
  --shadow-sm: 0 1px 2px rgba(22,33,58,.05);
  --shadow-md: 0 4px 16px -4px rgba(22,33,58,.10);
  --header-bg: rgba(255,255,255,.78);
  --radius: 14px;

  /* ── Legacy aliases (older templates still reference these) ── */
  --navy:       #1b2d4f;
  --navy-dark:  #111e36;
  --cream:      var(--bg);
  --accent-dark:  var(--accent-strong);   /* may be overridden per-org */
  --accent-light: var(--accent-soft);     /* may be overridden per-org */
  --orange:    var(--amber);
  --orange-bg: var(--amber-bg);
  /* Old nav vars — retained so per-org injection doesn't error; the
     2026 header is neutral/frosted and no longer consumes these. */
  --nav-effective-bg:     var(--surface);
  --nav-effective-text:   var(--text);
  --nav-effective-border: var(--border);
}

/* ── Dark theme ──
   html[data-theme="dark"] (0,1,1) outranks the :root (0,1,0) overrides
   injected per-org in base.html, so dark mode wins even for branded orgs. */
html[data-theme="dark"] {
  --accent-soft: color-mix(in srgb, var(--accent) 18%, var(--surface));

  --bg:        #0e1320;
  --surface:   #161d2e;
  --surface-2: #1b2336;
  --text:      #e8edf6;
  --muted:     #8c97ad;
  --border:    #273249;

  --green: #4ade80;  --green-bg:  color-mix(in srgb, #4ade80 14%, var(--surface));
  --amber: #fbbf24;  --amber-bg:  color-mix(in srgb, #fbbf24 14%, var(--surface));
  --red:   #f87171;  --red-bg:    color-mix(in srgb, #f87171 14%, var(--surface));
  --violet:#a78bfa;  --violet-bg: color-mix(in srgb, #a78bfa 14%, var(--surface));

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 6px 20px -4px rgba(0,0,0,.45);
  --header-bg: rgba(14,19,32,.72);

  /* Branded nav colours apply in light mode only — dark keeps a neutral
     header so a white/light branding choice can't blind a dark page. */
  --nav-effective-bg:     var(--surface);
  --nav-effective-text:   var(--text);
  --nav-effective-border: var(--border);

  /* Legacy aliases re-pointed for dark surfaces */
  --navy:       #dbe4f3;   /* mostly used as a text colour */
  --navy-dark:  #eef3fb;
  --accent-light: color-mix(in srgb, var(--accent) 18%, var(--surface));
  --accent-dark:  color-mix(in srgb, var(--accent) 70%, white);
}

/* ════════════════════════════════════════════════════════════════
   SKINS — Formal (default, no attribute) vs Casual (data-skin)
   Casual carries the pre-v12 personality — Nunito, navy/cream,
   warmer tones — re-expressed through the v12 token system.
   Combined selector (html[data-skin][data-theme]) outranks both
   single-attribute blocks, so all four combinations resolve cleanly.
   ════════════════════════════════════════════════════════════════ */

/* ── Casual · light (the classic v11 palette) ── */
html[data-skin="casual"] {
  --font: 'Nunito', system-ui, sans-serif;

  --bg:        #f5f3ef;   /* cream */
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --text:      #1b2d4f;   /* navy */
  --muted:     #6b7d96;
  --border:    #dce3ef;

  --green: #276749;  --green-bg: color-mix(in srgb, #276749 10%, var(--surface));
  --amber: #b45309;  --amber-bg: color-mix(in srgb, #f59e0b 14%, var(--surface));
  --red:   #c53030;  --red-bg:   color-mix(in srgb, #c53030 10%, var(--surface));

  --shadow-sm: 0 1px 3px rgba(27,45,79,.07);
  --shadow-md: 0 4px 18px -2px rgba(27,45,79,.14);
  --header-bg: rgba(255,255,255,.85);
  --radius: 14px;

  --navy: #1b2d4f;
  --navy-dark: #111e36;
}

/* ── Casual · dark (warm dark navy) ── */
html[data-skin="casual"][data-theme="dark"] {
  --bg:        #121a2c;
  --surface:   #1a2338;
  --surface-2: #202b44;
  --text:      #e9edf6;
  --muted:     #93a1bb;
  --border:    #2c3a59;

  --green: #4ade80;  --green-bg: color-mix(in srgb, #4ade80 14%, var(--surface));
  --amber: #fbbf24;  --amber-bg: color-mix(in srgb, #fbbf24 14%, var(--surface));
  --red:   #f87171;  --red-bg:   color-mix(in srgb, #f87171 14%, var(--surface));

  --shadow-sm: 0 1px 2px rgba(0,0,0,.32);
  --shadow-md: 0 6px 22px -4px rgba(0,0,0,.5);
  --header-bg: rgba(18,26,44,.75);

  --navy: #dbe4f3;
  --navy-dark: #eef3fb;
}

/* ── Casual personality — chunkier strokes, heavier type ── */
html[data-skin="casual"] { --radius: 16px; }
html[data-skin="casual"] :is(.btn, .search-input, .session-select, .tab-btn,
                             .leaver-toggle, .form-group input, .form-group select,
                             .form-group textarea, .form-input) { border-width: 2px; }
html[data-skin="casual"] :is(.card, .member-card, .stat-card, .reg-card,
                             .data-table, .activity-feed, .callout) { border-width: 2px; }
html[data-skin="casual"] .callout { border-left-width: 3px; }
html[data-skin="casual"] :is(h1, h2, h3, .btn, .stat-value) { font-weight: 800; }
html[data-skin="casual"] .avatar { border-radius: 50%; }      /* classic round avatars */
html[data-skin="casual"] .btn { border-radius: 12px; }

/* ── Casual LIGHT is the faithful v11 stylesheet ──
   Loaded from static/css/skin-casual.css (generated verbatim from git
   42906ff). Its rules are scoped html[data-skin="casual"]:not([data-theme=
   "dark"]) and out-rank everything above, so casual light = exact v11:
   navy header (via --nav-effective-*), white underline nav, cream pages.
   Casual DARK falls back to the v12 components with the warm tokens above. */

/* ── Emoji ↔ Lucide icon switching ──
   Templates render both forms; the active skin decides which shows.
   Formal: Lucide SVGs.  Casual (light & dark): the classic emojis. */
.ico-emoji { display: none; }
html[data-skin="casual"] .ico-emoji { display: inline; }
html[data-skin="casual"] .brand-mark { display: none; }
html[data-skin="casual"] :is(.nav-icon, .stat-icon, .activity-icon, .callout-icon) .lucide { display: none; }
/* Any dual-render container (element that has a direct .ico-emoji child) hides its Lucide SVG in casual */
html[data-skin="casual"] :has(> .ico-emoji) .lucide { display: none; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg); color: var(--text);
  min-height: 100vh; font-size: 14px; line-height: 1.5;
  display: flex; flex-direction: column;
  transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}

/* Lucide icon defaults */
.lucide { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; vertical-align: -3px; }

/* ─── APP HEADER — frosted, sticky, honours per-org nav branding ──
   --nav-effective-* come from the branding settings (dark/accent/white).
   The colour is applied as a translucent tint so the frosted blur keeps
   working; with no branding it resolves to the neutral surface colour.  */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 24px;
  background: color-mix(in srgb, var(--nav-effective-bg) 84%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--nav-effective-border);
  color: var(--nav-effective-text);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 15.5px; font-weight: 800; letter-spacing: -.01em; }
.brand a { color: var(--nav-effective-text); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff; box-shadow: 0 2px 8px var(--accent-ring); flex-shrink: 0;
}
.brand-mark .lucide { width: 17px; height: 17px; }
.brand-icon { font-size: 22px; }
.brand-logo { height: 34px; width: auto; max-width: 160px; object-fit: contain; }

.header-right { display: flex; align-items: center; gap: 10px; }
/* Header pills/buttons derive from the nav text colour so they read
   correctly on white, dark-navy and accent branded headers alike. */
.user-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--nav-effective-text) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--nav-effective-text) 16%, transparent);
  border-radius: 99px; padding: 5px 13px;
  font-size: 12.5px; font-weight: 600; color: var(--nav-effective-text);
}
.logout-btn {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--nav-effective-text) 28%, transparent);
  color: color-mix(in srgb, var(--nav-effective-text) 80%, transparent);
  border-radius: 9px; padding: 6px 13px;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: all .18s;
}
.logout-btn:hover { color: var(--nav-effective-text); border-color: var(--nav-effective-text); }

/* Square icon button (theme toggle, etc.) */
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--nav-effective-text) 16%, transparent);
  background: color-mix(in srgb, var(--nav-effective-text) 9%, transparent);
  color: color-mix(in srgb, var(--nav-effective-text) 80%, transparent);
  cursor: pointer; transition: all .15s;
}
.icon-btn:hover { color: var(--nav-effective-text); background: color-mix(in srgb, var(--nav-effective-text) 16%, transparent); }

/* ─── SESSION PILL / SWITCHER ──────────────────── */
.session-pill {
  display: flex; align-items: center; gap: 7px;
  background: color-mix(in srgb, var(--nav-effective-text) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--nav-effective-text) 16%, transparent);
  border-radius: 99px; padding: 5px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--nav-effective-text);
  white-space: nowrap;
}
.session-pill-dot {
  width: 7px; height: 7px; background: var(--green); border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent);
}
.session-pill-btn { cursor: pointer; font-family: inherit; transition: border-color .15s; }
.session-pill-btn:hover { border-color: var(--accent); }

.session-switcher { position: relative; }
.session-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-md); min-width: 170px; z-index: 500; overflow: hidden; padding: 4px;
}
.session-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; background: none; border: none; border-radius: 8px;
  text-align: left; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); cursor: pointer; transition: background .12s;
}
.session-menu-item:hover  { background: var(--surface-2); }
.session-menu-item.active { background: var(--accent-soft); color: var(--accent); }

/* ─── NAV — frosted secondary bar, pill links ───── */
.app-nav {
  background: var(--header-bg);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
  display: flex; gap: 2px;
  position: relative;  /* anchor for sliding pill */
}
/* Sliding active pill — positioned by JS */
#nav-pill {
  position: absolute;
  background: var(--accent-soft);
  border-radius: 9px;
  pointer-events: none;
  z-index: 0;
}
.nav-link {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600;
  color: var(--muted); text-decoration: none;
  position: relative; z-index: 1;   /* stay above pill */
  transition: color .15s;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--accent); background: transparent; }
.nav-link.soon { opacity: 0.5; pointer-events: none; }
.nav-icon { font-size: 15px; display: inline-flex; align-items: center; }
.nav-icon .lucide { width: 15.5px; height: 15.5px; }
.soon-tag {
  font-size: 9px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; padding: 1px 5px;
  letter-spacing: .05em; text-transform: uppercase;
}

/* ─── COMING SOON PAGE ──────────────────────────── */
.coming-soon {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 80px 24px; max-width: 480px; margin: 0 auto;
}
.coming-soon-icon { font-size: 52px; margin-bottom: 20px; }
.coming-soon h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 10px; }
.coming-soon p { font-size: 15px; color: var(--muted); line-height: 1.6; }
.version-badge {
  display: inline-block; margin-top: 20px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 99px; padding: 6px 16px; font-size: 13px; font-weight: 700;
}

/* ─── PAGE CONTENT ──────────────────────────────── */
.page-content { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 28px 24px; }

/* ─── TOOLBAR ───────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 0 1 280px; min-width: 160px; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; width: 16px; height: 16px;
}
.search-input {
  width: 100%; height: 44px; padding: 0 14px 0 42px;
  border: 1px solid var(--border); border-radius: 11px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  outline: none; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.session-select {
  height: 44px; padding: 0 30px 0 12px; appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2365718a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center;
  border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); outline: none; cursor: pointer;
  transition: border-color .15s;
}
.session-select:hover { border-color: color-mix(in srgb, var(--muted) 40%, var(--border)); }
.session-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.leaver-toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted);
  white-space: nowrap; transition: border-color .18s, color .18s; user-select: none;
}
.leaver-toggle:hover { border-color: var(--accent); color: var(--text); }
.leaver-toggle.active { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.leaver-toggle input { display: none; }

.count-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 99px; padding: 8px 16px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
  cursor: pointer; user-select: none;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  transition: border-color .18s, background .18s;
}
.count-pill:hover { border-color: var(--accent); }
.count-pill.showing-all { background: var(--accent); color: #fff; }

/* ─── MEMBER CARDS (base styles; members page refines) ── */
.members-grid { display: flex; gap: 12px; align-items: flex-start; }
.member-col { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.member-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  overflow: hidden; cursor: pointer;
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
}
.member-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: var(--shadow-md);
}
.member-card.expanded { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); transform: none; }

.card-head { padding: 13px 15px; display: flex; align-items: flex-start; gap: 11px; user-select: none; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px;
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13.5px; flex-shrink: 0; margin-top: 1px;
}
.card-name-wrap { flex: 1; min-width: 0; }
.card-name-wrap h3 {
  font-size: 14.5px; font-weight: 700; color: var(--text); letter-spacing: -.01em;
  line-height: 1.3; white-space: normal; overflow: visible; word-break: break-word;
}
.card-member-id {
  display: inline-block;
  font-family: ui-monospace, 'SF Mono', monospace; font-size: 10.5px; font-weight: 600;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 7px;
}
.card-name-wrap p { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.chevron { color: var(--muted); font-size: 12px; transition: transform .25s; flex-shrink: 0; margin-top: 4px; }
.member-card.expanded .chevron { transform: rotate(180deg); }

.card-body { display: none; border-top: 1px solid var(--border); }
.member-card.expanded .card-body { display: block; }

.detail-section { padding: 13px 17px; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }
.sec-title {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 10px;
}
.dg { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 18px; }
.di .lbl { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.di .val { font-size: 13.5px; font-weight: 600; color: var(--text); margin-top: 1px; word-break: break-word; }
.di.full { grid-column: 1 / -1; }

.badge { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; }
.badge-yes    { background: var(--red-bg);    color: var(--red); }
.badge-no     { background: var(--green-bg);  color: var(--green); }
.badge-active { background: var(--green-bg);  color: var(--green); }
.badge-leaver { background: var(--amber-bg);  color: var(--amber); }
.badge-admin  { background: var(--accent);    color: #fff; }
.badge-editor { background: var(--accent-soft); color: var(--accent); }
.badge-leader { background: var(--green-bg);  color: var(--green); }
.badge-ro       { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-inactive { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ─── STATES ─────────────────────────────────────── */
.loading-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .75s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state p { font-size: 14px; font-weight: 600; }

.prompt-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.prompt-icon { font-size: 40px; margin-bottom: 14px; }
.prompt-state h3 { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.prompt-state p  { font-size: 14px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 14px; font-weight: 600; }

/* ─── BUTTONS ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-family: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all .18s; text-decoration: none;
}
.btn .lucide { width: 14.5px; height: 14.5px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px var(--accent-ring); }
.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn-teal { background: var(--accent); color: #fff; box-shadow: 0 2px 8px var(--accent-ring); }
.btn-teal:hover { background: var(--accent-strong); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--border)); background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ─── MODAL ──────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(8,12,22,.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 200; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 18px; padding: 32px;
  width: 100%; max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  max-height: 90vh; overflow-y: auto;
  animation: modal-rise .22s ease both;
}
@keyframes modal-rise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px;
  position: sticky; bottom: -32px;
  padding: 16px 32px 24px;
  margin-left: -32px; margin-right: -32px;
  background: var(--surface); border-top: 1px solid var(--border);
}

/* ─── FORM ELEMENTS ──────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea,
.form-input {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 14px; color: var(--text);
  outline: none; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* ─── TABLE ──────────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  background: var(--surface); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.data-table th {
  background: var(--surface-2); color: var(--muted);
  padding: 11px 16px; text-align: left;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle; font-weight: 500;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--accent-soft); }
.data-table .actions { display: flex; gap: 8px; }

/* ─── PAGE HEADER ROW ────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.page-header .sub { color: var(--muted); font-size: 13.5px; font-weight: 500; margin-top: 3px; }

/* ─── DASHBOARD / DOCUMENTS shared ──────────────── */
.dash-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  color: var(--text); margin-bottom: 10px;
}
.dash-section-title .lucide { width: 16px; height: 16px; color: var(--muted); }

/* Generic surface card */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}

/* Text-link style button */
.link-btn {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent); font-weight: 600; font-size: 13px; text-decoration: none;
  padding: 5px 10px; border-radius: 8px; transition: background .15s;
  border: none; background: transparent; font-family: inherit; cursor: pointer;
}
.link-btn:hover { background: var(--accent-soft); }
.link-btn .lucide { width: 14px; height: 14px; }

/* ─── DETAIL LABEL/VALUE (approvals cards) ───────── */
.detail-label {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px;
}
.detail-value { font-size: 13.5px; font-weight: 600; color: var(--text); word-break: break-word; }

/* ─── TAB BAR (approvals, etc.) ─────────────────── */
.tab-btn {
  padding: 8px 17px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); font-family: inherit;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: border-color .18s, color .18s, background .18s;
}
.tab-btn:hover  { border-color: var(--accent); color: var(--text); }
.tab-btn.active { border-color: var(--accent); background: var(--accent); color: #fff; }

/* ─── FLAG BADGES (medical, unattended exit) ─────── */
.flag-badge {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  border-radius: 99px; padding: 2px 9px; margin-left: 6px; vertical-align: middle;
}
.flag-medical    { background: var(--red-bg); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); }
.flag-unattended { background: var(--amber-bg); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); }

/* ─── MEMBER NAME (used in approvals) ───────────── */
.member-name { font-size: 17px; font-weight: 700; color: var(--text); }

/* ─── ALERT BOX ──────────────────────────────────── */
.alert-box { padding: 14px 18px; border-radius: 12px; margin-bottom: 16px; font-size: 14px; line-height: 1.7; }
.alert-box.err { background: var(--red-bg); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); }
.alert-box strong { font-size: 15px; font-weight: 800; display: block; margin-bottom: 6px; }

/* ─── FLASH / TOAST ──────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: var(--bg);
  padding: 13px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-md); z-index: 300;
  opacity: 0; transform: translateY(12px);
  transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err  { background: var(--red); color: #fff; }

/* ─── ENTRANCE ANIMATION (opt-in via .rise) ─────── */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .4s ease both; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────
   Five layout tiers:
   Desktop            > 1199px   (default — no query)
   Tablet landscape   1024–1199px
   Tablet portrait    768–1023px  ← main iPad portrait fix
   Mobile landscape   480–767px
   Mobile portrait    < 480px
   ─────────────────────────────────────────────────────────────── */

/* ── Tablet landscape (1024–1199px) ────────────────────────────── */
@media (max-width: 1199px) {
  .page-content  { padding: 24px 20px; }
  .app-nav       { padding: 6px 14px; }
  .nav-link      { padding: 8px 11px; font-size: 13px; }
}

/* ── Tablet portrait (768–1023px) — primary iPad fix ───────────── */
@media (max-width: 1023px) {
  .app-header    { height: 56px; padding: 0 16px; }
  .page-content  { padding: 18px 14px; }

  /* Nav becomes horizontally scrollable so every item stays reachable */
  .nav-scroll-wrap { position: relative; overflow: hidden; }
  .nav-scroll-wrap::after {
    content: '';
    position: absolute; top: 0; right: 0; bottom: 0; width: 32px;
    background: linear-gradient(to right, transparent, var(--bg));
    pointer-events: none; z-index: 1;
  }
  .app-nav {
    padding: 6px 8px;
    overflow-x: auto; overflow-y: hidden;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap; gap: 0;
  }
  .app-nav::-webkit-scrollbar { display: none; }
  .nav-link {
    padding: 8px 10px; font-size: 12px; font-weight: 600;
    white-space: nowrap; flex-shrink: 0; gap: 4px;
  }
  .nav-icon { font-size: 14px; }

  .members-grid  { gap: 10px; }
  .toolbar       { gap: 8px; }
  .search-wrap   { min-width: 160px; }
  .page-header h1 { font-size: 18px; }

  .data-table              { font-size: 13px; }
  .data-table th,
  .data-table td           { padding: 10px 12px; }
}

/* ── Mobile landscape (480–767px) ──────────────────────────────── */
@media (max-width: 767px) {
  .page-content  { padding: 14px 12px; }

  .nav-label     { display: none; }
  .nav-link      { padding: 9px 13px; }
  .brand-label   { display: none; }

  .members-grid  { gap: 8px; }
  .member-col    { gap: 8px; }
  .dg            { grid-template-columns: 1fr; }
  .user-pill     { display: none; }

  .data-table th:nth-child(n+4),
  .data-table td:nth-child(n+4) { display: none; }

  .modal-overlay { padding: 12px; }
  .modal         { padding: 20px 16px; border-radius: 14px; }
  .modal-footer  { padding: 12px 16px 16px; margin-left: -16px; margin-right: -16px; bottom: -20px; }

  .card-actions  { flex-wrap: wrap; }
  .app-footer    { flex-direction: column; gap: 3px; text-align: center; padding: 10px 16px; }
}

/* ── Mobile portrait (< 480px) ─────────────────────────────────── */
@media (max-width: 479px) {
  .app-header    { height: 50px; padding: 0 12px; }
  .logout-btn    { padding: 5px 10px; font-size: 12px; }
  .page-content  { padding: 10px 8px; }
  .nav-link      { padding: 9px 11px; }
  .nav-icon      { font-size: 15px; }
  .modal         { padding: 16px 12px; border-radius: 12px; }
  .modal h2      { font-size: 16px; margin-bottom: 14px; }
  .page-header h1 { font-size: 15px; }
  .btn           { padding: 8px 13px; font-size: 13px; }
  .btn-sm        { padding: 5px 10px; font-size: 11.5px; }
}

/* ─── APP FOOTER ─────────────────────────────────── */
.app-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 24px; font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--surface);
}
.footer-version { font-weight: 700; letter-spacing: .04em; color: var(--accent); opacity: .7; }

/* ── Page-transition slide (nav clicks) ─────────────────────────────── */
@keyframes _page-in {
  from { opacity: 0; transform: translateX(28px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes _page-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-28px); }
}
@media (prefers-reduced-motion: no-preference) {
  .page-content {
    animation: _page-in .22s cubic-bezier(.25,.46,.45,.94) both;
  }
  .page-content.page-exit {
    animation: _page-out .17s cubic-bezier(.55,0,1,.45) both;
    pointer-events: none;
  }
}

/* ── Audit pagination controls ───────────────────────────────────────── */
.audit-pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  padding: 14px 0 4px;
  font-size: 13px; color: var(--muted);
}
.audit-pager-btns { display: flex; align-items: center; gap: 6px; }
.audit-pager-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background .14s, border-color .14s;
}
.audit-pager-btn:hover:not(:disabled) {
  background: var(--surface-2); border-color: var(--accent);
}
.audit-pager-btn:disabled { opacity: .38; cursor: default; }
.audit-pager-info { font-weight: 500; }
