:root {
  --ink: #1a1a1a;
  --ink-soft: #3d3d3d;
  --muted: #6b6b6b;
  --stone: #f3f0eb;
  --stone-2: #e8e2d9;
  --paper: #faf8f5;
  --white: #ffffff;
  --line: #ddd6cb;
  --gold: #a67c52;
  --gold-deep: #8b6540;
  --success: #1f6b4a;
  --success-bg: #e8f5ef;
  --error: #9b2c2c;
  --error-bg: #fdeeee;
  --warning: #8a5a00;
  --warning-bg: #fff6e5;
  --info: #1e4d6b;
  --info-bg: #e8f3f8;
  --sidebar-w: 260px;
  --topbar-h: 84px;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(26, 26, 26, 0.08);
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--stone);
  line-height: 1.5;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* —— Admin shell —— */
.admin-body {
  min-height: 100vh;
}

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

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--ink);
  color: var(--white);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 0;
  z-index: 1;
}

.brand-logo {
  width: auto;
  height: 44px;
  max-width: min(260px, 58vw);
  object-fit: contain;
}

.brand-text {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.topbar-user {
  margin-left: auto;
  text-align: right;
  min-width: 0;
  z-index: 2;
}

.topbar-user-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.topbar-user-email {
  display: none;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
}

.nav-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  padding: 10px;
  z-index: 2;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
}

.admin-body-grid {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
}

.admin-sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: min(86vw, var(--sidebar-w));
  z-index: 35;
  background: #111;
  color: rgba(255, 255, 255, 0.88);
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  box-shadow: var(--shadow);
}

.admin-sidebar.is-open {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 30;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.8);
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.sidebar-link:hover,
.sidebar-link.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.sidebar-link.is-active {
  box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar-icon {
  opacity: 0.7;
  width: 1.1rem;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-note {
  margin: 0.85rem 0.5rem 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.04em;
}

.logout-form {
  margin: 0;
}

.admin-main {
  padding: 1.25rem 1rem 2.5rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* —— Flash —— */
.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.flash-success {
  background: var(--success-bg);
  color: var(--success);
}
.flash-error {
  background: var(--error-bg);
  color: var(--error);
}
.flash-warning {
  background: var(--warning-bg);
  color: var(--warning);
}
.flash-info {
  background: var(--info-bg);
  color: var(--info);
}

.flash-dismiss {
  border: 0;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
}

/* —— Typography / page —— */
.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-deep);
  font-weight: 600;
}

.page-hero {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background:
    linear-gradient(135deg, rgba(250, 248, 245, 0.96), rgba(243, 240, 235, 0.9)),
    var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.page-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0.55rem 0 0;
  color: var(--muted);
  max-width: 38rem;
}

.page-hero-art {
  border-radius: 10px;
  overflow: hidden;
  max-height: 180px;
}

.page-hero-art img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.page-hero-gallery {
  min-height: 180px;
}

.page-hero--compact {
  grid-template-columns: 1fr;
}

.dashboard-empty {
  min-height: 50vh;
}

/* —— Fade gallery —— */
.fade-gallery {
  width: 100%;
}

.fade-gallery-stage {
  display: grid;
  grid-template-columns: repeat(var(--gallery-cols, 3), minmax(0, 1fr));
  gap: 0.85rem;
  width: 100%;
  height: 100%;
}

.fade-gallery-slot {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  aspect-ratio: 4 / 5;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.fade-gallery-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition:
    opacity var(--fade-duration, 1.1s) ease,
    transform 1.6s ease;
  will-change: opacity, transform;
}

.fade-gallery-img.is-active {
  opacity: 1;
  transform: scale(1);
  z-index: 1;
}

.fade-gallery--login .fade-gallery-slot {
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.fade-gallery--login .fade-gallery-slot:nth-child(1) {
  transform: translateY(6%);
}

.fade-gallery--login .fade-gallery-slot:nth-child(2) {
  transform: translateY(-4%);
}

.fade-gallery--login .fade-gallery-slot:nth-child(3) {
  transform: translateY(10%);
}

.fade-gallery--hero .fade-gallery-slot {
  aspect-ratio: 16 / 11;
  border: 1px solid var(--line);
  background: var(--stone-2);
}

.fade-gallery--promo .fade-gallery-slot {
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  background: var(--white);
}

@media (prefers-reduced-motion: reduce) {
  .fade-gallery-img {
    transition: none;
    transform: none;
  }
}

.stats-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card,
.module-card,
.form-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 1.1rem 1.2rem;
}

.stat-card h2 {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  margin: 0.55rem 0 0.2rem;
  font-size: 1.05rem;
  font-weight: 600;
  word-break: break-word;
}

.stat-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.section-heading {
  margin-bottom: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
}

.section-heading p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.module-grid {
  display: grid;
  gap: 1rem;
}

.module-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.module-card-media {
  aspect-ratio: 16 / 10;
  background: var(--stone-2);
  overflow: hidden;
}

.module-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.module-card-body {
  padding: 1rem 1.1rem 1.2rem;
}

.module-card-body h3 {
  margin: 0.45rem 0 0.35rem;
  font-size: 1.1rem;
}

.module-card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-deep);
  background: rgba(166, 124, 82, 0.12);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
}

/* —— Forms —— */
.form-panel {
  padding: 1.25rem;
  max-width: 520px;
}

.field {
  display: block;
  margin-bottom: 1rem;
}

.field-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}

.field input:focus {
  outline: 2px solid rgba(166, 124, 82, 0.45);
  border-color: var(--gold);
  background: var(--white);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 2.85rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--ink);
  background: rgba(26, 26, 26, 0.06);
  outline: none;
}

.password-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: currentColor;
}

.password-toggle.is-visible .icon-eye {
  display: none;
}

.password-toggle.is-visible .icon-eye-off {
  display: block;
}

.password-toggle .icon-eye-off[hidden] {
  display: none;
}

.password-toggle.is-visible .icon-eye-off {
  display: block;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.8rem 1.2rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: var(--white);
}

.btn-primary:hover {
  background: #000;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-block {
  width: 100%;
}

.security-box {
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(166, 124, 82, 0.06);
}

.security-box legend {
  padding: 0 0.35rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-deep);
  font-weight: 700;
}

.security-prompt {
  margin: 0 0 0.75rem;
  color: var(--ink-soft);
}

/* —— Login page —— */
.login-body {
  min-height: 100vh;
  background: var(--ink);
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

.login-showcase {
  display: none;
  position: relative;
  overflow: hidden;
  background: #0d0d0d;
  min-height: 280px;
}

.login-showcase-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.78)),
    radial-gradient(circle at top right, rgba(166, 124, 82, 0.35), transparent 45%);
}

.login-showcase .fade-gallery {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 8% 7% 22%;
}

.login-showcase-copy {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 8%;
  z-index: 3;
  color: var(--white);
}

.login-showcase-copy h1 {
  margin: 0.2rem 0 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  font-weight: 600;
}

.login-showcase-copy p {
  margin: 0;
  max-width: 28rem;
  color: rgba(255, 255, 255, 0.78);
}

.login-eyebrow {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: #d4b48c !important;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
  background:
    radial-gradient(circle at top, rgba(166, 124, 82, 0.12), transparent 40%),
    var(--paper);
}

.login-panel-inner {
  width: 100%;
  max-width: 420px;
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.75rem;
}

.login-logo {
  height: 72px;
  width: auto;
  max-width: min(360px, 100%);
  object-fit: contain;
  border-radius: 8px;
}

.login-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 600;
}

.login-subheading {
  margin: 0.35rem 0 1.25rem;
  color: var(--muted);
}

.login-footnote {
  margin: 1.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* —— Errors —— */
.error-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--stone);
}

.error-card {
  width: 100%;
  max-width: 460px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.error-logo {
  margin: 0 auto 1rem;
  height: 56px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  border-radius: 8px;
}

.error-card h1 {
  margin: 0.2rem 0 0.6rem;
  font-family: var(--font-display);
  font-size: 2rem;
}

.error-card p {
  color: var(--muted);
}

.error-card code {
  font-size: 0.85em;
  word-break: break-all;
}

/* —— Responsive breakpoints —— */
@media (min-width: 640px) {
  .admin-topbar {
    padding: 0 1.35rem;
  }

  .brand-logo {
    height: 52px;
    max-width: 300px;
  }

  .topbar-user-email {
    display: block;
  }

  .admin-main {
    padding: 1.75rem 1.5rem 3rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .page-hero {
    padding: 1.5rem;
  }
}

@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }

  .admin-body-grid {
    grid-template-columns: var(--sidebar-w) 1fr;
  }

  .admin-sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    width: var(--sidebar-w);
    transform: none;
    box-shadow: none;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }

  .sidebar-backdrop {
    display: none !important;
  }

  .page-hero:not(.page-hero--compact) {
    grid-template-columns: 1.4fr 1fr;
    align-items: center;
  }

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

  .login-page {
    grid-template-columns: 1.15fr 0.85fr;
  }

  .login-showcase {
    display: block;
    min-height: 100vh;
  }
}

@media (min-width: 1100px) {
  .module-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .admin-main {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

@media (max-width: 899px) {
  body.nav-open {
    overflow: hidden;
  }

  .fade-gallery--promo .fade-gallery-stage,
  .fade-gallery--hero .fade-gallery-stage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fade-gallery--promo .fade-gallery-slot:nth-child(3) {
    grid-column: 1 / -1;
    max-width: 70%;
    justify-self: center;
    aspect-ratio: 16 / 10;
  }
}

@media (max-width: 480px) {
  .fade-gallery--promo .fade-gallery-stage {
    grid-template-columns: 1fr;
  }

  .fade-gallery--promo .fade-gallery-slot:nth-child(3) {
    max-width: 100%;
    aspect-ratio: 4 / 5;
  }

  .fade-gallery--hero .fade-gallery-stage {
    grid-template-columns: 1fr;
  }
}
