/* ============ APP SHELL ============ */
#app-shell{ display: flex; min-height: 100vh; }

/* ---------- Splash screen: icon as a profile photo, fades smoothly into the app ---------- */
#app-splash{
  position: fixed; inset: 0; z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--paper);
  transition: opacity 0.5s ease;
}
#app-splash.app-splash--hide{ opacity: 0; pointer-events: none; }
.app-splash__icon{
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 12px 32px rgba(28,34,48,0.2), 0 0 0 1px var(--line);
  animation: splashPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes splashPop{
  from{ transform: scale(0.7); opacity: 0; }
  to{ transform: scale(1); opacity: 1; }
}
.app-splash__title{ font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--ink); }
.app-splash__sub{ font-size: 11.5px; color: var(--ink-faint); letter-spacing: 0.6px; text-transform: uppercase; }
/* Progress bar — driven by real boot milestones (see splashStep in app.js). */
.app-splash__progress{
  width: 168px; height: 4px; margin-top: 8px;
  background: var(--paper-sunken); border-radius: 100px; overflow: hidden;
}
.app-splash__bar{
  height: 100%; width: 0; border-radius: 100px;
  background: var(--accent);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.app-splash__status{
  font-size: 11px; color: var(--ink-faint); margin-top: -4px;
  letter-spacing: 0.2px; min-height: 14px;
}

/* ---------- Desktop sidebar ---------- */
.sidebar{
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #EDEFEB;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
}
.sidebar__brand{
  padding: calc(22px + env(safe-area-inset-top)) 20px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__brand-mark{
  width: 34px; height: 34px; border-radius: 8px;
  object-fit: cover; flex-shrink: 0;
  background: var(--accent); /* fallback while the remote logo loads */
}
.sidebar__brand-copy{ min-width: 0; }
.sidebar__brand-text{ font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: 0.3px; }
/* The subtitle is a domain, so it stays lowercase — the uppercase + 1px tracking
   this slot used for "EVENT & FINANCE" would push krishnashah.photography past the
   248px sidebar and wrap. Truncates rather than wraps if the sidebar ever narrows. */
.sidebar__brand-sub{
  font-size: 10.5px; color: #9BA3AE; letter-spacing: 0.2px; text-transform: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* sprocket rail texture — signature detail, kept quiet */
.sidebar__rail{
  position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background-image: radial-gradient(circle, rgba(255,255,255,0.14) 1.6px, transparent 1.6px);
  background-size: 6px 14px;
  background-repeat: repeat-y;
  background-position: 3px 10px;
}

.sidebar__nav{ flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar__link{
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #C7CCD3; font-size: 13.5px; font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease;
}
.sidebar__link i{ width: 16px; text-align: center; font-size: 14px; color: #8B93A0; transition: color 0.18s ease; }
.sidebar__link:hover{ background: rgba(255,255,255,0.08); color: #fff; }
.sidebar__link:hover i{ color: #fff; }
.sidebar__link.active{ background: var(--accent); color: #fff; }
.sidebar__link.active i{ color: #fff; }

.sidebar__footer{ padding: 14px 18px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar__user{ display: flex; align-items: center; gap: 10px; }
.sidebar__user-copy{ min-width: 0; }
/* Avatar slot: a Font Awesome icon until a photo is uploaded, then the image. */
.sidebar__avatar{
  width: 32px; height: 32px; border-radius: 50%;
  flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.10);
  border: 1.5px solid rgba(255,255,255,0.25);
  color: #9BA3AE; font-size: 12px;
}
.sidebar__avatar img{ width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar__user-name{ font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-role{ font-size: 11px; color: #9BA3AE; }
/* Shortcut straight to Preferences from the sidebar footer. */
.sidebar__pref-btn{
  margin-left: auto; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #9BA3AE; background: rgba(255,255,255,0.06);
  font-size: 13px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.1s ease;
}
.sidebar__pref-btn:hover{ background: rgba(255,255,255,0.15); color: #fff; }
.sidebar__pref-btn:active{ transform: scale(0.92); }

/* ---------- Main column ---------- */
.main-col{ flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar{
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  position: sticky; top: 0; z-index: 30;
  padding-left: 28px; padding-right: 28px;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner{
  height: var(--topbar-h); max-width: var(--content-max); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar__title{ font-size: 22px; }
.topbar__actions{ display: flex; align-items: center; gap: 10px; }

.page-content{
  padding: 26px 28px 60px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ---------- Mobile top header (shown < 900px instead of sidebar) ---------- */
.mobile-topbar{
  display: none;
  align-items: center; justify-content: space-between; gap: 10px;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  position: sticky; top: 0; z-index: 30;
  background: var(--mobile-topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
}
.mobile-topbar__brand{ display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 17px; flex-shrink: 0; }
/* Title sits on the right, next to the status chip, and truncates rather than
   colliding with the brand on narrow screens. */
#mobile-title{ margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.mobile-topbar__mark{ width: 26px; height: 26px; border-radius: 6px; object-fit: cover; }

/* ---------- Bottom tab bar (mobile) ---------- */
.bottom-bar{
  display: none;
  /* Anchor to the home-indicator (safe-area) with a small gap, instead of adding the
     safe-area on TOP of a 14px offset — that double-count floated the bar too high on iOS.
     Now it sits low, like a native tab bar. */
  position: fixed; bottom: max(10px, env(safe-area-inset-bottom)); left: 14px; right: 14px; z-index: 50;
  align-items: center; gap: 10px;
}
.bottom-nav{
  flex: 1;
  height: 62px;
  border-radius: 9999px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 1px 6px rgba(28,34,48,0.03), inset 0 1px 0 rgba(255,255,255,0.5);
}
.bottom-nav__inner{ display: flex; height: 100%; align-items: center; position: relative; }
.bottom-nav__indicator{
  position: absolute; top: 2px; bottom: 2px; left: 0; width: 0;
  background: var(--nav-indicator-bg); border-radius: 9999px; z-index: 0;
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  backdrop-filter: blur(10px) saturate(180%);
  /* One curve, one duration, for both edges — see positionNavIndicator() in
     router.js for why a split transform/width transition made it wobble. */
  transition: left 0.4s cubic-bezier(0.65, 0, 0.35, 1),
              width 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.bottom-nav__item{
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-soft); font-size: 10px; font-weight: 600;
  transition: color 0.15s ease, transform 0.1s ease;
}
.bottom-nav__item i{ font-size: 18px; }
.bottom-nav__item.active{ color: var(--accent); }
.bottom-nav__item:active{ transform: scale(0.92); }
.bottom-nav__fab{
  flex-shrink: 0;
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--glass-bg); color: var(--accent);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 1px 6px rgba(28,34,48,0.03), inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform 0.12s ease;
}
.bottom-nav__fab:active{ transform: scale(0.92); }

/* ============ RESPONSIVE SWITCH ============ */
@media (max-width: 900px){
  .sidebar{ display: none; }
  .main-col{ margin-left: 0; }
  .topbar{ display: none; }
  .mobile-topbar{ display: flex; }
  .bottom-bar{ display: flex; }
  .page-content{ padding: 16px 14px 100px; }
  body{ padding-bottom: 0; }
}

/* Filters bar — side by side on desktop, stacked full-width on mobile */
.filters-bar{ display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filters-bar > *{ flex: 1; min-width: 200px; }
@media (max-width: 900px){
  .filters-bar{ flex-direction: column; align-items: stretch; }
  .filters-bar > *{ width: 100%; min-width: 0; }
}

/* Desktop layout with right-side insights rail (uses the empty space) */
.content-with-rail{ display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 1240px){
  .content-with-rail{ grid-template-columns: 1fr 300px; align-items: start; }
}
.insight-rail{ display: flex; flex-direction: column; gap: 16px; position: sticky; top: 82px; }
@media (max-width: 1239px){ .insight-rail{ display: none; } }

/* ---------- Wide-screen item grid: repeated cards (crew/services/transactions/roster/FY) sit
   side by side on big monitors instead of stretching one column edge-to-edge ---------- */
.item-grid{ display: block; }
@media (min-width: 1400px){
  .item-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; align-items: start; }
  .item-grid > .list-row{
    border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
    padding: 16px 18px; margin: 0; background: var(--paper-raised);
    box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, border-color 0.15s ease;
  }
  .item-grid > .list-row:hover{ box-shadow: var(--shadow-md); border-color: var(--line-strong); }
  .item-grid > .crew-side-label{ grid-column: 1 / -1; }
}

.ai-zone{ margin-bottom: 18px; }

/* Page header used inside content (desktop shows via topbar, mobile shows inline) */
.page-heading{ display: none; margin-bottom: 16px; align-items: center; gap: 10px; }
.page-back{ flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--paper-raised); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; padding: 0; }
.page-back:active{ transform: scale(0.95); }
@media (max-width: 900px){
  .page-heading{ display: flex; }
}

/* Utility grid/flex */
.grid{ display: grid; gap: 16px; }
.grid-2{ grid-template-columns: repeat(2, 1fr); }
.grid-3{ grid-template-columns: repeat(3, 1fr); }
.grid-4{ grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px){
  .grid-2, .grid-3, .grid-4{ grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px){
  .grid-3, .grid-4{ grid-template-columns: 1fr 1fr; }
}

.desktop-only{ display: block; }
.mobile-only{ display: none; }
@media (max-width: 900px){
  .desktop-only{ display: none !important; }
  .mobile-only{ display: block !important; }
}

.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.flex-row{ display: flex; align-items: center; }
.gap-8{ gap: 8px; } .gap-10{ gap: 10px; } .gap-12{ gap: 12px; } .gap-16{ gap: 16px; }

/* Modal / sheet overlay (mobile uses bottom sheet feel, desktop centers) */
.overlay{
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.overlay.open, .overlay.closing{ display: flex; }
.overlay.open{ opacity: 1; }
.overlay.closing{ opacity: 0; }
.sheet{
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 520px;
  max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  box-shadow: 0 6px 26px rgba(28,34,48,0.12);
  animation: sheetIn 0.24s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  position: relative;
}
.sheet-close-x{
  position: absolute; top: 14px; right: 14px; z-index: 7;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg); color: var(--ink);
  -webkit-backdrop-filter: blur(var(--glass-blur)); backdrop-filter: blur(var(--glass-blur));
  box-shadow: 0 0 0 1px rgba(0,0,0,0.04), 0 1px 6px rgba(28,34,48,0.06);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.sheet-close-x:hover{ background: var(--line-strong); color: var(--ink); }
.sheet-close-x:active{ transform: scale(0.92); }
.overlay.closing .sheet{ animation: sheetOut 0.22s ease forwards; }
@keyframes sheetIn{
  from{ transform: translateY(18px) scale(0.98); opacity: 0; }
  to{ transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes sheetOut{
  from{ transform: translateY(0) scale(1); opacity: 1; }
  to{ transform: translateY(10px) scale(0.98); opacity: 0; }
}
@media (max-width: 900px){
  .overlay{ align-items: flex-end; padding: 0; }
  .sheet{ max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  @keyframes sheetIn{
    from{ transform: translateY(100%); opacity: 1; }
    to{ transform: translateY(0); opacity: 1; }
  }
  @keyframes sheetOut{
    from{ transform: translateY(0); opacity: 1; }
    to{ transform: translateY(100%); opacity: 1; }
  }
}

/* Hide the mobile tab bar while typing — the on-screen keyboard otherwise pushes this
   fixed bar into the middle of the screen. */
.bottom-bar.bottom-bar--typing{ display: none !important; }

/* iOS ONLY (html.ios is set from JS): the sheet stays FLUSH to the bottom (its background
   fills down to the screen edge, so nothing shows underneath); we only trim the inner
   bottom padding a little vs Android so it isn't an oversized gap, while still clearing the
   home indicator. Android keeps full safe-area padding; desktop keeps the centred modal. */
@media (max-width: 900px){
  html.ios .sheet{ padding-bottom: max(12px, calc(env(safe-area-inset-bottom) - 12px)); }
}
