:root {
  --green-900: #10331d;
  --green-700: #1f5c34;
  --green-600: #2c7a45;
  --green-500: #3f9a5c;
  --gold: #c9962c;
  --bg: #f4f6f2;
  --card-bg: #ffffff;
  --border: #dde3d8;
  --text: #1c2620;
  --text-muted: #5b6b60;
  --red: #b3392c;
  --amber: #b8862c;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.topnav {
  background: var(--green-900);
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

header.topnav .brand {
  font-weight: 700;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

header.topnav .brand .flag {
  color: var(--gold);
}

nav.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

nav.tabs a {
  color: #eef3ea;
  text-decoration: none;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

nav.tabs a:hover {
  background: rgba(255, 255, 255, 0.12);
}

nav.tabs a.active {
  background: var(--green-600);
  font-weight: 600;
}

.month-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

h2 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.75rem;
}

p.subtitle {
  color: var(--text-muted);
  margin-top: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.kpi-card .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green-700);
}

.kpi-card .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--card-bg);
}

table th,
table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table tbody tr:hover {
  background: #f0f5ef;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table-wrap table {
  border: none;
  border-radius: 0;
}

a.row-link {
  color: var(--green-700);
  text-decoration: none;
  font-weight: 600;
}

a.row-link:hover {
  text-decoration: underline;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.healthy {
  background: #e3f3e6;
  color: var(--green-700);
}

.badge.mastitis,
.badge.lameness,
.badge.reproductive-disorder {
  background: #fbe7e3;
  color: var(--red);
}

.badge.pregnant {
  background: #eaf0fb;
  color: #2c4d9a;
}

.badge.open {
  background: #fdf1de;
  color: var(--amber);
}

.badge.served,
.badge.voluntary-waiting-period {
  background: #f1eefb;
  color: #6a3fa0;
}

.badge.dry,
.badge.heifer {
  background: #eef1ec;
  color: var(--text-muted);
}

button,
.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  background: var(--green-600);
  color: #fff;
  font-weight: 600;
}

button:hover,
.btn:hover {
  background: var(--green-700);
}

button.secondary {
  background: #fff;
  color: var(--green-700);
  border: 1px solid var(--green-600);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

select,
input[type='number'],
input[type='text'] {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

form.inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.event-log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}

.event-log li {
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--border);
  color: var(--text-muted);
}

.event-log li .month-tag {
  color: var(--green-700);
  font-weight: 600;
  margin-right: 0.4rem;
}

.profit.positive {
  color: var(--green-700);
}

.profit.negative {
  color: var(--red);
}

.disclaimer {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--green-900);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: 320px;
}

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

.toast.error {
  background: var(--red);
}
