:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5eaf1;
  --brand: #1f4e79;
  --brand-dark: #163a59;
  --blue: #2d9bf0;
  --green: #5bb545;
  --purple: #6e5acb;
  --orange: #ff9f2d;
  --danger: #d93025;
  --shadow: 0 10px 26px rgba(31, 78, 121, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 22px 14px;
  background: linear-gradient(180deg, #1d466d 0%, #143656 100%);
  color: #f7fbff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong {
  display: block;
  font-size: 1rem;
  line-height: 1.12;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #bcd5ec;
  font-size: 0.78rem;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-item,
.ghost-button,
.primary-button,
.icon-button,
.import-label,
.menu-button,
.notification-button {
  border: 0;
  border-radius: 7px;
  min-height: 38px;
  padding: 9px 11px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  color: #dceaf7;
  font-size: 0.88rem;
  text-align: left;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 20px;
  color: #ffffff;
  opacity: 0.9;
}

.nav-item:hover,
.nav-item.active {
  background: #2876bd;
  color: #ffffff;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 0 6px;
}

.ghost-button,
.import-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef6ff;
  color: var(--brand);
  font-weight: 700;
}

.sidebar .ghost-button,
.sidebar .import-label {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.import-label input {
  display: none;
}

.main {
  min-width: 0;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 74px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.menu-button,
.notification-button {
  display: grid;
  place-items: center;
  width: 38px;
  background: #ffffff;
  color: #5f6b7a;
}

.notification-button {
  position: relative;
  border: 1px solid transparent;
}

.notification-button span {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 3px;
  font-size: 1.45rem;
  font-weight: 800;
}

h2 {
  margin-bottom: 0;
  font-size: 0.98rem;
}

.page-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 9px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.farm-box {
  display: grid;
  gap: 1px;
  width: 170px;
}

.farm-box label,
.form-panel label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.farm-box input {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45, 155, 240, 0.13);
}

.section {
  display: none;
  padding: 22px 26px 28px;
}

.section.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  position: relative;
  min-height: 105px;
  padding: 18px 16px 14px 78px;
}

.metric-icon {
  position: absolute;
  top: 24px;
  left: 18px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 1rem;
}

.metric-blue .metric-icon {
  background: var(--blue);
}

.metric-green .metric-icon {
  background: var(--green);
}

.metric-purple .metric-icon {
  background: var(--purple);
}

.metric-orange .metric-icon {
  background: var(--orange);
}

.metric span {
  display: block;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 1.8rem;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: #2876bd;
  font-size: 0.75rem;
  font-weight: 700;
}

.dashboard-grid,
.content-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-secondary {
  grid-template-columns: minmax(330px, 0.9fr) minmax(430px, 1.1fr);
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading span {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.line-chart {
  min-height: 225px;
}

.line-chart svg {
  display: block;
  width: 100%;
  height: 225px;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 225px;
  color: var(--muted);
}

.donut-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: center;
  gap: 18px;
  min-height: 225px;
}

.donut {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 25%, var(--blue) 25% 60%, var(--purple) 60% 80%, var(--orange) 80% 100%);
  box-shadow: inset 0 0 0 36px #ffffff;
}

.legend-list {
  display: grid;
  gap: 12px;
  color: var(--ink);
  font-size: 0.82rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.form-panel {
  align-self: start;
}

.wide-form {
  max-width: 980px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 13px;
}

.form-panel label {
  display: grid;
  gap: 7px;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  background: #257fcc;
}

.search {
  max-width: 310px;
}

.table-wrap {
  max-height: 610px;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.icon-button {
  min-height: 33px;
  padding: 7px 10px;
  background: #eef6ff;
  color: #2876bd;
}

.icon-button.danger {
  color: var(--danger);
  background: #fff0ee;
}

.record-list,
.stack-list,
.summary-list,
.species-grid {
  display: grid;
  gap: 9px;
}

.species-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.record,
.alert,
.summary-item,
.species-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  background: #ffffff;
}

.species-card strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
}

.species-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.alert {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 9px;
}

.alert::before {
  content: "⌁";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #edf6ff;
  color: var(--blue);
}

.record-top,
.summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.record strong,
.alert strong {
  display: block;
  margin-bottom: 3px;
}

.record small,
.alert small {
  color: var(--muted);
}

.record p {
  margin: 8px 0 0;
  color: var(--muted);
}

.supplies-table table {
  min-width: 0;
}

.supplies-table td,
.supplies-table th {
  padding: 9px 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eaf7e7;
  color: #31811f;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.expense,
.badge.low {
  background: #fff2df;
  color: #b55a00;
}

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

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(380px, calc(100vw - 44px));
  transform: translateY(20px);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--brand-dark);
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.cloud-login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 35, 56, 0.72);
}

.cloud-login-box {
  display: grid;
  gap: 12px;
  width: min(390px, 100%);
  border-radius: 10px;
  padding: 26px;
  background: #ffffff;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.cloud-login-box img {
  justify-self: center;
  width: 104px;
  height: 104px;
  border-radius: 18px;
  object-fit: cover;
}

.cloud-login-box h2 {
  font-size: 1.35rem;
}

.cloud-login-box p,
.cloud-login-box small {
  color: var(--muted);
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid,
  .dashboard-grid,
  .content-grid,
  .dashboard-secondary {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .section,
  .topbar,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    grid-template-columns: auto 1fr;
  }

  .top-actions {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .nav,
  .metric-grid,
  .dashboard-grid,
  .content-grid,
  .dashboard-secondary,
  .form-grid,
  .donut-row,
  .species-grid {
    grid-template-columns: 1fr;
  }

  .search {
    max-width: none;
  }
}
