:root {
  --bg: #f6f7fb;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --ink: #15171a;
  --muted: #68707d;
  --line: rgba(26, 31, 38, 0.1);
  --green: #1f8a5b;
  --green-dark: #12633f;
  --blue: #2b7bbb;
  --amber: #d99a22;
  --coral: #df684b;
  --chip: #eef3f8;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow-soft: 0 18px 50px rgba(24, 32, 46, 0.11);
  --shadow-card: 0 10px 24px rgba(24, 32, 46, 0.08);
  color: var(--ink);
  background: linear-gradient(180deg, #f9fbff 0%, #f2f5f0 52%, #f7f4ee 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.app-shell {
  margin: 0 auto;
  max-width: 1460px;
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 10px 32px rgba(24, 32, 46, 0.08);
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 10px 12px 10px 10px;
}

.brand {
  align-items: center;
  display: inline-flex;
  font-weight: 850;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--green), var(--blue));
  border-radius: 999px;
  color: white;
  display: inline-flex;
  font-size: 0.78rem;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.nav-actions {
  display: flex;
  gap: 8px;
}

.nav-button,
.back-button {
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  color: white;
  cursor: pointer;
  font-weight: 820;
  min-height: 40px;
  padding: 0 18px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.nav-button:hover,
.back-button:hover {
  box-shadow: 0 12px 24px rgba(24, 32, 46, 0.16);
  transform: translateY(-1px);
}

.notice {
  background: #fff8df;
  border: 1px solid rgba(217, 154, 34, 0.36);
  border-radius: var(--radius-md);
  color: #765416;
  margin: 18px 0;
  padding: 13px 16px;
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.section-header h2,
.detail-title h2 {
  letter-spacing: 0;
  margin: 0;
}

.farms-page {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  margin-top: 18px;
  padding: 22px;
}

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

.section-header .eyebrow,
.detail-title .eyebrow {
  color: var(--green);
}

.section-header h2 {
  font-size: clamp(1.9rem, 3vw, 3.1rem);
  line-height: 1;
}

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

.search-box {
  align-items: center;
  background: var(--surface-solid);
  border: 1px solid rgba(26, 31, 38, 0.12);
  border-radius: 999px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 48px;
  padding: 0 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-box:focus-within {
  border-color: rgba(31, 138, 91, 0.5);
  box-shadow: 0 0 0 4px rgba(31, 138, 91, 0.12);
}

.search-box > span:first-child {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.search-box input {
  background: transparent;
  border: 0;
  min-width: 0;
  outline: none;
  width: 100%;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-tabs button {
  background: #eef3f8;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 750;
  min-height: 36px;
  padding: 7px 13px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.category-tabs button:hover {
  background: #e4edf4;
  transform: translateY(-1px);
}

.category-tabs .is-active {
  background: var(--ink);
  color: white;
}

.farm-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.farm-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: grid;
  min-height: 430px;
  overflow: hidden;
  padding: 0;
  text-align: left;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.farm-card:hover {
  border-color: rgba(31, 138, 91, 0.3);
  box-shadow: 0 18px 38px rgba(24, 32, 46, 0.13);
  transform: translateY(-3px);
}

.farm-preview {
  align-items: end;
  background:
    linear-gradient(135deg, rgba(21, 23, 26, 0.12), rgba(31, 138, 91, 0.16)),
    radial-gradient(circle at 24% 28%, rgba(255, 255, 255, 0.85) 0 12%, transparent 13%),
    linear-gradient(135deg, #dcefe4, #dfeafa 52%, #f7e6c4);
  display: flex;
  min-height: 155px;
  padding: 18px;
}

.preview-category {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 850;
  padding: 8px 12px;
  text-transform: uppercase;
}

.farm-card-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.farm-card-title {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.farm-card-title strong {
  font-size: 1.2rem;
  line-height: 1.18;
}

.farm-card-title small {
  background: var(--chip);
  border-radius: 999px;
  color: #465362;
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 850;
  padding: 6px 9px;
}

.farm-card-description {
  color: var(--muted);
  display: -webkit-box;
  line-height: 1.48;
  min-height: 66px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.farm-card-stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.farm-card-stats > span {
  background: #f6f8fb;
  border-radius: 16px;
  min-height: 74px;
  padding: 11px;
}

.farm-card-stats strong,
.farm-card-stats small {
  display: block;
}

.farm-card-stats strong {
  font-size: 1rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.farm-card-stats small {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 6px;
}

.farm-tags,
.tag-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.farm-tags span,
.tag {
  background: var(--chip);
  border-radius: 999px;
  color: #465362;
  font-size: 0.68rem;
  font-weight: 820;
  padding: 5px 9px;
  text-transform: uppercase;
}

.empty-state {
  color: var(--muted);
  grid-column: 1 / -1;
  padding: 18px;
}

.detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  margin-top: 20px;
  min-width: 0;
  overflow: hidden;
  padding: 16px;
}

.back-button {
  margin-bottom: 14px;
}

.detail-hero {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(238, 247, 243, 0.92)),
    linear-gradient(90deg, rgba(43, 123, 187, 0.09), rgba(217, 154, 34, 0.12));
  border: 1px solid var(--line);
  border-radius: 24px;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 28px;
}

.detail-title h2 {
  color: var(--ink);
  font-size: clamp(2.1rem, 4vw, 4.4rem);
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.detail-title p:not(.eyebrow) {
  color: #4d5662;
  line-height: 1.62;
  margin: 14px 0 0;
  max-width: 780px;
}

.detail-actions {
  align-content: start;
  display: grid;
  gap: 10px;
  min-width: 190px;
}

.download-button,
.video-link {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  font-weight: 850;
  gap: 8px;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  text-decoration: none;
  transition: box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.download-button {
  background: var(--green);
  box-shadow: 0 12px 22px rgba(31, 138, 91, 0.25);
  color: white;
}

.download-button:hover,
.video-link:hover {
  transform: translateY(-1px);
}

.video-link {
  background: white;
  border-color: rgba(43, 123, 187, 0.2);
  color: var(--blue);
}

.tag-strip {
  margin-top: 18px;
}

.stat-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 20px 0;
}

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

.stat-card {
  border-radius: var(--radius-lg);
  min-height: 142px;
  padding: 18px;
  position: relative;
}

.stat-card::before {
  background: var(--green);
  border-radius: 999px;
  content: "";
  height: 5px;
  left: 18px;
  position: absolute;
  right: 18px;
  top: 0;
}

.stat-card:nth-child(2)::before {
  background: var(--coral);
}

.stat-card:nth-child(3)::before {
  background: var(--blue);
}

.stat-card:nth-child(4)::before {
  background: var(--amber);
}

.stat-icon {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.stat-card p {
  color: var(--muted);
  margin: 22px 0 8px;
}

.stat-card strong {
  display: block;
  font-size: 1.9rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.stat-card span {
  color: var(--muted);
  display: block;
  font-size: 0.84rem;
  margin-top: 9px;
}

.content-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
}

.video-panel {
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(21, 23, 26, 0.94), rgba(18, 99, 63, 0.86)),
    #11130f;
  border-radius: var(--radius-lg);
  min-height: 300px;
  overflow: hidden;
}

.video-panel iframe {
  border: 0;
  height: 100%;
  width: 100%;
}

.missing-video {
  align-items: center;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  justify-content: center;
}

.missing-video strong {
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  padding: 12px 18px;
}

.info-stack {
  display: grid;
  gap: 20px;
}

.info-panel {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.info-panel h3 {
  color: #2b3139;
  font-size: 0.92rem;
  letter-spacing: 0;
  margin: 0 0 14px;
  text-transform: uppercase;
}

.material-list {
  display: grid;
  gap: 9px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.material-list li,
.extra-stats div {
  align-items: center;
  background: #f6f8fb;
  border-radius: 14px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 42px;
  padding: 10px 12px;
}

.material-list span,
.extra-stats dt {
  color: #515b66;
}

.material-list strong,
.extra-stats dd {
  font-weight: 850;
  margin: 0;
  text-align: right;
}

.extra-stats {
  display: grid;
  gap: 9px;
  margin: 0;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.detail-footer {
  background: rgba(246, 248, 251, 0.9);
  border-radius: var(--radius-lg);
  color: #4f5965;
  margin-top: 20px;
  padding: 18px 22px;
}

.detail-footer div {
  line-height: 1.45;
}

.schematic-name {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 6px 8px 0;
  overflow-wrap: anywhere;
  text-align: center;
}

.sr-only {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

@media (max-width: 1120px) {
  .section-header,
  .detail-hero,
  .content-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    border-radius: 22px;
  }

  .farm-grid,
  .farm-card-stats,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .farms-page,
  .detail {
    padding: 14px;
  }

  .detail-actions {
    min-width: 0;
  }
}
