:root {
  --forest: #1d3b2a;
  --forest-2: #2b5239;
  --leaf: #3f7d3a;
  --leaf-l: #edf3ea;
  --sand: #c9a86a;
  --vetten: #3f7d3a;
  --zaaien: #a2731f;
  --spuiten: #2f6690;
  --bg: #f4f2ec;
  --card: #fff;
  --text: #1c241e;
  --muted: #6b6f66;
  --line: #e3e0d6;
  --danger: #b3261e;
  --radius: 10px;
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--leaf); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: .005em; line-height: 1.2; }
h1 { font-size: 1.75rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.ic { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex-shrink: 0; }
.eyebrow { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Bovenbalk ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--forest); color: #fff; padding: 0 1.25rem; height: 60px;
  padding-top: env(safe-area-inset-top); box-sizing: content-box;
}
.topbar a { color: rgba(255,255,255,.82); text-decoration: none; }
.topbar a:hover { color: #fff; }
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; letter-spacing: .02em; color: #fff !important; }
.brand img { width: 32px; height: 32px; }
.mainnav { display: flex; gap: .25rem; flex: 1; height: 100%; }
.mainnav a { display: flex; align-items: center; gap: .45rem; padding: 0 .85rem; font-weight: 500; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.mainnav a.active { color: #fff; border-bottom-color: var(--sand); }
.userbox { display: flex; gap: 1.1rem; align-items: center; }
.userbox a { display: flex; align-items: center; gap: .45rem; }
.userbox a.active { color: #fff; }

/* Tabbalk onderaan (gsm) */
.tabbar { display: none; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 2rem; }

/* ---------- Fotobanner ---------- */
.hero {
  position: relative; color: #fff; background: var(--forest) center / cover no-repeat;
  min-height: 230px; display: flex; align-items: flex-end;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(14,30,21,.15) 0%, rgba(14,30,21,.45) 55%, rgba(14,30,21,.85) 100%);
}
.hero-inner { position: relative; width: 100%; max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem; }
.hero h1 { margin: 0 0 .2rem; font-size: 2.1rem; }
.hero p { margin: 0; color: rgba(255,255,255,.85); }
.hero .eyebrow { color: rgba(255,255,255,.75); }
.hero-stats { display: flex; gap: 2.5rem; margin-top: 1.1rem; flex-wrap: wrap; }
.hero-stats .v { font-family: var(--font-head); font-size: 1.8rem; font-weight: 600; line-height: 1; }
.hero-stats .l { font-size: .82rem; color: rgba(255,255,255,.75); margin-top: .25rem; }
.hero-sm { min-height: 150px; }
.hero-sm h1 { font-size: 1.6rem; }

/* ---------- Kaarten, knoppen, formulieren ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--forest); border-radius: 8px; padding: .55rem 1rem; font: inherit; font-weight: 600;
  background: var(--forest); color: #fff; cursor: pointer; text-decoration: none; line-height: 1.3;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--forest-2); border-color: var(--forest-2); }
.btn-sec { background: #fff; color: var(--text); border-color: #cfcbbf; }
.btn-sec:hover { background: #f7f6f1; border-color: #b9b5a8; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); padding: .35rem; }
.btn-ghost:hover { background: #efede6; border-color: transparent; color: var(--text); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e4b6b2; }
.btn-danger:hover { background: #fbeeed; border-color: var(--danger); }
.btn-sm { padding: .35rem .7rem; font-size: .875rem; }
.btn-big { width: 100%; padding: .95rem 1rem; font-size: 1.1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn + .btn { margin-left: -1px; }

label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .95rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search],
select, textarea {
  width: 100%; font: inherit; padding: .6rem .75rem; border: 1px solid #cfcbbf; border-radius: 8px;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--leaf); outline-offset: -1px; border-color: var(--leaf); }
textarea { min-height: 70px; resize: vertical; }
.form-row { margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: .95rem; margin-top: .15rem; }
.back { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; text-decoration: none; margin-bottom: .6rem; }

.flash { display: flex; gap: .6rem; align-items: center; padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1.25rem; font-weight: 500; border: 1px solid; }
.flash-ok { background: #eef5ea; color: #24502a; border-color: #cfe3c8; }
.flash-err { background: #fbeeed; color: #8c1d18; border-color: #efc9c5; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 4px; font-size: .72rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; border: 1px solid;
}
.b-vetten { color: var(--vetten); background: #eef5ec; border-color: #cfe2ca; }
.b-zaaien { color: var(--zaaien); background: #faf3e6; border-color: #ead8b3; }
.b-spuiten { color: var(--spuiten); background: #ebf2f8; border-color: #c7d9e8; }
.b-grey { color: var(--muted); background: #f2f1ec; border-color: var(--line); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: 0; margin-right: .45rem; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); white-space: nowrap; }
th a { color: inherit; text-decoration: none; }
tbody tr:hover { background: #faf9f5; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; width: 1%; }
tr.inactive td { opacity: .5; }
.card > .table-wrap:first-child, .card > table:first-child { margin: -.5rem -.7rem; }

/* ---------- Statistieken ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .v { font-family: var(--font-head); font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: .4rem; }
.stat.t-vetten { border-top: 3px solid var(--vetten); }
.stat.t-zaaien { border-top: 3px solid var(--zaaien); }
.stat.t-spuiten { border-top: 3px solid var(--spuiten); }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; align-items: end; }
.filters label { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--forest); border-bottom-color: var(--forest); }

/* ---------- Kaart ---------- */
.map { height: 540px; border-radius: var(--radius); overflow: hidden; z-index: 1; border: 1px solid var(--line); }
.map-sm { height: 260px; }
.leaflet-container { font: inherit; }
.leaflet-tooltip.field-label {
  background: rgba(20,30,22,.72); color: #fff; border: 0; box-shadow: none; font-weight: 600; padding: 2px 7px; border-radius: 4px;
}
.leaflet-tooltip.field-label::before { display: none; }
.layout-map { display: grid; grid-template-columns: 1fr 380px; gap: 1.25rem; align-items: start; }

/* ---------- Invoerscherm ---------- */
.entry { max-width: 560px; margin: 0 auto; }
.step { margin-top: 1.4rem; }
.step-title { display: block; font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
.type-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.type-choice input { position: absolute; opacity: 0; pointer-events: none; }
.type-choice label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
  padding: 1rem .3rem .85rem; border-radius: var(--radius); background: #fff; border: 1px solid #cfcbbf;
  font-size: 1rem; font-weight: 600; cursor: pointer; margin: 0; color: var(--text);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.type-choice label .ic { width: 28px; height: 28px; stroke-width: 1.6; }
.type-choice .t-vetten .ic { color: var(--vetten); }
.type-choice .t-zaaien .ic { color: var(--zaaien); }
.type-choice .t-spuiten .ic { color: var(--spuiten); }
.type-choice input:checked + label { border-color: var(--forest); background: var(--leaf-l); box-shadow: inset 0 0 0 1px var(--forest); }
.type-choice input:focus-visible + label { outline: 2px solid var(--leaf); outline-offset: 2px; }

.entry select, .entry input[type=text], .entry input[type=date] { font-size: 1.1rem; padding: .75rem .85rem; }
.amount-wrap { position: relative; }
.amount-wrap .unit {
  position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
  font-weight: 600; color: var(--muted); font-size: 1.1rem; pointer-events: none;
}
.entry .amount-wrap input { padding-right: 3rem; font-size: 1.6rem; font-weight: 600; font-family: var(--font-head); }
.calc { margin-top: .4rem; color: var(--leaf); font-weight: 600; min-height: 1.4em; font-size: .95rem; }
.gps-btn { width: 100%; margin-bottom: .5rem; }
.gps-msg { display: flex; gap: .45rem; align-items: flex-start; font-size: .95rem; margin: 0 0 .6rem; }
.gps-msg:empty { display: none; }
.gps-msg.ok { color: var(--leaf); }
.gps-msg.warn { color: #8a5a00; }
.gps-msg.err { color: var(--danger); }
.field-hint { margin-top: .4rem; font-size: .875rem; color: var(--muted); }
.quick-dates { display: flex; margin-top: .5rem; }
.quick-dates .btn { flex: 1; }
details.more summary { cursor: pointer; color: var(--leaf); font-weight: 600; padding: .5rem 0; font-size: .95rem; list-style: none; display: flex; align-items: center; gap: .4rem; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; display: inline-block; width: 1em; text-align: center; }
details.more[open] summary::before { content: "–"; }
.success-box { text-align: center; padding: 2rem 1.25rem; }
.success-box .ok-ic { width: 52px; height: 52px; color: var(--leaf); stroke-width: 1.6; }
.success-box h2 { font-size: 1.5rem; margin: .5rem 0 .75rem; }
.summary-line { font-size: 1.05rem; margin-bottom: 1.25rem; }
.recent-list { list-style: none; padding: 0; margin: 0; }
.recent-list li { padding: .7rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .75rem; align-items: center; }
.recent-list li:last-child { border-bottom: 0; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  background: #0f1f16 url("img/sproeien-sm.jpg") 22% center / cover no-repeat;
  position: relative;
}
@media (min-width: 900px) { .login-page { background-image: url("img/sproeien.jpg"); } }
.login-page::before { content: ""; position: fixed; inset: 0; background: linear-gradient(180deg, rgba(10,22,15,.35), rgba(10,22,15,.75)); }
.login-page .wrap { position: relative; width: 100%; max-width: 420px; }
.login-card { padding: 2rem 1.75rem; border: 0; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.login-brand img { width: 46px; height: 46px; }
.login-brand h1 { margin: 0; font-size: 1.6rem; }
.login-brand p { margin: 0; color: var(--muted); font-size: .9rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.login-foot { position: relative; text-align: center; color: rgba(255,255,255,.7); font-size: .85rem; margin-top: 1rem; }

/* ---------- Veldpagina ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 120px 1fr auto; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .note { display: flex; gap: .4rem; align-items: flex-start; margin-top: .2rem; font-size: .9rem; color: var(--muted); }

.admin-links { display: none; }

/* ---------- Responsief ---------- */
@media (max-width: 1100px) {
  .mainnav a span { display: none; }
  .mainnav a { padding: 0 .7rem; }
}
@media (max-width: 960px) {
  .layout-map { grid-template-columns: 1fr; }
  .map { height: 420px; }
}
@media (max-width: 720px) {
  body.has-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .wrap { padding: 1rem .9rem 1.5rem; }
  .topbar { height: 52px; padding-left: .9rem; padding-right: .9rem; }
  .mainnav { display: none; }
  .topbar .brand { flex: 1; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem;
    padding: .55rem 0 .5rem; font-size: .72rem; font-weight: 600; color: var(--muted); text-decoration: none;
    border-top: 2px solid transparent; margin-top: -1px;
  }
  .tabbar a .ic { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--forest); border-top-color: var(--forest); }
  .admin-links { display: block; }
  h1 { font-size: 1.45rem; }
  .hero { min-height: 170px; }
  .hero h1 { font-size: 1.6rem; }
  .hero-inner { padding: 1.1rem .9rem; }
  .hero-stats { gap: 1.5rem; }
  .hero-stats .v { font-size: 1.4rem; }
  .hero-sm { min-height: 110px; }
  .hide-sm { display: none !important; }
  .card { padding: 1rem; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; padding: .7rem 0; border-bottom: 1px solid var(--line); }
  table.responsive tr:last-child { border-bottom: 0; }
  table.responsive td { display: block; border: 0; padding: .1rem 0; text-align: left; }
  table.responsive td.num { text-align: left; }
  table.responsive td.actions { text-align: left; width: auto; padding-top: .3rem; }
  table.responsive td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .85rem; }
  .timeline li { grid-template-columns: 1fr auto; gap: .2rem 1rem; }
  .timeline li > :first-child { grid-column: 1 / -1; }
}

/* ---------- Verfijningen ---------- */
input[type=checkbox], input[type=radio] { accent-color: var(--forest); }
.filter-box > summary { display: none; }
.filter-box > summary::-webkit-details-marker { display: none; }
@media (max-width: 720px) {
  .hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .stat { padding: .75rem .9rem; }
  .stat .v { font-size: 1.4rem; }
  .filter-box { padding: 0; }
  .filter-box > summary {
    display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem;
    font-weight: 600; cursor: pointer; list-style: none;
  }
  .filter-box > summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; }
  .filter-box[open] > summary::after { content: "–"; }
  .filter-box .filters { padding: 0 1rem 1rem; }
  /* Registraties compact als kaartjes */
  table.compact tr { display: grid; grid-template-columns: 1fr auto; grid-auto-flow: dense; gap: .1rem .75rem; }
  table.compact td { padding: 0; }
  table.compact td[data-l]::before { content: none; }
  table.compact td.c-date { grid-column: 1; font-size: .85rem; color: var(--muted); }
  table.compact td.c-type { grid-column: 2; grid-row: 1; text-align: right; }
  table.compact td.c-field { grid-column: 1; font-weight: 600; }
  table.compact td.c-amount { grid-column: 2; text-align: right; }
  table.compact td.c-product { grid-column: 1; font-size: .9rem; }
  table.compact td.c-perha { grid-column: 2; text-align: right; font-size: .85rem; color: var(--muted); }
  table.compact td.c-user { grid-column: 1; font-size: .85rem; color: var(--muted); }
  table.compact td.c-notes { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }
  table.compact td.c-notes:empty { display: none; }
  table.compact td.actions { grid-column: 2; grid-row: 4; text-align: right; padding: 0; }
}
.layout-map > * { min-width: 0; }

/* ---------- Teelten (oogst) ---------- */
.harvest-form { background: #faf9f5; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.cycle-totals { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .875rem; color: var(--muted); padding: .2rem 0 .6rem; }
details.cycle { border-top: 1px solid var(--line); }
details.cycle:first-of-type { border-top: 0; }
details.cycle > summary {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 0; cursor: pointer; list-style: none;
}
details.cycle > summary::-webkit-details-marker { display: none; }
details.cycle > summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; margin-left: .5rem; }
details.cycle[open] > summary::after { content: "–"; }
.cycle-title { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; }
.cycle-title .ic { color: var(--muted); }
details.cycle > summary .small { margin-left: auto; }
.cycle-body { padding-bottom: 1rem; }
