/* DFA – Haupt-Stylesheet
   Design: dunkel, mobil-first, Touch-optimiert
   CSS-Variablen kompatibel mit V3-Design-System */

:root {
  --bg:   #0d1b2a; --bg2:  #112236; --bg3:  #162d44;
  --brd:  #1e3d5c; --brd2: #2a5070;
  --tx:   #d4e8f5; --mu:   #6a90b0;
  --ac:   #f0a030; --gn:   #30d880;
  --rd:   #f04060; --bl:   #3090f0; --pu:   #a060f0;
  --f:    'Segoe UI', system-ui, -apple-system, sans-serif;
  --fm:   'Consolas', 'Courier New', monospace;
  --r:    10px; --r2: 16px;
  --nav-h: 60px; --top-h: 52px;
  --shadow: 0 4px 16px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--tx);
  font-family: var(--f); line-height: 1.5;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent;
}
a { color: var(--bl); text-decoration: none; }
button { cursor: pointer; font-family: var(--f); border: none; outline: none; }
input, select, textarea {
  background: var(--bg3); color: var(--tx); border: 1px solid var(--brd);
  border-radius: var(--r); padding: 9px 12px; font-family: var(--f);
  font-size: 14px; width: 100%; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--bl); }
label { font-size: 12px; color: var(--mu); display: block; margin-bottom: 4px; font-weight: 600; }
textarea { resize: vertical; min-height: 60px; }

/* ── Layout ─────────────────────────────────────────────────────── */
#app { height: 100dvh; display: flex; flex-direction: column; }

#topbar {
  height: var(--top-h); background: var(--bg2); border-bottom: 1px solid var(--brd);
  display: flex; align-items: center; padding: 0 14px; gap: 10px; flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
}
.topbar-logo { font-size: 18px; font-weight: 800; color: var(--ac); flex: 1; }
.topbar-user { font-size: 12px; color: var(--mu); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mu); flex-shrink: 0; }
.sync-dot--online  { background: var(--gn); }
.sync-dot--offline { background: var(--rd); animation: pulse .8s infinite; }
.offline-banner {
  background: var(--rd); color: #fff; text-align: center;
  padding: 5px; font-size: 12px; font-weight: 700; display: none;
}
.offline-banner.show { display: block; }

#main-content { flex: 1; overflow-y: auto; padding: 14px 14px 80px; }

/* ── Navigation (Bottom) ─────────────────────────────────────────── */
#bottom-nav {
  height: var(--nav-h); background: var(--bg2); border-top: 1px solid var(--brd);
  display: flex; flex-shrink: 0; position: sticky; bottom: 0; z-index: 100;
}
.nav-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; font-size: 10px; font-weight: 600;
  color: var(--mu); border: none; background: none; padding: 4px;
  transition: color .15s; position: relative; min-height: 56px;
}
.nav-tab.active { color: var(--ac); }
.nav-tab.active::before {
  content: ''; position: absolute; top: 0; left: 20%; right: 20%;
  height: 2px; background: var(--ac); border-radius: 0 0 2px 2px;
}
.nav-tab .icon { font-size: 22px; }
.nav-badge {
  position: absolute; top: 6px; right: 50%; transform: translateX(14px);
  background: var(--rd); color: #fff; border-radius: 10px;
  padding: 1px 5px; font-size: 10px; font-weight: 700; min-width: 16px; text-align: center;
}

/* ── FAB ─────────────────────────────────────────────────────────── */
#fab {
  position: fixed; bottom: 74px; right: 16px; z-index: 200;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--ac); color: #0d1b2a; font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(240,160,48,.45); transition: transform .2s;
}
#fab.open { transform: rotate(45deg); }
#fab-menu {
  position: fixed; bottom: 136px; right: 16px; z-index: 199;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  opacity: 0; pointer-events: none; transform: translateY(16px);
  transition: opacity .2s, transform .2s;
}
#fab-menu.open { opacity: 1; pointer-events: all; transform: translateY(0); }
.fab-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  background: var(--bg2); border: 1px solid var(--brd2); border-radius: 24px;
  color: var(--tx); font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow); transition: border-color .15s;
  /* Button-Defaults zuruecksetzen */
  font-family: inherit; text-align: left; cursor: pointer;
  /* Kein 300ms-Delay, keine Doppeltap-Interpretation auf dem Handy */
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
/* Hover nur an Geraeten mit echtem Zeiger – am Handy stoert es sonst */
@media (hover: hover) and (pointer: fine) {
  .fab-item:hover { border-color: var(--ac); }
}
.fab-item:active { border-color: var(--ac); background: var(--bg3); }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--brd); border-radius: var(--r2);
  padding: 14px; margin-bottom: 12px;
}
.card--warn { border-color: rgba(240,64,96,.4); border-left: 3px solid var(--rd); }
.card-hd { display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: var(--mu); margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .4px; }

/* ── KPI ─────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi-card { background: var(--bg2); border: 1px solid var(--brd); border-radius: var(--r2);
  padding: 14px; text-align: center; }
.kpi-val  { font-size: 28px; font-weight: 800; color: var(--ac); }
.kpi-label { font-size: 11px; color: var(--mu); margin-top: 2px; }

/* Status-Balken */
.status-bar { display: flex; height: 24px; border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.status-seg { display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; min-width: 20px; transition: width .3s; }
.status-legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--mu); }
.status-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 3px; }

/* ── Sau-Liste ───────────────────────────────────────────────────── */
.sau-row {
  display: flex; align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--brd); cursor: pointer;
  touch-action: pan-y; transition: background .1s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.sau-row:active { background: rgba(255,255,255,.03); transform: scale(.99); }
.sau-row__inner { flex: 1; }
.sau-row__id    { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.sau-row__id .nr  { font-size: 11px; color: var(--mu); background: var(--bg3);
  padding: 1px 6px; border-radius: 4px; }
.sau-row__id .ohm { font-size: 14px; font-weight: 700; }
.sau-row__meta  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sau-row__timing { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.timing-pill { font-size: 11px; padding: 1px 7px; border-radius: 8px; font-weight: 700; }
.timing--tragend { background: rgba(48,216,128,.15); color: var(--gn); }
.timing--wb      { background: rgba(48,144,240,.15); color: var(--bl); }
.timing--abf     { background: rgba(240,160,48,.15); color: var(--ac); }
.flag { font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 800; }
.flag--np  { background: rgba(240,160,48,.2); color: var(--ac); }
.flag--sel { background: rgba(240,64,96,.2);  color: var(--rd); }
.wurfnr, .bucht { font-size: 11px; color: var(--mu); }
.icon-btn { background: none; color: var(--mu); font-size: 18px; padding: 8px; border-radius: 50%;
  min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { color: var(--tx); }
.sau-row__actions { flex-shrink: 0; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px; border-radius: var(--r); font-size: 14px; font-weight: 700;
  background: var(--bg3); color: var(--tx); border: 1px solid var(--brd2);
  transition: border-color .15s, background .15s; min-height: 44px;
}
.btn:hover     { border-color: var(--ac); }
.btn-primary   { background: var(--ac); color: #0d1b2a; border-color: var(--ac); }
.btn-primary:hover { background: #ffc040; }
.btn-danger    { background: rgba(240,64,96,.15); color: var(--rd); border-color: var(--rd); }
.btn-xs        { padding: 4px 10px; font-size: 11px; font-weight: 700;
  background: var(--bg3); color: var(--mu); border: 1px solid var(--brd);
  border-radius: 6px; min-height: 28px; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; font-size: 11px; font-weight: 800;
  background: var(--bg3); color: var(--mu); border: 1px solid var(--brd);
}
.badge-red { background: rgba(240,64,96,.2); color: var(--rd); border-color: var(--rd); }

/* ── Modal ───────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 500; display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#modal-overlay.open { opacity: 1; pointer-events: all; }
#modal-box {
  background: var(--bg2); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 600px; max-height: 90dvh;
  overflow-y: auto; padding: 20px 16px 32px;
  border: 1px solid var(--brd); border-bottom: none;
  transform: translateY(40px); transition: transform .25s;
}
#modal-overlay.open #modal-box { transform: translateY(0); }
#modal-close {
  position: absolute; top: 12px; right: 16px;
  font-size: 24px; color: var(--mu); background: none;
  padding: 4px 8px; border-radius: 6px;
}
#modal-close:hover { color: var(--tx); }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; }
.form-group--full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.verlust-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.verlust-grid label { font-size: 11px; }
.verlust-grid input { padding: 6px 8px; font-size: 13px; }

/* ── Detail-Ansicht ──────────────────────────────────────────────── */
.detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.detail-title  { font-size: 20px; font-weight: 800; }
.qual-score    { padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 800; }
.qual--gut     { background: rgba(48,216,128,.2); color: var(--gn); }
.qual--mittel  { background: rgba(240,160,48,.2); color: var(--ac); }
.qual--schlecht{ background: rgba(240,64,96,.2);  color: var(--rd); }
.detail-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
/* Blöcke der Sauenkarte (seit 1.13.0): Identität, Abstammung, Zukauf, Zyklus.
   Ein Block ohne gefülltes Feld wird gar nicht erst erzeugt. */
.detail-block    { margin-bottom: 14px; }
.detail-block h4 { font-size: 11px; color: var(--mu); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.detail-block .detail-grid { margin-bottom: 0; }
.detail-kv small { font-weight: 400; color: var(--mu); }
.detail-kv     { background: var(--bg3); border-radius: 8px; padding: 8px 10px; }
.detail-kv span { font-size: 10px; color: var(--mu); display: block; }
.detail-kv strong { font-size: 13px; }
.detail-section { margin: 14px 0; }
.detail-section h4 { font-size: 12px; color: var(--mu); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail-table th { color: var(--mu); font-size: 11px; text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--brd); }
.detail-table td { padding: 6px 6px; border-bottom: 1px solid rgba(30,61,92,.3); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tk-row  { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--brd); font-size: 13px; }
.tk-result { padding: 2px 8px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.tk--tragend { background: rgba(48,216,128,.2); color: var(--gn); }
.tk--leer    { background: rgba(240,64,96,.2);  color: var(--rd); }
.tk--offen   { background: var(--bg3);          color: var(--mu); }
.proto-row   { display: flex; gap: 8px; align-items: center; font-size: 12px; padding: 5px 0; border-bottom: 1px solid rgba(30,61,92,.3); flex-wrap: wrap; }
.proto-date  { color: var(--mu); flex-shrink: 0; }
.proto-user  { color: var(--mu); margin-left: auto; }
.force-badge { background: rgba(240,64,96,.2); color: var(--rd); font-size: 10px; padding: 1px 5px; border-radius: 4px; font-weight: 800; }

/* ── Muster ──────────────────────────────────────────────────────── */
.muster-row  { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--brd); }
.muster-icon { font-size: 20px; flex-shrink: 0; }
.muster-title { font-size: 13px; font-weight: 700; }
.muster-detail { font-size: 12px; color: var(--mu); margin-top: 2px; }

/* ── Events ──────────────────────────────────────────────────────── */
.event-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--brd); cursor: pointer; font-size: 13px; }
.event-type { font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 700;
  background: var(--bg3); color: var(--bl); flex-shrink: 0; }
.event-date { color: var(--mu); flex-shrink: 0; }
.event-note { color: var(--mu); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Meds ────────────────────────────────────────────────────────── */
.med-row { padding: 10px 0; border-bottom: 1px solid var(--brd); }
.med-row--storniert { opacity: .5; }
.med-main { font-size: 13px; margin-bottom: 4px; }
.med-meta { font-size: 11px; color: var(--mu); }
.storno-badge { background: rgba(240,64,96,.2); color: var(--rd); font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 800; margin-left: 6px; }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: calc(var(--top-h) + 8px); left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 6px; pointer-events: none;
  width: calc(100% - 32px); max-width: 400px;
}
.toast {
  padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; pointer-events: auto;
  animation: toastIn .2s ease; box-shadow: var(--shadow);
}
.toast--success  { background: rgba(48,216,128,.2); border: 1px solid var(--gn); color: var(--gn); }
.toast--error    { background: rgba(240,64,96,.2);  border: 1px solid var(--rd); color: var(--rd); }
.toast--warn     { background: rgba(240,160,48,.2); border: 1px solid var(--ac); color: var(--ac); }
.toast--conflict { background: rgba(160,96,240,.2); border: 1px solid var(--pu); color: var(--pu); }
.toast--info     { background: var(--bg2); border: 1px solid var(--brd); color: var(--tx); }
@keyframes toastIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
@keyframes pulse   { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── States ──────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--mu); }
.empty-icon  { font-size: 48px; margin-bottom: 12px; }
.empty-text  { font-size: 15px; margin-bottom: 16px; }
.empty-mini  { text-align: center; color: var(--mu); font-size: 13px; padding: 10px 0; }
.loading     { text-align: center; color: var(--mu); padding: 20px; animation: pulse 1s infinite; }
.error-state { color: var(--rd); text-align: center; padding: 20px; }

/* ── Login ───────────────────────────────────────────────────────── */
#login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg);
}
.login-card {
  background: var(--bg2); border: 1px solid var(--brd); border-radius: 20px;
  padding: 32px 24px; width: 100%; max-width: 360px;
}
.login-logo { text-align: center; font-size: 24px; font-weight: 800; color: var(--ac); margin-bottom: 24px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-error { color: var(--rd); font-size: 12px; text-align: center; margin-top: 8px; display: none; }

/* ── Desktop (≥640px) ────────────────────────────────────────────── */
@media (min-width: 640px) {
  #main-content { max-width: 800px; margin: 0 auto; }
  .kpi-grid     { grid-template-columns: repeat(4, 1fr); }
  /* Zentrieren wie #main-content ueber auto-Raender. Vorher stand hier
     left:50% + translateX(-50%). Die Leiste liegt aber als Flex-Element
     im normalen Fluss (position:sticky), also linksbuendig - das
     translateX hat sie um 400px nach links aus dem Bild geschoben, und
     der erste Eintrag "Start" war nicht mehr erreichbar. */
  #bottom-nav   { max-width: 800px; width: 100%; margin: 0 auto; }
  /* max() faengt den Bereich 640-800px ab: dort wird calc() negativ und
     der Knopf rutscht ueber den rechten Rand hinaus. */
  #fab, #fab-menu { right: max(16px, calc(50% - 400px + 16px)); }
  .detail-grid  { grid-template-columns: repeat(3, 1fr); }
}

/* ── DFA-Shell Erweiterungen ──────────────────────────────────────── */

/* Login */
.login-icon  { font-size: 48px; margin-bottom: 4px; }
.login-sub   { font-size: 12px; color: var(--mu); margin-top: 2px; }
.login-hint  { font-size: 11px; color: var(--mu); text-align: center; margin-top: 12px; }

/* Topbar-Titel */
.topbar-title { font-size: 16px; font-weight: 800; color: var(--ac); }
.queue-badge  { font-size: 11px; color: var(--ac); background: rgba(240,160,48,.15);
  padding: 2px 8px; border-radius: 10px; font-weight: 700; }

/* DFA Dashboard */
.dfa-header   { margin-bottom: 14px; }
.dfa-betrieb  { font-size: 20px; font-weight: 800; color: var(--tx); }
.dfa-date     { font-size: 12px; color: var(--mu); margin-top: 2px; }

/* Schnellzugriff-Grid */
.quicknav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.quicknav-btn  {
  background: var(--bg2); border: 1px solid var(--brd); border-radius: var(--r2);
  padding: 14px 12px; display: flex; flex-direction: column; align-items: flex-start;
  gap: 4px; cursor: pointer; transition: border-color .15s, background .1s;
  -webkit-tap-highlight-color: transparent;
}
.quicknav-btn:hover  { border-color: var(--ac); background: var(--bg3); }
.quicknav-btn:active { transform: scale(.98); }
.qn-icon   { font-size: 26px; }
.qn-label  { font-size: 13px; font-weight: 700; color: var(--tx); }
.qn-count  { font-size: 11px; color: var(--ac); font-weight: 700; }
.qn-badge-soon {
  font-size: 10px; color: var(--mu); background: var(--bg3);
  padding: 1px 7px; border-radius: 8px; border: 1px solid var(--brd);
}

/* Status-Balken */
.status-bar-wrap { margin-bottom: 12px; }

/* Modul-Platzhalter */
.module-placeholder {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px; text-align: center; gap: 10px;
}
.ph-icon     { font-size: 52px; }
.ph-title    { font-size: 22px; font-weight: 800; color: var(--tx); }
.ph-sub      { font-size: 14px; color: var(--mu); max-width: 280px; line-height: 1.6; }
.ph-badge    {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px;
  border-radius: 20px; font-size: 13px; font-weight: 700;
  background: rgba(48,144,240,.15); color: var(--bl); border: 1px solid rgba(48,144,240,.3);
}
.ph-api      { font-size: 12px; color: var(--mu); margin-top: 4px; }
.ph-api code { color: var(--bl); }
.ph-features { display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
  width: 100%; max-width: 300px; }
.ph-features div { background: var(--bg2); border: 1px solid var(--brd); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; text-align: left; }

/* Sub-Navigation Sauenplaner */
.sub-nav {
  display: flex; gap: 0; border-bottom: 1px solid var(--brd);
  margin: -14px -14px 14px; overflow-x: auto; scrollbar-width: none;
}
.sub-nav::-webkit-scrollbar { display: none; }
.sub-tab {
  flex: 1; min-width: 70px; padding: 10px 4px; font-size: 12px; font-weight: 700;
  color: var(--mu); background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.sub-tab.active { color: var(--ac); border-bottom-color: var(--ac); }
.sub-view { display: none; }
.sub-view.active { display: block; }

/* Filter-Bar */
.filter-bar {
  display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
}
.filter-bar input  { flex: 1; min-width: 100px; }
.filter-bar select { width: auto; padding: 8px 10px; flex-shrink: 0; }

/* Event-Karte */
.event-card { margin-bottom: 8px; }
.event-card--faellig { border-left: 3px solid var(--rd); }

/* Einstellungen */
.settings-content { display: flex; flex-direction: column; gap: 0; }
.settings-info    { font-size: 13px; color: var(--mu); line-height: 1.8; }

/* Show-More */
.show-more { text-align: center; color: var(--bl); font-size: 12px;
  padding: 8px 0; cursor: pointer; }
.show-more:hover { text-decoration: underline; }

/* Module-View */
.module { display: none; }
.module.active { display: block; }

/* btn-sm */
.btn-sm { padding: 7px 12px; font-size: 12px; min-height: 36px; }

/* Desktop ≥640px */
@media (min-width: 640px) {
  .quicknav-grid { grid-template-columns: repeat(4, 1fr); }
  .sub-nav .sub-tab { font-size: 13px; padding: 12px 16px; }
}

/* ── Sauenplaner-Erweiterungen ────────────────────────────────── */
/* Wochenliste */
.kw-nav { display:flex;align-items:center;gap:10px;margin-bottom:14px; }
.kw-title { flex:1;text-align:center;font-size:15px; }
.kw-dates { font-size:11px;color:var(--mu);margin-top:2px; }
.wl-row { display:flex;align-items:center;gap:8px;padding:10px 0;border-bottom:1px solid var(--brd);flex-wrap:wrap; }
.wl-ohm { font-size:14px;font-weight:700; }
.wl-nr  { font-size:11px;color:var(--mu);background:var(--bg3);padding:1px 6px;border-radius:4px; }
.wl-info { font-size:12px;color:var(--mu); }
.wl-date { font-size:12px;color:var(--mu);margin-left:auto; }

/* KPI */
.aufgabe-row { display:flex;gap:10px;padding:9px 0;border-bottom:1px solid var(--brd);align-items:flex-start; }
.aufgabe-p1  { border-left:3px solid var(--rd);padding-left:8px; }
.aufgabe-p2  { border-left:3px solid var(--ac);padding-left:8px; }
.aufg-icon   { font-size:18px;flex-shrink:0; }
.aufg-sau    { font-size:13px;font-weight:700; }
.aufg-text   { font-size:12px;color:var(--mu); }
.score-dist  { margin:10px 0; }
.score-dist-bar { display:flex;height:20px;border-radius:6px;overflow:visible;position:relative; }
.sdb-seg     { height:100%; }
.sdb-marker  { position:absolute;bottom:22px;transform:translateX(-50%);font-size:11px;font-weight:700;color:var(--tx); }
.sdb-median  { color:var(--ac); }
.score-dist-legend { display:flex;gap:16px;font-size:12px;margin-top:24px; }

/* Sauenkarte */
.sk-group { margin-bottom:12px; }
.sk-grid  { display:grid;grid-template-columns:repeat(auto-fill,minmax(110px,1fr));gap:8px;margin-top:8px; }
.sk-card  { border:1px solid;border-radius:10px;padding:8px;cursor:pointer;transition:opacity .15s;min-height:72px; }
.sk-card:active { opacity:.7; }
.sk-ohm   { font-size:12px;font-weight:700;display:flex;align-items:center;gap:4px;flex-wrap:wrap; }
.sk-nr    { font-size:10px;color:var(--mu);background:var(--bg3);padding:1px 4px;border-radius:3px; }
.sk-wurfnr { font-size:11px;color:var(--mu);margin-top:2px; }
.sk-info  { font-size:11px;font-weight:700;margin-top:2px; }
.sk-flag  { font-size:9px;padding:1px 4px;border-radius:3px;background:rgba(240,160,48,.2);color:var(--ac);font-weight:800;margin-top:2px;display:inline-block; }
.sk-flag--sel { background:rgba(240,64,96,.2);color:var(--rd); }

/* Protokoll */
.proto-entry { padding:8px 0;border-bottom:1px solid var(--brd); }
.proto-entry--force { border-left:3px solid var(--rd);padding-left:8px; }
.proto-entry-sau  { font-size:12px;font-weight:700;color:var(--mu); }
.proto-entry-main { display:flex;align-items:center;gap:6px;font-size:14px;margin:3px 0; }
.proto-von   { color:var(--mu); }
.proto-arrow { color:var(--mu); }
.proto-nach  { font-weight:700; }
.proto-entry-meta { font-size:11px;color:var(--mu);display:flex;gap:10px; }

/* Sammelaktionen */
.sammel-select-all { display:flex;align-items:center;gap:8px;margin-top:6px;font-size:12px; }

/* Desktop ≥640px Erweiterungen */
@media (min-width:640px) {
  .sk-grid { grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); }
}

/* ── Lieferschein-Import ──────────────────────────────────────── */
.ls-summary { display:flex;gap:8px;flex-wrap:wrap;margin-bottom:10px; }
.ls-table   { border:1px solid var(--brd);border-radius:8px;overflow:hidden;margin-top:8px; }
.ls-th      { display:grid;grid-template-columns:32px 1fr 80px 80px 1fr 70px;gap:6px;
              padding:8px;background:var(--bg3);font-size:11px;font-weight:700;color:var(--mu); }
.ls-tr      { display:grid;grid-template-columns:32px 1fr 80px 80px 1fr 70px;gap:6px;
              padding:9px 8px;border-top:1px solid var(--brd);align-items:center;font-size:12px; }
.ls-tr--dup { opacity:.5; }
.ls-ohm     { font-weight:700;font-size:13px; }
.ls-val     { color:var(--mu); }
.ls-status  { text-align:right; }

/* ── Timing Säugetag ──────────────────────────────────────────── */
.timing--saeugen { background:rgba(240,160,48,.15);color:var(--ac); }

/* ── Validierungs-Fehler ──────────────────────────────────────── */
.val-errors { margin-bottom:12px; }

/* ── Backup-Warnbanner ────────────────────────────────────────── */
#backup-warning-banner { flex-shrink:0; }

/* ── Lieferschein Mobile (schmale Spalten) ─────────────────── */
@media (max-width: 480px) {
  .ls-th, .ls-tr { grid-template-columns:28px 1fr 60px 60px 0fr 60px; }
  .ls-th span:nth-child(5), .ls-tr .ls-val:nth-child(5) { display:none; }
}

/* ── HIT/TAM Modul ────────────────────────────────────────────── */
.hit-header {
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  padding:12px; border-radius:10px; margin-bottom:12px;
  border: 1px solid var(--brd);
}
.hit-header--ok   { background:rgba(48,216,128,.08); border-color:rgba(48,216,128,.3); }
.hit-header--warn { background:rgba(240,160,48,.08); border-color:rgba(240,160,48,.3); }
.hit-logo { font-size:20px; font-weight:800; color:var(--tx); flex-shrink:0; }
.hit-bnr  { flex:1; display:flex; flex-direction:column; gap:2px; }

/* ── Feldwirtschaft ─────────────────────────────────────────── */
.fruchtfolge-grid { display:flex;gap:8px;flex-wrap:wrap;overflow-x:auto;padding:4px 0; }
.ff-item  { text-align:center;min-width:72px;background:var(--bg3);border:1px solid var(--brd);
  border-radius:8px;padding:6px 8px;flex-shrink:0; }
.ff-jahr  { font-size:10px;color:var(--mu);font-weight:700; }
.ff-frucht { font-size:12px;font-weight:700;margin:2px 0; }
.ff-sorte  { font-size:10px;color:var(--mu); }
.ff-ertrag { font-size:11px;color:var(--ac);font-weight:700; }
/* Gehaltsklassen-Chips */
.gk-chip { display:inline-flex;align-items:center;gap:6px;padding:4px 10px;
  border-radius:20px;border:1px solid var(--brd);background:var(--bg3);
  font-size:12px; }
.gk-chip span:first-child { color:var(--mu);font-size:11px; }
.gk-klasse { border-radius:4px;padding:1px 6px;color:#fff;font-size:11px;font-weight:800; }

/* ── Notizen-Modul ──────────────────────────────────────────── */
.ntz-toolbar { display:flex;flex-direction:column;gap:8px;margin-bottom:10px; }
.ntz-filter-tabs { display:flex;gap:4px;overflow-x:auto;padding-bottom:2px; }
.ntz-filter-tabs .sub-tab { flex-shrink:0; }

/* Notizkarte */
.ntz-card { background:var(--bg2);border:1px solid var(--brd);border-radius:10px;
  padding:10px;margin-bottom:8px;transition:opacity .2s; }
.ntz-card--dringend { border-left:3px solid var(--rd); }
.ntz-card--done { opacity:.55; }
.ntz-card__header { display:flex;align-items:center;gap:6px;margin-bottom:6px;flex-wrap:wrap; }
.ntz-kat   { font-size:12px;font-weight:700; }
.ntz-prio  { font-size:16px; }
.ntz-datum { margin-left:auto; }
.ntz-text  { font-size:13px;line-height:1.6;white-space:pre-wrap; }
.ntz-text--done { text-decoration:line-through;color:var(--mu); }
.ntz-link  { font-size:11px;color:var(--bl);margin-top:4px; }
.ntz-ablauf{ font-size:11px;margin-top:4px; }
.ntz-tags  { display:flex;flex-wrap:wrap;gap:4px;margin-top:6px; }
.ntz-tag   { font-size:11px;background:var(--bg3);border:1px solid var(--brd);
  border-radius:10px;padding:2px 8px;cursor:pointer; }
.ntz-tag:hover { background:var(--ac);color:#fff; }
.ntz-actions { display:flex;gap:6px;margin-top:8px;padding-top:6px;
  border-top:1px solid var(--brd); }
.btn-xs--ok { color:var(--gn) !important;border-color:var(--gn) !important; }

/* Spracheingabe */
.ntz-mic-btn { position:relative; }
.ntz-mic--active { background:var(--rd) !important;color:#fff !important;
  animation: ntz-pulse 1s infinite; }
@keyframes ntz-pulse {
  0%,100% { opacity:1; }
  50%      { opacity:.6; }
}
.ntz-sprache-preview {
  background:var(--bg3);border:1px solid var(--brd);border-radius:8px;
  padding:10px;margin-bottom:8px;min-height:40px;font-size:13px;line-height:1.6;
}

/* Tag Suggestions */
.ntz-tag-suggest { display:flex;flex-wrap:wrap;gap:4px;margin-top:4px; }

/* Sau-Suchergebnisse */
.ntz-sau-result { padding:8px;border-bottom:1px solid var(--brd);cursor:pointer;font-size:13px; }
.ntz-sau-result:hover { background:var(--bg3); }

/* ── Sammelmasken (seit 1.12.0) ───────────────────────────────────────
   Eine Zeile je Sau, fuer alle fuenf Masken gleich. Hochkant gebaut:
   [☐ Ohrmarke / Tage] [Felder] [✎], darunter Bemerkung bzw. Vorschau.
   Die Checkbox hat eine feste Spalte - vorher schob eine dreistellige
   Ohrmarke sie nach rechts. */
.sz-liste {
  border: 1px solid var(--brd); border-radius: 8px; margin: 10px 0;
  max-height: 55vh; overflow-y: auto;
}
.sz-kopf, .sz {
  display: grid; align-items: center; column-gap: 6px; padding: 7px 8px;
}
.sz-kopf { grid-template-columns: minmax(0,1fr) auto 68px; }
.sz      { grid-template-columns: minmax(0,1fr) auto auto 34px; }
.sz-kopf { margin-top: 10px; padding-bottom: 0; font-size: 11px; font-weight: 700; color: var(--mu); }
.sz-kopf .sz-felder span { width: 46px; text-align: center; }
.sz { border-top: 1px solid var(--brd); }
.sz:first-child { border-top: none; }
.sz.is-sel { background: rgba(240,160,48,.06); }

.sz-wahl {
  display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer;
  margin: 0; color: var(--tx); font-size: 14px;   /* globale label-Regel aufheben */
}
input.sz-cb { width: 22px; height: 22px; padding: 0; flex: 0 0 22px; accent-color: var(--ac); }
.sz-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sz-ohm  { font-weight: 700; font-size: 14px; }
.sz-tage { font-size: 11px; color: var(--mu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sz-felder { display: flex; gap: 4px; align-items: center; }
input.sz-zahl { width: 46px; padding: 6px 4px; text-align: center; font-size: 14px; border-radius: 6px; }
.sz-wert { width: 46px; text-align: center; font-size: 13px; color: var(--mu); }
select.sz-ergebnis { width: auto; padding: 6px; font-size: 13px; border-radius: 6px; }

/* Abweichendes Datum je Zeile.

   Das Feld selbst bleibt unsichtbar, getippt wird auf den Knopf daneben,
   der showPicker() aufruft - so erscheint der gewohnte Kalender des
   Handys, ohne dass ein volles Datumsfeld je Zeile die Breite sprengt.

   Nicht display:none und nicht visibility:hidden: Ein so verstecktes
   Feld oeffnet in manchen Browsern keinen Picker. Deshalb ein Pixel
   gross und durchsichtig. */
input.sz-datum {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  opacity: 0; border: none; pointer-events: none;
}
.sz-kal {
  visibility: hidden; min-width: 34px; height: 34px; padding: 0 5px;
  border-radius: 6px; background: transparent; color: var(--mu);
  font-size: 15px; white-space: nowrap;
}
.sz.is-sel .sz-kal { visibility: visible; }
/* Weicht der Tag ab, steht er statt des Symbols da - sichtbar, bevor
   gebucht wird, nicht erst in der Rueckmeldung. */
.sz.hat-datum .sz-kal {
  color: var(--ac); font-size: 12px; font-weight: 700;
  background: rgba(240,160,48,.12);
}

/* ✎ nur bei angehakter Sau. visibility statt display: die Spalte bleibt
   gleich breit, die Zahlenfelder springen beim Anhaken nicht. */
.sz-stift {
  visibility: hidden; width: 34px; height: 34px; border-radius: 6px;
  background: transparent; color: var(--mu); font-size: 16px; position: relative;
}
.sz.is-sel .sz-stift { visibility: visible; }
.sz.hat-notiz .sz-stift { color: var(--ac); }
.sz.hat-notiz .sz-stift::after {
  content: ''; position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--ac);
}

.sz-vorschau, .sz-bemerkung { grid-column: 1 / -1; display: none; padding-left: 32px; }
.sz.is-sel.hat-notiz:not(.is-offen) .sz-vorschau {
  display: block; font-size: 12px; color: var(--tx); opacity: .85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 2px;
}
.sz.is-sel.is-offen .sz-bemerkung { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 6px; }
.sz-bemerkung input { flex: 1; min-width: 130px; padding: 7px 9px; font-size: 13px; border-radius: 6px; }
.sz-bemerkung input.sz-anz { flex: 0 0 76px; min-width: 76px; text-align: center; }

.sz-leer { padding: 16px; font-size: 13px; color: var(--mu); text-align: center; }
.sz-hinweis { font-size: 12px; color: var(--mu); margin: 4px 0 10px; }
.sz-fuss { align-items: center; }
.sz-anzahl { margin-right: auto; font-size: 12px; color: var(--mu); }
.sz-fehlerliste { border: 1px solid var(--rd); border-radius: 8px; margin: 8px 0; }
.sz-fehler { padding: 8px 10px; font-size: 13px; border-top: 1px solid var(--brd); }
.sz-fehler:first-child { border-top: none; }
.sz-fehler strong { margin-right: 6px; }

/* ── Ereignisse in der Sauenkarte ─────────────────────────────────── */
.ev-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 0; border-bottom: 1px solid var(--brd); font-size: 12px;
}
.ev-row:last-child { border-bottom: none; }
.ev-row--offen { border-left: 2px solid var(--ac); padding-left: 6px; }
.ev-date  { color: var(--mu); flex-shrink: 0; min-width: 74px; }
.ev-typ   { font-weight: 600; flex-shrink: 0; }
.ev-notiz { color: var(--tx); flex: 1; min-width: 120px; }
.ev-eber  { color: var(--mu); font-size: 11px; }
.ev-anzahl { color: var(--tx); font-size: 12px; font-weight: 600; }
.ev-bearbeiten { margin-left: auto; }
.ev-offen {
  margin-left: auto; background: var(--ac); color: #0d1b2a;
  border-radius: 8px; padding: 1px 7px; font-size: 10px; font-weight: 700;
}
/* Zyklusfelder in der Sauenmaske */
.form-zyklus { margin-top: 8px; border-top: 1px solid var(--brd); padding-top: 8px; }
.form-zyklus summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--mu); }

/* Notiz in der Sauenkarte */
.sau-notiz {
  font-size: 13px; line-height: 1.6; white-space: pre-wrap;
  background: var(--bg3); border: 1px solid var(--brd);
  border-radius: 8px; padding: 8px 10px;
}
/* ── Bilder zu Notizen ────────────────────────────────────────────
   An main.css anhaengen. Nutzt die vorhandenen Variablen (--mu, --ac, --rd).
   ---------------------------------------------------------------- */

.ntz-bilder {
  margin: 8px 0 4px;
}

.ntz-bilder__liste {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.ntz-bild {
  position: relative;
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, .05);
}

.ntz-bild img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.ntz-bild__platz {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mu);
  font-size: 18px;
}

/* Loeschknopf: klein, aber auf dem Handy mit Handschuh noch treffbar.
   44 px waeren Pflicht fuer einen Hauptknopf - hier ist die Kachel selbst
   das Ziel, der Knopf die Ausnahme. */
.ntz-bild__weg {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.ntz-bild__weg:hover { background: var(--rd); }

.ntz-bild__gps {
  position: absolute;
  bottom: 2px;
  left: 3px;
  font-size: 11px;
  text-shadow: 0 0 3px #000;
}

.ntz-bilder__weg {
  font-size: 11px;
  color: var(--mu);
  margin: 4px 0;
}

.ntz-bild__neu {
  display: inline-block;
  cursor: pointer;
  margin-top: 2px;
}

/* Grossansicht */
.ntz-bild-gross {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.ntz-bild-gross img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 6px;
}

.ntz-bild-gross__laedt {
  color: var(--mu);
  padding: 40px 0;
}

