:root {
  --bg: #f3f0e8; --card: #fffdf8; --ink: #1d2a21; --muted: #6b756c; --line: #e2ddd0;
  --green: #2c6b3a; --green-d: #234a2c; --green-l: #e4efdf; --red: #b3372b;
  --r: 14px; --tabs: 62px; --top: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); overscroll-behavior: none; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* knoppen en velden */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; }
.btn:disabled { opacity: .6; }
.btn:active { transform: scale(.98); }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.link { background: none; border: 0; padding: 0; color: var(--green); font-weight: 600; text-decoration: underline; }
.field { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 14px 0 0; }
.field input, .field select { display: block; width: 100%; min-height: 48px; margin-top: 6px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 17px; font-weight: 400; color: var(--ink); }
.field input:focus, .field select:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two > :only-child { grid-column: 1 / -1; }
.error { color: var(--red); font-weight: 600; min-height: 22px; margin: 10px 0 6px; font-size: 15px; }
.hint, .muted, .sub { color: var(--muted); font-size: 14px; }
.hint { text-align: center; margin-top: 12px; }
.seg { display: flex; background: #e7e2d5; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: none; font-weight: 600; color: var(--muted); padding: 0 12px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.small button { min-height: 34px; font-size: 14px; }

/* inloggen */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(170deg, #dfe9d6 0%, var(--bg) 55%); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 22px; padding: 26px 22px; box-shadow: 0 10px 40px rgba(35,74,44,.14); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand b { display: block; font-size: 22px; letter-spacing: -.3px; }
.brand span { color: var(--muted); font-size: 14px; }
.auth .reg .seg { margin-top: 18px; }

/* opbouw app */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; grid-template-areas: "top" "main" "tabs"; }
.top { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(8px + var(--safe-t)) 16px 8px; background: var(--green-d); color: #fff; min-height: var(--top); }
.top-title { min-width: 0; }
.top-title b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title span { display: block; font-size: 12px; opacity: .8; }
.top-title span:empty { display: none; }
#yearSel { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 10px; min-height: 38px; padding: 0 10px; font-weight: 700; }
#yearSel option { color: #000; }
.tabs { grid-area: tabs; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; border: 0; background: none; min-height: var(--tabs); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tabs svg, .fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--green); }
.view { grid-area: main; position: relative; overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.view.pad { padding: 18px 16px 110px; }
.view.pad > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.fab { position: fixed; right: 16px; bottom: calc(var(--tabs) + var(--safe-b) + 16px); z-index: 900; display: flex; align-items: center; gap: 6px; height: 56px; padding: 0 22px 0 16px; border-radius: 28px; border: 0; background: var(--green); color: #fff; font-weight: 700; font-size: 17px; box-shadow: 0 6px 20px rgba(0,0,0,.28); }
.fab svg { stroke-width: 2.4; }

/* kaart */
#view-kaart { overflow: hidden; }
#map { position: absolute; inset: 0; background: #26302a; }
.plabel span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font: 600 12px/1 -apple-system, sans-serif; color: #fff; text-shadow: 0 0 3px #000, 0 0 6px #000; pointer-events: none; }
body.far .plabel { display: none; }
.legend { position: absolute; left: 10px; top: 10px; z-index: 500; background: rgba(255,253,248,.94); border-radius: 12px; padding: 8px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.legend b { font-size: 12px; color: var(--muted); }
i { font-style: normal; }
.legend i, .chip i, .statline i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.map-banner { position: absolute; left: 10px; right: 10px; bottom: 14px; z-index: 600; background: var(--card); border-radius: 16px; padding: 10px 10px 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.map-empty { position: absolute; left: 16px; right: 16px; top: 16px; z-index: 600; max-width: 420px; margin: 0 auto; background: var(--card); border-radius: 18px; padding: 18px; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.map-empty h2 { font-size: 20px; margin-bottom: 6px; }
.map-empty p { color: var(--muted); font-size: 15px; margin-bottom: 14px; }

/* kalender */
.bar { position: sticky; left: 0; top: 0; z-index: 5; background: var(--bg); padding: 12px 16px 8px; display: flex; flex-direction: column; gap: 10px; }
.bar .seg { align-self: flex-start; min-width: 220px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 32px; padding: 0 11px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; opacity: .45; }
.chip.on { opacity: 1; }
#view-kalender { padding-bottom: 100px; }
.cal { min-width: 780px; padding: 0 16px 0 0; }
.cal .row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.cal .rname { position: sticky; left: 0; z-index: 3; flex: none; width: 132px; padding: 0 8px 0 16px; background: var(--bg); border: 0; text-align: left; font-size: 13px; font-weight: 600; min-height: 34px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .track { position: relative; flex: 1; min-height: 34px; }
.cal .head { position: sticky; top: 0; z-index: 4; background: var(--bg); border-bottom: 1px solid #cfc9b8; }
.cal .head .rname { min-height: 26px; z-index: 5; }
.cal .months { min-height: 26px; }
.cal .months span { position: absolute; top: 4px; padding-left: 5px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.cal .track u { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.cal .track u.now { background: var(--red); width: 2px; opacity: .55; }
.cal .mark { position: absolute; top: 6px; bottom: 6px; border: 0; padding: 0; border-radius: 5px; box-shadow: 0 0 0 1.5px var(--bg); z-index: 2; }
.cal .mark.span { opacity: .85; z-index: 1; }
.cal .mark::after { content: ""; position: absolute; inset: -8px -6px; }

/* lijsten */
.list { padding: 0 16px; max-width: 860px; margin: 0 auto; }
.sheet .list { padding: 0; margin-top: 18px; }
.list h3 { font-size: 14px; color: var(--muted); margin: 18px 0 6px; text-transform: uppercase; letter-spacing: .4px; }
.arow { display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; margin-bottom: 6px; }
.arow > i { flex: none; width: 12px; height: 12px; border-radius: 4px; margin-top: 5px; }
.arow b { font-weight: 600; }
.arow small { color: var(--muted); font-size: 13px; }
.arow em { display: block; font-style: normal; color: var(--muted); font-size: 14px; }
.empty { text-align: center; padding: 48px 24px; color: var(--muted); max-width: 440px; margin: 0 auto; }
.empty h2 { color: var(--ink); font-size: 22px; margin-bottom: 8px; }
.empty .btn { margin-top: 20px; }

/* percelen */
.headline { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.headline h1 { font-size: 26px; letter-spacing: -.4px; }
.headline p { color: var(--muted); font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.card { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.card-top b { font-size: 17px; }
.card-top span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.statline { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 14px; }
.statline.big { margin: 10px 0 16px; font-size: 15px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.panel h3 { font-size: 17px; margin-bottom: 6px; }
.panel p { font-size: 15px; }
.panel .muted { margin-top: 10px; }
.code { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.code b { font: 700 24px/1 ui-monospace, Menlo, monospace; letter-spacing: 3px; background: var(--green-l); padding: 12px 16px; border-radius: 12px; }

/* venster van onder */
.sheet-back { position: fixed; inset: 0; z-index: 2000; background: rgba(20,30,22,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92%; background: var(--bg); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 6px 20px; }
.sheet-head h2 { font-size: 21px; letter-spacing: -.3px; }
.x { width: 44px; height: 44px; border-radius: 22px; border: 0; background: #e7e2d5; font-size: 24px; line-height: 1; }
.sheet-body { overflow: auto; padding: 4px 20px calc(24px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.typegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.typegrid button { display: flex; align-items: center; gap: 9px; min-height: 46px; padding: 0 12px; text-align: left; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-weight: 600; font-size: 15px; }
.typegrid button i { flex: none; width: 14px; height: 14px; border-radius: 5px; background: var(--c); }
.typegrid button.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); }
.fieldhead { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 18px 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.unitgrid { display: flex; flex-wrap: wrap; gap: 6px; max-height: 190px; overflow: auto; padding: 2px; }
.unitgrid button { min-height: 38px; padding: 0 12px; border-radius: 19px; border: 1.5px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; }
.unitgrid button.on { background: var(--green); border-color: var(--green); color: #fff; }
.sheet .btn.big { margin-top: 8px; }
.pick { display: flex; flex-wrap: wrap; gap: 6px; }
.pick button { min-height: 42px; padding: 0 16px; border-radius: 21px; border: 1.5px solid var(--line); background: var(--card); font-size: 15px; font-weight: 600; }
.pick button::first-letter { text-transform: uppercase; }
.pick button.on { background: var(--green); border-color: var(--green); color: #fff; }
.detail { display: flex; gap: 14px; margin: 8px 0 6px; }
.detail .dot { flex: none; width: 8px; border-radius: 4px; }
dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 16px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; }
details.more { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
details.more summary { font-weight: 600; color: var(--green); cursor: pointer; min-height: 32px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs) + var(--safe-b) + 84px); transform: translateX(-50%); z-index: 3000; max-width: calc(100% - 32px); background: #1d2a21; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.3); text-align: center; }
.toast button { margin-left: 10px; background: none; border: 0; color: #ffe14d; font-weight: 700; text-decoration: underline; }

/* groot scherm: menu links, kalender past zonder schuiven */
@media (min-width: 900px) {
  .app { grid-template-columns: 96px 1fr; grid-template-rows: auto 1fr; grid-template-areas: "top top" "tabs main"; }
  .tabs { flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--line); padding-top: 10px; }
  .tabs button { flex: none; min-height: 72px; }
  .fab { bottom: 24px; right: 24px; }
  .toast { bottom: 96px; }
  .sheet-back { align-items: center; }
  .sheet { border-radius: 22px; max-height: 88%; }
  .cal { min-width: 0; }
  .cal .rname { width: 180px; }
  .bar { flex-direction: row; align-items: center; }
}

@media print {
  .top, .tabs, .fab, .bar, .toast, .sheet-back { display: none !important; }
  .app, .view { display: block; height: auto; overflow: visible; }
  body { background: #fff; }
  .arow { break-inside: avoid; border-color: #ccc; }
  .arow > i { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
