/* Admin shell layout. Breakpoints: mobile <640, tablet 640–1023, desktop >=1024. */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--fm-sidebar-width); flex: none; background: var(--fm-primary); color: #fff;
  padding: var(--fm-space-4) var(--fm-space-2); display: flex; flex-direction: column; gap: var(--fm-space-4);
  transition: width 0.2s ease-out;
}
.sidebar__brand { display: flex; justify-content: center; }
.brand-full { --fm-logo-h: 112px; }
.brand-emblem { --fm-emblem-size: 48px; display: none; }
.header__emblem { --fm-emblem-size: 36px; display: none; }
#nav { display: flex; flex-direction: column; gap: var(--fm-space-1); }
.nav-item {
  display: flex; align-items: center; gap: var(--fm-space-3); min-height: 44px; padding: 0 var(--fm-space-4);
  border-left: 3px solid transparent; border-radius: var(--fm-radius-sm);
  background: none; border-top: 0; border-right: 0; border-bottom: 0;
  color: inherit; font: var(--fm-text-body); text-align: left; cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: rgb(255 255 255 / 8%); }
.nav-item:focus-visible { outline: 2px solid #fff; }
.nav-item.is-active { background: rgb(255 255 255 / 12%); border-left-color: var(--fm-accent); font-weight: 600; }
.nav-item__icon { width: 20px; text-align: center; flex: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.header {
  height: var(--fm-header-height); background: var(--fm-surface); border-bottom: 1px solid var(--fm-border);
  display: flex; align-items: center; gap: var(--fm-space-4); padding: 0 var(--fm-space-6);
}
.header__text { flex: 1; min-width: 0; }
.header__title { font: var(--fm-text-h2); margin: 0; color: var(--fm-primary); flex: 1; }
.header__sub, .header__user, .nav-group, .nav-item__svg, .header__toggle .tg-new { display: none; } /* premium-only (see premium.css) */
.header__toggle {
  width: 44px; height: 44px; border: 0; background: none; border-radius: var(--fm-radius-sm);
  font-size: 20px; cursor: pointer; color: var(--fm-primary);
}
.header__toggle:hover { background: var(--fm-background); }
.header__toggle:focus-visible { outline: 2px solid var(--fm-primary); }

.content { padding: var(--fm-space-6); max-width: var(--fm-content-max); width: 100%; margin: 0 auto; }
.grid-stats { display: grid; gap: var(--fm-space-4); grid-template-columns: repeat(4, 1fr); margin-bottom: var(--fm-space-6); }
.toolbar { display: flex; gap: var(--fm-space-3); margin-bottom: var(--fm-space-4); flex-wrap: wrap; }
.toolbar .fm-input { max-width: 320px; }
.toolbar select.fm-input { width: auto; min-width: 160px; }
.toolbar__spacer { margin-left: auto; }
.gallery-section { margin-bottom: var(--fm-space-8); }
.gallery-row { display: flex; flex-wrap: wrap; gap: var(--fm-space-3); align-items: center; }
.gallery-grid { display: grid; gap: var(--fm-space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: var(--fm-space-2) var(--fm-space-4); margin: 0; }
.detail-list dt { color: var(--fm-text-secondary); }
.detail-list dd { margin: 0; }
.settings-stack { display: grid; gap: var(--fm-space-4); }
.settings-grid { align-items: start; }
.fm-table--matrix th, .fm-table--matrix td { text-align: center; }
.fm-table--matrix th[scope='row'] { text-align: left; background: transparent; color: var(--fm-text); font-weight: 500; }
.fm-table--matrix td.perm-cell, .fm-table--matrix th[scope='row'] { padding-top: 0; padding-bottom: 0; }
.perm-cell .fm-check { justify-content: center; }
.section-title { font: var(--fm-text-h3); color: var(--fm-primary); margin: 0 0 var(--fm-space-3); }

/* collapsed (icons only) */
.shell.is-collapsed .sidebar { width: var(--fm-sidebar-width-collapsed); }
.shell.is-collapsed .nav-item__label { display: none; }
.shell.is-collapsed .brand-full { display: none; }
.shell.is-collapsed .brand-emblem { display: block; }
.shell.is-collapsed .nav-item { justify-content: center; padding: 0; }

@media (max-width: 1023px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
}

/* mobile: sidebar becomes an off-canvas drawer */
@media (max-width: 639px) {
  /* visibility:hidden (after the slide-out) removes the closed drawer's links from the keyboard Tab order */
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease-out, visibility 0s linear 0.2s; }
  .shell.is-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease-out, visibility 0s; }
  .scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 50%); z-index: 10; }
  .header { padding: 0 var(--fm-space-4); }
  .header__emblem { display: block; } /* drawer is closed on mobile, so show the brand mark in the header */
  .header__tag { display: none; }
  .content { padding: var(--fm-space-4); }
  .grid-stats { grid-template-columns: 1fr; }
  .toolbar .fm-input { max-width: none; }
}

/* ---------- Admin sign-in gate + Lead Management + Accounts ---------- */
.fm-login { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; background: linear-gradient(160deg, #203968 0%, #16294d 100%); padding: 16px; }
.fm-login__card { background: #fff; border-radius: 16px; padding: 28px; width: min(420px, 100%); display: grid; gap: 10px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.fm-login__logo { justify-self: start; height: auto; }
.fm-login__title { margin: 4px 0 0; font-size: 22px; color: #203968; }
.fm-login__err { color: #991b1b; min-height: 20px; margin: 0; font-size: 14px; }
.ld__filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; background: #fff; border: 1px solid var(--fm-border, #e5e7eb); border-radius: 12px; padding: 14px; }
.ld__f { display: grid; gap: 4px; font-size: 12px; color: #4b5563; }
.ld__f--actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.ld__rem { max-width: 260px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ld__hist { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
.acc__pw { display: block; padding: 12px; background: #f3f4f6; border-radius: 8px; font-size: 18px; letter-spacing: .5px; user-select: all; }
