/* ============================================================
   KlauenDok – Gemeinsames Stylesheet
   Aesthetik: "agro-klinisch" – sauber, hoher Kontrast,
   große Touch-Ziele für die einhändige Bedienung am Klauenstand.
   Mobile-first, iPhone-optimiert.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,800&display=swap");

:root {
  /* Farben */
  --gruen: #15412a;        /* Stalltür-Grün, Primärfarbe */
  --gruen-hell: #2c7a4b;   /* Aktion / Erfolg */
  --gruen-blass: #e6efe7;  /* sanfter Hintergrund-Akzent */
  --amber: #d98e00;        /* Warnung / fällig */
  --rot: #c0392b;          /* überfällig / Gefahr */
  --creme: #f5f2ea;        /* Seitenhintergrund */
  --karte: #ffffff;        /* Kartenflächen */
  --tinte: #14201a;        /* Haupttext */
  --grau: #6b756e;         /* Sekundärtext */
  --linie: #dcd7cb;        /* Trennlinien / Rahmen */

  /* Maße */
  --radius: 16px;
  --tap: 58px;             /* Mindesthöhe für Tap-Ziele */
  --schatten: 0 2px 10px rgba(20, 32, 26, 0.08);
  --schatten-stark: 0 6px 24px rgba(20, 32, 26, 0.16);

  /* Schrift */
  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--tinte);
  background: var(--creme);
  /* dezente Textur statt flacher Fläche */
  background-image:
    radial-gradient(circle at 12% 0%, rgba(44, 122, 75, 0.06), transparent 40%),
    radial-gradient(circle at 90% 8%, rgba(217, 142, 0, 0.05), transparent 35%);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(78px + env(safe-area-inset-bottom)); /* Platz für Bottom-Nav */
  min-height: 100vh;
}

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--gruen);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--schatten);
}
.topbar h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  margin: 0;
  flex: 1;
}
.topbar .back {
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  width: 42px; height: 42px;
  border-radius: 12px;
  font-size: 1.4rem;
  display: grid; place-items: center;
  cursor: pointer;
}
.topbar .meta { font-size: 0.78rem; opacity: 0.85; text-align: right; }

/* ---------- Layout ---------- */
.wrap { padding: 18px; max-width: 640px; margin: 0 auto; }
.stack > * + * { margin-top: 14px; }

h2 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 1.15rem;
  margin: 4px 0 2px;
}
.muted { color: var(--grau); font-size: 0.88rem; }

/* ---------- Karten ---------- */
.card {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--schatten);
}
.card.tap { cursor: pointer; transition: transform 0.08s ease, box-shadow 0.15s ease; }
.card.tap:active { transform: scale(0.985); box-shadow: var(--schatten-stark); }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  min-height: var(--tap);
  border: none;
  border-radius: 14px;
  background: var(--gruen-hell);
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); filter: brightness(0.95); }
.btn.dark { background: var(--gruen); }
.btn.ghost { background: transparent; color: var(--gruen); border: 2px solid var(--linie); }
.btn.danger { background: var(--rot); }
.btn.warn { background: var(--amber); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ---------- Formulare ---------- */
label.field { display: block; }
label.field > span { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  font-size: 1.05rem; /* >=16px verhindert iOS-Zoom */
  font-family: var(--body);
  padding: 12px 14px;
  border: 2px solid var(--linie);
  border-radius: 12px;
  background: #fff;
  color: var(--tinte);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gruen-hell);
  box-shadow: 0 0 0 4px rgba(44, 122, 75, 0.15);
}

/* ---------- Chips / Auswahlraster (große Tap-Ziele) ---------- */
.grid { display: grid; gap: 10px; }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }

.chip {
  min-height: var(--tap);
  border: 2px solid var(--linie);
  border-radius: 12px;
  background: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--tinte);
  cursor: pointer;
  display: grid; place-items: center;
  text-align: center;
  transition: all 0.12s ease;
  padding: 6px;
}
.chip small { display: block; font-family: var(--body); font-weight: 500; font-size: 0.7rem; color: var(--grau); }
.chip[aria-pressed="true"] {
  background: var(--gruen); color: #fff; border-color: var(--gruen);
}
.chip[aria-pressed="true"] small { color: rgba(255,255,255,0.8); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700;
  background: var(--gruen-blass); color: var(--gruen);
}
.badge.warn { background: #fdf0d6; color: var(--amber); }
.badge.rot { background: #fbe3df; color: var(--rot); }
.badge.grau { background: #ededea; color: var(--grau); }

/* ---------- Statistik-Kacheln ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--karte); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--schatten);
}
.stat .num { font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1; color: var(--gruen); }
.stat .lbl { font-size: 0.8rem; color: var(--grau); margin-top: 4px; }
.stat.accent .num { color: var(--amber); }
.stat.alert .num { color: var(--rot); }

/* ---------- Listen ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  background: var(--karte); border: 1px solid var(--linie);
  border-radius: 14px; padding: 14px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
}
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 700; }
.list .sub { font-size: 0.84rem; color: var(--grau); }

/* ---------- Bottom-Navigation (Daumenbedienung) ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 14px rgba(20, 32, 26, 0.06);
}
.bottomnav a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--grau); font-size: 0.68rem; font-weight: 600;
  padding: 9px 4px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bottomnav a .ic { font-size: 1.35rem; line-height: 1; }
.bottomnav a.active { color: var(--gruen); }

/* ---------- Hinweise / leere Zustände ---------- */
.empty { text-align: center; color: var(--grau); padding: 40px 16px; }
.empty .big { font-size: 2.4rem; margin-bottom: 8px; }

.notice { padding: 12px 14px; border-radius: 12px; font-size: 0.9rem; }
.notice.err { background: #fbe3df; color: var(--rot); }
.notice.ok { background: var(--gruen-blass); color: var(--gruen); }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  padding-bottom: 24px;
  background:
    radial-gradient(circle at 50% -10%, rgba(44,122,75,0.18), transparent 55%),
    var(--creme);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--karte); border-radius: 22px; padding: 30px 26px;
  box-shadow: var(--schatten-stark); border: 1px solid var(--linie);
}
.brand { text-align: center; margin-bottom: 22px; }
.brand .logo {
  width: 72px; height: 72px; margin: 0 auto 12px;
  border-radius: 20px; background: var(--gruen);
  display: grid; place-items: center; font-size: 2.2rem; box-shadow: var(--schatten);
}
.brand h1 { font-family: var(--display); font-weight: 800; font-size: 1.7rem; margin: 0; letter-spacing: -0.02em; }
.brand p { color: var(--grau); margin: 4px 0 0; font-size: 0.9rem; }

/* Lade-Spinner */
.spinner {
  width: 22px; height: 22px; border: 3px solid rgba(255,255,255,0.4);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-load { display: grid; place-items: center; padding: 50px; }
.center-load .spinner { border-color: var(--linie); border-top-color: var(--gruen); }

/* Eingangs-Animation */
.fade-in { animation: fade 0.35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
