:root {
  --ink: #18201d;
  --muted: #68756f;
  --line: #d9e1dc;
  --surface: #ffffff;
  --wash: #f4f7f3;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --leaf: #496b4d;
  --soft: #eef4ea;
  --gold: #b6813a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--wash);
}

a { color: var(--accent-dark); text-decoration: none; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 72px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  color: var(--ink);
}

.brand::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 47%, white 47%, white 53%, transparent 53%),
    linear-gradient(0deg, transparent 28%, white 28%, white 34%, transparent 34%),
    var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.45), 0 8px 18px rgba(15, 118, 110, 0.22);
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-weight: 700;
}

nav form { margin: 0; }

.link-button {
  border: 0;
  padding: 0;
  color: var(--accent-dark);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.hero {
  padding: 52px 0 36px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 38px;
  align-items: center;
  min-height: 560px;
  padding: 62px 0 44px;
}

.hero-copy {
  max-width: 770px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #cdd9c8;
  border-radius: 999px;
  color: var(--leaf);
  background: #ffffffb8;
  font-size: 0.9rem;
  font-weight: 850;
}

h1 {
  margin: 18px 0 14px;
  max-width: 860px;
  font-size: clamp(2.5rem, 5vw, 5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
  letter-spacing: 0;
}

p { color: var(--muted); line-height: 1.6; }

.hero-copy p {
  max-width: 680px;
  font-size: 1.15rem;
}

.searchbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  max-width: 820px;
  margin-top: 24px;
}

.hero-search {
  max-width: 780px;
  padding: 8px;
  border: 1px solid #d4ded7;
  border-radius: 14px;
  background: rgba(255,255,255,0.86);
  box-shadow: 0 18px 45px rgba(31, 41, 55, 0.1);
}

.hero-search input {
  min-height: 56px;
  border: 0;
  border-radius: 10px;
  font-size: 1.05rem;
}

.hero-search button {
  min-height: 56px;
  padding: 0 24px;
}

.suggest-wrap {
  position: relative;
}

.suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.14);
}

.suggestions a {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.suggestions a:last-child { border-bottom: 0; }
.suggestions a:hover { background: #f0fdfa; }

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.quick-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d5dfd8;
  border-radius: 999px;
  color: var(--leaf);
  background: rgba(255,255,255,0.74);
  font-weight: 750;
}

.hero-panel {
  overflow: hidden;
  border: 1px solid #d6dfd7;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(31, 41, 55, 0.15);
}

.hero-panel-image {
  min-height: 265px;
  background:
    linear-gradient(rgba(18, 32, 29, 0.08), rgba(18, 32, 29, 0.18)),
    url("https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=900&q=80");
  background-position: center;
  background-size: cover;
}

.hero-panel-content {
  padding: 22px;
}

.hero-panel-content strong {
  display: block;
  font-size: 1.22rem;
}

.hero-panel-content p {
  margin-bottom: 18px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.mini-stats span {
  display: grid;
  gap: 2px;
  padding: 13px;
  border-radius: 8px;
  background: var(--soft);
}

.mini-stats b {
  font-size: 1.35rem;
}

input, textarea, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: white;
}

textarea { resize: vertical; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  color: white;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.2);
}

button:hover, .button:hover { background: var(--accent-dark); }
.secondary { background: #374151; }
.secondary:hover { background: #1f2937; }

.messages {
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 8px 14px;
  background: #eff6ff;
}

.messages p { margin: 5px 0; color: #1e3a8a; }

.pagehead { margin-bottom: 24px; }

.cemetery-pagehead {
  display: grid;
  gap: 18px;
  padding: 26px 0 18px;
}

.back-link {
  width: fit-content;
  font-weight: 750;
}

.cemetery-pagehead h1 {
  max-width: 820px;
  margin-top: 12px;
  font-size: clamp(2.2rem, 4vw, 4rem);
}

.cemetery-pagehead p {
  margin-top: 0;
  font-size: 1.05rem;
}

.cemetery-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 22px;
  align-items: start;
  margin-bottom: 28px;
}

.cemetery-summary article {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.84);
}

.compact-facts {
  margin: 0;
}

.cemetery-profile {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 24px;
  align-items: start;
  margin: 0 0 28px;
}

.cemetery-profile figure,
.cemetery-hero {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.cemetery-profile img,
.cemetery-hero img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.cemetery-profile figcaption {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.cemetery-profile article {
  min-width: 0;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 18px 0 0;
}

.facts div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.facts dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.facts dd {
  margin: 4px 0 0;
  font-weight: 750;
}

.compact-preview {
  display: grid;
}

.compact-preview div {
  padding: 14px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.gallery figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.gallery figcaption {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.admin-gallery form {
  padding: 0 10px 10px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 22px 0;
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 30px 0;
}

.value-card {
  min-height: 210px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.82);
  box-shadow: 0 18px 42px rgba(31, 41, 55, 0.07);
}

.value-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  border-radius: 50%;
  color: white;
  background: var(--leaf);
  font-weight: 850;
}

.panel, .card, .row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel { padding: 22px; }
.narrow { max-width: 620px; margin: 0 auto; }

.list {
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 15px;
  color: var(--ink);
}

.row span {
  display: grid;
  gap: 4px;
}

small, em {
  color: var(--muted);
  font-style: normal;
}

.compact .row { padding: 10px 12px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.selectable {
  cursor: pointer;
}

.logo {
  max-width: 150px;
  max-height: 72px;
  object-fit: contain;
}

.profile-logo {
  display: block;
  max-width: 180px;
  max-height: 90px;
  object-fit: contain;
  margin-bottom: 14px;
}

.service-list {
  display: grid;
  gap: 8px;
}

.service-list div {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: center;
}

.service-list img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
}

.service-admin-list {
  display: grid;
  gap: 14px;
}

.service-edit {
  align-content: start;
}

.service-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.service-edit-head img {
  width: 80px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
}

.quote-layout {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 24px;
  align-items: start;
}

.marketplace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.marketplace-flow {
  display: block;
}

.marketplace-main {
  min-width: 0;
}

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 20px;
}

.section-head p {
  margin: 0;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #cfdad2;
  border-radius: 999px;
  color: var(--leaf);
  background: rgba(255,255,255,0.8);
  font-weight: 800;
  white-space: nowrap;
}

.service-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.service-tab {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #cfdad2;
  color: var(--leaf);
  background: rgba(255,255,255,0.88);
  box-shadow: none;
}

.service-tab span {
  min-width: 0;
  text-align: left;
  line-height: 1.08;
}

.service-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--soft);
  font-size: 0.85rem;
  font-weight: 900;
}

.service-tab:hover {
  color: white;
}

.service-tab.active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.service-tab.active .service-count,
.service-tab:hover .service-count {
  color: var(--accent-dark);
  background: white;
}

.service-tab:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.provider-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.provider-offer[hidden],
.offer-service[hidden],
#empty-service[hidden] {
  display: none !important;
}

.provider-offer {
  display: grid;
  grid-template-rows: 128px minmax(154px, 1fr) 42px;
  gap: 18px;
  min-height: 360px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 36px rgba(31, 41, 55, 0.07);
}

.provider-offer > input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.provider-offer.is-selected {
  border-color: #74aaa2;
  box-shadow: 0 18px 40px rgba(15, 118, 110, 0.13);
}

.provider-offer-top {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 16px;
  align-items: start;
  min-height: 128px;
}

.provider-offer-top strong {
  display: block;
  min-height: 46px;
  font-size: 1.05rem;
  line-height: 1.18;
}

.provider-offer-top p {
  display: -webkit-box;
  min-height: 62px;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.32;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.offer-logo {
  width: 86px;
  height: 66px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.offer-logo.fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: var(--leaf);
  font-size: 1.45rem;
  font-weight: 850;
}

.offer-services {
  display: grid;
  gap: 10px;
  align-self: stretch;
}

.offer-service {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 9px;
  min-height: 154px;
  padding: 16px;
  border-radius: 8px;
  background: var(--soft);
}

.offer-service span {
  font-weight: 800;
  line-height: 1.1;
}

.offer-service b {
  color: var(--accent-dark);
  font-size: 1.16rem;
  line-height: 1.05;
}

.offer-service small {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.35;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.offer-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: stretch;
  min-height: 42px;
  padding-top: 0;
}

.select-provider {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid #cfdad2;
  border-radius: 999px;
  background: #fff;
  color: var(--leaf);
  font-weight: 850;
  cursor: pointer;
}

.select-provider input {
  width: 18px;
  min-height: 18px;
}

.provider-offer.is-selected .select-provider {
  border-color: #74aaa2;
  background: #edf7f3;
  color: var(--accent-dark);
}

.small-button {
  min-height: 38px;
  padding: 0 14px;
}

.action-spacer {
  visibility: hidden;
}

.quote-cta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid #c8d7cf;
  border-radius: 8px;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 18px 42px rgba(31, 41, 55, 0.13);
  backdrop-filter: blur(12px);
}

.quote-cta strong {
  display: block;
  color: var(--accent-dark);
  font-size: 1.08rem;
}

.quote-cta p {
  margin: 3px 0 0;
}

.app-modal {
  width: min(620px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

.app-modal::backdrop {
  background: rgba(24, 32, 29, 0.46);
  backdrop-filter: blur(5px);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 13px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(24, 32, 29, 0.24);
}

.modal-card h2,
.modal-card p {
  margin-bottom: 0;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  color: var(--muted);
  background: var(--soft);
}

.provider-modal-card {
  gap: 14px;
}

.provider-modal-image {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
}

.provider-modal-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.provider-modal-facts div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.provider-modal-facts dt {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.provider-modal-facts dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.lead-box {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(31, 41, 55, 0.08);
}

.lead-box h2,
.lead-box p {
  margin-bottom: 0;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-weight: 500;
  color: var(--muted);
}

.check input {
  width: auto;
  min-height: auto;
  margin-top: 4px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.lead {
  align-items: flex-start;
}

.inline-form {
  display: grid;
  grid-template-columns: 140px 100px auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 820px) {
  .topbar, nav { align-items: flex-start; flex-direction: column; padding: 14px 20px; }
  .searchbar, .split, .quote-layout, .cemetery-profile, .home-hero, .value-grid, .marketplace-layout, .cemetery-summary { grid-template-columns: 1fr; }
  .home-hero { min-height: auto; padding-top: 36px; }
  .hero-panel { order: -1; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .lead-box { position: static; }
  .quote-cta { align-items: stretch; flex-direction: column; }
  .provider-offer-top { grid-template-columns: 70px 1fr; }
  .offer-logo { width: 70px; height: 54px; }
  .inline-form { grid-template-columns: 1fr; width: 100%; }
  .offer-actions { align-items: stretch; flex-direction: column; }
  .select-provider, .small-button { width: 100%; justify-content: center; }
  .provider-modal-facts { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .service-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .provider-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .service-tabs,
  .provider-results {
    grid-template-columns: 1fr;
  }

  .provider-offer {
    grid-template-rows: auto auto auto;
    min-height: 0;
  }

  .provider-offer-top,
  .provider-offer-top strong,
  .provider-offer-top p,
  .offer-service {
    min-height: 0;
  }
}
