:root {
  --bg: #f5f7f6;
  --card: #ffffff;
  --text: #1b2421;
  --muted: #66756f;
  --line: #dbe4e0;
  --primary: #1f6f5c;
  --primary-soft: #e8f3ef;
  --green: #16834c;
  --green-soft: #e8f6ee;
  --orange: #b85b00;
  --orange-soft: #fff1df;
  --red: #b42318;
  --red-soft: #feeceb;
  --blue: #235fa4;
  --blue-soft: #eaf2fb;
  --shadow: 0 8px 28px rgba(20, 42, 34, .08);
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  color: #fff; background: var(--primary); font-weight: 800; font-size: 22px;
  box-shadow: var(--shadow);
}
.brand h1 { margin: 0; font-size: clamp(18px, 3vw, 26px); }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.role-nav {
  position: sticky; top: 0; z-index: 20;
  max-width: 1180px; margin: 4px auto 0; padding: 10px 18px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  background: rgba(245, 247, 246, .94); backdrop-filter: blur(10px);
}
.role-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  min-height: 46px; border-radius: 12px; font-weight: 700;
}
.role-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.app-shell { max-width: 1180px; margin: 0 auto; padding: 12px 18px 48px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
}
.card h2, .card h3 { margin-top: 0; }
.top-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 7px; }
.select, .text-input {
  width: 100%; min-height: 46px; border: 1px solid var(--line); background: #fff;
  border-radius: 11px; padding: 0 12px; color: var(--text);
}
.date-box {
  border: 1px solid var(--line); border-radius: 11px; min-height: 46px; padding: 8px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.date-box strong { font-size: 15px; }
.date-box span { color: var(--muted); font-size: 12px; }
.subnav { display: flex; gap: 8px; margin: 14px 0; }
.subnav button {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 11px; padding: 12px;
  font-weight: 800;
}
.subnav button.active { color: var(--primary); background: var(--primary-soft); border-color: #b9d9ce; }
.info-banner, .status-banner {
  border-radius: 12px; padding: 12px 14px; margin: 12px 0; border: 1px solid var(--line);
}
.info-banner { background: var(--blue-soft); border-color: #bfd3ee; color: #174b83; }
.status-banner.new { background: var(--green-soft); border-color: #bfe3cf; color: #0d6639; }
.status-banner.changed { background: var(--orange-soft); border-color: #f0c68f; color: #934600; }
.category-card { padding: 0; overflow: hidden; }
.category-title {
  padding: 14px 16px; background: #fbfcfb; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.category-title h3 { margin: 0; font-size: 17px; }
.category-title span { color: var(--muted); font-size: 12px; }
.order-row {
  min-height: 92px; display: block;
  padding: 13px 16px; border-bottom: 1px solid #edf1ef;
}
.order-row:last-child { border-bottom: 0; }
.order-main { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.order-row .item-name { font-weight: 700; line-height: 1.25; }
.comment-control {
  margin-top: 7px;
}
.comment-toggle-btn {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.comment-toggle-btn.has-comment {
  color: var(--orange);
  border-color: #efc68f;
  background: var(--orange-soft);
}
.comment-panel {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #dfe7e3;
}
.comment-panel[hidden] {
  display: none !important;
}
.item-comment-label { display: block; margin-top: 0; }
.item-comment-label > span {
  display: block; font-size: 12px; color: var(--muted);
  font-weight: 700; margin-bottom: 5px;
}
.item-comment-label small { font-weight: 500; }
.item-comment {
  width: 100%; min-height: 64px; max-height: 140px; resize: vertical;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px;
  background: #fff; color: var(--text); line-height: 1.35;
}
.item-comment:focus, .stepper-input:focus, .select:focus, .text-input:focus {
  outline: 3px solid rgba(31,111,92,.14); border-color: var(--primary);
}
.draft-note {
  border: 1px solid #b9d9ce; background: var(--primary-soft); color: #175847;
  border-radius: 11px; padding: 10px 12px; margin: 10px 0 14px; font-size: 12px; font-weight: 700;
}
.draft-note.dirty { background: var(--orange-soft); border-color: #efc68f; color: #914800; }

.stepper { display: grid; grid-template-columns: 42px 48px 42px; gap: 5px; flex: 0 0 auto; }
.stepper-btn {
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 23px; line-height: 1; color: var(--primary); font-weight: 800;
}
.stepper-input {
  width: 48px; height: 42px; border: 1px solid var(--line); border-radius: 10px;
  text-align: center; font-weight: 800; -moz-appearance: textfield;
}
.stepper-input::-webkit-outer-spin-button, .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.toggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.toggle button { border: 0; background: #fff; padding: 10px 13px; font-weight: 800; }
.toggle button.active { background: var(--primary); color: #fff; }
.primary-btn, .secondary-btn, .danger-btn, .small-btn {
  border-radius: 11px; font-weight: 800; border: 1px solid transparent;
}
.primary-btn { width: 100%; min-height: 52px; background: var(--primary); color: #fff; padding: 12px 18px; }
.secondary-btn { background: #fff; border-color: var(--line); color: var(--text); padding: 10px 14px; }
.danger-btn { background: #fff; border-color: #efc4c0; color: var(--red); padding: 10px 14px; }
.small-btn { min-height: 35px; padding: 7px 10px; background: #fff; border-color: var(--line); }
.small-btn.success { color: var(--green); border-color: #b8ddc8; }
.small-btn.warn { color: var(--orange); border-color: #efc99b; }
.small-btn.red { color: var(--red); border-color: #efc4c0; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.status-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.status-card { border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 12px; min-height: 100px; }
.status-card.ok { border-color: #b8ddc8; background: var(--green-soft); }
.status-card.changed { border: 2px solid #e69132; background: var(--orange-soft); }
.status-card.missing { background: #fafafa; }
.status-card .loc { font-weight: 800; margin-bottom: 7px; }
.status-pill { display: inline-flex; border-radius: 999px; padding: 5px 8px; font-size: 11px; font-weight: 900; }
.status-pill.ok { color: var(--green); background: #d8f0e2; }
.status-pill.changed { color: var(--red); background: var(--red-soft); }
.status-pill.missing { color: #6f7774; background: #eef1ef; }
.alert-box { border: 2px solid #e69132; background: var(--orange-soft); border-radius: 13px; padding: 14px; margin: 12px 0; }
.alert-box h3 { color: #984a00; margin-bottom: 8px; }
.change-line { padding: 7px 0; border-bottom: 1px dashed #e7c08c; }
.change-line:last-child { border-bottom: 0; }
.old { text-decoration: line-through; color: var(--muted); }
.new { font-weight: 900; color: var(--red); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
th, td { border-bottom: 1px solid #edf1ef; padding: 10px 11px; text-align: right; font-size: 13px; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: inherit; }
th { background: #f8faf9; font-size: 12px; color: var(--muted); }
td.total, th.total { font-weight: 900; background: #f1f7f4; }
.location-detail { border: 1px solid var(--line); border-radius: 12px; margin: 9px 0; overflow: hidden; }
.location-detail summary { list-style: none; cursor: pointer; padding: 13px 14px; display: flex; justify-content: space-between; gap: 12px; font-weight: 800; }
.location-detail summary::-webkit-details-marker { display:none; }
.location-detail.changed { border: 2px solid #e69132; }
.detail-body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.detail-item { padding: 9px 0; border-bottom: 1px solid #f0f2f1; }
.detail-item:last-child { border-bottom: 0; }
.detail-main { display: flex; justify-content: space-between; gap: 16px; }
.detail-comment { margin-top: 6px; padding: 8px 10px; border-radius: 9px; background: #fff7df; color: #6f4a00; font-size: 13px; }
.comment-list { display: grid; gap: 8px; }
.comment-card { border: 1px solid #ead7a5; background: #fffaf0; border-radius: 11px; padding: 11px 12px; }
.comment-meta { font-size: 12px; color: var(--muted); font-weight: 800; margin-bottom: 4px; }
.comment-text { font-weight: 700; line-height: 1.35; }

.shop-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #edf1ef;
}
.shop-add-row:last-child { border-bottom: 0; }
.shop-item-main { min-width: 0; }
.shop-item-title { font-weight: 800; line-height: 1.25; }
.shop-list { display: grid; gap: 9px; }
.shop-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.shop-card .shop-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.shop-card.delivered { background: #f4faf6; opacity: .82; }
.shop-card.out { background: #fff3f2; }
.shop-card.partial { background: #fff8e9; }
.shop-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.shop-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}
.shop-controls .small-btn {
  min-height: 42px;
  padding-inline: 14px;
  white-space: nowrap;
}
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-list { display: grid; gap: 10px; }
.admin-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
}
.admin-main { min-width: 0; }
.admin-title { font-weight: 800; line-height: 1.25; }
.admin-meta { margin-top: 4px; }
.admin-actions { display:flex; gap:8px; flex-wrap:wrap; }
.admin-actions .small-btn { min-height: 38px; }
.add-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 12px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 12px 16px; border-radius: 12px; background: #1e2d28; color: #fff; font-weight: 800;
  box-shadow: var(--shadow); z-index: 100; animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translate(-50%, 12px); opacity: 0 } to { transform: translate(-50%, 0); opacity: 1 } }
.empty { text-align: center; padding: 24px; color: var(--muted); }
.footer-note { text-align:center; color:var(--muted); font-size:11px; margin-top:20px; }
@media (max-width: 820px) {
  .top-grid, .admin-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .app-header { align-items: flex-start; }
  }
@media (max-width: 560px) {
  .app-header { padding-top: 14px; }
  .brand p { display: none; }
  .role-nav { gap: 5px; padding-left: 10px; padding-right: 10px; }
  .role-btn { font-size: 13px; min-height: 43px; }
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .card { padding: 14px; border-radius: 13px; }
  .status-grid { grid-template-columns: 1fr; }
  .subnav { gap: 6px; margin: 10px 0 12px; }
  .subnav button { min-height: 50px; padding: 10px 8px; font-size: 14px; }
  .order-row { padding: 13px 12px; }
  .order-main { align-items: center; gap: 10px; }
  .order-row .item-name { font-size: 15px; flex: 1; }
  .stepper { grid-template-columns: 48px 52px 48px; gap: 6px; }
  .stepper-btn { width: 48px; height: 48px; font-size: 26px; }
  .stepper-input { width: 52px; height: 48px; font-size: 17px; }
  .toggle button { min-height: 48px; padding: 10px 15px; }
  .item-comment { min-height: 46px; font-size: 16px; }
  .primary-btn { min-height: 58px; font-size: 16px; }
  .meal-submit { box-shadow: 0 8px 24px rgba(20,42,34,.18); }

  .shop-add-row { grid-template-columns: 1fr; gap: 10px; }
  .shop-controls { width: 100%; justify-content: space-between; }
  .shop-controls .stepper { flex: 1 1 auto; grid-template-columns: 48px minmax(56px, 1fr) 48px; }
  .shop-controls .small-btn { flex: 0 0 auto; min-width: 120px; }
  .add-form { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .order-main { align-items: flex-start; flex-direction: column; }
  .stepper, .toggle { align-self: stretch; }
  .stepper { grid-template-columns: 48px 1fr 48px; }
  .stepper-input { width: 100%; }
  .toggle { display: grid; grid-template-columns: 1fr 1fr; }
}


/* V5 winkelindeling */
.shop-category-card { padding: 0; overflow: hidden; }
.shop-category-title {
  padding: 13px 16px; border-bottom: 1px solid var(--line); background: #fbfcfb;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.shop-category-title h3 { margin: 0; }
.shop-category-title span { color: var(--muted); font-size: 12px; }
.shop-item-meta { min-width: 0; display: grid; gap: 3px; }
.shop-item-meta span, .supplier-line { color: var(--muted); font-size: 12px; }
.kitchen-shop-group { margin: 18px 0 22px; }
.kitchen-shop-group > h3 { margin: 0 0 9px; }
.shop-admin-add-form { display: grid; grid-template-columns: 1.3fr .8fr 1fr; gap: 8px; margin-top: 12px; }
.shop-admin-add-form .primary-btn { grid-column: 1 / -1; }
.admin-shop-row { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 560px) {
  .brand p { display: block; font-size: 11px; }
  .brand h1 { font-size: 18px; }
  .shop-item-title { font-size: 15px; }
  .shop-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
  }
  .shop-controls .stepper {
    grid-template-columns: 48px minmax(56px, 1fr) 48px;
    width: 100%;
  }
  .shop-controls .stepper-input { width: 100%; }
  .shop-controls .small-btn {
    width: 100%;
    min-height: 46px;
  }
  .shop-admin-add-form { grid-template-columns: 1fr; }
  .shop-admin-add-form .primary-btn { grid-column: auto; }
  .admin-shop-row { grid-template-columns: 1fr; }
}


@media (min-width: 561px) {
  .admin-actions .small-btn.red { margin-left: auto; }
}


/* V7 layoutcorrecties */
.shop-category-card .shop-add-row {
  padding: 12px 16px;
}
.shop-category-card .shop-item-main,
.shop-category-card .shop-controls {
  min-width: 0;
}
.shop-category-card .shop-item-title {
  padding-right: 8px;
}

.admin-shop-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  overflow: hidden;
}
.admin-shop-row .admin-main,
.admin-shop-row .admin-fields,
.admin-shop-row .admin-actions {
  min-width: 0;
}
.admin-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.admin-field {
  display: block;
  min-width: 0;
}
.admin-field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.admin-field .select {
  width: 100%;
  min-width: 0;
}
.admin-shop-row .admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-shop-row .admin-actions .small-btn.red {
  margin-left: 0;
}
.supplier-admin-list {
  display: grid;
  gap: 8px;
}
.supplier-admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.supplier-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}
.supplier-add-form .primary-btn {
  width: auto;
  min-height: 46px;
}
@media (max-width: 560px) {
  .shop-category-card .shop-add-row {
    padding: 12px;
  }
  .admin-fields {
    grid-template-columns: 1fr;
  }
  .admin-shop-row .admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .admin-shop-row .admin-actions .small-btn {
    width: 100%;
  }
  .admin-shop-row .admin-actions .small-btn.red {
    grid-column: 1 / -1;
  }
  .supplier-admin-row {
    grid-template-columns: 1fr;
  }
  .supplier-admin-row .admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .supplier-add-form {
    grid-template-columns: 1fr;
  }
  .supplier-add-form .primary-btn {
    width: 100%;
  }
}

/* V8 opmerkingen */
@media (max-width: 560px) {
  .comment-control { margin-top: 6px; }
  .comment-toggle-btn {
    min-height: 38px;
    padding: 7px 11px;
    font-size: 12px;
  }
  .comment-panel .item-comment {
    min-height: 72px;
    font-size: 16px;
  }
}
