/**
 * 肥料养分智能配方计算器
 */
:root {
  --nf-green: #1a4d2e;
  --nf-green-mid: #2d7a4e;
  --nf-soft: #e8f4ec;
  --nf-cream: #fbf7ef;
  --nf-gold: #c9962a;
  --nf-border: #d4e8d8;
  --nf-muted: #5c6b62;
  --nf-danger: #a04000;
  --nf-radius: 14px;
  --nf-shadow: 0 4px 20px rgba(26, 77, 46, 0.08);
}

.nf-page {
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(180deg, #eef4f0 0%, #f5f7f5 50%, #fafcfa 100%);
  color: #1c1c1c;
  margin: 0;
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: 72px;
  overflow-x: hidden;
}

.nf-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  .nf-wrap {
    padding: 16px 12px 32px;
  }
  .nf-hero {
    margin-bottom: 12px;
  }
}
@media (max-width: 720px) {
  .nf-wrap {
    padding: 14px 12px 28px;
  }
  .nf-hero {
    padding: 16px 14px 16px;
  }
  .nf-hero p {
    font-size: 12.5px;
  }
  .nf-card {
    padding: 14px 12px 16px;
  }
  .nf-field label {
    font-size: 13px;
    margin-bottom: 6px;
  }
  .nf-field input,
  .nf-field select {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
  }
  .nf-field input:focus,
  .nf-field select:focus {
    box-shadow: 0 0 0 2px rgba(45, 122, 78, 0.25);
  }
}

.nf-hero {
  background: linear-gradient(135deg, var(--nf-green) 0%, #245c38 55%, var(--nf-green-mid) 100%);
  color: #fff;
  border-radius: var(--nf-radius);
  padding: 20px 20px 18px;
  margin-bottom: 16px;
  box-shadow: var(--nf-shadow);
}
.nf-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.1rem, 3.5vw, 1.55rem);
  font-weight: 800;
}
.nf-hero p {
  margin: 0;
  font-size: 13px;
  opacity: 0.92;
  line-height: 1.65;
  max-width: 900px;
}

.nf-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: stretch;
}
@media (max-width: 720px) {
  .nf-modes {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    gap: 8px;
    padding: 2px 0 12px;
    margin-bottom: 12px;
    scrollbar-width: thin;
  }
  .nf-mode-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    max-width: min(300px, 88vw);
    white-space: normal;
    text-align: left;
    line-height: 1.35;
    padding: 10px 14px;
  }
}
.nf-mode-btn {
  border: 1px solid var(--nf-border);
  background: #fff;
  color: var(--nf-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
  transition: 0.2s;
}
.nf-mode-btn:hover {
  border-color: var(--nf-green-mid);
  color: var(--nf-green);
}
.nf-mode-btn.active {
  background: var(--nf-green);
  color: #fff;
  border-color: var(--nf-green);
}

.nf-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 400px);
  gap: 18px;
  align-items: stretch;
}
.nf-col-left {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 100%;
}
@media (min-width: 961px) {
  .nf-grid > .nf-col-left {
    align-self: stretch;
    background: linear-gradient(180deg, #f9fcf9 0%, #eef4f0 100%);
    border: 1px solid var(--nf-border);
    border-radius: var(--nf-radius);
    padding: 12px 12px 14px;
    box-sizing: border-box;
  }
  .nf-grid > .nf-col-left > .nf-card {
    background: #fff;
  }
}
.nf-col-left > .nf-card {
  margin-bottom: 14px;
}
.nf-col-left .nf-actions {
  margin-top: 4px;
}
.nf-col-foot-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--nf-muted);
  line-height: 1.55;
  flex: 1;
  min-height: 0;
  padding-top: 8px;
  border-top: 1px dashed var(--nf-border);
}
@media (max-width: 960px) {
  .nf-page {
    min-height: 0;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }
  .nf-wrap {
    padding-bottom: 24px;
  }
  .nf-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .nf-col-left {
    min-height: 0;
  }
  .nf-col-foot-hint {
    flex: none;
    border-top: none;
    padding-top: 0;
  }
}

.nf-card {
  background: #fff;
  border: 1px solid var(--nf-border);
  border-radius: var(--nf-radius);
  padding: 16px 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--nf-shadow);
}
.nf-card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--nf-green);
  font-weight: 800;
}

.nf-field {
  margin-bottom: 12px;
}
.nf-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--nf-green);
  margin-bottom: 5px;
}
.nf-field .nf-sub {
  font-weight: 400;
  color: var(--nf-muted);
  font-size: 11px;
}
.nf-field input,
.nf-field select {
  width: 100%;
  padding: 11px 11px;
  border: 1px solid var(--nf-border);
  border-radius: 10px;
  font-size: 15px;
  box-sizing: border-box;
  min-height: 46px;
  background: #fafcfa;
}
.nf-field input:focus,
.nf-field select:focus {
  outline: none;
  border-color: var(--nf-green-mid);
  background: #fff;
}

.nf-grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 520px) {
  .nf-grid3 {
    grid-template-columns: 1fr;
  }
}

.nf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.nf-btn-primary {
  background: linear-gradient(135deg, var(--nf-green), var(--nf-green-mid));
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  min-height: 46px;
}
.nf-btn-ghost {
  background: #fff;
  border: 1px solid var(--nf-border);
  color: var(--nf-green);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.nf-btn-gold {
  background: linear-gradient(135deg, var(--nf-gold), #e8b84b);
  color: #1a1a1a;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}

.nf-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid var(--nf-border);
}
.nf-rows-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}
.nf-rows-table th {
  background: var(--nf-soft);
  color: var(--nf-green);
  padding: 10px 8px;
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}
.nf-rows-table td {
  padding: 8px 6px;
  border-top: 1px solid #eef2ee;
  vertical-align: middle;
}
.nf-rows-table input,
.nf-rows-table select {
  width: 100%;
  max-width: 120px;
  padding: 8px;
  border: 1px solid var(--nf-border);
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
  min-height: 40px;
}
.nf-rows-table .nf-name-input {
  max-width: 160px;
}
.nf-rows-table .nf-btn-del {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #e8c4c4;
  background: #fff8f8;
  color: #922;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.nf-results {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
}
.nf-results > .nf-card {
  margin-bottom: 0;
}
.nf-results .nf-script {
  flex: 1;
  min-height: 120px;
  max-height: none !important;
}
@media (max-width: 960px) {
  .nf-results .nf-script {
    min-height: 100px;
  }
}

.nf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 400px) {
  .nf-kpi-grid {
    grid-template-columns: 1fr;
  }
}
.nf-kpi {
  background: var(--nf-soft);
  border: 1px solid #cfe8d6;
  border-radius: 12px;
  padding: 11px;
}
.nf-kpi .t {
  font-size: 11px;
  color: var(--nf-muted);
  font-weight: 600;
}
.nf-kpi .v {
  font-size: 17px;
  font-weight: 800;
  color: var(--nf-green);
  margin-top: 4px;
}
.nf-kpi .st {
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
}
.nf-kpi .st.match {
  color: var(--nf-green-mid);
}
.nf-kpi .st.low {
  color: #2980b9;
}
.nf-kpi .st.high,
.nf-kpi .st.very_high {
  color: var(--nf-danger);
}

.nf-result-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  border-radius: 10px;
  border: 1px solid var(--nf-border);
}
.nf-result-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
}
.nf-result-table th,
.nf-result-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2ee;
  text-align: left;
}
.nf-result-table th {
  background: var(--nf-cream);
  color: #4a3d20;
  font-weight: 700;
}

.nf-risk {
  background: #fff9f0;
  border: 1px solid #f5d9b8;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: #6a4a20;
  margin-top: 10px;
}
.nf-risk ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.nf-script {
  margin-top: 10px;
  padding: 12px;
  background: var(--nf-cream);
  border: 1px solid #ead9b8;
  border-radius: 10px;
  font-size: 13px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.65;
}

.nf-hint {
  font-size: 12px;
  color: var(--nf-muted);
  margin-top: 6px;
}

.nf-alert {
  padding: 10px 12px;
  background: #fff5f0;
  border: 1px solid #f5cdb8;
  border-radius: 10px;
  color: var(--nf-danger);
  font-size: 13px;
  margin-bottom: 10px;
}

.nf-ref details {
  margin-top: 16px;
  border: 1px solid var(--nf-border);
  border-radius: var(--nf-radius);
  background: #fff;
  padding: 10px 14px;
}
.nf-ref summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--nf-green);
  font-size: 14px;
}
.nf-ref table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}
.nf-ref th,
.nf-ref td {
  border: 1px solid var(--nf-border);
  padding: 8px;
}
.nf-ref th {
  background: var(--nf-soft);
}
.nf-ref tbody tr {
  cursor: pointer;
}
.nf-ref tbody tr:hover {
  background: #f6faf7;
}

.nf-toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 77, 46, 0.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  max-width: 90vw;
}
.nf-toast.show {
  opacity: 1;
}

.nf-compound-panel {
  display: none;
}
.nf-compound-panel.active {
  display: block;
}

/* 平板与手机：肥料行、推荐配方表改为卡片式，避免多列表格缩成「电脑端缩小版」 */
@media (max-width: 900px) {
  .nf-rows-table {
    min-width: 0 !important;
  }
  .nf-table-wrap {
    overflow: visible;
    border: none;
    background: transparent;
  }
  .nf-rows-table thead {
    display: none;
  }
  .nf-rows-table tbody tr {
    display: block;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--nf-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--nf-shadow);
  }
  .nf-rows-table tbody td {
    display: block;
    width: 100% !important;
    max-width: none !important;
    border: none;
    padding: 8px 0;
    text-align: left;
  }
  .nf-rows-table tbody td[data-label]:not([data-label=''])::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--nf-green);
    margin-bottom: 4px;
    letter-spacing: 0.02em;
  }
  .nf-rows-table tbody td .nf-btn-del {
    width: 100%;
    min-height: 44px;
    margin-top: 4px;
  }
  .nf-rows-table input[type='checkbox'].nf-auto {
    width: 22px;
    height: 22px;
    min-height: 0 !important;
    accent-color: var(--nf-green-mid);
  }
  .nf-rows-table input,
  .nf-rows-table select {
    max-width: none !important;
    width: 100% !important;
    min-height: 46px;
    font-size: 16px;
  }

  .nf-result-table {
    min-width: 0 !important;
  }
  .nf-result-table-wrap {
    overflow: visible;
    border: none;
    background: transparent;
  }
  .nf-result-table thead {
    display: none;
  }
  .nf-result-table tbody tr {
    display: block;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--nf-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--nf-shadow);
  }
  .nf-result-table tbody td {
    display: block;
    width: 100% !important;
    border: none;
    padding: 6px 0;
    text-align: left;
    font-size: 14px;
  }
  .nf-result-table tbody td[data-label]:not([data-label=''])::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #4a3d20;
    margin-bottom: 4px;
  }
}
