* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--agric-font, Inter, sans-serif);
  background: #f4f7f4;
  color: #1f2a1f;
}
a { color: var(--agric-primary, #2e7d32); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; background: #fff; border-bottom: 1px solid #e4e9e3;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand a { color: #1f2a1f; }
.brand-logo { height: 28px; }
.topnav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.role-badge {
  background: var(--agric-secondary, #8bc34a); color: #1f2a1f;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}

.content { max-width: 960px; margin: 0 auto; padding: 32px 20px; }
.footer { text-align: center; padding: 20px; color: #7a8a7a; font-size: 12px; }

.app-shell { display: flex; align-items: flex-start; max-width: 1180px; margin: 0 auto; }
.sidebar {
  width: 200px; flex-shrink: 0; background: #fff; border-right: 1px solid #e4e9e3;
  min-height: calc(100vh - 60px); padding: 20px 0;
}
.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: #3a453a; font-size: 14px; font-weight: 500;
}
.sidebar nav a:hover { background: #f4f7f4; text-decoration: none; }
.sidebar nav a.active { background: #eef5ee; color: var(--agric-primary, #2e7d32); border-right: 3px solid var(--agric-primary, #2e7d32); }
.sidebar .icon { font-size: 16px; }
.app-shell .content { flex: 1; max-width: none; }

.card {
  background: #fff; border-radius: 10px; padding: 24px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06); margin-bottom: 20px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #d3dbd2; border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
button, .btn {
  background: var(--agric-primary, #2e7d32); color: #fff; border: 0;
  padding: 10px 16px; border-radius: 6px; font-size: 14px; cursor: pointer;
}
button.secondary, .btn.secondary { background: #eef2ee; color: #1f2a1f; }
.error { background: #fdecea; color: #b3261e; padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.success { background: #e8f5e9; color: #256029; padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eef1ee; }

/* AI provider admin */
.muted { color: #66766a; }
.small { font-size: 12px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: #eef2ee;
  border-radius: 999px; padding: 4px 12px; font-size: 13px;
}
.chip-num {
  background: var(--agric-primary, #2e7d32); color: #fff; border-radius: 999px;
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: #e8f5e9; color: #256029; }
.badge-warn { background: #fff8e1; color: #8a6d00; }
.badge-danger { background: #fdecea; color: #b3261e; }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { background: #fdecea; color: #b3261e; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.checkbox-row input { width: auto; }
details.edit-row { margin-top: 4px; }
details.edit-row summary { cursor: pointer; color: var(--agric-primary, #2e7d32); font-size: 12px; }
details.edit-row .card-inline {
  background: #f9faf9; border: 1px solid #eef1ee; border-radius: 8px; padding: 12px; margin-top: 8px; min-width: 260px;
}

/* AI chat */
.chat-window { display: flex; flex-direction: column; gap: 12px; min-height: 320px; margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: 10px; max-width: 75%; font-size: 14px; line-height: 1.4; }
.msg.user { align-self: flex-end; background: var(--agric-primary, #2e7d32); color: #fff; }
.msg.assistant { align-self: flex-start; background: #eef2ee; color: #1f2a1f; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }
.teach-btn { background: none; border: none; color: #7a8a7a; font-size: 12px; cursor: pointer; padding: 2px 0; }
