/* ==========================================================================
   Auth (login / OTP)
   ========================================================================== */

.auth-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: var(--app-max);
  margin-inline: auto;
  padding: calc(var(--safe-top) + var(--space-6))
           max(var(--space-5), var(--safe-left))
           calc(var(--safe-bottom) + var(--space-6))
           max(var(--space-5), var(--safe-right));
}

.auth-screen__top {
  flex: 1;
}

.auth-screen__bottom {
  padding-top: var(--space-6);
}

.auth-logo {
  width: 5.5rem;
  /* Matches logo-180.png (180x162). Without it the heading jumps down as the
     logo decodes, which is the first thing anyone sees on the login screen. */
  aspect-ratio: 180 / 162;
  object-fit: contain;
  margin-inline: auto;
  margin-bottom: var(--space-8);
}

/* Staff sign-in screens carry the same logo at a smaller size. */
.auth-logo--sm {
  width: 4.5rem;
  margin-bottom: var(--space-6);
}

.auth-title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-6);
}

.phone-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);

  padding: var(--space-1) var(--space-3);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);

  transition: border-color var(--fast) var(--ease),
              box-shadow var(--fast) var(--ease);
}

.phone-field:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(39, 57, 184, 0.16);
}

.phone-field__prefix {
  font-weight: var(--weight-semi);
  color: var(--muted);
  padding-inline-end: var(--space-2);
  border-right: 1px solid var(--line);
}

.phone-field .input {
  border: none;
  background: none;
  box-shadow: none;
  padding-inline: var(--space-2);
  letter-spacing: 0.04em;
}

.phone-field .input:focus {
  box-shadow: none;
}

.legal-text {
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}

.legal-text a {
  color: var(--brand);
  text-decoration: underline;
}

.resend-row {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: center;
}

/* On anything bigger than a phone the full-height, space-between phone layout
   leaves a huge gap between the form and the button. Collapse it into a
   centred card instead. */
@media (min-width: 48rem) {
  .auth-screen {
    max-width: 26rem;
    min-height: 100dvh;
    justify-content: center;
    padding-block: var(--space-10);
  }

  .auth-screen__top {
    flex: 0 1 auto;
    padding: var(--space-8);
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2);
  }

  .auth-screen__bottom {
    padding-top: var(--space-5);
  }

  .auth-logo {
    margin-bottom: var(--space-6);
  }

  .auth-title {
    font-size: var(--text-xl);
  }
}

/* ==========================================================================
   Resident dashboard
   ========================================================================== */

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);

  /* The shell already supplies the safe-area inset above this row, so no
     extra top margin -- that was what left a dead band under the status bar. */
  margin-top: 0;
  margin-bottom: var(--space-4);
}

.dashboard-brand {
  height: 3.25rem;
  width: auto;
  max-width: 11rem;
  object-fit: contain;
}

.dashboard-greeting {
  display: flex;
  align-items: center;
  gap: var(--space-3);

  padding: var(--space-4);
  margin-bottom: var(--space-5);

  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.dashboard-greeting__body {
  flex: 1;
  min-width: 0;
}

.dashboard-greeting__name {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-greeting__role {
  font-size: var(--text-sm);
  color: var(--muted);
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  color: var(--ink);
  background: var(--card);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-1);
}

.icon-btn svg {
  width: 1.35rem;
  height: 1.35rem;
}

.icon-btn__badge {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* Compact row layout: label on the left, icon on the right. A column layout
   with the icon pushed to the bottom made these cards roughly twice as tall
   as they need to be. */
.tile {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);

  min-height: 3.5rem;
  padding: 0.8rem;

  color: var(--ink);
  background: var(--card);
  border-radius: 1.2rem;
  box-shadow: 0 0.25rem 0.9rem rgba(0, 0, 0, 0.04);

  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.tile:hover {
  text-decoration: none;
  transform: translateY(-0.15rem);
  box-shadow: var(--shadow-2);
}

.tile:active {
  transform: scale(0.985);
}

.tile__body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.tile__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);

  font-size: 0.8rem;
  font-weight: var(--weight-semi);
  line-height: 1.3;
}

.tile__subtitle {
  font-size: 0.62rem;
  line-height: 1.3;
  color: var(--muted);
}

/* One size for every tile icon. The old per-icon widths existed only to
   compensate for the artwork having different amounts of padding baked in;
   the SVGs all share a 48x48 viewBox, so they line up on their own. */
.tile__icon {
  width: 2.1rem;
  height: 2.1rem;
  flex-shrink: 0;
  align-self: center;
}

/* Seven tiles leave a lone card on the last row of the two-column grid;
   letting it span the full width keeps the block square. */
.tile-grid > .tile:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ---- horizontal photo strip ---- */

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--space-6) 0 var(--space-3);
}

.section-heading h2 {
  font-size: var(--text-lg);
}

.photo-strip {
  display: flex;
  gap: 0.9rem;

  margin-inline: calc(var(--space-4) * -1);
  padding-inline: var(--space-4);
  padding-bottom: 0.5rem;

  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.photo-strip::-webkit-scrollbar {
  display: none;
}

/* 4:5 portrait, matching the 1080x1350 artwork these slides are authored at. */
.photo-strip__card {
  flex: 0 0 8.5rem;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #eee;
  border-radius: 1.1rem;
  box-shadow: 0 0.25rem 0.9rem rgba(0, 0, 0, 0.08);
  scroll-snap-align: start;
}

.photo-strip__card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.banner-stack {
  display: grid;
  gap: var(--space-3);
}

.banner-stack a {
  display: block;
  line-height: 0;
}

/* Pinned to the 3:1 the posters are authored at (2160x720). Pinning it here
   rather than letting the file decide means the row keeps its height even
   before the image has loaded -- no reflow -- and a poster exported at the
   wrong ratio is cropped instead of stretching the whole section. */
.banner-stack img {
  width: 100%;
  aspect-ratio: 3 / 1;
  object-fit: cover;

  /* Top, not centre. These posters carry their artwork in the upper ~58% of
     the canvas with blank space below, so a centre crop clipped the top of
     the logo and filled the bottom of the box with white. Anchoring to the
     top keeps the whole composition. On a poster already exported at 3:1
     nothing is cropped and this has no effect. */
  object-position: center top;

  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

/* Last block on the dashboard: the shell's bottom padding and the bottom nav
   already provide the clearance, so it must not add another gap of its own.
   `line-height: 0` above removes the descender space under the inline image,
   which was the visible band beneath the final banner. */
.banner-stack:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Bills / receipts
   ========================================================================== */

.amount {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

.detail-list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.detail-list__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--text-sm);
}

.detail-list__label {
  color: var(--muted);
  flex-shrink: 0;
}

.detail-list__value {
  font-weight: var(--weight-medium);
  text-align: right;
  overflow-wrap: anywhere;
}

.month-group {
  margin-top: var(--space-6);
}

.month-group__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--muted);
  margin-bottom: var(--space-2);
}

/* ==========================================================================
   Visitors
   ========================================================================== */

.visitor-card {
  padding: var(--space-4);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.visitor-card + .visitor-card {
  margin-top: var(--space-3);
}

.visitor-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.visitor-card__photo {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: cover;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  cursor: zoom-in;
  flex-shrink: 0;
}

.visitor-card__body {
  flex: 1;
  min-width: 0;
}

.timeline {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
  font-size: var(--text-xs);
  color: var(--muted);
}

/* ==========================================================================
   Memberships
   ========================================================================== */

.plan-card {
  padding: var(--space-6);
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-ink) 100%);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-brand);
}

.plan-card__price {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: 1;
}

.plan-card__unit {
  font-size: var(--text-sm);
  opacity: 0.85;
}

.price-breakdown {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  margin-block: var(--space-5);
  background: var(--brand-soft);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.price-breakdown__total {
  display: flex;
  justify-content: space-between;
  padding-top: var(--space-2);
  margin-top: var(--space-1);
  border-top: 1px solid var(--brand-border);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--brand-ink);
}

.member-names {
  display: grid;
  gap: var(--space-2);
}

.qr-frame {
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.qr-frame img {
  width: min(15rem, 60vw);
  /* QR codes are square; reserving the box stops the "Show this at the gate"
     caption from jumping when the image arrives. */
  aspect-ratio: 1;
  cursor: zoom-in;
}

/* ==========================================================================
   Profile
   ========================================================================== */

.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  margin-bottom: var(--space-5);
  text-align: center;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.photo-picker {
  position: relative;
  display: inline-block;
}

.photo-picker__hint {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  color: #fff;
  background: var(--brand);
  border: 2px solid var(--card);
  border-radius: var(--radius-full);
}

.photo-picker__hint svg {
  width: 1rem;
  height: 1rem;
}

/* ==========================================================================
   Staff (admin / guard)
   ========================================================================== */

.staff-login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--space-5);
}

.staff-login__panel {
  width: 100%;
  max-width: 24rem;
  padding: var(--space-8) var(--space-6);
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
}

.staff-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);

  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--safe-top) + var(--space-3));
  margin-bottom: var(--space-5);

  color: #fff;
  background: var(--brand);
}

.staff-bar__title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.staff-bar .btn--ghost {
  color: #fff;
}

.staff-bar .btn--ghost:hover {
  background: rgba(255, 255, 255, 0.15);
}

.staff-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.staff-nav .badge-count {
  margin-left: var(--space-1);
}

/* ---- overview strip ---- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;

  padding: var(--space-4);

  color: var(--ink);
  background: var(--card);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

a.stat:hover {
  text-decoration: none;
  box-shadow: var(--shadow-2);
}

.stat--warn { border-left-color: var(--warn); }
.stat--ok   { border-left-color: var(--ok); }

.stat__value {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: 1.1;
}

.stat__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-2);
}

.stat__note {
  font-size: var(--text-xs);
  color: var(--muted);
}

@media (min-width: 48rem) {
  .stat-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 80rem) {
  .stat-row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* ---- filter bar ---- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-4);
}

.filter-bar .input,
.filter-bar .select {
  width: auto;
  min-width: 9rem;
  flex: 1 1 9rem;
}

.search-bar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.search-bar .input {
  flex: 1;
}

.result-list {
  display: grid;
  gap: var(--space-2);
}

@media (min-width: 48rem) {
  .staff-bar {
    padding-inline: var(--space-6);
  }

  .staff-bar__title {
    font-size: var(--text-lg);
  }

  .search-bar {
    max-width: 34rem;
  }

  .result-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Staff forms read as two columns of fields on a laptop. */
  .staff-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    align-items: start;
  }

  .staff-form-grid > .card {
    margin-top: 0;
  }

  .staff-form-grid > .card + .card {
    margin-top: 0;
  }
}

@media (min-width: 80rem) {
  .result-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* The admin console is a desk tool, so it gets the full width rather than
   the phone-sized reading column. */
@media (min-width: 64rem) {
  .staff-login__panel {
    max-width: 26rem;
    padding: var(--space-10) var(--space-8);
  }
}

/* ==========================================================================
   Wider screens
   --------------------------------------------------------------------------
   The app is phone-first; these only relax the layout where there is room.
   ========================================================================== */

@media (min-width: 48rem) {
  .tile-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
  }

  .tile {
    min-height: 7rem;
    padding: 1.2rem;
  }

  .tile__title { font-size: 1rem; }
  .tile__subtitle { font-size: 0.8rem; }

  .tile__icon {
    width: 2.5rem;
    height: 2.5rem;
  }

  /* Three and four column layouts lay out evenly, so no full-width spanning. */
  .tile-grid > .tile:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .photo-strip__card {
    flex: 0 0 11rem;
  }

  .banner-stack {
    grid-template-columns: repeat(3, 1fr);
  }

  .app-shell {
    padding-inline: var(--space-6);
  }
}

@media (min-width: 64rem) {
  .tile-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .tile {
    min-height: 7.5rem;
  }

  .photo-strip__card {
    flex: 0 0 13rem;
  }

  .app-shell--wide {
    padding-inline: var(--space-8);
  }

  /* The rail already shows the brand, so drop the duplicate logo. The menu
     button stays: Help, Contact and Log out live only in the drawer. */
  .dashboard-topbar .dashboard-brand {
    display: none;
  }

  .dashboard-topbar {
    justify-content: space-between;
  }

  /* Greeting and the notification bell share a row with room to spare. */
  .dashboard-greeting {
    padding: var(--space-5) var(--space-6);
  }

  .dashboard-greeting__name {
    font-size: var(--text-lg);
  }
}

@media (min-width: 80rem) {
  .banner-stack {
    gap: var(--space-4);
  }

  .photo-strip__card {
    flex: 0 0 15rem;
  }
}
