:root {
  --bg: #f5f3ef;
  --card: #ffffff;
  --text: #1b1f1d;
  --muted: #6c7370;
  --line: #e6e2db;
  --accent: #2f6f5e;
  --accent-2: #3f8c76;
  --accent-soft: #e3efea;
  --accent-text: #ffffff;
  --warm: #c9772f;
  --danger: #b4412f;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(30 25 15 / .05), 0 6px 20px rgb(30 25 15 / .05);
  --shadow-lift: 0 12px 32px rgb(30 25 15 / .18);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413;
    --card: #1a1e1d;
    --text: #eceeed;
    --muted: #98a09d;
    --line: #2a302e;
    --accent: #62b79d;
    --accent-2: #4ea088;
    --accent-soft: #1d302a;
    --accent-text: #0c1915;
    --warm: #e39b5a;
    --danger: #e3735f;
    --shadow: none;
    --shadow-lift: 0 12px 32px rgb(0 0 0 / .5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
body.dragging-active { user-select: none; -webkit-user-select: none; cursor: grabbing; }
main {
  max-width: 600px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.02em; line-height: 1.2; }
h2 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 28px 4px 10px; font-weight: 650; display: flex; align-items: center; gap: 8px;
}
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.loading { color: var(--muted); text-align: center; margin-top: 30vh; }
svg { width: 20px; height: 20px; flex: none; }
svg.inline { width: 14px; height: 14px; vertical-align: -2px; fill: currentColor; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stack > * + * { margin-top: 12px; }
.empty { color: var(--muted); text-align: center; padding: 22px 16px; }

/* ---------- header ---------- */
header.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 8px; }
.brand { font-size: 1.5rem; font-weight: 750; }
.brand span, .logo span { color: var(--warm); }
.back { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; font-weight: 600; margin-left: -6px; padding: 8px 6px; }
.iconbtn {
  position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow);
}
.iconbtn svg { width: 22px; height: 22px; }
.dot {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--warm); color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center;
}
.pill { background: var(--warm); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .72rem; letter-spacing: 0; }

/* ---------- overzicht ---------- */
.summary {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text);
  border-radius: 22px; padding: 20px; margin-top: 6px; box-shadow: var(--shadow);
}
.summary .muted { color: inherit; opacity: .8; }
.summary .big { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.summary .right { text-align: right; }

/* ---------- lijsten ---------- */
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.row-card {
  display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); position: relative; touch-action: pan-y;
}
.row-card.dragging {
  z-index: 10; box-shadow: var(--shadow-lift); border-color: var(--accent);
  transition: box-shadow .15s; scale: 1.02;
}
.handle {
  display: grid; place-items: center; width: 34px; flex: none; color: var(--muted); cursor: grab;
  touch-action: none; border-radius: 16px 0 0 16px; opacity: .7;
}
.handle svg { fill: currentColor; width: 18px; height: 18px; }
.handle:hover { opacity: 1; }
.row-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 12px;
  color: inherit; text-decoration: none; background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.row-card:not(:has(.handle)) .row-main { padding-left: 14px; }
.num {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums;
}
.is-done .num { background: var(--accent); color: var(--accent-text); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.is-done .title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.meta { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.chev { color: var(--muted); display: grid; }

/* stappen */
.step .tick {
  width: 30px; height: 30px; margin: auto 0 auto 2px; border-radius: 50%; flex: none; cursor: pointer;
  border: 2px solid var(--line); background: var(--card); color: var(--muted); display: grid; place-items: center;
  font: 600 .8rem/1 inherit; font-variant-numeric: tabular-nums; padding: 0;
}
.step:not(:has(.handle)) .tick { margin-left: 12px; }
.step .tick:disabled { cursor: default; }
.step .tick svg { width: 16px; height: 16px; }
.step.is-done .tick { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.step-main { justify-content: space-between; }
.cost { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.step.is-done .cost { color: var(--muted); font-weight: 500; }
.row-card.editing { padding: 12px; }
.step-edit { width: 100%; display: flex; flex-direction: column; gap: 8px; }

/* detail */
.detail-head { padding: 6px 4px 0; }
.detail-head h1 { font-size: 1.75rem; margin: 2px 0 6px; overflow-wrap: anywhere; }
.detail-head.is-done h1 { text-decoration: line-through; color: var(--muted); }
.detail-head .note { color: var(--muted); white-space: pre-wrap; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--warm); }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.totals > div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.totals strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.totals > div:first-child { background: var(--accent-soft); border-color: transparent; }
.totals > div:first-child strong { color: var(--accent); }

/* ---------- formulieren ---------- */
label.field { display: block; font-size: .85rem; color: var(--muted); }
label.field > span { display: block; margin-bottom: 6px; }
input[type="text"], textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
select { width: auto; padding: 10px 12px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.code { text-transform: uppercase; letter-spacing: .35em; font-size: 1.5rem; text-align: center; font-family: ui-monospace, Menlo, monospace; }
.row { display: flex; gap: 8px; align-items: center; }
.btnrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.euro { position: relative; display: block; }
.euro span { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.euro input { padding-left: 30px; font-variant-numeric: tabular-nums; }

.add { display: flex; gap: 8px; margin-top: 12px; }
.add input { border-radius: 14px; box-shadow: var(--shadow); }
.add-step { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; padding: 12px; }

button.primary, button.secondary, button.danger {
  font: inherit; font-weight: 650; border-radius: 12px; padding: 12px 16px; cursor: pointer; border: 1px solid transparent;
  min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
button.primary { background: var(--accent); color: var(--accent-text); width: 100%; }
button.primary.auto { width: auto; }
button.primary.round { width: 50px; height: 50px; padding: 0; border-radius: 14px; flex: none; }
button.primary.round svg { width: 22px; height: 22px; }
button.primary svg { width: 18px; height: 18px; }
button.secondary { background: var(--card); color: var(--text); border-color: var(--line); }
button.secondary.sm { min-height: 38px; padding: 8px 12px; font-size: .9rem; }
button.secondary svg { width: 16px; height: 16px; color: var(--accent); }
button.danger { background: none; color: var(--danger); border-color: var(--line); }
button.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 10px; }
button:disabled { opacity: .55; cursor: default; }
button:active:not(:disabled) { transform: scale(.98); }

/* ---------- welkom / aanvragen ---------- */
.welcome { text-align: center; padding: 8vh 8px 20px; }
.welcome h1 { margin: 16px 0 8px; }
.logo {
  width: 76px; height: 76px; margin: 0 auto; border-radius: 22px; display: flex; align-items: center; justify-content: center; gap: 1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; font-size: 1.4rem; letter-spacing: -.02em;
  box-shadow: var(--shadow);
}
.spinner {
  width: 44px; height: 44px; margin: 0 auto; border-radius: 50%;
  border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hint { background: var(--accent-soft); border-radius: 14px; padding: 14px 16px; font-size: .92rem; margin-bottom: 16px; }
.hint ol { margin: 6px 0 0; padding-left: 20px; }
.error { color: var(--danger); font-size: .9rem; }

/* ---------- beheer ---------- */
.request .who, .devices .who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.approve-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.approve-row select { width: 100%; min-height: 46px; }
button.link.danger-link { color: var(--danger); padding: 10px 0 0; font-size: .9rem; }
.devices { list-style: none; margin: 0; padding: 4px 16px; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.devices li:last-child { border-bottom: 0; }
.devices button.danger { min-height: 38px; padding: 8px 12px; font-size: .88rem; }
.secret { font: .85rem ui-monospace, Menlo, monospace; word-break: break-all; padding: 12px; background: var(--accent-soft); border-radius: 10px; user-select: all; }

#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .9rem; font-weight: 500;
  box-shadow: 0 6px 24px rgb(0 0 0 / .25); max-width: calc(100% - 32px); text-align: center;
}

@media (max-width: 380px) {
  .totals { grid-template-columns: 1fr 1fr; }
  .totals > div:first-child { grid-column: span 2; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- op beginscherm zetten ---------- */
.install-card { display: flex; gap: 14px; align-items: flex-start; }
.install-card img, .install-bar img, .sheet-head img { border-radius: 22%; flex: none; box-shadow: var(--shadow); }
.install-card p { margin: 4px 0 12px; }
.install-card button { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.install-card button svg.inline { width: 18px; height: 18px; vertical-align: 0; }
.install-bar {
  display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 8px 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); line-height: 1.3;
}
.install-bar button.primary.small-btn { width: auto; flex: none; min-height: 38px; padding: 8px 14px; font-size: .88rem; }
.install-bar .close { flex: none; font-size: 1.4rem; line-height: 1; padding: 6px 8px; color: var(--muted); }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background .2s ease;
}
.sheet-backdrop.open { background: rgb(0 0 0 / .4); }
.sheet {
  width: 100%; max-width: 520px; background: var(--card); color: var(--text); border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lift);
  transform: translateY(100%); transition: transform .22s ease;
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.sheet-head p { margin: 0; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 12px 0 18px; }
.steps li { counter-increment: s; position: relative; padding: 10px 0 10px 42px; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 8px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: .9rem;
}
.steps svg.inline { width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); }
.sheet button { width: 100%; }
