/* ==========================================================================
   Lagerplaner – styles.css
   1 Tokens & Themes · 2 Grundlayout · 3 Gemeinsame Komponenten · 4 Builder
   ========================================================================== */

/* ---------- 1  Tokens (hell = Standard) ---------- */
:root {
  color-scheme: light;
  --bg: #e8ebed;
  --panel: #fbfcfc;
  --panel-2: #f0f2f3;
  --ink: #161b1f;
  --muted: #59646c;
  --line: #d3d9dd;
  --accent: #f2b705;
  --accent-ink: #161b1f;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --err: #c8261c;
  --info: #2468a8;
  --f-disp: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 6px;

  /* Canvas-Farben */
  --c-floor: #f3f5f6;
  --c-grid: rgba(22, 27, 31, .07);
  --c-grid10: rgba(22, 27, 31, .18);
  --c-wall: #2b3238;
  --c-yard: #d5dadd;
  --c-road: #7b8287;
  --c-roadline: #f2b705;
  --c-walk: #bfe0bb;
  --c-buf: #8fb0ee;
  --c-chk: #b1a2e6;
  --c-pick: #6fcabd;
  --c-pack: #dba7d0;
  --c-wa: #8ccf98;
  --c-chg: #f2c94c;
  --c-office: #aab2b8;
  --c-wallcell: #4b545b;
  --c-pal: #e8641b;
  --c-narrow: #c2410c;
  --c-flow: #2f7fd1;
  --c-drive: #8a5a2b;
  --c-mobile: #7b6bd6;
  --c-block: #b08a5a;
  --c-shelf: #5f8196;
  --c-pallet: #a9743a;
  --c-label: #161b1f;
  --c-labelbg: rgba(251, 252, 252, .88);
  --c-bad: #d7261e;
  --c-truckin: #2f7fd1;
  --c-truckout: #e8641b;

  /* Rollen (Simulation) */
  --r-pruef: #7b6bd6;
  --r-ein: #2f7fd1;
  --r-aus: #e0702a;
  --r-komm: #1f9d8f;
  --r-verl: #c23b6b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111518;
    --panel: #181d21;
    --panel-2: #1f252a;
    --ink: #e6eaed;
    --muted: #9aa5ad;
    --line: #2c343a;
    --accent: #f2b705;
    --accent-ink: #161b1f;
    --ok: #4cc38a;
    --warn: #f0b429;
    --err: #ff6b5e;
    --info: #6fb1f2;

    --c-floor: #262c30;
    --c-grid: rgba(255, 255, 255, .055);
    --c-grid10: rgba(255, 255, 255, .15);
    --c-wall: #9aa5ad;
    --c-yard: #14181b;
    --c-road: #50575c;
    --c-roadline: #f2b705;
    --c-walk: #4d6d4b;
    --c-buf: #4f6fb0;
    --c-chk: #6f62b4;
    --c-pick: #2f8f83;
    --c-pack: #a1649a;
    --c-wa: #4a9a5b;
    --c-chg: #b48f1e;
    --c-office: #566068;
    --c-wallcell: #9aa4ab;
    --c-pal: #e8641b;
    --c-narrow: #e0551d;
    --c-flow: #3f8fe0;
    --c-drive: #a8743a;
    --c-mobile: #8f80e6;
    --c-block: #9c7c4c;
    --c-shelf: #7a9bb0;
    --c-pallet: #c49a5e;
    --c-label: #f1f4f6;
    --c-labelbg: rgba(20, 24, 27, .84);
    --c-bad: #ff5a4d;
    --c-truckin: #4aa3ff;
    --c-truckout: #ff9f43;

    --r-pruef: #9a8cf0;
    --r-ein: #4aa3ff;
    --r-aus: #ff9f43;
    --r-komm: #38c1b1;
    --r-verl: #ee6a9a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111518;
  --panel: #181d21;
  --panel-2: #1f252a;
  --ink: #e6eaed;
  --muted: #9aa5ad;
  --line: #2c343a;
  --accent: #f2b705;
  --accent-ink: #161b1f;
  --ok: #4cc38a;
  --warn: #f0b429;
  --err: #ff6b5e;
  --info: #6fb1f2;

  --c-floor: #262c30;
  --c-grid: rgba(255, 255, 255, .055);
  --c-grid10: rgba(255, 255, 255, .15);
  --c-wall: #9aa5ad;
  --c-yard: #14181b;
  --c-road: #50575c;
  --c-roadline: #f2b705;
  --c-walk: #4d6d4b;
  --c-buf: #4f6fb0;
  --c-chk: #6f62b4;
  --c-pick: #2f8f83;
  --c-pack: #a1649a;
  --c-wa: #4a9a5b;
  --c-chg: #b48f1e;
  --c-office: #566068;
  --c-wallcell: #9aa4ab;
  --c-pal: #e8641b;
  --c-narrow: #e0551d;
  --c-flow: #3f8fe0;
  --c-drive: #a8743a;
  --c-mobile: #8f80e6;
  --c-block: #9c7c4c;
  --c-shelf: #7a9bb0;
  --c-pallet: #c49a5e;
  --c-label: #f1f4f6;
  --c-labelbg: rgba(20, 24, 27, .84);
  --c-bad: #ff5a4d;
  --c-truckin: #4aa3ff;
  --c-truckout: #ff9f43;

  --r-pruef: #9a8cf0;
  --r-ein: #4aa3ff;
  --r-aus: #ff9f43;
  --r-komm: #38c1b1;
  --r-verl: #ee6a9a;
}

/* ---------- 2  Grundlayout ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 var(--f-body);
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
h1, h2, h3, h4 { font-family: var(--f-disp); font-weight: 600; margin: 0; letter-spacing: .01em; }
p { margin: 0; }
button, select, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.btn:focus-visible, .tab:focus-visible, .tool:focus-visible, .seg button:focus-visible { outline-offset: 1px; box-shadow: 0 0 0 4px rgba(242, 183, 5, .28); }

.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

/* Kopfzeile */
.appbar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px 24px;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.appbar::after { /* Bodenmarkierung unter dem Header */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 10px, #161b1f 10px 20px);
  opacity: .9;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 3px; flex: none;
  background: repeating-linear-gradient(-45deg, #f2b705 0 5px, #161b1f 5px 10px);
  box-shadow: inset 0 0 0 1.5px #161b1f;
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--f-disp); font-weight: 700; font-size: 22px; letter-spacing: .02em; text-transform: uppercase; }
.brand-sub { font-family: var(--f-mono); font-size: 11px; color: var(--muted); margin-top: 2px; }

.tabs { display: flex; gap: 2px; align-self: stretch; align-items: stretch; }
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  font-family: var(--f-disp); font-weight: 600; font-size: 17px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
  padding: 8px 14px; border-bottom: 3px solid transparent; margin-bottom: -9px; padding-bottom: 14px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.presetbar { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field span { font-family: var(--f-disp); font-weight: 600; font-size: 14px; letter-spacing: .05em; text-transform: uppercase; }
select, input[type="text"], input[type="number"], textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 10px; min-height: 34px;
}
select { max-width: min(46vw, 330px); }

/* Views */
.views { min-height: 0; position: relative; }
.view {
  height: 100%; min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
}
.view.task { display: block; overflow: auto; }
.pane {
  min-height: 0; min-width: 0; overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px 16px 24px;
}
.pane.side { border-right: 0; border-left: 1px solid var(--line); }
.stage { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.cwrap {
  position: relative; flex: 1 1 0; min-height: 200px; min-width: 0;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cwrap canvas { display: block; flex: none; margin: 0 auto; }

@media (max-width: 1099px) {
  html, body { height: auto; }
  .app { height: auto; display: block; }
  .views { min-height: 0; }
  .view { display: flex; flex-direction: column; height: auto; }
  .stage { order: -1; }
  .pane, .pane.side { overflow: visible; border: 0; border-top: 1px solid var(--line); }
  .cwrap { flex: none; display: block; min-height: 0; overflow: hidden; }
  .appbar { gap: 8px 16px; }
  .presetbar { margin-left: 0; width: 100%; }
  .presetbar .field { flex: 1; }
  select { max-width: none; width: 100%; }
  .tab { margin-bottom: 0; padding-bottom: 8px; }
}

/* ---------- 3  Gemeinsame Komponenten ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 5px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--f-disp); font-weight: 600; font-size: 15px; letter-spacing: .03em;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--muted); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: #161b1f; }
.btn.primary:hover:not(:disabled) { background: #ffc61a; border-color: #161b1f; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: var(--line); }
.btn.danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn[aria-pressed="false"].toggle { opacity: .85; }

.seg { display: inline-flex; width: 100%; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.seg button {
  flex: 1 1 0; appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 6px 8px; min-height: 34px;
  font-family: var(--f-disp); font-weight: 500; font-size: 14px; letter-spacing: .02em; line-height: 1.15;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--panel-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.seg.stack { flex-direction: column; }
.seg.stack button { border-right: 0; border-bottom: 1px solid var(--line); text-align: left; padding-left: 10px; }
.seg.stack button:last-child { border-bottom: 0; }

.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.stepper button { appearance: none; width: 36px; border: 0; background: var(--panel-2); cursor: pointer; font-size: 18px; line-height: 1; }
.stepper button:hover:not(:disabled) { background: var(--line); }
.stepper button:disabled { opacity: .4; cursor: not-allowed; }
.stepper input {
  width: 48px; text-align: center; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  border-radius: 0; min-height: 34px; padding: 0 4px; background: var(--panel);
  font-family: var(--f-mono); font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pane-h {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-disp); font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.pane-h:first-child { margin-top: 0; }
.pane-h::before { content: ""; width: 10px; height: 10px; background: repeating-linear-gradient(-45deg, var(--accent) 0 3px, #161b1f 3px 6px); border-radius: 1px; flex: none; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; min-width: 0; }
.kpi.big { grid-column: 1 / -1; padding: 10px 12px; border-left: 4px solid var(--accent); }
.kpi-l { font-size: 12px; color: var(--muted); line-height: 1.2; }
.kpi-v { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-weight: 500; font-size: 20px; line-height: 1.2; margin-top: 3px; white-space: nowrap; }
.kpi.big .kpi-v { font-size: 34px; font-weight: 500; letter-spacing: -.01em; }
.kpi-v small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.kpi.is-err .kpi-v { color: var(--err); }
.kpi.is-warn .kpi-v { color: var(--warn); }

.pill {
  display: inline-block; flex: none;
  font-family: var(--f-disp); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  padding: 1px 7px 0; border-radius: 3px; border: 1.5px solid currentColor; line-height: 1.5;
}
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }
.pill.err { color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); }
.pill.info { color: var(--info); }

.chk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chk {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px;
}
.chk.lvl-ok { border-left-color: var(--ok); }
.chk.lvl-warn { border-left-color: var(--warn); }
.chk.lvl-err { border-left-color: var(--err); }
.chk.lvl-info { border-left-color: var(--info); }
.chk .chk-t { font-weight: 600; line-height: 1.25; padding-top: 1px; }
.chk .chk-x { grid-column: 2; font-size: 13px; color: var(--muted); line-height: 1.35; }
.chk.has-cells { cursor: pointer; }
.chk.has-cells:hover { background: var(--panel); border-color: var(--muted); border-left-color: inherit; }
.chk.has-cells .chk-t::after { content: "  – im Plan zeigen"; font-weight: 400; font-size: 12px; color: var(--muted); }
.chk.is-active { outline: 2px solid var(--accent); outline-offset: -2px; }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  background: var(--ink); color: var(--panel); border-radius: var(--radius); padding: 9px 16px;
  font-weight: 500; box-shadow: 0 6px 22px rgba(0, 0, 0, .28); border-left: 4px solid var(--accent);
  animation: toast-in .18s ease-out;
}
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 4  Builder ---------- */
.tool-group { display: flex; flex-direction: column; gap: 2px; }
.tool {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px;
  width: 100%; appearance: none; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  padding: 6px 8px; min-height: 36px;
  font-weight: 500;
}
.tool:hover { background: var(--panel-2); }
.tool[aria-pressed="true"] { background: var(--panel-2); border-color: var(--ink); box-shadow: inset 4px 0 0 var(--accent); }
.tool .sw { width: 20px; height: 20px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); display: block; }
.tool .sw.none { background: repeating-linear-gradient(-45deg, transparent 0 3px, var(--line) 3px 5px); border-style: dashed; border-color: var(--muted); }
.tool .sw.erase { background: var(--panel); border-color: var(--err); position: relative; }
.tool .sw.erase::after { content: ""; position: absolute; inset: 8px 2px auto 2px; height: 2px; background: var(--err); transform: rotate(-35deg); }
.tool kbd, kbd.k {
  font-family: var(--f-mono); font-size: 11px; min-width: 20px; text-align: center;
  padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--panel); color: var(--muted);
}

.opts { display: flex; flex-direction: column; gap: 12px; }
.opt { display: flex; flex-direction: column; gap: 5px; }
.opt-l { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.lvread { font-family: var(--f-mono); font-size: 12.5px; padding: 6px 9px; border-radius: var(--radius); border: 1px solid; line-height: 1.35; font-variant-numeric: tabular-nums; }
.lvread.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.lvread.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.lvread.err { color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); }
.lvread small { display: block; font-family: var(--f-body); color: var(--muted); font-size: 12px; }
.checkrow { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; font-size: 13.5px; }
.checkrow input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

.infocard { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.infocard h3 { font-size: 20px; display: flex; align-items: center; gap: 8px; }
.infocard h3 .sw { width: 14px; height: 14px; border-radius: 2px; border: 1px solid rgba(0, 0, 0, .35); flex: none; }
.infocard .short { margin: 6px 0 8px; }
.infocard ul { list-style: none; margin: 4px 0 8px; padding: 0; font-size: 13px; }
.infocard li { padding-left: 18px; position: relative; margin: 2px 0; }
.infocard li.pro::before { content: "+"; position: absolute; left: 3px; color: var(--ok); font-weight: 700; }
.infocard li.con::before { content: "–"; position: absolute; left: 4px; color: var(--err); font-weight: 700; }
.infocard .facts { font-family: var(--f-mono); font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; line-height: 1.5; }
.infocard .sub { font-family: var(--f-disp); font-weight: 700; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

/* Toolbar über dem Plan */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tb-group { display: flex; gap: 6px; flex-wrap: wrap; }
.tb-hint { flex: 1 1 260px; font-size: 12.5px; color: var(--muted); line-height: 1.3; }

#lsCanvas { background: transparent; user-select: none; -webkit-user-select: none; touch-action: none; }

.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 260px;
  background: var(--ink); color: var(--panel); border-radius: var(--radius);
  padding: 7px 10px; font-size: 12.5px; line-height: 1.4; box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}
.tip b { font-family: var(--f-disp); font-size: 15px; letter-spacing: .02em; }
.tip .mono { font-family: var(--f-mono); font-size: 11.5px; opacity: .85; }
.tip .bad { color: #ff9a90; }
.tip .good { color: #8ee0b0; }

/* Export / Import */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(10, 14, 17, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: var(--radius); width: min(640px, 100%); max-height: 100%; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 18px 60px rgba(0, 0, 0, .4); }
.dialog-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-h h2 { font-size: 24px; }
.dialog textarea { width: 100%; resize: vertical; font-family: var(--f-mono); font-size: 12px; line-height: 1.4; word-break: break-all; }
.dialog-f { display: flex; justify-content: flex-end; gap: 8px; }
.io-msg { min-height: 1.3em; font-size: 13px; }
.io-msg.err { color: var(--err); }
.io-msg.ok { color: var(--ok); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
