:root {
  --green: #1a7a4a;
  --green-light: #e8f5ee;
  --green-mid: #2d9e63;
  --amber: #e6920a;
  --red: #c0392b;
  --gray-100: #f7f8fa;
  --gray-200: #eaecef;
  --gray-500: #6b7280;
  --gray-900: #111827;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Top bar ── */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--green);
  text-decoration: none;
}

.topbar-logo svg { flex-shrink: 0; }

.pathway-switcher {
  display: flex;
  gap: 4px;
  margin-left: 24px;
}

.pathway-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}

.pathway-btn.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.pathway-btn:not(.active):hover {
  background: var(--green-light);
  color: var(--green);
  border-color: var(--green);
}

.topbar-spacer { flex: 1; }

.topbar-meta {
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

/* ── Sidebar ── */
.sidebar {
  background: #fff;
  border-right: 1px solid var(--gray-200);
  padding: 20px 16px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-500);
  margin-bottom: 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--gray-900);
  text-decoration: none;
  font-size: 13px;
  transition: background .12s;
}

.sidebar-link:hover { background: var(--gray-100); }
.sidebar-link.active { background: var(--green-light); color: var(--green); font-weight: 600; }

.filter-group {
  margin-bottom: 14px;
}

.filter-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  margin-bottom: 6px;
  display: block;
}

.filter-select, .filter-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  background: var(--gray-100);
  color: var(--gray-900);
}

.filter-select:focus, .filter-input:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
}

/* ── Main content ── */
.main {
  padding: 24px;
}

/* ── Hero stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 16px 20px;
}

.stat-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 4px;
  font-weight: 500;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--green);
  line-height: 1.1;
}

.stat-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ── Plantation table ── */
.table-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
}

.table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-title {
  font-size: 15px;
  font-weight: 600;
}

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

.btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover { background: var(--green-mid); }

.btn-outline {
  background: #fff;
  color: var(--green);
  border: 1px solid var(--green);
}

.btn-outline:hover { background: var(--green-light); }

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  border: 1px solid var(--gray-200);
}

.btn-ghost:hover { background: var(--gray-100); }

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

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-100);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ── Risk badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-low { background: #dcfce7; color: #15803d; }
.badge-medium { background: #fef9c3; color: #a16207; }
.badge-high { background: #fee2e2; color: #b91c1c; }
.badge-verified { background: var(--green-light); color: var(--green); }
.badge-pending { background: #f3f4f6; color: #6b7280; }

/* ── Detail view ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.detail-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 20px;
}

.detail-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

.detail-field {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px solid var(--gray-200);
  gap: 12px;
}

.detail-field:last-child { border-bottom: none; }

.detail-key {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
  flex-shrink: 0;
}

.detail-val {
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.hash-display {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--green);
  background: var(--green-light);
  padding: 8px 12px;
  border-radius: 6px;
  word-break: break-all;
  letter-spacing: .03em;
  margin-top: 8px;
}

/* ── Telemetry chart area ── */
.chart-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
}

.mini-bar {
  flex: 1;
  background: var(--green-light);
  border-radius: 3px 3px 0 0;
  position: relative;
  min-height: 4px;
  transition: background .15s;
}

.mini-bar:hover { background: var(--green); }

.mini-bar-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--gray-500);
  white-space: nowrap;
}

/* ── Chain of custody banner ── */
.coc-banner {
  background: linear-gradient(135deg, var(--green) 0%, #0d5c38 100%);
  color: #fff;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.coc-banner-text h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.coc-banner-text p {
  font-size: 13px;
  opacity: .85;
}

/* ── Lot table ── */
.lot-sensors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sensor-chip {
  background: var(--green-light);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: monospace;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
}

.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--gray-900); }

/* ── Footer ── */
.footer {
  padding: 16px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-200);
  margin-top: 32px;
}

.footer a { color: var(--green); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
