:root {
  color-scheme: light;
  --green: #174a3b;
  --green-2: #236451;
  --green-soft: #e9f2ee;
  --ink: #17211e;
  --muted: #63706c;
  --line: #d8dfdc;
  --panel: #ffffff;
  --bg: #f3f6f5;
  --danger: #a72b2b;
  --danger-soft: #fbeaea;
  --shadow: 0 10px 30px rgba(20, 50, 40, .10);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); padding-bottom: 92px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
.hidden, .role-hidden { display: none !important; }

input, textarea, select {
  width: 100%;
  border: 1px solid #cbd5d1;
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
  transition: border .2s, box-shadow .2s;
}
input:focus, textarea:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 4px rgba(35, 100, 81, .12); }
textarea { resize: vertical; }

button, .file-button, .button-link {
  border: 0;
  border-radius: 13px;
  padding: 12px 16px;
  font-weight: 800;
  text-decoration: none;
}
button:disabled { opacity: .58; cursor: wait; }
.primary { background: var(--green); color: white; }
.primary:active { background: var(--green-2); }
.secondary { background: var(--green-soft); color: var(--green); }
.ghost { background: transparent; color: var(--green); }
.danger { background: var(--danger-soft); color: var(--danger); }
.button-link { display: inline-flex; align-items: center; justify-content: center; margin-top: 16px; }
.compact-button { padding: 10px 13px; }
.icon-button { width: 48px; height: 48px; padding: 0; font-size: 27px; }

.eyebrow { margin: 0; color: var(--green-2); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
.muted { color: var(--muted); line-height: 1.5; }
.alert { padding: 13px 15px; border-radius: 13px; line-height: 1.45; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.success { background: var(--green-soft); color: var(--green); }

/* Inloggen en installeren */
.login-page, .install-page { min-height: 100vh; padding: 24px; display: grid; place-items: center; }
.login-card, .install-card {
  width: min(520px, 100%);
  padding: clamp(24px, 5vw, 42px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 24px 70px rgba(20, 50, 40, .16);
}
.login-card h1, .install-card h1 { margin: 6px 0 10px; font-size: clamp(28px, 6vw, 42px); }
.brand-mark { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 22px; border-radius: 19px; background: var(--green); color: white; font-size: 31px; font-weight: 900; }
.login-form, .install-form { display: grid; gap: 15px; margin-top: 24px; }
.login-form label, .install-form label { display: grid; gap: 7px; font-weight: 800; }
.install-shell { width: min(850px, 100%); }
.install-card { width: 100%; }
.install-form fieldset { margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 17px; display: grid; gap: 15px; }
.install-form legend { padding: 0 8px; color: var(--green); font-weight: 900; }

/* App */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: calc(16px + env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 16px max(22px, env(safe-area-inset-left));
  background: rgba(243, 246, 245, .94);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(216, 223, 220, .85);
}
.app-header h1 { margin: 2px 0 0; font-size: clamp(24px, 4vw, 36px); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-status-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.connection-status { padding: 5px 9px; border-radius: 999px; font-size: 12px; }
.connection-status.connecting { background: #fff4d5; color: #775b00; }
.connection-status.online { background: var(--green-soft); color: var(--green); }
.connection-status.offline { background: var(--danger-soft); color: var(--danger); }
.user-badge { color: var(--muted); font-size: 12px; font-weight: 700; }

main { width: min(1020px, 100%); margin: 0 auto; padding: 22px; }
.search-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); }
.search-panel > label { display: block; margin-bottom: 8px; font-weight: 800; }
.search-row { display: flex; gap: 10px; }
#searchInput { font-size: 18px; }
.stats { margin-top: 12px; color: var(--muted); font-size: 14px; }

.card-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.item-card { display: grid; grid-template-columns: 132px 1fr; min-height: 154px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 19px; box-shadow: 0 5px 20px rgba(20, 50, 40, .07); text-align: left; padding: 0; color: inherit; }
.item-card:hover { border-color: #b8c9c2; transform: translateY(-1px); }
.card-image { min-height: 154px; background: linear-gradient(145deg, #dae7e2, #eef4f1); display: grid; place-items: center; overflow: hidden; }
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-placeholder { font-size: 35px; opacity: .55; }
.card-body { padding: 15px; min-width: 0; }
.card-article { color: var(--green-2); font-weight: 900; letter-spacing: .04em; }
.card-title { margin: 6px 0 14px; font-size: 17px; line-height: 1.28; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.location-badge { display: inline-flex; gap: 7px; align-items: center; max-width: 100%; padding: 7px 10px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 14px; font-weight: 800; }
.location-badge span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { margin-top: 10px; color: var(--muted); font-size: 12px; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state h2 { color: var(--ink); }
.empty-icon { font-size: 56px; }

.bottom-nav {
  --nav-count: 4;
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(620px, calc(100% - 24px));
  display: grid;
  grid-template-columns: repeat(var(--nav-count), 1fr);
  padding: 8px;
  background: rgba(255,255,255,.95);
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: 0 14px 40px rgba(20,50,40,.20);
  backdrop-filter: blur(18px);
}
.nav-button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px; background: transparent; color: var(--muted); font-size: 20px; }
.nav-button span { font-size: 11px; }
.nav-button.active { color: var(--green); background: var(--green-soft); }

/* Dialogen */
.modal { width: min(760px, calc(100% - 28px)); max-height: min(88vh, 900px); border: 0; border-radius: 24px; padding: 0; color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.30); }
.modal::backdrop { background: rgba(10, 25, 20, .48); backdrop-filter: blur(3px); }
.modal form, #detailContent, .small-modal, .modal-pad { padding: 22px; }
.modal-header, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.modal h2, .modal h3 { margin: 3px 0 0; }
.form-grid { display: grid; gap: 15px; margin-top: 20px; }
.form-grid label { display: grid; gap: 7px; font-weight: 800; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.photo-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.photo-note { margin: 10px 0 0; font-size: 13px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.photo-thumb { position: relative; aspect-ratio: 4/3; overflow: hidden; border-radius: 14px; background: #e8eeeb; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; padding: 0; border-radius: 50%; background: rgba(30,30,30,.72); color: white; }
.pending-label { position: absolute; left: 7px; top: 7px; padding: 4px 7px; border-radius: 8px; background: var(--green); color: white; font-size: 11px; font-weight: 900; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }

.detail-modal { width: min(820px, calc(100% - 28px)); }
.detail-top { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; }
.detail-title { margin: 5px 0 12px; font-size: clamp(23px, 4vw, 34px); }
.detail-location { margin: 18px 0; padding: 16px; border-radius: 16px; background: var(--green); color: white; }
.detail-location small { display: block; opacity: .75; margin-bottom: 4px; }
.detail-location strong { font-size: 23px; }
.detail-info { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 18px 0; }
.info-tile { padding: 13px; background: #f3f6f5; border-radius: 13px; }
.info-tile small { color: var(--muted); display: block; margin-bottom: 4px; }
.detail-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 22px -22px -22px; padding: 0 22px 22px; }
.detail-actions { display: flex; gap: 10px; margin-top: 20px; }
.update-line, .no-photo { font-size: 13px; }
.small-modal { max-width: 570px; }
.import-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 20px 0; }
.summary-box { padding: 15px; border-radius: 14px; background: #f1f5f3; }
.summary-box strong { display: block; font-size: 25px; }
.import-errors { margin: 12px 0; padding: 13px 15px; border-radius: 13px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.import-errors ul { margin: 8px 0 0; padding-left: 20px; }
.import-errors li + li { margin-top: 4px; }

/* Gebruikers */
.users-modal { width: min(820px, calc(100% - 28px)); }
.dialog-header-actions { display: flex; align-items: center; gap: 8px; }
.users-list { padding: 0 22px 22px; display: grid; gap: 10px; }
.user-row { width: 100%; display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); background: #fff; text-align: left; color: var(--ink); }
.user-row.inactive { opacity: .58; }
.user-avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--green-soft); color: var(--green); font-weight: 900; font-size: 20px; }
.user-row-main { display: grid; gap: 4px; }
.user-row-main small, .user-row-meta small { color: var(--muted); }
.user-row-meta { display: grid; justify-items: end; gap: 4px; color: var(--green); font-size: 13px; font-weight: 800; }
.checkbox-label { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 10px !important; }
.checkbox-label input { width: 20px; height: 20px; }
.login-remember { margin-top: 2px; font-weight: 700 !important; color: var(--ink); }
.login-remember span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; }
.login-remember small { color: var(--muted); font-size: 12px; font-weight: 700; }

.account-info { display: flex; justify-content: space-between; gap: 12px; padding: 14px; margin-top: 18px; border-radius: 14px; background: var(--green-soft); color: var(--green); }

/* Afbeelding vergroten */
.detail-photo, .photo-enlarge { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: inherit; overflow: hidden; background: transparent; }
.photo-enlarge { height: 100%; }
.detail-photo img, .photo-enlarge img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-photo { aspect-ratio: 4/3; border-radius: 15px; }
.detail-photo:focus-visible, .photo-enlarge:focus-visible { outline: 4px solid rgba(35, 100, 81, .35); outline-offset: 3px; }
.zoom-hint { position: absolute; right: 9px; bottom: 9px; padding: 6px 9px; border-radius: 10px; background: rgba(17, 28, 24, .78); color: #fff; font-size: 12px; font-weight: 800; backdrop-filter: blur(5px); }

.image-viewer { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: #0b0e0d; color: #fff; }
.image-viewer::backdrop { background: rgba(0, 0, 0, .92); }
.image-viewer-shell { position: relative; width: 100%; height: 100%; display: grid; place-items: center; padding: max(64px, calc(28px + env(safe-area-inset-top))) max(70px, calc(24px + env(safe-area-inset-right))) max(58px, calc(24px + env(safe-area-inset-bottom))) max(70px, calc(24px + env(safe-area-inset-left))); }
.image-viewer img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: 0 18px 55px rgba(0, 0, 0, .42); touch-action: pinch-zoom; user-select: none; -webkit-user-drag: none; }
.image-viewer-close, .image-viewer-nav { position: absolute; z-index: 2; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.22); background: rgba(20, 24, 23, .72); color: #fff; box-shadow: 0 8px 25px rgba(0,0,0,.28); backdrop-filter: blur(9px); }
.image-viewer-close { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 20px; }
.image-viewer-nav { top: 50%; width: 52px; height: 72px; padding: 0; transform: translateY(-50%); border-radius: 16px; font-size: 44px; line-height: 1; }
.image-viewer-prev { left: max(12px, env(safe-area-inset-left)); }
.image-viewer-next { right: max(12px, env(safe-area-inset-right)); }
.image-viewer-counter { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 7px 12px; border-radius: 999px; background: rgba(20, 24, 23, .72); color: rgba(255,255,255,.92); font-size: 13px; font-weight: 800; backdrop-filter: blur(9px); }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 105px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 13px; background: #17211e; color: white; box-shadow: var(--shadow); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  body { padding-bottom: 86px; }
  .login-page, .install-page { padding: 12px; }
  .app-header { align-items: flex-start; padding-left: 14px; padding-right: 14px; }
  .app-header h1 { font-size: 23px; }
  .header-actions { flex-direction: column-reverse; align-items: flex-end; }
  .compact-button { font-size: 12px; padding: 8px 10px; }
  main { padding: 14px; }
  .card-list { grid-template-columns: 1fr; }
  .item-card { grid-template-columns: 110px 1fr; min-height: 138px; }
  .card-image { min-height: 138px; }
  .two-cols, .detail-info { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-gallery { grid-template-columns: 1fr; }
  .modal { width: calc(100% - 14px); max-height: 94vh; border-radius: 20px; }
  .modal-actions { flex-wrap: wrap; }
  .user-row { grid-template-columns: 42px 1fr; }
  .user-row-meta { grid-column: 2; justify-items: start; }
  .dialog-header-actions #newUserButton { font-size: 12px; padding: 9px 10px; }
  .image-viewer-shell { padding-left: 12px; padding-right: 12px; }
  .image-viewer-nav { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); width: 48px; height: 48px; transform: none; border-radius: 50%; font-size: 38px; }
  .image-viewer-prev { left: max(14px, env(safe-area-inset-left)); }
  .image-viewer-next { right: max(14px, env(safe-area-inset-right)); }
}

.check-list { display: grid; gap: 10px; margin-top: 24px; }
.check-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 13px 15px; border-radius: 13px; background: #f3f6f5; }
.check-row span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; font-weight: 900; }
.check-row em { color: var(--muted); font-style: normal; text-align: right; }
.check-ok span { background: var(--green-soft); color: var(--green); }
.check-error { background: var(--danger-soft); color: var(--danger); }
.check-error span { background: var(--danger); color: white; }
@media (max-width: 560px) {
  .check-row { grid-template-columns: 28px 1fr; }
  .check-row em { grid-column: 2; text-align: left; }
}

/* Zoeken en barcode scannen */
.search-row { align-items: center; }
.search-row #searchInput { flex: 1 1 auto; min-width: 0; }
.scan-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; min-height: 48px; }

.scanner-modal { width: min(720px, calc(100% - 28px)); }
.scanner-shell { padding: 22px; }
.scanner-help { margin: 12px 0 16px; }
.scanner-video-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  background: #0b0e0d;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
#scannerVideo { display: block; width: 100%; height: 100%; object-fit: cover; background: #0b0e0d; }
.scanner-frame {
  position: absolute;
  inset: 25% 7%;
  border: 3px solid rgba(255,255,255,.95);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.28);
  pointer-events: none;
}
.scanner-frame::before,
.scanner-frame::after,
.scanner-frame span::before,
.scanner-frame span::after {
  content: '';
  position: absolute;
  width: 34px;
  height: 34px;
  border-color: #74d7b8;
  border-style: solid;
}
.scanner-frame::before { left: -3px; top: -3px; border-width: 5px 0 0 5px; border-radius: 12px 0 0 0; }
.scanner-frame::after { right: -3px; top: -3px; border-width: 5px 5px 0 0; border-radius: 0 12px 0 0; }
.scanner-frame span::before { left: -3px; bottom: -3px; border-width: 0 0 5px 5px; border-radius: 0 0 0 12px; }
.scanner-frame span::after { right: -3px; bottom: -3px; border-width: 0 5px 5px 0; border-radius: 0 0 12px 0; }
.scanner-status { min-height: 24px; margin-top: 13px; color: var(--muted); font-weight: 700; }
.scanner-status.scanner-error { color: var(--danger); }
.scanner-actions { margin-top: 15px; }

@media (max-width: 560px) {
  .search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
  .scan-button { padding-left: 12px; padding-right: 12px; }
  .scan-button span { display: none; }
  .scanner-shell { padding: 16px; }
  .scanner-video-wrap { aspect-ratio: 3 / 4; }
  .scanner-frame { inset: 30% 6%; }
  .scanner-actions { align-items: stretch; }
  .scanner-actions .spacer { display: none; }
  .scanner-actions button { flex: 1 1 auto; }
}
