/*!
 * shopfloor3D · Oberfläche
 * oon Branding: Rot #EF2902 · Dunkel #151D23 · Weiß #FFFFFF · Schrift MoscaType (Ersatz: Outfit)
 * Layout: App-Rahmen mit Kopfzeile, Bibliothek links, randlose 3D-Halle mit schwebenden Werkzeugen, Eigenschaften rechts
 */
:root {
  --bg: #0f161b;
  --panel: #151d23;
  --raise: #1b252d;
  --raise-2: #222e37;
  --line: #24303a;
  --line-strong: #34434f;
  --ink: #ffffff;
  --ink-2: #c6cfd6;
  --muted: #7d8c98;
  --accent: #ef2902;
  --accent-hover: #ff3d17;
  --accent-ink: #ffffff;
  --accent-soft: rgba(239, 41, 2, .15);
  --warn: #ffb020;
  --warn-soft: rgba(255, 176, 32, .14);
  --ok: #3dd68c;
  --ok-soft: rgba(61, 214, 140, .12);
  --glass: rgba(21, 29, 35, .8);
  --shadow: 0 12px 32px rgba(0, 0, 0, .38);
  --scene: #0d1317;
  --floor: #162028;
  --grid-minor: #2d3d49;
  --grid-major: #4f6474;
  --wall: #2a3640;
  --scrim: rgba(6, 10, 13, .66);

  --f-ui: "MoscaType", "Outfit", system-ui, "Segoe UI", sans-serif;
  --f-mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  --r: 10px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eceff2;
  --panel: #ffffff;
  --raise: #f4f6f8;
  --raise-2: #e8ecf0;
  --line: #e0e5ea;
  --line-strong: #cbd3da;
  --ink: #151d23;
  --ink-2: #36424c;
  --muted: #687582;
  --accent: #ef2902;
  --accent-hover: #d42200;
  --accent-ink: #ffffff;
  --accent-soft: rgba(239, 41, 2, .1);
  --warn: #b86e00;
  --warn-soft: rgba(230, 150, 0, .15);
  --ok: #128555;
  --ok-soft: rgba(18, 133, 85, .1);
  --glass: rgba(255, 255, 255, .86);
  --shadow: 0 12px 30px rgba(21, 29, 35, .14);
  --scene: #e2e7eb;
  --floor: #d2d9df;
  --grid-minor: #bcc6ce;
  --grid-major: #97a4ae;
  --wall: #9ca8b2;
  --scrim: rgba(21, 29, 35, .42);
  color-scheme: light;
}

* { box-sizing: border-box }
html, body { height: 100%; margin: 0 }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--f-ui); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit }
[hidden] { display: none !important }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.ic { width: 18px; height: 18px; flex: none }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }
kbd {
  font-family: var(--f-mono); font-size: 11px; line-height: 1;
  padding: 2px 5px; border-radius: 4px; border: 1px solid var(--line-strong);
  background: var(--raise); color: var(--ink-2);
}

/* ---------- Rahmen ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 312px;
  grid-template-rows: 60px minmax(0, 1fr);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.top {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 18px;
  padding-inline: 18px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); flex: none }
.logo { display: block; width: 58px; color: var(--ink) }
.logo svg { display: block; width: 100%; height: auto }
.brand-sep { width: 1px; height: 22px; background: var(--line-strong) }
.product { font-size: 19px; font-weight: 500; letter-spacing: -.01em }
.product b { font-weight: 700; color: var(--accent) }

.doc { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 }
.docname {
  min-width: 0; width: min(360px, 100%);
  field-sizing: content; min-inline-size: 160px; max-inline-size: 360px;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 10px; font-size: 15px; font-weight: 500; color: var(--ink);
  text-overflow: ellipsis;
}
.docname:hover { border-color: var(--line) }
.docname { padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8c98' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L19 9l-4-4L4 16v4Z'/%3E%3Cpath d='m13.5 6.5 4 4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 15px }
.docname:focus { border-color: var(--line-strong); background: var(--raise); outline: none }
.docstate { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); white-space: nowrap }
.docstate::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted) }
.docstate[data-state="saved"]::before { background: var(--ok) }
.docstate[data-state="dirty"]::before, .docstate[data-state="new"]::before { background: var(--accent) }
.docstate[data-state="saving"]::before { background: var(--warn) }

.top-actions { display: flex; align-items: center; gap: 8px; flex: none }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--raise); color: var(--ink);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--muted) }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2) }
.btn.ghost:hover { background: var(--raise); color: var(--ink) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover) }
.btn.danger { color: var(--accent) }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px }
.btn:disabled { opacity: .5; cursor: default }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--raise); color: var(--ink) }
.icon-btn.glass { background: var(--glass); border-color: var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px) }
.user {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--raise-2); color: var(--ink); font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid var(--line-strong);
}

.menu-wrap { position: relative }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 250px; padding: 6px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  display: grid;
}
.menu button {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  text-align: left; padding: 9px 10px; border: 0; border-radius: 6px; background: none; cursor: pointer; color: var(--ink);
}
.menu button:hover, .menu button:focus-visible { background: var(--raise) }
.menu small { font-family: var(--f-mono); font-size: 11px; color: var(--muted) }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px }

/* ---------- Seitenleisten ---------- */
.side { background: var(--panel); overflow: auto; min-height: 0; padding: 16px }
.lib { border-right: 1px solid var(--line) }
.panel { border-left: 1px solid var(--line) }
.side h4 {
  margin: 20px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.side h4:first-child { margin-top: 0 }

.search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--raise); color: var(--muted);
}
.search:focus-within { border-color: var(--muted) }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); font-size: 14px }
.search input::placeholder { color: var(--muted) }
.lib .search { margin-bottom: 6px }
.lib .lg h4 { margin: 20px 0 8px }
.parts { display: grid; gap: 2px }
.part {
  display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 12px; align-items: center;
  width: 100%; padding: 6px; text-align: left; border-radius: 8px; border: 1px solid transparent; background: none;
  cursor: grab; color: var(--ink);
}
.part:hover { background: var(--raise); border-color: var(--line) }
.part:active { cursor: grabbing }
.thumb { width: 60px; height: 46px; border-radius: 6px; background: var(--raise-2); display: grid; place-items: center; overflow: hidden }
.thumb img { width: 60px; height: 46px; object-fit: contain; display: block }
.part b { display: block; font-weight: 500; font-size: 14px; line-height: 1.2 }
.part small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.25 }
.libnote { font-size: 12px; color: var(--muted); margin: 16px 2px 0; line-height: 1.5 }

/* ---------- Halle ---------- */
.stage { position: relative; min-height: 0; overflow: hidden; background: var(--scene) }
#view { position: absolute; inset: 0 }
#view canvas { display: block; touch-action: none }
.hud { position: absolute; left: 14px; right: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; pointer-events: none }
.hud > * { pointer-events: auto }
.hud-top { top: 14px }
.hud-bottom { bottom: 14px; justify-content: space-between; align-items: flex-end }
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tog {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px;
  border: 0; border-radius: 7px; background: none; color: var(--ink-2); font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.tog:hover { color: var(--ink); background: var(--raise) }
.tog.on { background: var(--accent-soft); color: var(--ink) }
.tog.on .ic { color: var(--accent) }
.chip {
  height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; backdrop-filter: blur(10px);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50% }
.chip.ok { background: var(--ok-soft); color: var(--ok) }
.chip.ok::before { background: var(--ok) }
.chip.bad { background: var(--warn-soft); color: var(--warn); border-color: var(--warn) }
.chip.bad::before { background: var(--warn) }
.readout, .keys {
  background: var(--glass); border: 1px solid var(--line); border-radius: 8px; backdrop-filter: blur(10px);
  padding: 6px 10px; font-size: 12.5px; color: var(--ink-2);
}
.readout { font-family: var(--f-mono); font-variant-numeric: tabular-nums; pointer-events: none }
.readout em { font-style: normal; color: var(--accent) }
.keys { pointer-events: none; max-width: calc(100% - 240px) }

/* ---------- Eigenschaften ---------- */
.panel h3 { margin: 0 0 2px; font-size: 19px; font-weight: 600; line-height: 1.2; text-wrap: balance }
.panel .type { font-size: 12.5px; color: var(--muted) }
.panel p { margin: 6px 0; color: var(--muted); font-size: 13px }
.fields { display: grid; gap: 10px; margin-top: 12px }
.row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px }
.row.two { grid-template-columns: repeat(2, minmax(0, 1fr)) }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0 }
label.f input, label.f select {
  height: 34px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--raise); color: var(--ink); width: 100%; min-width: 0; font-size: 13.5px;
}
label.f input[type="number"] { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 13px }
label.f input:focus, label.f select:focus { border-color: var(--muted); outline: none }
.dims { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 16px 0 0; font-size: 13px }
.dims dt { color: var(--muted) }
.dims dd { margin: 0; font-family: var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; font-size: 12.5px }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px }
.warn { margin-top: 12px; padding: 9px 11px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px }
table.bom { width: 100%; border-collapse: collapse; font-size: 13px }
table.bom td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top }
table.bom td:last-child { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; font-size: 12.5px }
table.bom tr.sum td { color: var(--ink); font-weight: 500 }
.keylist { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; font-size: 12.5px; color: var(--muted); align-items: center }
.keylist > span:nth-child(odd) { white-space: nowrap }

/* ---------- Dialog ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: var(--scrim);
  display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  backdrop-filter: blur(3px);
}
.dialog {
  width: min(900px, 100%); max-height: min(720px, 100%);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden;
}
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 0 22px }
.dlg-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em }
.dlg-head .icon-btn { margin-left: auto }
.mode { font-size: 12px; color: var(--muted); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-strong) }
.dlg-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 22px }
.dlg-tools .search { flex: 1 1 240px }
.dlg-note { margin: 0 22px 12px; padding: 9px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink-2); font-size: 13px }
.tablewrap { overflow: auto; min-height: 0; flex: 1 1 auto; padding: 0 12px 14px }
table.layouts { width: 100%; border-collapse: collapse; font-size: 13.5px }
table.layouts th {
  position: sticky; top: 0; background: var(--panel); z-index: 1;
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.layouts td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle }
table.layouts tr:hover td { background: var(--raise) }
table.layouts .num { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 12.5px }
table.layouts .nm { font-weight: 500; color: var(--ink) }
table.layouts .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap }
table.layouts .open-tag { margin-left: 8px; font-size: 11px; color: var(--accent); font-weight: 600; letter-spacing: .04em; text-transform: uppercase }
table.layouts .acts { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap }
.empty { color: var(--muted); padding: 28px 10px; text-align: center; margin: 0 }

/* ---------- Konto, Formulare ---------- */
button.user { cursor: pointer; padding: 0 }
button.user:hover { border-color: var(--muted) }
.menu-head { display: grid; gap: 1px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px }
.menu-head b { font-weight: 600 }
.menu-head small { color: var(--muted); font-family: var(--f-mono); font-size: 11.5px }
.dialog.narrow { width: min(460px, 100%) }
.dlg-body { display: grid; gap: 12px; padding: 16px 22px 22px }
.dlg-body .dlg-note { margin: 0 }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px }
.dlg-pad { margin: 0 22px 12px }
.form-err { margin: 0; padding: 9px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); border: 1px solid var(--accent); font-size: 13px }
.user-add { align-items: flex-end }
.user-add label.f { flex: 1 1 180px }
.chk { display: inline-flex; align-items: center; gap: 7px; height: 34px; font-size: 13.5px; color: var(--ink-2); cursor: pointer }
.chk input { width: 16px; height: 16px; accent-color: var(--accent) }
.pw-reveal { margin: 0 22px 14px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--ok); background: var(--ok-soft); display: grid; gap: 8px; font-size: 13.5px }
.pw-reveal small { color: var(--ink-2); line-height: 1.45 }
.pw-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap }
.pw-reveal code { font-family: var(--f-mono); font-size: 17px; letter-spacing: .06em; padding: 4px 10px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line-strong); user-select: all }
.role { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted) }
.role.admin { color: var(--accent); border-color: var(--accent) }
.docname-wrap { position: relative; display: inline-flex; align-items: center; min-width: 0 }

.selband { position: absolute; z-index: 5; pointer-events: none; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 3px }

/* ---------- Technische Daten ---------- */
#specBox { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line) }
#specBox h4 { margin-top: 14px }
.dims.specs dd { font-family: var(--f-ui); font-size: 13px; text-align: right; overflow-wrap: anywhere }
.dims.specs dt { white-space: nowrap }
.spec-note { font-size: 12.5px !important; line-height: 1.5; color: var(--muted) }
.tag { font-size: 10px; font-weight: 600; letter-spacing: .08em; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); margin-left: 6px; vertical-align: 1px }
.sim-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-left: 4px; vertical-align: 2px }
label.f textarea { padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--raise); color: var(--ink); width: 100%; font: inherit; font-size: 13px; resize: vertical }
label.f textarea:focus { border-color: var(--muted); outline: none }
a.btn { text-decoration: none }
.muted { color: var(--muted) }

/* ---------- Anmeldung ---------- */
.login {
  min-height: 100%; display: grid; place-items: center;
  padding: 32px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px));
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(239, 41, 2, .16), transparent 60%),
    linear-gradient(var(--bg), var(--bg));
}
.login-card {
  width: min(400px, 100%); display: grid; gap: 14px;
  padding: 30px 28px 22px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 14px }
.login-card h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.01em }
.login-sub { margin: -8px 0 4px; color: var(--muted); font-size: 14px }
.login-card .dlg-note { margin: 0; line-height: 1.5 }
.login-card code { display: block; margin-top: 6px; font-family: var(--f-mono); font-size: 11.5px; word-break: break-all }
.login-card label.f input { height: 42px; font-size: 15px }
.login-btn { height: 44px; justify-content: center; font-size: 15px; margin-top: 4px }

/* ---------- Meldungen ---------- */
.toasts {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 8px; width: min(520px, calc(100% - 32px));
}
.toast {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 14px; border-radius: 10px; background: var(--ink); color: var(--panel);
  box-shadow: var(--shadow); font-size: 13.5px; animation: tin .2s ease-out;
}
.toast.err { background: var(--accent); color: #fff }
.toast .msg { flex: 1 1 200px }
.toast button { border: 0; background: none; color: inherit; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; text-decoration: underline; text-underline-offset: 3px }
@keyframes tin { from { opacity: 0; transform: translateY(6px) } }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 240px minmax(0, 1fr) 280px }
  .top-actions .btn span { display: none }
  .top-actions .btn { padding: 0 10px }
  .keys { display: none }
}
@media (max-width: 860px) {
  html, body { height: auto }
  .app { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto }
  .top { flex-wrap: wrap; padding-block: 10px; gap: 10px 14px; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)) }
  .doc { order: 3; flex-basis: 100% }
  .top-actions { margin-left: auto }
  .stage { height: 64vh; min-height: 380px; order: 1 }
  .lib { order: 2; border-right: 0; border-top: 1px solid var(--line) }
  .panel { order: 3; border-left: 0; border-top: 1px solid var(--line) }
  .parts { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) }
  .tog span { display: none }
  table.layouts .hide-s { display: none }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important } }
