:root {
  --green: #2e6b34;
  --green-dark: #1f4a24;
  --bg: #f4f6f2;
  --card: #ffffff;
  --ink: #1d241c;
  --muted: #6b7567;
  --line: #dde3d8;
  --warn: #b3261e;
  --chip: #e7eee4;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--warn); font-size: 13.5px; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--green-dark), var(--green) 55%, #5a8f51); }
.auth-card { background: var(--card); border-radius: 16px; padding: 32px 28px; width: 100%;
  max-width: 380px; box-shadow: 0 18px 50px rgba(0,0,0,.28); }
.auth-card h1 { margin: 0 0 4px; color: var(--green-dark); letter-spacing: .5px; }
.auth-card form { display: grid; gap: 14px; margin-top: 18px; }
.auth-card label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.auth-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.auth-card input:focus { outline: 2px solid var(--green); border-color: transparent; }
.tabs { display: flex; gap: 6px; margin-top: 16px; }
.tab { flex: 1; padding: 8px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 8px; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--green); color: #fff; border-color: var(--green); }

button.primary { padding: 11px; background: var(--green); color: #fff; border: 0;
  border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
button.primary:hover { background: var(--green-dark); }
button.ghost { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff;
  border-radius: 8px; padding: 6px 12px; cursor: pointer; }
/* In-card text buttons (auth card has a white background — .ghost is for the
   dark topbar and would be white-on-white here). */
button.linklike { background: transparent; border: 0; color: var(--green);
  font-size: 13.5px; cursor: pointer; padding: 2px; justify-self: start;
  text-decoration: underline; }
button.linklike:hover { color: var(--green-dark); }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 22px;
  background: var(--green-dark); color: #fff; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; letter-spacing: .6px; font-size: 17px; }
.topbar nav { display: flex; gap: 4px; }
.topbar .nav { background: transparent; border: 0; color: #d9e4d4; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-size: 14.5px; }
.topbar .nav.active, .topbar .nav:hover { background: rgba(255,255,255,.14); color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .muted { color: #c9d6c3; }

main { max-width: 1080px; margin: 26px auto; padding: 0 20px 60px; }

/* Cards & stats */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.card .big { font-size: 28px; font-weight: 700; color: var(--green-dark); }
.card .label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.usage-bar { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; margin-top: 8px; }
.usage-bar > div { height: 100%; background: var(--green); }
.usage-bar > div.hot { background: var(--warn); }

/* Tables */
.section { margin-top: 26px; }
.section h2 { font-size: 17px; margin: 0 0 10px; color: var(--green-dark); }
table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: #eef2ea; font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f7faf5; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 2px 10px;
  font-size: 12px; color: var(--green-dark); }
.chip.warn { background: #fbe9e7; color: var(--warn); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1; max-width: 320px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; }

/* Inline edit */
td .editable { border-bottom: 1px dashed var(--muted); cursor: text; }
td input.inline { font-size: 14px; padding: 4px 6px; border: 1px solid var(--green); border-radius: 6px; }

.empty { padding: 36px; text-align: center; color: var(--muted); background: var(--card);
  border: 1px dashed var(--line); border-radius: 12px; }
.banner { margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; background: #fff7e0;
  border: 1px solid #eadfae; font-size: 13.5px; }

/* Dashboard / charts */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.chart-card h3 { margin: 0 0 8px; font-size: 14px; color: var(--green-dark); }
.chart { width: 100%; height: auto; display: block; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-tick { font: 11px system-ui, sans-serif; fill: var(--muted); }
.chart-empty { padding: 40px 0; text-align: center; color: var(--muted); font-size: 13.5px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { width: 150px; height: 150px; flex: none; }
.donut-total { font: 700 22px system-ui, sans-serif; fill: var(--green-dark); }
.legend { display: grid; gap: 6px; font-size: 13.5px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; }

.kpis .card .big.pos, td.pos { color: #2e6b34; }
.kpis .card .big.neg, td.neg { color: var(--warn); }
.nowrap { white-space: nowrap; }

/* Chips */
.chip.ok { background: #e3f1e1; color: var(--green-dark); }
.chip.info { background: #e2ecf2; color: #2d5a6b; }
.chip.dark { background: #e4e4e4; color: #444; }

/* Needs-attention panel */
.attention { list-style: none; margin: 0; padding: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.attention li { padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 14px;
  border-left: 4px solid transparent; }
.attention li:last-child { border-bottom: 0; }
.attention .att-danger { border-left-color: var(--warn); background: #fdf6f5; }
.attention .att-warn { border-left-color: #c9a227; background: #fffcf2; }
.attention .att-info { border-left-color: #9aa5ad; }
.all-clear { padding: 16px; background: #e9f3e6; border: 1px solid #cfe3c8;
  border-radius: 12px; color: var(--green-dark); font-size: 14px; }

/* Animal links / detail page */
.animal-link { color: var(--green-dark); font-weight: 600; text-decoration: none; }
.animal-link:hover { text-decoration: underline; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--green-dark); }
.detail-header { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.detail-header h1 { margin: 0; font-size: 26px; color: var(--green-dark); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px;
  margin-top: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; }
.fact .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.fact > div:last-child { font-size: 14.5px; }
h3.sub { font-size: 13.5px; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .5px; }

/* Toolbar selects */
.toolbar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); font-size: 14px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.timeline li { display: flex; gap: 12px; align-items: baseline; padding: 8px 14px;
  border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.tl-date { color: var(--muted); font-size: 12.5px; white-space: nowrap; min-width: 78px; }
.timeline .chip { min-width: 74px; text-align: center; }
.chip.tl-weight { background: #e7eee4; }
.chip.tl-vaccine { background: #e2ecf2; color: #2d5a6b; }
.chip.tl-treatment { background: #f4e8d8; color: #7a5520; }
.chip.tl-illness { background: #fbe9e7; color: var(--warn); }
.chip.tl-breeding, .chip.tl-birth { background: #f0e4f0; color: #6b2d66; }
.chip.tl-milk { background: #eef3f6; color: #2d5a6b; }
.chip.tl-sold { background: #e2ecf2; color: #2d5a6b; }
.chip.tl-deceased { background: #e4e4e4; color: #444; }
.chip.tl-cost { background: #f4f0d8; color: #6b5d20; }

/* Footer */
.footer { max-width: 1080px; margin: 0 auto; padding: 14px 20px 26px;
  display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
