/* Düngerplan – schlichtes, ruhiges Arbeitswerkzeug */
:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #f0efe8;
  --line: #e1dfd5;
  --line-strong: #c9c6b8;
  --text: #24261f;
  --muted: #6e7065;
  --accent: #3d7a3a;
  --accent-ink: #ffffff;
  --accent-soft: #e5efdf;
  --danger: #b4412f;
  --ok: #3d7a3a;
  --ok-bg: #e3efdc;
  --under: #a35c00;
  --under-bg: #fbecd2;
  --over: #2b5f9e;
  --over-bg: #dfe9f6;
  --focus: #6a9f3c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 32, 20, .06), 0 2px 8px rgba(30, 32, 20, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #181a16;
    --surface: #21241f;
    --surface-2: #2a2e27;
    --line: #353a31;
    --line-strong: #4a5044;
    --text: #e7e8e1;
    --muted: #9da196;
    --accent: #79b66f;
    --accent-ink: #10200e;
    --accent-soft: #2a3a27;
    --danger: #e0806f;
    --ok: #8cc982;
    --ok-bg: #263a23;
    --under: #f0b35e;
    --under-bg: #3d2f19;
    --over: #8fb6ec;
    --over-bg: #1f2e42;
    --focus: #9bd07a;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #181a16; --surface: #21241f; --surface-2: #2a2e27; --line: #353a31; --line-strong: #4a5044;
  --text: #e7e8e1; --muted: #9da196; --accent: #79b66f; --accent-ink: #10200e; --accent-soft: #2a3a27;
  --danger: #e0806f; --ok: #8cc982; --ok-bg: #263a23; --under: #f0b35e; --under-bg: #3d2f19;
  --over: #8fb6ec; --over-bg: #1f2e42; --focus: #9bd07a; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p { margin: .25rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.strong { font-weight: 600; }
.inline { display: inline; }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem max(16px, calc((100vw - 1320px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand svg { width: 24px; height: 24px; fill: var(--accent); }
.brand .vein { stroke: var(--surface); stroke-width: 2; fill: none; }
.topbar nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.topbar nav a, .linkbtn {
  padding: .4rem .7rem; border-radius: 8px; color: var(--muted); font: inherit; background: none; border: 0; cursor: pointer;
}
.topbar nav a.on { color: var(--text); background: var(--surface-2); }
.topbar nav a:hover, .linkbtn:hover { color: var(--text); text-decoration: none; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.crumbs { display: flex; gap: .4rem; font-size: .85rem; color: var(--muted); margin-bottom: .5rem; flex-wrap: wrap; }
.crumbs .sep:last-child { display: none; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.eyebrow { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15rem; }
.tag { font-size: .8rem; font-weight: 500; background: var(--accent-soft); color: var(--accent); padding: .15rem .5rem; border-radius: 99px; vertical-align: middle; }
.sectionhead { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.narrowcard { max-width: 460px; }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--under-bg); color: var(--danger); }

/* Buttons & Felder */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger, .icon.danger { color: var(--danger); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.icon {
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: .2rem .35rem; border-radius: 6px;
}
.icon:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon:disabled { opacity: .3; cursor: default; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 99px; padding: .2rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; color: var(--text); }
.chip:hover { background: var(--accent-soft); }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; margin-top: .75rem; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 7px; padding: .45rem .55rem; width: 100%; min-width: 0;
}
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .45rem; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.quick { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

.profil-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.profil-grid .card { margin: 0; }
.betriebe tr.aktiv td { background: var(--accent-soft); }

/* Superadmin im fremden Betrieb */
.einstieg { display: flex; justify-content: center; align-items: center; gap: .8rem; flex-wrap: wrap;
  background: var(--under-bg); color: var(--under); padding: .5rem 1rem; font-size: .9rem; border-bottom: 1px solid var(--line); }
.einstieg strong { color: var(--text); }

/* Login */
.login .switch-link { text-align: center; font-size: .9rem; margin: .8rem 0 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.login { max-width: 380px; margin: 8vh auto 0; padding: 1.6rem; }
.login h1 { margin-bottom: .5rem; }

/* Planübersicht */
.plan-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.plan-card { display: flex; flex-direction: column; gap: .6rem; margin: 0; }
.plan-link { display: flex; justify-content: space-between; align-items: baseline; color: var(--text); }
.plan-link:hover { text-decoration: none; }
.plan-link:hover .plan-name { color: var(--accent); }
.plan-name { font-size: 1.4rem; font-weight: 700; }
.plan-year { color: var(--muted); font-size: .85rem; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0; }
.facts div { background: var(--surface-2); border-radius: 8px; padding: .4rem .55rem; }
.facts dt { font-size: .75rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

/* Dialoge */
.dlg { border: 1px solid var(--line); border-radius: 12px; padding: 1.3rem; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
.dlg::backdrop { background: rgba(20, 22, 15, .4); }
.dlg h2 { margin: 0; }
.dlg.dlg-wide { width: min(760px, calc(100vw - 32px)); }

/* Hinweis Demoversion */
.demo-hinweis {
  background: var(--under-bg); color: var(--under); border: 1px solid currentColor; border-radius: 10px;
  padding: .6rem .9rem; margin-bottom: 1rem; font-size: .92rem; line-height: 1.45;
}
.demo-hinweis strong { text-transform: uppercase; letter-spacing: .04em; margin-right: .2rem; }
@media print { .demo-hinweis { display: none; } }

/* Video-Anleitung auf der Planübersicht */
.video-band {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem;
  padding: 1rem 1.2rem; border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 75%);
}
.video-play {
  flex: none; width: 3.4rem; height: 3.4rem; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  transition: transform .15s;
}
.video-play:hover { transform: scale(1.06); }
.video-play svg { width: 1.6rem; height: 1.6rem; fill: #fff; margin-left: .2rem; }
.video-text { flex: 1 1 16rem; display: flex; flex-direction: column; gap: .15rem; }
.video-text strong { font-size: 1.1rem; }
.video-text span { color: var(--muted); font-size: .9rem; }
.dlg.dlg-video { width: min(960px, calc(100vw - 32px)); }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; margin-top: .6rem; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@media print { .video-band { display: none; } }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .4rem; }
.dlg-head h2 { font-size: 1.1rem; }
.grid.tab12 thead th { white-space: normal; vertical-align: bottom; }
.grid.tab12 thead th:last-child { width: 9rem; }
.grid.tab12 thead th.ton { white-space: nowrap; width: 6.5rem; }
.tab12 tr.on td { background: var(--accent-soft); font-weight: 600; }
.info-btn {
  display: inline-grid; place-items: center; width: 1.15rem; height: 1.15rem; margin-left: .3rem; padding: 0; vertical-align: 1px;
  border-radius: 50%; border: 1px solid var(--accent); background: none; color: var(--accent);
  font: italic 700 .72rem/1 Georgia, serif; cursor: pointer;
}
.info-btn:hover { background: var(--accent); color: #fff; }

/* Tabellen */
.tablewrap { overflow-x: auto; margin: 0 -.2rem; padding: 0 .2rem; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid th, .grid td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.grid thead th { font-size: .78rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.grid th.grp { text-align: center; border-bottom: 1px solid var(--line); }
.grid .num { text-align: right; white-space: nowrap; }
.grid tfoot td, .grid tr.total td { font-weight: 700; border-top: 1px solid var(--line-strong); }
.grid tr.sub td { font-weight: 600; background: var(--surface-2); }
.grid tr.dim td { color: var(--muted); }
.grid.narrow { max-width: 620px; }
.grid input.cell { width: 6.5em; text-align: right; padding: .3rem .4rem; }
.grid td.num input.cell { margin-left: auto; display: block; }
.crops tbody tr.rowlink { cursor: pointer; }
.crops tbody tr.rowlink:hover td { background: var(--surface-2); }
.rowactions { white-space: nowrap; text-align: right; }
.kontrolle input.cell { width: 5.5em; }

/* Kulturen mit Schlägen */
.crops tr.kulturkopf td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--line-strong); }
.crops tr.kulturkopf td .tag { font-size: .7rem; margin-left: .3rem; }
.crops tr.schlag td:nth-child(2) { padding-left: 1.6rem; position: relative; }
.crops tr.schlag td:nth-child(2)::before { content: "↳"; position: absolute; left: .6rem; color: var(--muted); }
.crops tr.hinweis td { border-bottom: 1px solid var(--line); padding-top: 0; }
.icon.add { color: var(--accent); font-weight: 700; }
.umwandeln { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
  background: var(--under-bg); color: var(--under); border-radius: 8px; padding: .55rem .8rem; margin-bottom: .8rem; font-size: .9rem; }
.schlagliste { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.schlagliste li { background: var(--surface-2); border-radius: 8px; padding: .3rem .65rem; }
/* Saldo-Status */
.saldo { font-weight: 600; }
.s-ok { color: var(--ok); }
.s-unter { color: var(--under); background: var(--under-bg); }
.s-ueber { color: var(--over); background: var(--over-bg); }
td.s-ok { background: var(--ok-bg); }
.legend { display: flex; gap: .4rem 1rem; flex-wrap: wrap; align-items: center; color: var(--muted); margin-top: .6rem; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: -.6rem; vertical-align: -1px; }
.dot.s-ok { background: var(--ok); }
.dot.s-unter { background: var(--under); }
.dot.s-ueber { background: var(--over); }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.stamm input:not([type=checkbox]), .stamm select { padding: .3rem .4rem; }
.stamm .c-name input, .stamm .c-label input { min-width: 14em; }
.stamm .c-bemerkung input { min-width: 12em; }
.stamm .c-sortierung input { width: 3.5em; }
.stamm tr.newrow td { background: var(--surface-2); }
.stamm td.num input.cell { width: 6em; }
.grid .center { text-align: center; }

/* Teilplan */
.details .fields { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); align-items: end; }
.details .w2 { grid-column: span 2; }
.stat { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); padding-bottom: .35rem; }
.stat strong { color: var(--text); font-size: 1.15rem; }
.warnings { margin: .6rem 0 0; padding: 0; list-style: none; }
.warnings li { color: var(--under); background: var(--under-bg); padding: .35rem .6rem; border-radius: 6px; font-size: .88rem; margin-top: .3rem; }
.savestate { font-size: .85rem; color: var(--ok); margin-right: .5rem; }
.savestate.busy { color: var(--muted); }
.savestate.err { color: var(--danger); }

.sheet { min-width: 860px; }
.sheet col.c-label { width: 26%; }
.sheet col.c-input { width: 42%; }
.sheet col.c-n { width: 8%; }
.sheet tr.sect th {
  background: var(--accent-soft); color: var(--accent); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .45rem .6rem; border-bottom: 0;
}
.sheet tbody + tbody tr.sect th { border-top: .6rem solid var(--surface); }
.sheet td .hint { display: block; font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.sheet td .hint.warn { color: var(--under); }
.sheet .korr td { vertical-align: top; }
.sheet .korr td > select, .sheet .korr td > input { margin-bottom: .3rem; }
.inline-fields { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .3rem; }
.mini-l { font-size: .78rem; }
.mini-l input.cell { width: 5.5em; }
.mini-l select { padding: .3rem .4rem; }
.mini-l.row { flex-direction: row; align-items: center; gap: .5rem; }

/* Schalter (Checkbox als Switch) */
.switch { flex-direction: row; align-items: center; gap: .55rem; color: var(--text); font-size: .85rem; cursor: pointer; width: fit-content; }
.switch input {
  appearance: none; -webkit-appearance: none; width: 2.3rem; height: 1.3rem; padding: 0; margin: 0; flex: none;
  border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface-2); position: relative; cursor: pointer;
  transition: background .15s;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.3rem - 6px); height: calc(1.3rem - 6px);
  border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s;
}
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(1rem); background: #fff; }
.sheet tr.faktor .inline-fields { flex-wrap: nowrap; }
.sheet tr.faktor .mini-l { flex: 1 1 0; min-width: 0; }
.sheet tr.colhead td { font-size: .75rem; color: var(--muted); padding-top: .55rem; padding-bottom: .15rem; border-bottom: 0; }
.drow td { vertical-align: middle; }
.drow select { padding: .35rem .45rem; }
.rowfields { display: flex; gap: .75rem; align-items: center; }
.rowfields input.cell { flex: none; }
.rowfields .icon { margin-left: auto; }
.saldo-row td { font-size: 1rem; }
.sheet tr.sect th.num { text-align: right; }
.sheet tr.grand td { background: var(--accent-soft); }

@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  .details .w2 { grid-column: span 1; }
  .details .fields { grid-template-columns: 1fr 1fr; }
  .pagehead .actions { width: 100%; }
}

/* Druck: A4 quer, ohne Bedienelemente */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  :root { --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --line: #ccc; --line-strong: #888; --text: #000; --muted: #555; }
  body { font-size: 10pt; }
  .topbar, .crumbs, .noprint, .btn, .icon, .flash, .legend, .tabs, select.mini, .savestate, tr.tpl { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; margin-bottom: 6mm; break-inside: avoid; }
  input, select, textarea { border: 0; background: none !important; padding: 0; appearance: none; -webkit-appearance: none; color: #000 !important; }
  .sheet { min-width: 0; }
  .tablewrap { overflow: visible; }
  .grid th, .grid td { padding: 2px 4px; }
  .s-unter, .s-ueber, td.s-ok { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
