@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');
@import url('./tokens.css');

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

/* The `hidden` attribute must always win, even over author `display` rules
   (e.g. flex/grid containers like the modal overlay and alerts panel). */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  /* Guard horizontal overflow on the actual page scroller. */
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text-primary);
  line-height: 1.6;
  /* `clip` (not `hidden`) so <body> doesn't become a second scroll container.
     `overflow-x: hidden` here forces overflow-y to compute as `auto`, which
     decoupled body-scroll from the viewport and caused janky/stuck scrolling
     and a misbehaving sticky header on mobile. */
  overflow-x: clip;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--color-primary-light);
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 1.75rem);
}

/* ─── Header ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  box-shadow: var(--shadow-header);
  transition:
    transform var(--duration-normal) var(--ease-out),
    background var(--duration-fast),
    border-color var(--duration-fast);
}

.site-header.is-scrolled {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--color-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 0.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3.5vw, 1.5rem);
  color: var(--color-primary);
  font-weight: 400;
  z-index: 101;
  text-decoration: none;
}

.logo:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary-light));
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px var(--color-primary-glow);
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 14px var(--color-primary-glow); }
  50% { box-shadow: 0 4px 22px rgba(232, 81, 10, 0.5); }
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 101;
  border-radius: var(--radius-md);
  transition: background var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

label.nav-toggle {
  display: none;
  margin: 0;
}

.nav-toggle:hover {
  background: var(--color-primary-subtle);
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text-primary);
  border-radius: 2px;
  transition:
    transform var(--duration-normal) var(--ease-out),
    opacity var(--duration-fast);
}

body.nav-open .nav-toggle span:nth-child(1),
.site-header:has(#site-nav-open:checked) .nav-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.nav-open .nav-toggle span:nth-child(2),
.site-header:has(#site-nav-open:checked) .nav-toggle span:nth-child(2) {
  opacity: 0;
}

body.nav-open .nav-toggle span:nth-child(3),
.site-header:has(#site-nav-open:checked) .nav-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.45);
  z-index: 98;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal);
  cursor: pointer;
}

.site-nav-state {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: nowrap;
}

.nav a {
  padding: 0.5rem 0.65rem;
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  color: var(--color-text-secondary);
  border-radius: var(--radius-full);
  transition:
    color var(--duration-fast),
    background var(--duration-fast),
    transform var(--duration-fast) var(--ease-spring);
}

.nav a:hover {
  color: var(--chip-text-active);
  background: var(--chip-bg-active);
  text-decoration: none;
  transform: translateY(-1px);
}

.nav a.active {
  color: var(--chip-text-active);
  background: var(--chip-bg-active);
}

/* ─── Hero ─── */
.hero {
  position: relative;
  padding: clamp(3rem, 10vw, 6rem) 0 clamp(2.5rem, 8vw, 5rem);
  text-align: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(232, 81, 10, 0.14), transparent),
    radial-gradient(ellipse 50% 40% at 90% 60%, rgba(45, 158, 22, 0.1), transparent),
    radial-gradient(ellipse 40% 35% at 5% 80%, rgba(232, 81, 10, 0.08), transparent),
    var(--color-surface-warm);
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: float 8s ease-in-out infinite;
  pointer-events: none;
}

.hero-orb--1 {
  width: 280px;
  height: 280px;
  background: var(--color-primary-subtle);
  top: -60px;
  right: -80px;
  animation-delay: 0s;
}

.hero-orb--2 {
  width: 200px;
  height: 200px;
  background: var(--color-secondary-subtle);
  bottom: 20px;
  left: -60px;
  animation-delay: -3s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(12px, -18px) scale(1.04); }
  66% { transform: translate(-8px, 10px) scale(0.96); }
}

.hero .container {
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: var(--chip-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--badge-ok-text);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
  animation: fade-up 0.7s var(--ease-out) both;
}

.hero-badge-dot {
  width: 8px;
  height: 8px;
  background: var(--color-secondary-light);
  border-radius: 50%;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6.5vw, 3.25rem);
  line-height: 1.15;
  margin-bottom: 1rem;
  animation: fade-up 0.7s var(--ease-out) 0.1s both;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-lead {
  color: var(--color-text-secondary);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  max-width: 36rem;
  margin: 0 auto 2rem;
  animation: fade-up 0.7s var(--ease-out) 0.2s both;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  animation: fade-up 0.7s var(--ease-out) 0.3s both;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.25rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9375rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--color-primary-glow);
  transition:
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast),
    filter var(--duration-fast);
}

.btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 28px var(--color-primary-glow);
  color: white;
  text-decoration: none;
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-outline {
  background: var(--color-bg);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  box-shadow: var(--shadow-card);
}

.btn-outline:hover {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  filter: none;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-width: 32rem;
  margin: 3rem auto 0;
  animation: fade-up 0.7s var(--ease-out) 0.45s both;
}

.stat {
  padding: 1rem 0.5rem;
  background: var(--stat-glass-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Sections ─── */
.section-head {
  text-align: center;
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4.5vw, 2.25rem);
  margin-bottom: 0.5rem;
  color: var(--color-text-primary);
}

.section-head p {
  color: var(--color-text-secondary);
  max-width: 32rem;
  margin: 0 auto;
}

.features {
  padding: var(--space-section) 0;
  background: var(--color-surface-warm);
  border-top: 1px solid var(--color-border);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: clamp(1rem, 3vw, 1.5rem);
}

.feature-card {
  position: relative;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 4vw, 1.75rem);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition:
    transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal),
    border-color var(--duration-fast);
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-normal) var(--ease-out);
}

.feature-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(232, 81, 10, 0.2);
}

.feature-card:hover::before {
  transform: scaleX(1);
}

.feature-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--color-primary-subtle);
  border-radius: var(--radius-md);
  font-size: 1.4rem;
  margin-bottom: 1rem;
  transition: transform var(--duration-normal) var(--ease-spring);
}

.feature-card:hover .feature-icon {
  transform: scale(1.1) rotate(-4deg);
}

.feature-card h3 {
  color: var(--color-text-primary);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Trust strip */
.trust-strip {
  padding: var(--space-section) 0;
  background: linear-gradient(180deg, var(--color-secondary-subtle), var(--color-surface));
}

.trust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 1rem;
}

.trust-item {
  text-align: center;
  padding: 1.25rem 1rem;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  transition: transform var(--duration-normal) var(--ease-out);
}

.trust-item:hover {
  transform: translateY(-4px);
}

.trust-item strong {
  display: block;
  color: var(--color-secondary);
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.trust-item span {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* CTA band */
.cta-band {
  margin: 0 clamp(1rem, 4vw, 1.75rem) var(--space-section);
  padding: clamp(2rem, 6vw, 3rem);
  background: linear-gradient(135deg, var(--color-primary), #c44308);
  border-radius: var(--radius-xl);
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
}

.cta-band::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.cta-band .container {
  position: relative;
  z-index: 1;
}

.cta-band h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: 0.75rem;
}

.cta-band p {
  opacity: 0.9;
  margin-bottom: 1.5rem;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.cta-band .btn {
  background: white;
  color: var(--color-primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.cta-band .btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-subtle);
}

/* ─── Contact page ─── */
.page-hero {
  position: relative;
  padding: clamp(2.5rem, 8vw, 4rem) 0 clamp(2rem, 5vw, 3rem);
  text-align: center;
  overflow: hidden;
}

.page-hero-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(160deg, var(--color-primary-subtle) 0%, transparent 50%),
    var(--color-surface-warm);
}

.page-hero .container {
  position: relative;
  z-index: 1;
}

.page-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3rem);
  margin-bottom: 0.75rem;
  animation: fade-up 0.6s var(--ease-out) both;
}

.page-hero .subtitle {
  color: var(--color-text-secondary);
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  max-width: 32rem;
  margin: 0 auto;
  animation: fade-up 0.6s var(--ease-out) 0.1s both;
}

.contact-page,
.contact-section {
  padding: var(--space-section) 0;
}

.contact-section {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

.contact-section .section-head h2 {
  color: var(--color-text-primary);
}

.contact-section .section-head p {
  color: var(--color-text-secondary);
}

/* Contact info must always be readable — no scroll-reveal hiding */
.contact-section .reveal {
  opacity: 1;
  transform: none;
}

.contact-cta {
  margin-top: clamp(2rem, 5vw, 3rem);
  text-align: center;
}

.contact-cta p {
  color: var(--color-text-primary);
  max-width: 32rem;
  margin: 0 auto 1.25rem;
  font-size: 1rem;
  line-height: 1.6;
}

.contact-highlight {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

.contact-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-primary);
  box-shadow: var(--shadow-card);
}

.contact-pill strong {
  color: var(--color-primary);
  font-weight: 700;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: clamp(1rem, 3vw, 1.5rem);
}

.contact-card {
  position: relative;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 4vw, 1.75rem);
  box-shadow: var(--shadow-card);
  transition:
    transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal);
}

.contact-card--featured {
  grid-column: 1 / -1;
  background: linear-gradient(
    135deg,
    var(--color-bg) 0%,
    var(--color-primary-subtle) 100%
  );
  border-color: rgba(232, 81, 10, 0.25);
}

[data-theme='dark'] .contact-card--featured {
  border-color: rgba(249, 115, 22, 0.4);
}

.contact-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}

@media (min-width: 640px) {
  .contact-card--featured {
    grid-column: span 2;
  }
}

.contact-card-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--color-primary-subtle);
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.contact-card h2 {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.contact-card p,
.contact-card li {
  color: var(--color-text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.contact-card ul {
  list-style: none;
}

.contact-card a {
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  padding: 0.35rem 0;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.contact-card a:hover {
  transform: translateX(4px);
  text-decoration: none;
}

.contact-card .highlight {
  color: var(--color-text-primary);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
}

.phone-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.phone-link {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem !important;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  transition:
    background var(--duration-fast),
    border-color var(--duration-fast),
    transform var(--duration-fast) var(--ease-spring) !important;
}

.phone-link:hover {
  background: var(--color-primary-subtle);
  border-color: rgba(232, 81, 10, 0.3);
  transform: translateX(0) scale(1.01) !important;
}

.phone-link::after {
  content: '→';
  opacity: 0.5;
  font-size: 0.875rem;
}

.hours-card {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.hours-block {
  flex: 1;
  min-width: 140px;
  padding: 1rem;
  background: var(--tag-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
}

.hours-block .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.hours-block .value {
  font-weight: 700;
  color: var(--color-text-primary);
  font-size: 1rem;
}

.contact-card .hours-block {
  background: var(--color-surface);
}

[data-theme='dark'] .contact-card .hours-block {
  background: var(--color-surface-warm);
}

/* ─── Footer ─── */
.site-footer {
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: clamp(1.5rem, 4vw, 2rem) 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.site-footer a {
  font-weight: 500;
}

/* ─── Animations ─── */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reveal {
  opacity: 1;
  transform: none;
}

.js-reveal-animate .reveal:not(.is-visible) {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
}

.js-reveal-animate .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* ─── Mobile ─── */
@media (max-width: 768px) {
  /* backdrop-filter traps position:fixed nav inside the short header bar */
  .site-header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--color-bg);
    z-index: 120;
  }

  .site-header.is-scrolled {
    background: var(--color-bg);
  }

  body.nav-open .site-header,
  .site-header:has(#site-nav-open:checked) {
    transform: none;
  }

  /* Lock page scroll while the drawer is open — derived purely from the
     checkbox state, so it can never get stuck locked from stale JS state. */
  body:has(#site-nav-open:checked) {
    overflow: hidden;
  }

  .header-controls {
    display: none;
  }

  .logo {
    flex: 1;
    min-width: 0;
  }

  .nav-toggle,
  label.nav-toggle {
    display: flex;
    order: 2;
    flex-shrink: 0;
    position: relative;
    z-index: 122;
    pointer-events: auto;
    margin-left: auto;
  }

  .nav-overlay {
    display: block;
    z-index: 118;
  }

  .nav {
    position: fixed;
    top: 0;
    right: 0;
    width: min(300px, 85vw);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: calc(var(--header-height) + 1.5rem) 1.25rem 2rem;
    background: var(--color-bg);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform var(--duration-normal) var(--ease-out);
    z-index: 110;
    gap: 0.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    pointer-events: none;
    visibility: hidden;
  }

  .nav .header-controls--drawer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 1.25rem;
    margin-bottom: 0.25rem;
    border-top: 1px solid var(--color-border);
    width: 100%;
    flex-shrink: 0;
  }

  .nav .header-controls--drawer .lang-dropdown {
    flex: 1;
    min-width: 0;
  }

  .nav .header-controls--drawer .lang-dropdown-trigger {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-size: 0.875rem;
  }

  .nav .header-controls--drawer .lang-current {
    max-width: none;
  }

  .nav .header-controls--drawer .theme-toggle {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .header-controls--drawer .lang-dropdown-menu {
    top: auto;
    bottom: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    min-width: 0;
  }

  body.nav-open .nav,
  #site-nav-open:checked ~ .nav,
  .site-header:has(#site-nav-open:checked) .nav {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    z-index: 125;
  }

  body.nav-open .nav-overlay,
  #site-nav-open:checked ~ .nav-overlay,
  .site-header:has(#site-nav-open:checked) .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .nav a {
    display: flex !important;
    align-items: center;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
  }

  .hero-stats {
    grid-template-columns: 1fr;
    max-width: 14rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .contact-card--featured {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .contact-highlight {
    flex-direction: column;
    align-items: stretch;
  }

  .contact-pill {
    justify-content: center;
  }
}

/* ─── Auth forms ─── */
.auth-page {
  padding-bottom: var(--space-section);
}

.auth-container {
  max-width: 480px;
  margin-top: -1rem;
}

.auth-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: clamp(1.5rem, 5vw, 2rem);
  box-shadow: var(--shadow-card-hover);
}

.auth-card.reveal,
.auth-page .auth-container .reveal {
  opacity: 1;
  transform: none;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 0.4rem;
}

.form-group .required {
  color: var(--color-primary);
}

.form-group input,
.form-group select {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-warm);
  color: var(--color-text-primary);
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

/* ---- MkulimaSelect (enhanced <select>) --------------------------------- */
.ms-select {
  position: relative;
  width: 100%;
}

/* The native select stays present (value/form source of truth) but hidden.
   Kept sized over the wrapper so browser validation can still target it. */
.ms-select > select.ms-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  margin: 0;
}

.ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  text-align: left;
  color: var(--color-text-primary);
  background: var(--color-surface-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast);
}

.ms-trigger:hover {
  border-color: var(--color-primary-light);
}

.ms-select.is-open .ms-trigger,
.ms-trigger:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.ms-select.is-disabled .ms-trigger {
  opacity: 0.6;
  cursor: not-allowed;
}

.ms-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--color-text-secondary);
  transition: transform var(--duration-fast) var(--ease-out);
}

.ms-select.is-open .ms-chevron {
  transform: rotate(180deg);
}

.ms-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card-hover);
}

.ms-option {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--color-text-primary);
  cursor: pointer;
}

.ms-option:hover,
.ms-option.is-active {
  background: var(--color-surface);
  outline: none;
}

.ms-option.is-selected {
  color: var(--color-primary);
  font-weight: 600;
  background: var(--color-primary-subtle);
}

.btn-full {
  width: 100%;
  margin-top: 0.5rem;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.form-alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.form-alert--error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.form-alert--success {
  background: var(--color-secondary-subtle);
  color: var(--color-secondary);
  border: 1px solid rgba(26, 107, 10, 0.2);
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

.auth-switch a {
  font-weight: 600;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 2.75rem;
  width: 100%;
}

.password-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.35rem;
  opacity: 0.7;
}

.password-toggle:hover {
  opacity: 1;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  z-index: 101;
}

@media (min-width: 769px) {
  .site-header .container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .site-header .nav {
    margin-left: auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    flex-shrink: 1;
    min-width: 0;
  }

  .site-header .logo {
    flex-shrink: 0;
  }

  .site-header .header-controls {
    order: 3;
    flex-shrink: 0;
  }

  .site-header .nav-toggle {
    order: 4;
  }
}

.header-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.header-icon--chevron {
  width: 0.85rem;
  height: 0.85rem;
  opacity: 0.55;
  transition: transform var(--duration-fast);
}

.lang-dropdown {
  position: relative;
}

.lang-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color var(--duration-fast),
    background var(--duration-fast);
}

.lang-dropdown-trigger:hover,
.lang-dropdown.is-open .lang-dropdown-trigger {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.lang-dropdown.is-open .header-icon--chevron {
  transform: rotate(180deg);
}

.lang-current {
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 10.5rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  z-index: 120;
}

.lang-dropdown-menu button {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.lang-dropdown-menu button:hover {
  background: var(--color-surface);
}

.lang-dropdown-menu button.is-active {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  font-weight: 600;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg);
  color: var(--color-text-primary);
  cursor: pointer;
  transition:
    border-color var(--duration-fast),
    background var(--duration-fast),
    color var(--duration-fast);
}

.theme-toggle:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.theme-toggle-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.theme-toggle-icon--sun {
  display: none;
}

.theme-toggle-icon--moon {
  display: block;
}

.theme-toggle.is-dark .theme-toggle-icon--sun {
  display: block;
}

.theme-toggle.is-dark .theme-toggle-icon--moon {
  display: none;
}

.hero-carousel {
  margin: 1rem 0 0.5rem;
  min-height: 2.5rem;
}

.carousel-caption {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-secondary);
  animation: fadeCaption 0.5s ease;
}

@keyframes fadeCaption {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.calc-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.calc-sidebar-head h2 {
  margin: 0;
  font-size: 1rem;
}

.calc-export-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.saved-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.tracker-open {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.saved-detail {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

/* Auth-aware visibility */
[data-guest-only] {
  display: revert;
}

[data-auth-only] {
  display: none !important;
}

body.is-logged-in [data-guest-only] {
  display: none !important;
}

body.is-logged-in [data-auth-only] {
  display: revert !important;
}

body.is-logged-in .hero-actions [data-auth-only].btn,
body.is-logged-in .cta-band [data-auth-only].btn,
body.is-logged-in .quick-links [data-auth-only].btn {
  display: inline-flex !important;
}

body.is-logged-in .nav [data-auth-only] {
  display: inline-flex !important;
}

/* ─── Profile page ─── */
.profile-container {
  max-width: 720px;
}

.profile-grid {
  display: grid;
  gap: 1.5rem;
}

.profile-card h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin-bottom: 1.25rem;
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--chip-bg);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--chip-text);
  transition: all var(--duration-fast);
}

.theme-option:hover {
  border-color: var(--chip-border-active);
  color: var(--chip-text-active);
}

.theme-option.active {
  border-color: var(--chip-border-active);
  background: var(--chip-bg-active);
  color: var(--chip-text-active);
  box-shadow: 0 0 0 1px var(--chip-border-active);
}

.theme-swatch {
  width: 40px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.theme-swatch--light { background: linear-gradient(135deg, #fff, #f7f6f3); }
.theme-swatch--dark { background: linear-gradient(135deg, #1e1e1e, #141414); }
.theme-swatch--system { background: linear-gradient(135deg, #fff 50%, #1e1e1e 50%); }

.profile-dl div {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
}

.profile-dl dt {
  color: var(--color-text-muted);
  font-weight: 500;
}

.profile-dl dd {
  font-weight: 600;
  color: var(--color-text-primary);
}

[data-theme='dark'] .site-header {
  background: rgba(30, 30, 30, 0.9);
}

[data-theme='dark'] .form-alert--error {
  background: #3b1515;
  color: #fca5a5;
  border-color: #7f1d1d;
}

[data-theme='dark'] .form-alert--success {
  background: var(--color-secondary-subtle);
  color: var(--color-secondary-light);
}

@media (min-width: 640px) {
  .profile-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── App shell (dashboard, calculators, records) ─── */
.app-body {
  background: var(--color-surface-warm);
}

.app-main {
  padding: clamp(1.5rem, 4vw, 2.5rem) 0 var(--space-section);
}

.app-head {
  margin-bottom: 1.75rem;
}

.app-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  margin-bottom: 0.35rem;
}

.app-head p {
  color: var(--color-text-secondary);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: transform var(--duration-normal) var(--ease-out);
}

.stat-card:hover {
  transform: translateY(-3px);
}

.stat-card-value {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-card--accent .stat-card-value { color: var(--color-secondary); }
.stat-card--warn .stat-card-value { color: var(--badge-warn-text); }

.stat-card-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-bar, .record-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.filter-btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--color-border);
  background: var(--chip-bg);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--chip-text);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--chip-bg-active);
  border-color: var(--chip-border-active);
  color: var(--chip-text-active);
}

.tracker-feed, .tracker-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tracker-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform var(--duration-fast), box-shadow var(--duration-fast);
}

.tracker-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-card-hover);
}

.tracker-body { flex: 1; min-width: 0; }

.tracker-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.tracker-meta {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.tracker-sub {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-top: 0.15rem;
}

.fav-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring), color var(--duration-fast), background var(--duration-fast);
}

.fav-btn:hover { transform: scale(1.15); color: var(--chip-text-active); background: var(--chip-bg-active); }
.fav-btn.is-favorite { color: var(--chip-text-active); background: var(--chip-bg-active); }

.badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
}

.badge--ok { background: var(--badge-ok-bg); color: var(--badge-ok-text); }
.badge--warn { background: var(--badge-warn-bg); color: var(--badge-warn-text); }

.type-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  background: var(--tag-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--tag-text);
}

.timeline { position: relative; padding-left: 1.5rem; }

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, var(--color-primary-subtle), var(--color-border));
}

.timeline-item {
  position: relative;
  margin-bottom: 1rem;
}

.timeline-dot {
  position: absolute;
  left: -1.5rem;
  top: 1.25rem;
  width: 12px;
  height: 12px;
  background: var(--color-primary);
  border: 2px solid var(--color-bg);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--color-primary-subtle);
}

.timeline-dot--warn { background: #d97706; box-shadow: 0 0 0 2px var(--badge-warn-bg); }

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2rem;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--color-border);
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* Calculators layout */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--color-border);
  background: var(--chip-bg);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--chip-text);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.tab-btn:hover {
  border-color: var(--chip-border-active);
  color: var(--chip-text-active);
}

.tab-btn.active {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

.calc-panel, .calc-sidebar {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.calc-sidebar h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--color-secondary);
}

.calc-form h2 {
  font-family: var(--font-display);
  margin-bottom: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-group--full { grid-column: 1 / -1; }

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

.calc-result {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--badge-ok-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  animation: fade-up 0.4s var(--ease-out);
}

.calc-result h3 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--badge-ok-text);
  margin-bottom: 0.75rem;
}

.result-dl div {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
}

.result-dl dt { color: var(--chip-text); }
.result-dl dd { font-weight: 600; color: var(--color-text-primary); }

/* Spray records layout */
.records-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.section-label {
  font-size: 1rem;
  color: var(--color-secondary);
  margin-bottom: 1rem;
  font-weight: 600;
}

.record-form-section { position: sticky; top: calc(var(--header-height) + 1rem); }

.quick-farm-details {
  margin-top: 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.quick-farm-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-primary);
}

/* Modal (2FA enrolment) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  animation: modal-fade var(--duration-fast) ease;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 26rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-hover);
  padding: 1.75rem;
  text-align: center;
  animation: modal-pop var(--duration-normal) var(--ease-spring);
}
@keyframes modal-pop { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
}
.modal-close:hover { color: var(--color-text); }
.modal-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.modal-title { font-size: 1.25rem; margin-bottom: 0.5rem; }
.modal-body { font-size: 0.9rem; color: var(--color-text-secondary); margin-bottom: 1.25rem; }
.modal-card .form-group { text-align: left; margin-bottom: 1rem; }
.modal-card .btn { margin-bottom: 0.6rem; }
.modal-alert { margin-bottom: 1rem; text-align: left; }

/* Notification / reminder cards */
.alerts-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.alert-card--high { border-left-color: var(--color-primary); }
.alert-card--critical { border-left-color: #dc2626; }
.alert-card--medium { border-left-color: var(--color-secondary); }
.alert-card--low { border-left-color: var(--color-border); }
.alert-icon { font-size: 1.25rem; line-height: 1.4; flex-shrink: 0; }
.alert-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.alert-body strong { font-size: 0.95rem; }
.alert-body span { font-size: 0.8125rem; color: var(--color-text-secondary); }
.alert-dismiss {
  flex-shrink: 0;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 0.25rem;
}
.alert-dismiss:hover { color: var(--color-text); }

/* Profile security: hint + toggle switch */
.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}
.auth-hint { font-size: 0.8125rem; color: var(--color-text-secondary); margin-bottom: 1rem; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  cursor: pointer;
}
.switch-row > span:first-child { display: flex; flex-direction: column; gap: 0.15rem; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--duration-fast);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-text-muted);
  transition: transform var(--duration-fast) var(--ease-spring), background var(--duration-fast);
}
.switch:checked { background: var(--color-primary); border-color: var(--color-primary); }
.switch:checked::after { transform: translateX(20px); background: #fff; }

/* Dashboard analytics */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.analytics-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
.analytics-card--wide { grid-column: 1 / -1; }
.analytics-card .section-label { margin-bottom: 1rem; }
.chart-empty { color: var(--color-text-muted); font-size: 0.875rem; }

/* Vertical bar chart (trend) */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 160px;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 0.35rem;
}
.chart-bar {
  width: 100%;
  max-width: 42px;
  background: linear-gradient(180deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height var(--duration-normal) var(--ease-spring);
}
.chart-bar-val { font-size: 0.75rem; font-weight: 700; color: var(--color-text-secondary); min-height: 1em; }
.chart-bar-label { font-size: 0.7rem; color: var(--color-text-muted); text-transform: capitalize; }

/* Stacked input-mix bar + legend */
.chart-stack {
  display: flex;
  height: 16px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--color-surface);
  margin-bottom: 1rem;
}
.chart-stack span { display: block; height: 100%; }
.chart-legend { display: flex; flex-direction: column; gap: 0.5rem; }
.chart-legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}
.chart-legend-row strong { margin-left: auto; }
.chart-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Horizontal bar charts (region, crops) */
.chart-hbars { display: flex; flex-direction: column; gap: 0.6rem; }
.chart-hbar-row { display: flex; align-items: center; gap: 0.6rem; }
.chart-hbar-label {
  flex: 0 0 30%;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-hbar-track {
  flex: 1;
  height: 10px;
  background: var(--color-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.chart-hbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) var(--ease-spring);
}
.chart-hbar-val { font-size: 0.8125rem; font-weight: 700; flex-shrink: 0; min-width: 1.5rem; text-align: right; }

@media (max-width: 720px) {
  .analytics-grid { grid-template-columns: 1fr; }
}

/* Role + status badges */
.badge--role,
.badge--status { color: #fff; }
.badge--FARMER { background: var(--color-secondary); }
.badge--EXTENSION_OFFICER { background: var(--color-primary); }
.badge--ADMIN,
.badge--SUPER_ADMIN { background: #6d28d9; }
.badge--ACTIVE { background: var(--color-secondary); }
.badge--HARVESTED { background: var(--color-primary); }
.badge--ABANDONED { background: var(--color-text-muted); }

/* User cards */
.user-assign {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.user-assign-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.user-assign select { min-width: 12rem; }

/* Crop-cycle cards with nested applications */
.rec-cycle .rec-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.rec-empty {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}
.rec-input {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
  border-radius: var(--radius-md);
}
.rec-input--SEED { border-left-color: var(--color-secondary); }
.rec-input--FERTILIZER { border-left-color: #6d28d9; }
.rec-input--PESTICIDE { border-left-color: var(--color-primary); }
.rec-input-type {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  flex-shrink: 0;
  padding-top: 0.15rem;
}
.rec-input-main { min-width: 0; }
.rec-input-main strong { display: block; font-size: 0.9375rem; }
.rec-input-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}
.rec-by { color: var(--color-text-muted); font-style: italic; }
.rec-cycle--loose { border-style: dashed; }

@media (max-width: 900px) {
  .calc-layout,
  .records-layout {
    grid-template-columns: 1fr;
  }

  .record-form-section { position: static; }
  .user-assign { flex-wrap: wrap; }
  .user-assign select { min-width: 100%; }
}

/* ─── Unified Farm Records page ─── */
.records-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.records-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.farms-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.farm-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 3vw, 1.5rem);
  box-shadow: var(--shadow-card);
}
.farm-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.farm-card-title h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.3;
}
.rec-farm-meta {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}
.rec-farm-owner {
  color: var(--color-primary);
  font-weight: 600;
  margin-left: 0.35rem;
}

.rec-cycle-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
  background: var(--color-surface-warm);
}
.rec-cycle-block--loose { border-style: dashed; background: transparent; }
.rec-cycle-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.rec-cycle-dates {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.rec-cycle-block .rec-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.rec-input--VISIT { border-left-color: #0e7490; }
.rec-input-notes {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-top: 0.25rem;
  white-space: pre-wrap;
}

.icon-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color var(--duration-fast), border-color var(--duration-fast), background var(--duration-fast);
}
.icon-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}
.icon-btn--danger:hover {
  color: #dc2626;
  border-color: #dc2626;
  background: #fef2f2;
}
[data-theme='dark'] .icon-btn--danger:hover { background: #3a1414; color: #f87171; border-color: #f87171; }

.rec-input-actions,
.rec-cycle-actions,
.farm-card-actions {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
}
.rec-cycle-head .rec-cycle-actions,
.rec-input .rec-input-actions { align-self: flex-start; }

/* Inputs with a fixed unit tag (SI unit / TZS) */
.input-unit {
  display: flex;
  align-items: stretch;
}
.input-unit input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}
.input-unit-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 0.65rem;
  border: 1px solid var(--color-border);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Loaders */
.spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: mk-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner--sm { width: 0.9rem; height: 0.9rem; }
.btn .spinner { border-color: rgba(255, 255, 255, 0.4); border-top-color: #fff; }
@keyframes mk-spin { to { transform: rotate(360deg); } }
.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 2.5rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}
.btn.is-loading { pointer-events: none; opacity: 0.85; }

/* Toast notifications */
.mk-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 150%);
  z-index: 300;
  max-width: min(92vw, 26rem);
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--color-text-primary);
  color: var(--color-bg);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-card-hover);
  transition: transform var(--duration-normal) var(--ease-spring), opacity var(--duration-fast);
  opacity: 0;
  pointer-events: none;
}
.mk-toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.mk-toast--error { background: #b91c1c; color: #fff; }

/* Wide form modals (records add/edit) */
.modal-card--form {
  max-width: 40rem;
  text-align: left;
  max-height: min(88dvh, 44rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-card--form .form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.modal-card--form .form-group { margin-bottom: 0; }
.modal-card--form .form-group--full { grid-column: 1 / -1; }
.modal-card--form textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font: inherit;
  font-size: 0.9375rem;
  resize: vertical;
}
.modal-card--form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}
@media (max-width: 560px) {
  .modal-card--form .form-grid { grid-template-columns: 1fr; }
}
.modal-card--form input[readonly] {
  opacity: 0.7;
  cursor: not-allowed;
}

/* List pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}
.pagination-info {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  min-width: 8rem;
  text-align: center;
}

/* Danger button + soft-delete surfaces */
.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 4px 18px rgba(220, 38, 38, 0.28);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.05); color: #fff; }
.btn-outline.btn-danger {
  background: var(--color-bg);
  color: #dc2626;
  border: 2px solid #dc2626;
  box-shadow: var(--shadow-card);
}

.filter-btn--deleted.active {
  background: #fef2f2;
  border-color: #dc2626;
  color: #b91c1c;
}
[data-theme='dark'] .filter-btn--deleted.active { background: #3a1414; color: #f87171; border-color: #f87171; }

.user-card--deleted { border-left: 3px solid #dc2626; }

/* Probe modal: a deleted user's related entities */
.probe-body { margin-bottom: 1rem; }
.probe-body .section-label { margin-top: 1rem; margin-bottom: 0.4rem; }
.probe-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
}
.probe-row span { font-size: 0.8125rem; color: var(--color-text-secondary); }
.probe-row .badge { align-self: flex-start; margin-top: 0.15rem; }

/* Profile danger zone (hard-to-reach self account deletion) */
.danger-zone {
  margin-top: 2.5rem;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-lg);
  background: #fef2f2;
}
[data-theme='dark'] .danger-zone { border-color: #7f1d1d; background: #2a1414; }
.danger-zone > summary {
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: #b91c1c;
  list-style: none;
}
[data-theme='dark'] .danger-zone > summary { color: #f87171; }
.danger-zone > summary::-webkit-details-marker { display: none; }
.danger-zone-body { padding: 0 1.25rem 1.25rem; }
.danger-zone-body p { font-size: 0.875rem; color: var(--color-text-secondary); margin-bottom: 0.75rem; }
.danger-zone-body input {
  margin-bottom: 0.75rem;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
