:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.7;
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.container,
.wrapper,
main {
  width: min(1400px, calc(100% - 24px));
  margin-inline: auto;
}

header,
.hero,
.page-header {
  margin: 18px auto 12px;
  width: min(1400px, calc(100% - 24px));
  background: linear-gradient(135deg, #eff6ff, #ffffff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

h1,
h2,
h3 {
  margin-top: 0;
  line-height: 1.35;
}

.panel,
.card,
section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

section.panel {
  padding: 18px;
  margin: 14px auto;
  width: min(1400px, calc(100% - 24px));
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px 16px;
  margin-top: 14px;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

input,
select,
button,
textarea {
  font: inherit;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.checkbox-grid label,
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

.checkbox-grid input[type="checkbox"],
.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.primary-btn,
button[type="submit"] {
  border: none;
  background: var(--primary);
  color: #fff;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.2s ease;
  margin-top: 16px;
}

.primary-btn:hover,
button[type="submit"]:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.mobile-hint {
  color: var(--muted);
  font-size: 0.94rem;
  margin-top: 10px;
}

#planContainer {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: #fff;
  padding: 10px;
  min-height: 280px;
}

.plan-placeholder {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.plan-svg-wrap {
  width: 100%;
  min-width: 780px;
}

.farm-plan-svg {
  width: 100%;
  height: auto;
  display: block;
}

.plan-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--danger);
  padding: 16px;
  border-radius: 14px;
}

.table-wrap,
.results-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

table th,
table td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: center;
}

.results-grid,
.stats-grid,
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.metric-card,
.stat-card,
.result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.metric-card strong,
.stat-card strong,
.result-card strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 6px;
}

#planningNotes ul {
  margin: 0;
  padding-right: 18px;
}

@media (max-width: 1100px) {
  .form-grid,
  .checkbox-grid,
  .results-grid,
  .stats-grid,
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  section.panel,
  header,
  .hero,
  .page-header {
    padding: 14px;
    border-radius: 14px;
  }

  .form-grid,
  .checkbox-grid,
  .results-grid,
  .stats-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  #planContainer {
    padding: 8px;
    min-height: 220px;
  }

  .plan-svg-wrap {
    min-width: 680px;
  }

  table {
    min-width: 640px;
  }

  .mobile-hint {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .container,
  .wrapper,
  main,
  section.panel,
  header,
  .hero,
  .page-header {
    width: min(100% - 14px, 100%);
  }

  .primary-btn,
  button[type="submit"] {
    width: 100%;
  }

  .plan-svg-wrap {
    min-width: 620px;
  }
}
