:root {
  color-scheme: light dark;
  /* Palette ported from /home/ravi/smartgateway's style.css (light values below; dark override
     further down). Old token names (--bg/--fg/--muted/--border/--accent/--danger) are kept as
     aliases onto this palette so every existing rule below still resolves correctly. */
  --bg: #f0f4fa;
  --s1: #ffffff; --s2: #f5f7fc; --s3: #eaf0fb;
  --b1: #cdd8ee; --b2: #b0c2e0; --b3: #93aed5;
  --blue: #2a6ef5; --blue2: #1a5ae0; --blue3: rgba(42, 110, 245, 0.10);
  --cyan: #007b87; --cyan2: rgba(0, 123, 135, 0.10);
  --emerald: #00875a; --em2: rgba(0, 135, 90, 0.10);
  --amber: #b06a00; --am2: rgba(176, 106, 0, 0.10);
  --rose: #d01030; --rose2: rgba(208, 16, 48, 0.10);
  --indigo: #5b4dd4; --in2: rgba(91, 77, 212, 0.10);
  --text: #0f1a2e; --text2: #253d5e; --text3: #5570a0;
  --sh: 0 4px 24px rgba(0, 0, 0, 0.12);
  --shb: 0 0 20px rgba(42, 110, 245, 0.15);
  --r: 8px; --rl: 12px; --rxl: 16px; --r2xl: 22px;
  --ff: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fh: var(--ff);
  --tr: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --topbar1-h: 56px;

  /* aliases used throughout this file */
  --fg: var(--text);
  --muted: var(--text3);
  --border: var(--b1);
  --accent: var(--blue);
  --danger: var(--rose);
  --login-card-bg: rgba(255, 255, 255, 0.92);
  --login-card-border: rgba(255, 255, 255, 0.6);
  --topbar-bg: rgba(255, 255, 255, 0.9);
}

/* Three-state theme: system default (this media query, unless overridden), or an explicit
   data-theme="light"/"dark" on <html> set by the theme picker (see app.js applyTheme()) and
   persisted to localStorage. :not([data-theme="light"]) lets an explicit light choice win even
   under a dark OS preference; the [data-theme="dark"] block below does the same in reverse. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #05080f;
    --s1: #0c1220; --s2: #111b2e; --s3: #162238;
    --b1: #1a2e4a; --b2: #243d60; --b3: #2d5080;
    --blue: #2a6ef5; --blue2: #4d8bf7; --blue3: rgba(42, 110, 245, 0.15);
    --cyan: #00c6d4; --cyan2: rgba(0, 198, 212, 0.12);
    --emerald: #00c896; --em2: rgba(0, 200, 150, 0.12);
    --amber: #f0a030; --am2: rgba(240, 160, 48, 0.12);
    --rose: #f04560; --rose2: rgba(240, 69, 96, 0.12);
    --indigo: #7c6ff7; --in2: rgba(124, 111, 247, 0.12);
    --text: #f0f4ff; --text2: #b8ccee; --text3: #7a96b8;
    --sh: 0 8px 40px rgba(0, 0, 0, 0.55);
    --shb: 0 0 28px rgba(42, 110, 245, 0.25);
    --login-card-bg: rgba(12, 18, 32, 0.88);
    --login-card-border: rgba(255, 255, 255, 0.08);
    --topbar-bg: rgba(8, 14, 28, 0.92);
  }
}

:root[data-theme="dark"] {
  --bg: #05080f;
  --s1: #0c1220; --s2: #111b2e; --s3: #162238;
  --b1: #1a2e4a; --b2: #243d60; --b3: #2d5080;
  --blue: #2a6ef5; --blue2: #4d8bf7; --blue3: rgba(42, 110, 245, 0.15);
  --cyan: #00c6d4; --cyan2: rgba(0, 198, 212, 0.12);
  --emerald: #00c896; --em2: rgba(0, 200, 150, 0.12);
  --amber: #f0a030; --am2: rgba(240, 160, 48, 0.12);
  --rose: #f04560; --rose2: rgba(240, 69, 96, 0.12);
  --indigo: #7c6ff7; --in2: rgba(124, 111, 247, 0.12);
  --text: #f0f4ff; --text2: #b8ccee; --text3: #7a96b8;
  --sh: 0 8px 40px rgba(0, 0, 0, 0.55);
  --shb: 0 0 28px rgba(42, 110, 245, 0.25);
  --login-card-bg: rgba(12, 18, 32, 0.88);
  --login-card-border: rgba(255, 255, 255, 0.08);
  --topbar-bg: rgba(8, 14, 28, 0.92);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ff);
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

body.login-page {
  background-image: url('/login-bg.svg');
  background-size: cover;
  /* was "center bottom" - the login card is also horizontally centered, so it sat directly on
     top of the skyline's focal point. Shifting the image left moves that out from behind it. */
  background-position: left bottom;
  background-repeat: no-repeat;
}

.login-card {
  max-width: 400px;
  margin: 6rem auto;
  background: var(--login-card-bg);
  border: 1px solid var(--login-card-border);
  border-radius: var(--r2xl);
  padding: 1.75rem 2rem 2rem;
  box-shadow: 0 20px 50px rgba(10, 20, 40, 0.25);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  min-height: 2.5rem;
}

.app-title { font-weight: 700; font-size: 1.1rem; }
.app-user { color: var(--muted); font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; }

/* Every render replaces #app-root's (== <main>) content wholesale with either a self-contained
   .login-card (own max-width/margin/padding) or .app-body (full-width sidebar+content shell) -
   main itself just needs to participate in the flex column and hand height down to whichever. */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
}
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; }

input, textarea, select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 0.9rem;
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; margin-top: 0.75rem; }

.card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.card-link { text-decoration: none; color: inherit; display: block; }

.card-row { display: flex; justify-content: space-between; align-items: center; }

.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 0.5rem; }

.callout {
  border: 2px solid var(--accent);
  border-radius: var(--rl);
  padding: 1rem;
  margin: 1rem 0;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--blue3);
}

.section-title { font-weight: 600; margin: 1.5rem 0 0.5rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }

.list-item { background: var(--s1); border: 1px solid var(--border); border-radius: var(--r); padding: 0.6rem 0.75rem; margin-bottom: 0.5rem; display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }

.muted { color: var(--muted); font-size: 0.85rem; }

.attachment-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

.field-checkbox-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; }
.field-checkbox-row input[type="checkbox"] { width: auto; margin: 0; }
.field-checkbox-row label { margin: 0; color: var(--fg); font-size: 0.9rem; cursor: pointer; }
.checkbox-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.75rem; }
.checkbox-list .field-checkbox-row { margin-top: 0.4rem; }
.checkbox-list .field-checkbox-row:first-child { margin-top: 0; }
.access-row { align-items: flex-start; }
.access-row-contact { font-size: 0.8rem; margin-top: 0.1rem; }
input[type="color"] { padding: 0.2rem; height: 2.3rem; cursor: pointer; }

.color-swatch { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 50%; border: 1px solid var(--border); vertical-align: middle; }
.icon-thumb { width: 22px; height: 22px; object-fit: contain; border-radius: 4px; vertical-align: middle; }

/* ── EVENTS: sidebar filters + split view ───────────────────────────── */
/* Lives in the sidebar itself, directly under the "Event List" nav item (see buildSidebar /
   renderEventList) - empty (so invisible) on every other page, since nothing else populates it. */
.sidebar-filters:not(:empty) { padding: 0.6rem 1rem 0.9rem; border-bottom: 1px solid var(--b1); margin-bottom: 0.4rem; }
.sidebar-filters .sf-field { display: flex; flex-direction: column; margin-bottom: 0.6rem; }
.sidebar-filters .sf-field label { margin: 0 0 0.2rem; font-size: 0.68rem; }
.sidebar-filters input, .sidebar-filters select { font-size: 0.78rem; padding: 0.35rem 0.5rem; }
.sidebar-filters .sf-actions { display: flex; gap: 0.4rem; }
.sidebar-filters .sf-actions button { flex: 1; font-size: 0.76rem; padding: 0.35rem 0.3rem; }
.sidebar-filters .sf-sort-row { display: flex; gap: 0.35rem; }
.sidebar-filters .sf-sort-row select { flex: 1; min-width: 0; }
.sidebar-filters .sf-sort-row button { flex-shrink: 0; white-space: nowrap; font-size: 0.72rem; padding: 0.35rem 0.5rem; }
.sidebar.collapsed .sidebar-filters { display: none; }

.events-split { display: flex; gap: 1rem; align-items: flex-start; min-height: 0; }
.events-list-pane {
  width: 320px; flex-shrink: 0; background: var(--s1); border: 1px solid var(--b1); border-radius: var(--rl);
  overflow-y: auto; max-height: calc(100vh - 180px); transition: width 0.18s ease, min-width 0.18s ease; position: relative;
}
.events-list-pane.collapsed { width: 40px; min-width: 40px; overflow: hidden; }
.events-list-pane.collapsed .tree-root, .events-list-pane.collapsed .events-list-tabs { display: none; }
/* Sits below the floated collapse button rather than beside it (a flex container next to a float
   doesn't wrap under it on its own), and is tightened up from the default .app-tab-bar spacing -
   which was sized for a full-width page header - to fit this 320px-wide pane. */
.events-list-tabs { clear: both; margin: 0.5rem 0.5rem 0; }
.events-list-tabs .app-tab-btn { padding: 0.4rem 0.7rem; font-size: 0.78rem; }
.events-detail-pane {
  flex: 1; min-width: 0; background: var(--s1); border: 1px solid var(--b1); border-radius: var(--rl);
  padding: 1.1rem 1.25rem; max-height: calc(100vh - 180px); overflow-y: auto;
}
.events-detail-pane.collapsed { display: none; }
.pane-collapse-btn {
  position: sticky; top: 0; float: right; margin: 0.4rem 0.4rem 0 0; width: 26px; height: 26px; padding: 0;
  border-radius: 6px; background: var(--s2); z-index: 5;
}

.tree-root { padding: 0.4rem; }
.tree-node-row {
  display: flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.5rem; border-radius: 6px; cursor: pointer;
  font-size: 0.85rem; color: var(--text2); transition: var(--tr);
}
.tree-node-row:hover { background: var(--blue3); color: var(--text); }
.tree-node-row.active { background: var(--blue3); color: var(--blue2); font-weight: 700; }
.tree-toggle { width: 1rem; text-align: center; flex-shrink: 0; color: var(--text3); font-size: 0.7rem; cursor: pointer; }
.tree-toggle.leaf { visibility: hidden; }
.tree-node-icon { width: 16px; height: 16px; border-radius: 4px; object-fit: contain; flex-shrink: 0; }
.tree-node-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; flex-shrink: 0; }
.tree-node-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tree-children { margin-left: 1.35rem; }
.tree-children.hidden { display: none; }
.tree-reorder { margin-left: auto; display: flex; gap: 2px; flex-shrink: 0; }
.tree-reorder-btn { width: 18px; height: 18px; padding: 0; font-size: 0.55rem; line-height: 1; border-radius: 4px; flex-shrink: 0; }

.dp-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.75rem; }
.dp-title { font-size: 1.1rem; font-weight: 800; color: var(--text); font-family: var(--fh); }

.stat-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.75rem 0 0.25rem; }
.stat-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 84px;
  padding: 0.5rem 0.75rem; border-radius: var(--r); background: var(--s2); border: 1px solid var(--b1);
}
.stat-chip .sc-val { font-size: 1.05rem; font-weight: 800; color: var(--text); font-family: var(--fh); }
.stat-chip .sc-label { font-size: 0.62rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.1rem; }
.stat-chip .sc-sub { font-size: 0.6rem; color: var(--text3); margin-top: 0.15rem; text-align: center; }
.cost-rollup-line { font-size: 0.78rem; color: var(--text3); margin: 0.2rem 0 0.6rem; }

/* ── BASIC TAB: End date / trip "Ends" slot ─────────────────────────────── */
/* Same grid cell as the End date input it stands in for, so a Trip's Basic tab renders at the same
   height/shape as any other event type - no extra trailing line, no layout shift. */
.end-computed-text {
  margin: 0; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--s2); color: var(--fg); font-size: 0.9rem; min-height: 1.2em;
}

/* ── PHOTOS TAB (event detail + global Upload Photos page) ─────────────── */
.photo-toolbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.photo-toolbar .spacer { flex: 1; }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.view-toggle button { border: none; border-radius: 0; }
.view-toggle button.active { background: var(--accent); color: #fff; }

/* ── FILES TAB (event detail) ───────────────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 0.5rem; }
.file-row { display: flex; align-items: center; gap: 0.6rem; }
.file-row-icon { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--bg2, #eee); }
.file-row .pr-info { flex: 1; min-width: 0; }
.file-row .pr-info > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row a { flex-shrink: 0; }
.file-row .danger { flex-shrink: 0; }

/* ── VIDEO TAB (event detail) ───────────────────────────────────────────── */
.video-list { display: flex; flex-direction: column; gap: 0.75rem; }
.video-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.video-thumb-wrap {
  position: relative; width: 220px; max-width: 100%; aspect-ratio: 16/9; border-radius: 6px;
  background: #000; flex-shrink: 0; cursor: pointer; overflow: hidden;
}
.video-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; color: rgba(255,255,255,0.9); text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  pointer-events: none;
}
.video-row .pr-info { flex: 1; min-width: 0; }
.video-row .pr-info > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-row a { flex-shrink: 0; }
.video-row .danger { flex-shrink: 0; }

/* ── ATTACHMENT UPLOAD REVIEW MODAL ─────────────────────────────────────── */
.review-section { margin-bottom: 1.1rem; }
.review-section:last-of-type { margin-bottom: 0; }
.review-section-title { font-weight: 600; font-size: 0.88rem; color: var(--text); margin-bottom: 0.4rem; }
.review-file-list { list-style: none; margin: 0 0 0.6rem; padding: 0; max-height: 140px; overflow-y: auto; }
.review-file-list li { font-size: 0.82rem; color: var(--text3); padding: 0.15rem 0; }
.field-radio-row { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.4rem; }
.field-radio-row label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--fg); margin: 0; cursor: pointer; }
.field-radio-row input[type="radio"] { width: auto; margin: 0; }

/* ── IMAGE PROPERTIES MODAL (global) ────────────────────────────────────── */
.exif-viewer-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; min-height: 260px; margin-top: 1.25rem; }
.exif-viewer-layout.hidden { display: none; }
.exif-file-col { display: flex; flex-direction: column; min-width: 0; }
.exif-file-list { list-style: none; margin: 0.6rem 0 0; padding: 0; overflow-y: auto; max-height: 65vh; border: 1px solid var(--b1); border-radius: var(--r); }
.exif-file-item { padding: 0.5rem 0.7rem; font-size: 0.82rem; color: var(--text2); cursor: pointer; border-bottom: 1px solid var(--b1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exif-file-item:last-child { border-bottom: none; }
.exif-file-item:hover { background: var(--s2); }
.exif-file-item.active { color: var(--blue2); background: var(--blue3); font-weight: 600; }
.exif-props-col { border: 1px solid var(--b1); border-radius: var(--r); padding: 0.75rem 0.85rem; min-width: 0; }
.exif-preview { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: contain; border-radius: var(--r); background: var(--s2); margin-bottom: 0.6rem; }
.exif-prop-row { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.4rem 0; border-bottom: 1px solid var(--b1); }
.exif-prop-row:last-child { border-bottom: none; }
.exif-prop-label { font-size: 0.68rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.6rem; }
.photo-grid-item { position: relative; border-radius: var(--r); overflow: hidden; border: 1px solid var(--border); cursor: pointer; background: var(--s2); aspect-ratio: 1; }
.photo-grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid-item .pg-check { position: absolute; top: 4px; left: 4px; width: 1.05rem; height: 1.05rem; z-index: 2; }
.photo-grid-item.is-selected { outline: 2px solid var(--blue2); outline-offset: -2px; }
.photo-grid-item.is-selected::after { content: ''; position: absolute; inset: 0; background: var(--blue3); pointer-events: none; z-index: 1; }
.photo-grid-item .pg-recreate-thumb {
  position: absolute; top: 4px; right: 4px; z-index: 2; width: 1.4rem; height: 1.4rem; padding: 0;
  line-height: 1; font-size: 0.75rem; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
}
.photo-grid-item .pg-caption { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.55); color: #fff; font-size: 0.68rem; padding: 0.2rem 0.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-grid-item .pg-public-toggle {
  position: absolute; bottom: 4px; right: 4px; z-index: 2; width: 1.4rem; height: 1.4rem; padding: 0;
  line-height: 1; font-size: 0.75rem; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
}
.photo-grid-item .pg-public-toggle.is-public { background: var(--blue); border-color: var(--blue); }

/* Admin-only "Public" toggle on a photo/video's list row - green once public so it reads at a
   glance which few items in an otherwise-private event are actually exposed. */
[data-toggle-public].is-public { background: var(--green, #1a9c5c); color: #fff; border-color: var(--green, #1a9c5c); }

.photo-row { display: flex; align-items: flex-start; gap: 0.6rem; }
.photo-row input[type="checkbox"] { margin-top: 0.3rem; }
.pr-position {
  flex-shrink: 0; min-width: 1.4rem; margin-top: 0.3rem; text-align: center; font-size: 0.72rem;
  font-weight: 700; color: var(--text3); font-family: var(--fh);
}
.photo-row .pr-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; flex-shrink: 0; }
.photo-row .pr-info { flex: 1; min-width: 0; }
.photo-row .pr-info > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-row .pr-info .pr-caption { font-weight: 600; }
.photo-row .pr-info .pr-filename { font-family: var(--mono, monospace); font-size: 0.82rem; }
.photo-row .danger { flex-shrink: 0; }
.pr-actions { display: flex; gap: 0.35rem; flex-shrink: 0; align-items: center; }
.pr-reorder { display: flex; gap: 2px; flex-shrink: 0; }

/* ── COST TAB ────────────────────────────────────────────────────────── */
.cost-section { margin-bottom: 1.5rem; }
.cost-total { font-weight: 700; color: var(--text); }

/* ── MAP TAB ─────────────────────────────────────────────────────────── */
.map-container { height: 360px; border-radius: var(--rl); overflow: hidden; border: 1px solid var(--b1); }
.route-summary { margin-top: 0.75rem; display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.route-summary > div { display: flex; flex-direction: column; }

/* ── SLIDESHOW ───────────────────────────────────────────────────────── */
.slideshow-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 3000; display: flex;
  flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem;
}
/* z-index above .slideshow-img-wrap - that wrap is `position: relative` (for the crop overlay to
   anchor to) and, being later in the DOM with an equal auto z-index, would otherwise paint over
   this button's own top-right corner and swallow its clicks despite being visually transparent
   there. */
.slideshow-close { position: absolute; top: 1rem; right: 1.25rem; z-index: 1; background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.3); }
.slideshow-fullscreen-btn {
  position: absolute; top: 1rem; right: 6.75rem; z-index: 1; width: 2.4rem; padding: 0.4rem 0;
  text-align: center; background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.3);
}
/* The image lives in its own flexible region so it can grow/shrink with viewport size, but the
   caption below (.slideshow-bottom) is a separate, fixed-height row below it - its screen position
   never depends on a given photo's aspect ratio/rendered height. */
.slideshow-img-wrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 0; }
.slideshow-img { max-width: 90%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.slideshow-video { max-width: 90%; max-height: 100%; border-radius: 6px; background: #000; }
/* Positioned relative to .slideshow-overlay itself (a fixed-position ancestor is a valid containing
   block), pinned to the left/right edge at the vertical center of the whole viewer - so they stay
   put across every photo/event, regardless of caption length, image aspect ratio, or whether the
   edit bar is showing. Previously they sat in the .slideshow-bottom flex row next to the caption,
   so a longer/shorter caption on the next event pushed them sideways. */
.slideshow-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1;
  background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.3); font-size: 1.4rem; width: 3rem; height: 3rem; border-radius: 50%;
}
.slideshow-nav-prev { left: 1rem; }
.slideshow-nav-next { right: 1rem; }
.slideshow-nav:disabled { opacity: 0.25; }
.slideshow-bottom { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 100%; margin-top: 1rem; }
.slideshow-caption { color: #fff; text-align: center; max-width: 640px; }
.slideshow-caption .sc-main { font-size: 0.95rem; font-weight: 600; }
.slideshow-caption .sc-sub { font-size: 0.78rem; color: rgba(255,255,255,0.65); margin-top: 0.2rem; }

.slideshow-edit-bar { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-top: 0.85rem; flex-wrap: wrap; }
.slideshow-edit-bar button { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.3); }
.slideshow-edit-bar button.danger { color: #ff9b9b; border-color: rgba(255, 107, 107, 0.55); }
.slideshow-edit-bar button.danger:hover { background: rgba(255, 107, 107, 0.18); }
.slideshow-crop-overlay { position: absolute; cursor: crosshair; background: rgba(0,0,0,0.25); }
.slideshow-crop-overlay.hidden { display: none; }
.slideshow-crop-box { position: absolute; border: 2px dashed #fff; background: rgba(255,255,255,0.15); pointer-events: none; }

/* Shown between clicking a photo/video thumbnail and its single-page viewer becoming ready -
   covers the whole viewport so nothing underneath can be clicked again (a second click before the
   viewer opens would otherwise start a second, redundant load) and shows a wait cursor everywhere. */
#busy-overlay { position: fixed; inset: 0; z-index: 4000; cursor: wait; }

.video-viewer-buffering {
  position: absolute; top: 50%; left: 50%; width: 2.5rem; height: 2.5rem; margin: -1.25rem 0 0 -1.25rem;
  border-radius: 50%; border: 3px solid rgba(255,255,255,0.25); border-top-color: #fff;
  animation: upp-spin 0.7s linear infinite;
}

/* ── UNASSIGNED PHOTO ASSIGN ─────────────────────────────────────────── */
.section-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin: 1.5rem 0 0.5rem; }
.section-title-row .section-title { margin: 0; }
.section-title-row select { width: auto; margin: 0; }
.unassigned-item { display: flex; gap: 0.75rem; align-items: center; }
.unassigned-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ── LOCATION FIELD + PICKER ─────────────────────────────────────────── */
.location-field { display: flex; align-items: center; gap: 0.5rem; }
.location-field .location-text {
  flex: 1; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--s2); color: var(--fg); font-size: 0.85rem; min-height: 1.2em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.location-field button { flex-shrink: 0; width: auto; }
/* Not scoped under #app-root - the picker is a document.body-level modal (see
   openLocationPicker), not a descendant of #app-root, so a scoped selector here would never match. */
.mo-box.lp-box { max-width: 1920px; }
.lp-search-row { display: flex; gap: 0.5rem; margin-bottom: 0.6rem; }
.lp-search-row input { flex: 1; }
.lp-search-row button { flex-shrink: 0; width: auto; }
.lp-results { max-height: 140px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.6rem; }
.lp-results.hidden { display: none; }
.lp-result-item { padding: 0.4rem 0.6rem; font-size: 0.8rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.lp-result-item:last-child { border-bottom: none; }
.lp-result-item:hover { background: var(--blue3); }
.lp-map { height: 320px; border-radius: var(--r); overflow: hidden; border: 1px solid var(--border); margin-bottom: 0.6rem; }
.lp-current { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.6rem; }

/* ── UPLOAD PROGRESS (background multi-upload) ──────────────────────── */
.upload-progress-panel {
  position: fixed; bottom: 20px; right: 20px; z-index: 2000; background: var(--s1); border: 1px solid var(--b2);
  border-radius: var(--r); padding: 0.7rem 1rem; font-size: 0.82rem; color: var(--text); box-shadow: var(--sh);
  display: flex; align-items: center; gap: 0.6rem;
}
.upload-progress-panel .upp-spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--b2); border-top-color: var(--blue);
  animation: upp-spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes upp-spin { to { transform: rotate(360deg); } }

/* ── UPLOAD GATE (event missing date/location) ──────────────────────── */
.upload-gate { text-align: center; padding: 2rem 1.25rem; color: var(--text3); font-size: 0.85rem; }

/* ── LOGIN / REGISTER TABS ─────────────────────────────────────────────── */
.app-tab-bar { display: flex; gap: 0; border-bottom: 2px solid var(--b1); margin: 1rem 0 1.25rem; }
.app-tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px;
  padding: 0.55rem 1.1rem; font-size: 0.8rem; font-weight: 600; font-family: var(--fh);
  color: var(--text3); cursor: pointer; transition: var(--tr); letter-spacing: 0.02em;
}
.app-tab-btn:hover { color: var(--text); background: var(--s2); }
.app-tab-btn.active { color: var(--blue2); border-bottom-color: var(--blue2); }
.app-tab-panel.hidden { display: none; }
.hidden { display: none; }

.oauth-grid { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 0.4rem; }
.oauth-btn {
  width: auto; height: 44px; padding: 0 1rem; border-radius: var(--r); border: 1px solid var(--b1);
  background: var(--s2); display: flex; align-items: center; gap: 0.5rem; cursor: pointer; transition: var(--tr);
  font-size: 0.82rem; font-weight: 600; color: var(--text2); font-family: var(--fh);
}
.oauth-btn:hover { border-color: var(--blue2); background: var(--s3); transform: translateY(-1px); }
.oauth-btn-soon { opacity: 0.55; }
.oauth-btn-soon:hover { border-color: var(--b1); background: var(--s2); transform: none; }

/* ── EVENTS: MONTH/YEAR DRILL-DOWN ──────────────────────────────────────── */
.my-grid { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.75rem; }
.my-cell {
  width: auto; min-width: 88px; height: 44px; padding: 0 1.1rem; border-radius: var(--r); border: 1px solid var(--b1);
  background: var(--s2); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--tr);
  font-size: 0.85rem; font-weight: 600; color: var(--text2); font-family: var(--fh);
}
.my-cell:hover { border-color: var(--blue2); background: var(--s3); color: var(--text); transform: translateY(-1px); }
.my-back-btn {
  background: none; border: none; padding: 0.3rem 0; margin-bottom: 0.4rem; cursor: pointer;
  font-size: 0.82rem; font-weight: 600; color: var(--blue2); font-family: var(--fh);
}
.my-back-btn:hover { text-decoration: underline; }

/* ── BADGES ──────────────────────────────────────────────────────────── */
.role-badge { display: inline-flex; padding: 0.15rem 0.6rem; border-radius: 20px; font-size: 0.7rem; font-weight: 700; font-family: var(--fh); letter-spacing: 0.02em; }
.role-3 { background: var(--rose2); border: 1px solid rgba(240, 69, 96, 0.4); color: var(--rose); }
.role-2 { background: var(--am2); border: 1px solid rgba(240, 160, 48, 0.4); color: var(--amber); }
.role-1 { background: var(--in2); border: 1px solid rgba(124, 111, 247, 0.4); color: var(--indigo); }
.role-0 { background: var(--em2); border: 1px solid rgba(0, 200, 150, 0.4); color: var(--emerald); }

.badge { display: inline-flex; align-items: center; gap: 3px; padding: 0.1rem 0.55rem; border-radius: 20px; font-size: 0.7rem; font-weight: 700; font-family: var(--fh); }
.b-cyan { background: var(--cyan2); color: var(--cyan); border: 1px solid rgba(0, 123, 135, 0.25); }
.b-amber { background: var(--am2); color: var(--amber); border: 1px solid rgba(176, 106, 0, 0.25); }

/* ── TOPBAR ──────────────────────────────────────────────────────────── */
.topbar {
  width: 100%; height: var(--topbar1-h); background: var(--topbar-bg); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--b1); display: flex; align-items: center; padding: 0 1.1rem; gap: 0.6rem;
  position: sticky; top: 0; z-index: 200; flex-shrink: 0;
}
.tbar-logo { cursor: pointer; display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-family: var(--fh); font-size: 1rem; color: var(--text); flex-shrink: 0; }
.app-icon { width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; display: block; }
.brand-wordmark { height: 30px; width: auto; border-radius: 8px; flex-shrink: 0; display: block; }
.tbar-space { flex: 1; }
.tbar-tenant-wrap {
  display: flex; align-items: center; gap: 0.4rem; cursor: pointer; padding: 0.25rem 0.65rem; border-radius: 20px;
  border: 1px solid rgba(42, 110, 245, 0.3); background: var(--blue3); transition: var(--tr); font-family: var(--fh);
}
.tbar-tenant-wrap:hover { border-color: rgba(42, 110, 245, 0.6); }
.tbar-tenant-wrap .t-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; color: var(--text3); }
.tbar-tenant-wrap .t-val { font-size: 0.75rem; font-weight: 700; color: var(--blue2); }
.tbar-tenant-wrap .t-caret { font-size: 0.55rem; color: var(--text3); }
.tbar-plan {
  display: flex; align-items: center; gap: 0.4rem; cursor: pointer; padding: 0.25rem 0.65rem; border-radius: 20px;
  border: 1px solid rgba(176, 106, 0, 0.3); background: var(--am2); transition: var(--tr); font-family: var(--fh);
}
.tbar-plan:hover { border-color: rgba(176, 106, 0, 0.6); }
.tbar-plan-static { cursor: default; }
.tbar-plan-static:hover { border-color: rgba(176, 106, 0, 0.3); }
.tbar-plan .p-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; color: var(--text3); }
.tbar-plan .p-val { font-size: 0.75rem; font-weight: 700; color: var(--amber); }
.tbar-plan .p-till { font-size: 0.65rem; color: var(--text3); }
.tbar-user { display: flex; align-items: center; gap: 0.45rem; cursor: pointer; padding: 0.15rem 0.6rem 0.15rem 0.2rem; border-radius: 20px; transition: var(--tr); }
.tbar-user:hover { background: var(--s2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--indigo));
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.7rem; color: #fff;
  flex-shrink: 0; font-family: var(--fh);
}
.tbar-user .u-email { font-size: 0.75rem; color: var(--text2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tenant dropdown (both login-page shared selector and post-login switcher) */
.tenant-dd {
  position: absolute; top: calc(100% + 6px); left: 0; background: var(--s1); border: 1px solid var(--b2);
  border-radius: var(--r); box-shadow: var(--sh); min-width: 240px; z-index: 600; overflow-y: auto; max-height: 320px;
  display: none; flex-direction: column;
}
.tenant-dd.open { display: flex; }
.tenant-dd-item { padding: 0.6rem 0.85rem; font-size: 0.8rem; cursor: pointer; color: var(--text2); border-bottom: 1px solid var(--b1); display: flex; align-items: center; gap: 0.5rem; }
.tenant-dd-item:last-child { border-bottom: none; }
.tenant-dd-item:hover { background: var(--s2); color: var(--text); }
.tenant-dd-item.active { color: var(--blue2); background: var(--blue3); }

/* notification bell + history dropdown */
.notif-btn {
  position: relative; width: auto; padding: 0.4rem 0.55rem; font-size: 1.05rem; line-height: 1;
  background: transparent; border: 1px solid transparent;
}
.notif-btn:hover { background: var(--s2); border-color: var(--b1); }
.notif-btn.has-unread::after {
  content: ''; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--rose); border: 2px solid var(--s1);
}
.notif-dd {
  position: absolute; top: calc(100% + 6px); right: 0; background: var(--s1); border: 1px solid var(--b2);
  border-radius: var(--r); box-shadow: var(--sh); width: 320px; z-index: 600; overflow-y: auto; max-height: 400px;
  display: none; flex-direction: column;
}
.notif-dd.open { display: flex; }
.notif-dd-item { padding: 0.6rem 0.85rem; font-size: 0.8rem; border-bottom: 1px solid var(--b1); border-left: 3px solid var(--blue); }
.notif-dd-item:last-child { border-bottom: none; }
.notif-dd-item.notif-success { border-left-color: var(--emerald); }
.notif-dd-item.notif-error { border-left-color: var(--rose); }
.notif-dd-item .notif-msg { color: var(--text); }
.notif-dd-item .notif-time { color: var(--text3); font-size: 0.7rem; margin-top: 0.2rem; }

/* ── APP BODY: SIDEBAR + MAIN ───────────────────────────────────────── */
.app-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.sidebar { width: 210px; flex-shrink: 0; background: var(--s1); border-right: 1px solid var(--b1); overflow-y: auto; padding: 0.9rem 0; transition: width 0.18s ease; display: flex; flex-direction: column; }
.nav-group-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text3); padding: 0.6rem 1.1rem 0.3rem; font-family: var(--fh); }
.nav-item {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.5rem 1rem 0.5rem 1.2rem; font-size: 0.82rem;
  font-weight: 600; color: var(--text2); cursor: pointer; transition: var(--tr); border-left: 2px solid transparent; font-family: var(--fh);
}
.nav-item:hover { color: var(--text); background: var(--blue3); }
.nav-item.active { color: var(--blue2); background: var(--blue3); border-left-color: var(--blue); }
.nav-item .ni-icon { font-size: 0.95rem; width: 1.1rem; text-align: center; flex-shrink: 0; }
.page-content { flex: 1; overflow-y: auto; padding: 1.5rem 1.75rem; }

/* collapsed = icon rail only, labels/group headers hidden - toggle persisted in localStorage (see app.js toggleSidebar) */
.sidebar-collapse-toggle { display: flex; align-items: center; justify-content: flex-end; padding: 0 0.9rem 0.5rem; cursor: pointer; color: var(--text3); flex-shrink: 0; }
.sidebar-collapse-toggle:hover { color: var(--text); }
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-collapse-toggle { justify-content: center; }
.sidebar.collapsed .nav-group-label, .sidebar.collapsed .ni-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0.55rem 0; border-left: none; }
.sidebar.collapsed .nav-item .ni-icon { width: auto; font-size: 1.05rem; }

.ph { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.4rem; gap: 0.9rem; flex-wrap: wrap; }
.ph-title { font-size: 1.3rem; font-weight: 800; color: var(--text); font-family: var(--fh); letter-spacing: -0.01em; }
.ph-sub { font-size: 0.78rem; color: var(--text3); margin-top: 0.15rem; }

/* Admin's "Public view" preview of the Events page - see renderEventList's realAdmin/canManage. */
.public-view-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  background: var(--blue3); border: 1px solid var(--blue); border-radius: var(--r);
  padding: 0.6rem 0.9rem; margin-bottom: 1rem; font-size: 0.85rem; color: var(--text);
}
.public-view-banner button { background: var(--blue); color: #fff; border-color: var(--blue); }
.events-list-tabs .public-view-toggle { margin-left: auto; }

/* ── TABLE (list pages) ─────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; background: var(--s1); border: 1px solid var(--b1); border-radius: var(--rl); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl thead tr { background: var(--s2); }
.tbl th { padding: 0.6rem 0.85rem; text-align: left; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text3); white-space: nowrap; border-bottom: 1px solid var(--b1); font-family: var(--fh); }
.tbl td { padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--b1); font-size: 0.82rem; color: var(--text); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--blue3); }

.empty { text-align: center; padding: 3rem 1.25rem; color: var(--text3); }
.empty .ei { font-size: 2.4rem; margin-bottom: 0.6rem; opacity: 0.35; }

/* ── MODAL (user account panel) ─────────────────────────────────────── */
.mo { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1.25rem; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.mo.open { opacity: 1; pointer-events: all; }
.mo-box { background: var(--s1); border: 1px solid var(--b2); border-radius: var(--r2xl); width: 100%; max-width: 380px; box-shadow: var(--sh); }
.mo-head { padding: 1.1rem 1.3rem 0.8rem; border-bottom: 1px solid var(--b1); display: flex; align-items: center; justify-content: space-between; }
.mo-title { font-size: 0.95rem; font-weight: 800; color: var(--text); font-family: var(--fh); }
.mo-close { width: 26px; height: 26px; border: none; background: var(--s2); color: var(--text2); border-radius: 6px; cursor: pointer; }
.mo-body { padding: 1.2rem 1.3rem; }
.mo-foot { padding: 0.9rem 1.3rem; border-top: 1px solid var(--b1); display: flex; gap: 0.6rem; justify-content: flex-end; }
.mo-box.mo-lg { max-width: 560px; }

.plan-offering-row {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.5rem; border-radius: var(--r);
  border: 1px solid var(--b1); margin-bottom: 0.5rem; cursor: pointer; transition: var(--tr);
}
.plan-offering-row:hover { border-color: rgba(42, 110, 245, 0.5); background: var(--s2); }
.plan-offering-row input[type="radio"] { width: auto; margin: 0; }
.plan-offering-row .po-title { flex: 1; font-size: 0.85rem; color: var(--text); }
.plan-offering-row .po-amount { font-size: 0.85rem; font-weight: 700; color: var(--blue2); }

/* ── THEME PICKER ────────────────────────────────────────────────────── */
.theme-picker { position: relative; display: flex; align-items: center; }
.theme-btn {
  width: 32px; height: 32px; border: 1px solid var(--b1); background: transparent; color: var(--text2);
  border-radius: var(--r); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: var(--tr); font-size: 0.95rem;
}
.theme-btn:hover { background: var(--s2); color: var(--text); border-color: var(--b2); }
.theme-picker-menu {
  position: absolute; top: calc(100% + 6px); right: 0; background: var(--s1); border: 1px solid var(--b2);
  border-radius: var(--r); box-shadow: var(--sh); display: none; flex-direction: column; min-width: 130px; z-index: 600; overflow: hidden;
}
.theme-picker-menu.open { display: flex; }
.theme-picker-opt {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.85rem; font-size: 0.8rem; cursor: pointer;
  color: var(--text2); transition: var(--tr); white-space: nowrap; border: none; background: transparent;
  width: 100%; text-align: left; font-family: var(--ff);
}
.theme-picker-opt:hover { background: var(--s2); color: var(--text); }
.theme-picker-opt.active { color: var(--blue2); background: var(--blue3); }

/* ── TOAST ───────────────────────────────────────────────────────────── */
#toast-container { position: fixed; top: 72px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; }
.toast {
  background: var(--s1); border: 1px solid var(--b2); border-radius: var(--r); padding: 0.75rem 1rem;
  font-size: 0.82rem; color: var(--text); min-width: 240px; max-width: 380px; box-shadow: var(--sh);
  pointer-events: all; border-left: 3px solid var(--blue); animation: toast-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.success { border-left-color: var(--emerald); }
.toast.error { border-left-color: var(--rose); }
@keyframes toast-in { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.fade { animation: toast-out 0.2s ease forwards; }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* ── MOBILE (see app.js renderHeader/renderShell/openDetail) ───────────────────────────────────
   Two structural changes: the sidebar becomes an off-canvas drawer (hamburger in the topbar,
   tap-outside/nav-item closes it) instead of a permanent 210px column, and the Events page's
   list+detail split shows one full-width pane at a time (Back button returns to the list) instead
   of the desktop side-by-side layout. Both hooks (.mobile-menu-btn, .sidebar-backdrop,
   .mobile-back-btn) exist in the markup at every width; only this block makes them visible/do
   anything, so nothing above needs its own mobile-vs-desktop branching in JS. */
.mobile-menu-btn {
  display: none; width: auto; padding: 0.4rem 0.55rem; font-size: 1.15rem; line-height: 1;
  background: transparent; border: 1px solid transparent; flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--s2); border-color: var(--b1); }
.sidebar-backdrop { display: none; }
.mobile-back-btn { display: none; }

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }

  .sidebar {
    position: fixed; top: var(--topbar1-h); left: 0; bottom: 0; z-index: 500; width: 240px;
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--sh);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  /* The desktop icon-rail "collapsed" state (see .sidebar.collapsed above) doesn't apply here -
     on mobile the drawer is either fully open or fully off-canvas, never a narrow icon strip, so
     these three rules undo it in case that flag is still set from a previous desktop session. */
  .sidebar.collapsed { width: 240px; }
  .sidebar.collapsed .nav-group-label, .sidebar.collapsed .ni-label { display: block; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 0.5rem 1rem 0.5rem 1.2rem; border-left: 2px solid transparent; }
  .sidebar.collapsed .nav-item .ni-icon { width: 1.1rem; font-size: 0.95rem; }
  .sidebar-collapse-toggle { display: none; } /* desktop-only control - the hamburger + backdrop replace it here */

  .sidebar-backdrop.open {
    display: block; position: fixed; top: var(--topbar1-h); left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4); z-index: 499;
  }

  .page-content { padding: 1rem; }

  /* Events page: list and detail as two full-width panes, one visible at a time - see
     openDetail's showing-detail toggle and the Back button's click handler in app.js. */
  .events-split { display: block; }
  .events-list-pane, .events-detail-pane { width: 100%; max-height: none; }
  .events-detail-pane { display: none; padding: 1rem; }
  .events-split.showing-detail .events-list-pane { display: none; }
  .events-split.showing-detail .events-detail-pane { display: block; }
  .pane-collapse-btn { display: none; } /* the desktop list-pane icon-rail collapse has no meaning in a single-full-width-pane layout */
  .mobile-back-btn {
    display: block; width: 100%; text-align: left; margin-bottom: 0.75rem; background: var(--s2);
    border: 1px solid var(--b1); color: var(--text2); font-weight: 600;
  }

  /* Single photo/video viewer (openSlideshow AND openVideoViewer - both share these exact class
     names, see renderVideoViewer's own comment on reusing .slideshow-* wholesale) - shrink the
     overlay's own padding and let the image/video claim the full width instead of the 90% sized
     for a desktop viewport with room to spare; the nav arrows move onto the image itself (they're
     already semi-transparent circles, a standard mobile gallery pattern) instead of sitting beside
     it, since there's no longer a side margin big enough to hold them without overlapping. */
  .slideshow-overlay { padding: 0.5rem; }
  .slideshow-img, .slideshow-video { max-width: 100%; }
  .slideshow-nav { width: 2.4rem; height: 2.4rem; font-size: 1.15rem; }
  .slideshow-nav-prev { left: 0.35rem; }
  .slideshow-nav-next { right: 0.35rem; }
  /* Stacked instead of side-by-side - avoids needing to know either button's actual rendered
     width (the close button carries a text label, the fullscreen one doesn't) to keep them from
     overlapping at a narrower top-right corner. */
  .slideshow-close { top: 0.5rem; right: 0.5rem; }
  .slideshow-fullscreen-btn { top: 3.3rem; right: 0.5rem; }
  .slideshow-caption { max-width: 100%; padding: 0 0.5rem; }
  .slideshow-bottom { margin-top: 0.5rem; }
  .slideshow-edit-bar { margin-top: 0.5rem; gap: 0.4rem; }

  /* Topbar: the tenant/plan/role pills are purely informational for the single-tenant case this
     app is actually used in, and crowd a narrow screen - moved into the sidebar drawer instead
     (see .sidebar-mobile-info and buildSidebar in app.js), reachable via the same hamburger. The
     avatar alone (no email text) is enough to open the user menu, which shows the full address. */
  /* :not(.tbar-tenant-interactive) - a gateway session's tenant chip is a real switcher (opens
     .tenant-dd), not just an info pill, and has no equivalent in the drawer below, so it stays. */
  .tbar-tenant-wrap:not(.tbar-tenant-interactive), .tbar-plan, .role-badge { display: none; }
  .tbar-user .u-email { display: none; }

  .sidebar-mobile-info { display: block; padding: 0 1.1rem 0.75rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--b1); }
  .smi-row { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.75rem; padding: 0.15rem 0; }
  .smi-label { color: var(--text3); font-weight: 700; }
  .smi-val { color: var(--text2); font-weight: 600; text-align: right; }
}

.sidebar-mobile-info { display: none; }
