:root {
  --bg: #f4f1ec;
  --card: #ffffff;
  --ink: #2b2724;
  --muted: #7a716a;
  --line: #e3ddd4;
  --accent: #8a5a2b;
  --accent-ink: #ffffff;
  --err: #b3261e;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }

.top { padding: 18px 28px 10px; display: flex; justify-content: space-between; align-items: flex-start; }
.top .uitloggen { font-size: 13px; }
.loginpagina { align-items: center; justify-content: center; }
.loginkaart { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px 30px;
  width: min(380px, 92vw); margin: auto; box-shadow: 0 10px 40px rgba(60,40,20,.08); }
.loginkaart h1 { margin: 0; font-size: 21px; }
.loginkaart .sub { color: var(--muted); font-size: 14px; margin: 4px 0 20px; }
.loginkaart button { margin-top: 16px; }
.top h1 { margin: 0; font-size: 22px; letter-spacing: .2px; }
.top .sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.layout {
  flex: 1; display: grid; grid-template-columns: 380px 1fr; gap: 20px;
  padding: 10px 28px 28px; min-height: 0;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 10px 14px 20px; }
  .viewer { min-height: 60vh; order: -1; }
}

.panel { display: flex; flex-direction: column; gap: 16px; }
.panel > form, .mand {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
     margin: 18px 0 8px; font-weight: 600; }
form > h2:first-child, .mand > h2:first-child { margin-top: 0; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.unit { color: var(--muted); font-size: 12px; }
input, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink); width: 100%;
}
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input:user-invalid { border-color: var(--err); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; min-height: 1em; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 16px; font: inherit; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#toogvelden { margin-top: 10px; }
.seg.small button { padding: 4px 10px; font-size: 13px; }
.tegels { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 6px; }
.tegels button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 7px;
  border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font: inherit; font-size: 12.5px; color: var(--ink); }
.tegels button svg { width: 34px; height: 34px; fill: #f3ece1; stroke: #6b5843; stroke-width: 1.6; stroke-linejoin: round; }
.tegels button[aria-pressed="true"] { border-color: var(--accent); background: #fbf5ee; box-shadow: inset 0 0 0 1px var(--accent); }
.tegels button[hidden] { display: none; }
.lagen { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.lagen .laag { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px;
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fcfbf8; }
.lagen .laag i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.lagen .vast { color: var(--muted); }
.combi { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
.combi .seg { align-self: stretch; }
.verdeling { margin-top: 12px; }
.verdeling-kop { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.maatvelden { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; margin-top: 8px; }
.maatvelden label { font-size: 11.5px; color: var(--muted); gap: 2px; }
.maatvelden input { padding: 6px 6px; font-size: 13.5px; }
.maatvelden input::placeholder { color: #a99f95; }

.stepper { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.stepper > div { display: flex; }
.stepper input { text-align: center; border-radius: 0; border-left: 0; border-right: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper button { width: 38px; border: 1px solid var(--line); background: #faf8f5; font-size: 18px; cursor: pointer; color: var(--ink); }
.stepper button:first-child { border-radius: 7px 0 0 7px; }
.stepper button:last-child { border-radius: 0 7px 7px 0; }

button.primary, button.ghost {
  font: inherit; padding: 9px 14px; border-radius: 8px; cursor: pointer; border: 1px solid var(--accent);
}
button.primary { background: var(--accent); color: var(--accent-ink); }
button.primary:disabled { opacity: .5; cursor: default; }
button.ghost { background: #fff; color: var(--accent); }
.wide { width: 100%; }
.btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btns.right { justify-content: flex-end; }

.add { display: grid; grid-template-columns: 70px 80px 1fr; gap: 8px; align-items: end; margin-top: 20px; }
.fout { color: var(--err); font-size: 13.5px; margin: 10px 0 0; }

details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; font-size: 14px; color: var(--accent); }
.grid-c { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 10px; }
.grid-c label { font-size: 12.5px; }

.mand ul { list-style: none; margin: 0 0 12px; padding: 0; }
.mand li { display: flex; justify-content: space-between; align-items: center; gap: 8px;
           padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mand li .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; }
.mand li .meta { color: var(--muted); font-size: 12.5px; }
.mand li .open { cursor: pointer; }

.viewer {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 520px; overflow: hidden;
  position: sticky; top: 16px; height: calc(100vh - 32px); align-self: start;
}
@media (max-width: 860px) { .viewer { position: relative; height: 60vh; } }
.tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); align-items: center; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 6px; font: inherit; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { background: #f1ebe2; color: var(--ink); }
.tabs { flex-wrap: wrap; row-gap: 6px; }
.werkbalk { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.explode { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.explode input[type=range] { width: 80px; }
.download summary { white-space: nowrap; }
.explode input[type=checkbox] { width: auto; }
.download { position: relative; margin: 0; padding: 0; border: 0; }
.download summary { list-style: none; cursor: pointer; font-size: 13px; padding: 5px 12px; border: 1px solid var(--accent);
  border-radius: 7px; color: var(--accent); background: #fff; }
.download summary::-webkit-details-marker { display: none; }
.download[open] summary { background: var(--accent); color: #fff; }
.download .menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; display: flex; flex-direction: column; min-width: 240px; }
.download .menu button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; font: inherit;
  font-size: 13.5px; cursor: pointer; color: var(--ink); }
.download .menu button:hover { background: #f4eee5; }
.explode input { width: 120px; padding: 0; }
.view { flex: 1; min-height: 0; position: relative; }
#view3d canvas { display: block; width: 100%; height: 100%; }
#viewsvg { overflow: auto; padding: 14px 18px 40px; }
.blad h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.blad-aanzicht svg { max-height: 62vh; }
.blad-doorsneden { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; margin-top: 18px; align-items: start; }
.blad-notities { margin: 16px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink); line-height: 1.55; }
@media (max-width: 1100px) { .blad-doorsneden { grid-template-columns: 1fr; } }
.bezig { position: absolute; right: 14px; bottom: 14px; background: rgba(43,39,36,.8); color: #fff;
         padding: 6px 12px; border-radius: 20px; font-size: 13px; }
.legenda { position: absolute; left: 12px; bottom: 10px; margin: 0; padding: 0; list-style: none;
           font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

dialog { border: 0; border-radius: 12px; padding: 22px; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(30,25,20,.4); }
dialog form > label, dialog .row2 { margin-bottom: 10px; }
dialog h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0 0 14px; }

/* Werktekening (stalraam/tekening.py) */
svg.tekening { width: 100%; height: auto; display: block; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.tekening * { vector-effect: non-scaling-stroke; }
.t-hout path { fill: #eadcc3; stroke: #4a3a28; stroke-width: 1.3; }
.t-sponning path { fill: none; stroke: #8f7756; stroke-width: .8; stroke-dasharray: 5 3; }
.t-fase path { fill: #f6efe3; stroke: #8f7756; stroke-width: .7; }
.t-glas path { fill: #dfeaf2; stroke: #4a3a28; stroke-width: 1; }
.t-glasrand path { fill: none; stroke: #5b8db3; stroke-width: .8; stroke-dasharray: 2 3; }
.t-dun { stroke: #4a3a28; stroke-width: .8; }
.t-maat { stroke: #5d554e; stroke-width: .8; }
.t-hulp { stroke: #8d847b; stroke-width: .5; }
.t-straal { stroke: #a0522d; stroke-width: .8; stroke-dasharray: 6 3; }
.t-pijl { fill: #a0522d; }
.t-r { fill: #a0522d; }
.t-tekst { fill: #2f2a26; font-weight: 500; }
.t-licht { fill: #5b7f99; font-style: italic; }
.t-titel { fill: #2f2a26; font-weight: 650; }
.t-snede { stroke: #c0392b; stroke-width: 1.4; stroke-dasharray: 10 3 2 3; }
.t-snedeletter { fill: #c0392b; font-weight: 700; }
.t-voorplaat { fill: #d9c7a3; stroke: #4a3a28; stroke-width: 1.2; }
.t-achterplaat { fill: #cdb894; stroke: #4a3a28; stroke-width: 1.2; }
.t-lat-buiten { fill: #bfa57c; stroke: #4a3a28; stroke-width: 1; }
.t-lat-binnen { fill: #a88d64; stroke: #4a3a28; stroke-width: 1; }
.t-glasruimte { fill: #dbe9f3; stroke: #8fb1c9; stroke-width: .8; }
.t-breuk { fill: none; stroke: #4a3a28; stroke-width: .9; }

/* Aanzicht */
.svg-buiten { fill: #e9dcc4; stroke: #5b4630; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.svg-sponning { fill: none; stroke: #8f7756; stroke-width: .8; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.svg-fase { fill: #f6efe3; stroke: #8f7756; stroke-width: .8; vector-effect: non-scaling-stroke; }
.svg-vak { fill: #dfeaf2; stroke: #5b4630; stroke-width: 1; vector-effect: non-scaling-stroke; }
.svg-maat { stroke: #6b625b; stroke-width: .8; fill: none; vector-effect: non-scaling-stroke; }
.svg-maattekst { fill: #3a342f; font-size: 13px; font-family: system-ui, sans-serif; }
