.home-stage {
  position: relative;
  min-height: calc(100vh - 4.5rem);
  padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 3vw, 1.75rem) 2.5rem;
  isolation: isolate;
}

.home-stage__atmosphere {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 70% 55% at 12% 18%, rgba(215, 228, 226, 0.55), transparent 60%),
    radial-gradient(ellipse 55% 50% at 88% 78%, rgba(196, 92, 38, 0.08), transparent 55%),
    linear-gradient(145deg, #e8ecef 0%, #eceef1 42%, #e4e7eb 100%);
}

/* Logged-in: darker top nav to separate from page background */
.site--home-auth .site-nav {
  background:
    linear-gradient(180deg, #2a3f45 0%, #1d3136 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.22);
  box-shadow: 0 10px 28px rgba(8, 24, 30, 0.22);
}

.site--home-auth .site-nav__brand-text,
.site--home-auth .site-nav__date {
  color: #f3f6f7;
}

.site--home-auth .site-nav__brand-shobe {
  color: rgba(243, 246, 247, 0.72);
}

.site--home-auth .site-nav__brand-logo {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.site--home-auth .site-nav__date {
  color: rgba(243, 246, 247, 0.88);
}

.site--home-auth .site-nav__user {
  color: #f3f6f7;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.site--home-auth .site-nav__user:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.18);
}

.site--home-auth .site-nav__user-label {
  color: rgba(243, 246, 247, 0.7);
}

.site--home-auth .site-nav__user-name {
  color: #fff;
}

.site--home-auth .site-nav__user-icon {
  background: linear-gradient(145deg, #c45c26, #9e4318);
}

@media (max-width: 820px) {
  .site--home-auth .site-nav__date {
    border-top-color: rgba(255, 255, 255, 0.12);
  }
}

.home-stage__grid {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(15, 42, 46, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 42, 46, 0.08) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 75% 65% at 50% 40%, #000 18%, transparent 78%);
}

.home-amvals {
  width: min(1100px, 100%);
  margin: 0 auto;
}

.home-amvals__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 1.15rem;
  text-align: center;
}

.home-amvals__title {
  margin: 0;
  font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  font-weight: 700;
  color: #4a5560;
  letter-spacing: -0.01em;
  line-height: 1.45;
}

.home-amvals__count {
  margin: 0;
  color: #6b7280;
  font-size: 0.82rem;
  font-weight: 600;
}

.home-amvals__empty {
  margin: 2.5rem auto;
  text-align: center;
  color: var(--muted);
  font-size: 1.02rem;
}

.home-amvals-notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.95rem;
  align-items: start;
  margin: 0.35rem 0 1.5rem;
  padding: 1.15rem 1.2rem;
  border-radius: 1rem;
  border: 1px solid rgba(180, 120, 40, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 248, 230, 0.96), rgba(255, 240, 210, 0.9));
  box-shadow: 0 12px 28px rgba(120, 70, 20, 0.08);
}

.home-amvals-notice--missing_signature {
  border-color: rgba(40, 100, 140, 0.28);
  background:
    linear-gradient(135deg, rgba(232, 244, 252, 0.96), rgba(220, 236, 248, 0.9));
  box-shadow: 0 12px 28px rgba(30, 70, 100, 0.08);
}

.home-amvals-notice__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.75rem;
  background: rgba(180, 120, 40, 0.14);
  color: #8a5a12;
}

.home-amvals-notice--missing_signature .home-amvals-notice__icon {
  background: rgba(40, 100, 140, 0.14);
  color: #1f5f84;
}

.home-amvals-notice__title {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--ink, #0f2a2e);
}

.home-amvals-notice__text {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--ink-soft, #1a3f45);
}

.home-amvals-notice__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.45rem;
  padding: 0.45rem 1rem;
  border-radius: 0.65rem;
  background: #1f4d5c;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.18s ease, transform 0.18s ease;
}

.home-amvals-notice__action:hover {
  background: #163845;
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .home-amvals-notice {
    grid-template-columns: 1fr;
  }
}

.home-summary {
  margin: 0 0 1.15rem;
  border-radius: 1rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(247, 244, 237, 0.88));
  border: 1px solid rgba(15, 42, 46, 0.1);
  box-shadow: 0 12px 28px rgba(15, 42, 46, 0.07);
  overflow: hidden;
}

.home-summary__toggle {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 1.05rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: right;
  cursor: pointer;
  transition: background 0.2s ease;
}

.home-summary__toggle:hover,
.home-summary__toggle:focus-visible {
  background: rgba(196, 92, 38, 0.06);
  outline: none;
}

.home-summary__icon {
  display: grid;
  place-items: center;
  width: 2.45rem;
  height: 2.45rem;
  border-radius: 0.75rem;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  box-shadow: 0 8px 18px rgba(196, 92, 38, 0.28);
}

.home-summary__label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.home-summary__label strong {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.home-summary__label small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.home-summary__chevron {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(15, 42, 46, 0.06);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}

.home-summary.is-open .home-summary__chevron {
  transform: rotate(180deg);
  background: rgba(196, 92, 38, 0.12);
  color: var(--accent-deep);
}

.home-summary__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.home-summary.is-open .home-summary__panel {
  grid-template-rows: 1fr;
}

.home-summary__panel[hidden] {
  display: none;
}

.home-summary__panel-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 1rem 1rem;
}

.home-summary-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 42, 46, 0.08);
}

.home-summary-table thead th {
  padding: 0.7rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
  background: rgba(15, 42, 46, 0.04);
  border-bottom: 1px solid rgba(15, 42, 46, 0.08);
  text-align: right;
}

.home-summary-table thead th:last-child {
  width: 7.5rem;
  text-align: center;
}

.home-summary-table tbody td {
  padding: 0.72rem 0.9rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid rgba(15, 42, 46, 0.06);
  vertical-align: middle;
}

.home-summary-table tbody tr:last-child td {
  border-bottom: 0;
}

.home-summary-table tbody tr:nth-child(even) td {
  background: rgba(15, 42, 46, 0.02);
}

.home-summary-table tbody td:last-child {
  text-align: center;
  white-space: nowrap;
}

.home-summary-table__count {
  display: inline-block;
  min-width: 1.5rem;
  font-weight: 800;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.home-summary-table__unit {
  margin-right: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.home-amvals__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: 0.9rem;
}

.home-amval-card {
  display: grid;
  grid-template-columns: 6.2rem 1fr;
  gap: 0.85rem;
  align-items: stretch;
  padding: 0.7rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(15, 42, 46, 0.1);
  box-shadow: 0 10px 28px rgba(15, 42, 46, 0.06);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: home-card-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.home-amval-card:nth-child(2) { animation-delay: 0.04s; }
.home-amval-card:nth-child(3) { animation-delay: 0.08s; }
.home-amval-card:nth-child(4) { animation-delay: 0.12s; }
.home-amval-card:nth-child(5) { animation-delay: 0.16s; }

.home-amval-card:hover,
.home-amval-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(196, 92, 38, 0.35);
  box-shadow: 0 16px 34px rgba(15, 42, 46, 0.12);
  outline: none;
}

.home-amval-card__media {
  width: 6.2rem;
  height: 6.2rem;
  border-radius: 0.8rem;
  overflow: hidden;
  background: rgba(15, 42, 46, 0.06);
  flex-shrink: 0;
}

.home-amval-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-amval-card__placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: rgba(15, 42, 46, 0.35);
}

.home-amval-card__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.15rem 0.1rem;
}

.home-amval-card__code {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.home-amval-card__desc {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-amval-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.home-amval-card__meta span {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: rgba(15, 42, 46, 0.06);
}

/* Modal */
.home-modal[hidden] {
  display: none !important;
}

.home-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  /* Keep clear of sticky top nav */
  padding: max(1rem, calc(env(safe-area-inset-top, 0px) + 5.25rem)) 1rem 1rem;
  align-content: center;
}

.home-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 32, 38, 0.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: home-fade-in 0.25s ease both;
}

.home-modal__sheet {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(86vh, 46rem);
  display: flex;
  flex-direction: column;
  background: #f7f4ed;
  border-radius: 1.1rem;
  box-shadow: 0 22px 48px rgba(8, 24, 30, 0.28);
  animation: home-sheet-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow: hidden;
}

.home-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid rgba(15, 42, 46, 0.08);
  background: rgba(255, 255, 255, 0.55);
}

.home-modal__head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}

.home-modal__close {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.55rem;
  background: rgba(15, 42, 46, 0.08);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.home-modal__body {
  padding: 0.75rem 0.85rem 0.95rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.home-modal__loading {
  margin: 1rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.home-detail-hero {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
  padding: 0.55rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(15, 42, 46, 0.08);
}

.home-detail-hero__media,
.home-detail-hero__media--empty {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 0.6rem;
  overflow: hidden;
  background: rgba(15, 42, 46, 0.06);
}

.home-detail-hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-detail-hero__media--empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.home-detail-hero__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.home-detail-hero__code {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}

.home-detail-hero__desc {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-detail-rows {
  display: grid;
  gap: 0.28rem;
}

.home-detail-row {
  display: grid;
  grid-template-columns: 6.2rem 1fr;
  gap: 0.35rem;
  padding: 0.32rem 0.45rem;
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.55);
}

.home-detail-row__label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.home-detail-row__value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
  line-height: 1.35;
}

.home-detail-section {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(15, 42, 46, 0.08);
}

.home-detail-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--ink);
}

.home-detail-card {
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.35rem;
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(15, 42, 46, 0.08);
}

.home-detail-card h4 {
  margin: 0 0 0.3rem;
  font-size: 0.76rem;
  color: var(--muted);
}

.home-detail-media {
  display: inline-block;
  margin-top: 0.3rem;
  border-radius: 0.45rem;
  overflow: hidden;
  max-width: 100%;
}

.home-detail-media img {
  display: block;
  max-width: min(100%, 10rem);
  max-height: 7rem;
  object-fit: cover;
}

body.has-home-modal {
  overflow: hidden;
}

@keyframes home-card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes home-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes home-sheet-in {
  from {
    opacity: 0.55;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 720px) {
  .home-modal {
    padding: max(1.25rem, calc(env(safe-area-inset-top, 0px) + 5.5rem)) 1.25rem 1.25rem;
  }

  .home-modal__sheet {
    max-height: min(82vh, 46rem);
  }

  .home-modal__head {
    padding: 0.8rem 1rem;
  }

  .home-modal__body {
    padding: 0.85rem 1rem 1.1rem;
  }

  .home-detail-hero {
    grid-template-columns: 6.5rem 1fr;
  }

  .home-detail-hero__media,
  .home-detail-hero__media--empty {
    width: 6.5rem;
    height: 6.5rem;
  }
}

@media (max-width: 820px) {
  .home-modal {
    /* Nav wraps date on smaller screens → taller header */
    padding-top: max(1rem, calc(env(safe-area-inset-top, 0px) + 6.75rem));
    padding-inline: 0.85rem;
    padding-bottom: 0.85rem;
    place-items: start center;
  }

  .home-modal__sheet {
    margin-top: 0;
    max-height: min(calc(100vh - 8.25rem), 40rem);
  }
}

@media (max-width: 560px) {
  .home-modal {
    padding-top: max(0.85rem, calc(env(safe-area-inset-top, 0px) + 7.25rem));
    padding-inline: 0.85rem;
    padding-bottom: 0.85rem;
  }

  .home-modal__sheet {
    width: 100%;
    max-height: min(calc(100vh - 8.75rem), 38rem);
    border-radius: 1rem;
  }

  .home-modal__head {
    padding: 0.6rem 0.75rem;
  }

  .home-modal__head h2 {
    font-size: 0.88rem;
  }

  .home-modal__body {
    padding: 0.65rem 0.75rem 0.85rem;
  }

  .home-summary__toggle {
    gap: 0.65rem;
    padding: 0.85rem 0.85rem;
  }

  .home-summary-table thead th:last-child,
  .home-summary-table tbody td:last-child {
    width: 5.5rem;
  }

  .home-amval-card {
    grid-template-columns: 5.2rem 1fr;
    gap: 0.7rem;
  }

  .home-amval-card__media {
    width: 5.2rem;
    height: 5.2rem;
  }

  .home-detail-hero {
    grid-template-columns: 4.6rem 1fr;
    gap: 0.55rem;
    padding: 0.45rem;
    margin-bottom: 0.55rem;
  }

  .home-detail-hero__media,
  .home-detail-hero__media--empty {
    width: 4.6rem;
    height: 4.6rem;
  }

  .home-detail-hero__code {
    font-size: 0.88rem;
  }

  .home-detail-hero__desc {
    font-size: 0.76rem;
    -webkit-line-clamp: 2;
  }

  .home-detail-row {
    grid-template-columns: 5.4rem 1fr;
    gap: 0.25rem;
    padding: 0.28rem 0.4rem;
  }

  .home-detail-row__label {
    font-size: 0.7rem;
  }

  .home-detail-row__value {
    font-size: 0.76rem;
  }

  .home-detail-section {
    margin-top: 0.55rem;
    padding-top: 0.5rem;
  }

  .home-detail-section h3 {
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
  }

  .home-detail-card {
    padding: 0.4rem 0.45rem;
    margin-bottom: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-amval-card,
  .home-modal__backdrop,
  .home-modal__sheet,
  .home-summary__panel,
  .home-summary__chevron {
    animation: none;
    transition: none;
  }

  .home-modal__sheet {
    transform: none;
  }
}
