:root {
  --bg: #0f172a;
  --panel: #0b1226;
  --accent: #46c37b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #1e293b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
}

p {
  margin: 0 0 12px;
}

a {
  color: inherit;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(11, 18, 38, 0.98));
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 12px 0 24px rgba(0, 0, 0, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(70, 195, 123, 0.15);
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sidebar nav {
  display: grid;
  gap: 10px;
}

.sidebar a {
  text-decoration: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  transition: border 120ms ease, transform 120ms ease, background 120ms ease;
}

.sidebar a:hover {
  border-color: var(--border);
  transform: translateX(2px);
}

.sidebar a.active {
  background: rgba(70, 195, 123, 0.12);
  border-color: rgba(70, 195, 123, 0.4);
  color: #e9fff2;
}

.content {
  padding: 32px;
  background: radial-gradient(circle at 10% 20%, #122045 0, transparent 25%),
      radial-gradient(circle at 90% 10%, #15305a 0, transparent 30%),
      radial-gradient(circle at 50% 80%, #142347 0, transparent 30%),
      var(--bg);
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  align-items: center;
  margin-bottom: 28px;
}

.hero h1 {
  font-size: 36px;
  margin-bottom: 12px;
}

.hero .lede {
  color: var(--muted);
  max-width: 720px;
  line-height: 1.6;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.kpi {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.kpi .value {
  font-size: 24px;
  font-weight: 700;
}

.card {
  background: rgba(10, 15, 30, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-subsection {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.table-subsection {
  height: 100%;
}

.card.warning {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 20px;
}

.card.info {
  background: linear-gradient(145deg, rgba(70, 195, 123, 0.12), rgba(255, 255, 255, 0.04));
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.field-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.map-panel {
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  color: var(--muted);
  gap: 6px;
}

input,
select,
textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

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

button {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

button.primary {
  background: linear-gradient(135deg, #3cbc78, #2da25f);
  color: #04100a;
  box-shadow: 0 10px 20px rgba(70, 195, 123, 0.3);
}

button.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  grid-column: 1 / -1;
}

.table-wrapper {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 100%;
  color: var(--text);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: rgba(10, 15, 30, 0.96);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.footer {
  margin-top: 24px;
  color: var(--muted);
  text-align: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-size: 12px;
  margin-bottom: 4px;
}

.muted {
  color: var(--muted);
}

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

.row-clickable {
  cursor: pointer;
}

th[data-sort-key] {
  cursor: pointer;
}

th[data-sort-key]::after {
  content: "⇅";
  font-size: 12px;
  margin-left: 6px;
  color: var(--muted);
}

th[data-sort-direction="asc"]::after {
  content: "▲";
  color: var(--accent);
}

th[data-sort-direction="desc"]::after {
  content: "▼";
  color: var(--accent);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: capitalize;
}

.status-badge::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-prepping {
  color: #b45309;
  background: rgba(180, 83, 9, 0.12);
  border: 1px solid rgba(180, 83, 9, 0.28);
}

.status-planted {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.status-harvested {
  color: #f97316;
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.28);
}

.status-default {
  color: #e2e8f0;
  background: rgba(226, 232, 240, 0.08);
  border: 1px solid rgba(226, 232, 240, 0.2);
}

.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  font-weight: 600;
}

.link.danger {
  color: #f97070;
}

.form-help {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.map-wrapper {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

#field-map {
  height: 420px;
  background: radial-gradient(circle at 20% 20%, rgba(70, 195, 123, 0.05), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.05), transparent 40%),
    rgba(255, 255, 255, 0.02);
}

.map-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.map-actions.stacked {
  flex-direction: column;
  align-items: flex-start;
}

.map-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.map-unavailable {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.map-status {
  padding: 12px;
  text-align: center;
}

[data-section].hidden {
  display: none;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    box-shadow: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 18px;
  }

  .hero {
    grid-template-columns: 1fr;
  }
}
