:root {
  --bg-deep: #4a2f22;
  --bg-mid: #7b5236;
  --bg-soft: #f5eee4;
  --surface: rgba(255, 252, 245, 0.82);
  --surface-strong: #fffdf7;
  --surface-muted: rgba(255, 249, 238, 0.55);
  --border: rgba(108, 72, 49, 0.16);
  --text: #38271d;
  --text-soft: #7b6555;
  --primary: #7d5638;
  --primary-dark: #5f3e27;
  --accent: #bf8a4d;
  --accent-soft: #ead2b2;
  --chart-1: #7d5638;
  --chart-2: #a87045;
  --chart-3: #c99558;
  --chart-4: #8e6b4b;
  --chart-5: #b68562;
  --chart-6: #6f4a32;
  --shadow: 0 24px 60px rgba(71, 45, 27, 0.14);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(234, 210, 178, 0.45), transparent 32%),
    radial-gradient(circle at top right, rgba(191, 138, 77, 0.14), transparent 22%),
    linear-gradient(180deg, #fbf5ee 0%, #f4eadf 48%, #efe5da 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.18), transparent 35%),
    repeating-linear-gradient(
      135deg,
      rgba(125, 86, 56, 0.018) 0,
      rgba(125, 86, 56, 0.018) 2px,
      transparent 2px,
      transparent 14px
    );
  z-index: -1;
}

body.ai-panel-open .page-shell {
  width: min(1200px, calc(100% - 470px));
  margin-left: 16px;
  margin-right: auto;
}

nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 32px;
  background: rgba(74, 47, 34, 0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #f9f3e7;
}

.nav-brand strong {
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-brand span {
  color: rgba(249, 243, 231, 0.72);
  font-size: 0.86rem;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

nav a {
  color: rgba(255, 251, 243, 0.85);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

nav a:hover,
nav a.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  transform: translateY(-1px);
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.8fr);
  gap: 22px;
  padding: 34px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--bg-deep), var(--bg-mid));
  border-radius: 32px;
  box-shadow: var(--shadow);
  color: #f7f3e8;
}

.hero::after {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -100px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(231, 199, 147, 0.3), transparent 68%);
}

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #f8e7c8;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 700;
}

.hero h1,
.hero h2 {
  margin: 16px 0 12px;
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 1.08;
  color: #fffdf6;
}

.hero p {
  max-width: 620px;
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
  color: rgba(247, 243, 232, 0.82);
}

.hero-side {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  align-content: end;
}

.hero-side-card {
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-side-card span {
  display: block;
  color: rgba(247, 243, 232, 0.7);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.hero-side-card strong {
  font-size: 1.45rem;
  color: #ffffff;
}

.hero-side-card p {
  margin-top: 8px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.stats-grid,
.charts-grid,
.analysis-grid,
.content-grid {
  display: grid;
  gap: 20px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
}

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

.analysis-grid {
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.35fr);
  margin-bottom: 24px;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.card.compact {
  padding: 20px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.section-heading h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text);
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.metric-card {
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.95), rgba(245, 240, 227, 0.88));
}

.metric-label {
  color: var(--text-soft);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.metric-value {
  font-size: clamp(1.8rem, 2.2vw, 2.4rem);
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 10px;
}

.metric-footnote {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.93rem;
  line-height: 1.5;
}

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

.field-group {
  display: grid;
  gap: 8px;
}

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

.lab,
.field-group label {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}

select,
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(125, 86, 56, 0.16);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus,
input[type="text"]:focus {
  border-color: rgba(125, 86, 56, 0.5);
  box-shadow: 0 0 0 4px rgba(125, 86, 56, 0.08);
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 12px 22px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fffdf7;
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 14px 28px rgba(95, 62, 39, 0.22);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(95, 62, 39, 0.28);
}

.checkbox-container {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(125, 86, 56, 0.12);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(125, 86, 56, 0.08);
}

.checkbox-item input {
  accent-color: var(--primary);
}

.hint-list,
.summary-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hint-list li,
.summary-list li {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--text-soft);
  line-height: 1.5;
}

.summary-list strong {
  display: block;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.chart-card canvas {
  width: 100% !important;
  height: 340px !important;
}

.chart-card.compact-chart canvas {
  height: 300px !important;
}

.table-card {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(125, 86, 56, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  color: var(--text);
  border-bottom: 1px solid rgba(125, 86, 56, 0.08);
}

th {
  background: rgba(125, 86, 56, 0.1);
  color: var(--primary-dark);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.32);
}

.table-empty {
  padding: 26px;
  text-align: center;
  color: var(--text-soft);
}

.team-container {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}

.team-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 20px;
  text-align: center;
  backdrop-filter: blur(15px);
  transition: 0.3s;
}

.team-card:hover {
  transform: scale(1.03);
}

.image,
.image-placeholder {
  width: 110px;
  height: 110px;
  border-radius: 50%;
}

.image {
  object-fit: cover;
}

.image-placeholder {
  background: rgba(255, 255, 255, 0.2);
  margin: 0 auto 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(95, 62, 39, 0.24);
  border-radius: 999px;
}

#agro-ai-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #9d6b46);
  color: #ffffff;
  border: 3px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 20px 35px rgba(95, 62, 39, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 9999;
  transition: transform 0.2s ease;
}

#agro-ai-btn:hover {
  transform: translateY(-3px);
}

#agro-chat {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(430px, 100vw);
  display: flex;
  flex-direction: column;
  border-radius: 0;
  overflow: hidden;
  background: rgba(255, 253, 247, 0.97);
  border-left: 1px solid rgba(125, 86, 56, 0.14);
  box-shadow: -18px 0 42px rgba(71, 45, 27, 0.12);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.28s ease;
}

body.ai-panel-open #agro-chat {
  transform: translateX(0);
}

.hidden {
  display: flex;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 700;
}

.chat-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-title small {
  color: rgba(255, 247, 237, 0.78);
  font-weight: 500;
}

.chat-close {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 1.2rem;
  cursor: pointer;
}

#chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  color: var(--text);
  display: block;
}

.user-msg p,
.bot-msg p {
  margin: 0;
  line-height: 1.55;
}

.user-msg,
.bot-msg {
  margin-bottom: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  overflow: hidden;
}

.user-msg {
  background: rgba(191, 138, 77, 0.14);
}

.bot-msg {
  background: rgba(125, 86, 56, 0.09);
}

.chat-visual {
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(125, 86, 56, 0.1);
  overflow: hidden;
}

#chat-messages canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: 220px !important;
}

#chat-messages table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#chat-messages th,
#chat-messages td {
  padding: 8px;
  font-size: 0.8rem;
  text-align: left;
  word-break: break-word;
}

#chat-messages th {
  background: rgba(125, 86, 56, 0.12);
}

#chat-input {
  border: none;
  border-top: 1px solid rgba(125, 86, 56, 0.12);
  border-radius: 0;
  padding: 16px 18px;
  background: #fffdf8;
}

@media (max-width: 1024px) {
  .hero,
  .analysis-grid,
  .charts-grid,
  .content-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .checkbox-container,
  .filter-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body.ai-panel-open .page-shell {
    width: min(100% - 20px, 1200px);
    margin-left: auto;
  }

  nav {
    padding: 16px 18px;
    align-items: flex-start;
    flex-direction: column;
  }

  .page-shell {
    width: min(100% - 20px, 1200px);
    margin-top: 18px;
  }

  .hero,
  .card {
    padding: 20px;
    border-radius: 24px;
  }

  .hero h1,
  .hero h2 {
    font-size: 1.8rem;
  }

  .chart-card canvas,
  .chart-card.compact-chart canvas {
    height: 280px !important;
  }

  #agro-chat {
    width: 100vw;
  }

  #agro-ai-btn {
    right: 14px;
    bottom: 14px;
  }
}
