/* Lagerverwaltung – Stylesheet
   Modernes, dichtes Desktop-Layout, voll responsiv, Hell-/Dunkelmodus. */

:root {
  --radius: 10px;
  --radius-sm: 7px;
  --gap: 12px;
  --header-h: 56px;
  --filter-h: 46px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --transition: 160ms cubic-bezier(.4, 0, .2, 1);
}

/* ---- Dunkelmodus (Standard) ---- */
[data-theme="dark"] {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev2: #1e222b;
  --surface: #1a1e26;
  --border: #2a2f3a;
  --border-strong: #3a414f;
  --text: #e6e9ef;
  --text-dim: #9aa3b2;
  --text-faint: #6b7280;
  --accent: #4f8cff;
  --accent-hover: #3b78f0;
  --accent-soft: #1d2c4a;
  --danger: #ef4444;
  --danger-soft: #3a1d1f;
  --row-hover: #21262f;
  --row-sel: #233252;
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---- Hellmodus ---- */
[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-elev: #ffffff;
  --bg-elev2: #f7f9fc;
  --surface: #ffffff;
  --border: #e2e6ee;
  --border-strong: #ccd3df;
  --text: #1a1f2b;
  --text-dim: #5a6473;
  --text-faint: #8a93a3;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e4ecfd;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --row-hover: #f0f4fb;
  --row-sel: #dfeaff;
  --shadow: 0 12px 40px rgba(20, 30, 60, .18);
  color-scheme: light;
}

/* Status-Töne */
:root {
  --t-ok: #22c55e;  --t-warn: #f59e0b;  --t-todo: #60a5fa;  --t-bad: #ef4444;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }

kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-elev2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-dim);
}

/* ---------- Kopfzeile ---------- */
.topbar {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--gap);
  padding: 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand .logo { font-size: 20px; }
.brand h1 { font-size: 16px; font-weight: 650; margin: 0; letter-spacing: .2px; white-space: nowrap; }

.search-wrap { position: relative; flex: 1 1 auto; max-width: 560px; }
.search-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-hint { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.search-wrap input:focus + .search-hint { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  height: 36px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.btn:hover { background: var(--bg-elev2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.icon { width: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-elev2); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.save-state { width: 10px; height: 10px; border-radius: 50%; background: var(--text-faint); margin-left: 2px; transition: background var(--transition); }
.save-state.saving { background: var(--t-warn); }
.save-state.saved { background: var(--t-ok); }
.save-state.error { background: var(--t-bad); }

/* ---------- Filterleiste ---------- */
.filterbar {
  height: var(--filter-h);
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.filter {
  height: 32px;
  padding: 0 26px 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  max-width: 220px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 13px, calc(100% - 10px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.filter:hover { border-color: var(--border-strong); }
.filter[data-active="1"] { border-color: var(--accent); color: var(--accent); }
.spacer { flex: 1 1 auto; }
.result-count { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

/* ---------- Tabelle ---------- */
.table-scroll { flex: 1 1 auto; overflow: auto; position: relative; }
.items-table { width: 100%; border-collapse: collapse; }
.items-table thead th {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-elev);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-dim);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.items-table th.sortable { cursor: pointer; }
.items-table th.sortable:hover { color: var(--text); }
.items-table th .arrow { font-size: 10px; margin-left: 4px; opacity: .8; }

.items-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.items-table tbody tr { cursor: default; }
.items-table tbody tr:hover { background: var(--row-hover); }
.items-table tbody tr.selected { background: var(--row-sel); box-shadow: inset 3px 0 0 var(--accent); }
.cell-name { font-weight: 550; }
.cell-cat { white-space: nowrap; }
.cell-cat .cat-text { color: var(--text); font-size: 13px; }
.cell-sub { color: var(--text-dim); }
.cell-date { color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-date { white-space: nowrap; }
.cell-comment { color: var(--text-dim); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-actions { width: 1%; }
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
tr:hover .row-actions, tr.selected .row-actions { opacity: 1; }
.row-actions .btn { height: 28px; width: 28px; padding: 0; }

/* Badges & Chips */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--t-ok); background: color-mix(in srgb, var(--t-ok) 14%, transparent); }
.badge.warn { color: var(--t-warn); background: color-mix(in srgb, var(--t-warn) 14%, transparent); }
.badge.todo { color: var(--t-todo); background: color-mix(in srgb, var(--t-todo) 14%, transparent); }
.badge.bad { color: var(--t-bad); background: color-mix(in srgb, var(--t-bad) 14%, transparent); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--bg-elev2); border: 1px solid var(--border); font-size: 12px; color: var(--text-dim); margin: 1px 2px 1px 0; }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: baseline; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--text-dim); }

/* ---------- Panels (Slide-over) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; animation: fade var(--transition); }
@keyframes fade { from { opacity: 0; } }

.panel {
  position: fixed; top: 0; right: 0; height: 100vh;
  width: min(460px, 100vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 50;
  display: flex; flex-direction: column;
  animation: slidein var(--transition);
}
.panel.wide { width: min(720px, 100vw); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-body { padding: 18px; overflow-y: auto; flex: 1 1 auto; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding-top: 8px; margin-top: 6px; }

.panel-body label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--text-dim); }
.panel-body label > input,
.panel-body label > select,
.panel-body label > textarea {
  display: block; width: 100%; margin-top: 5px;
  height: 38px; padding: 0 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.panel-body label > textarea { height: auto; padding: 9px 11px; resize: vertical; }
.panel-body label > input:focus,
.panel-body label > select:focus,
.panel-body label > textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.muted { color: var(--text-faint); font-weight: 400; }

/* Mehrfach-Auswahl Chips (Lagerplätze) */
.chips-select {
  margin-top: 5px; min-height: 38px;
  display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start;
  padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.chips-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 6px;
  background: var(--bg-elev2); border: 1px solid var(--border);
  font-size: 12px; cursor: pointer; user-select: none;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .x { opacity: .6; }
.chips-empty { color: var(--text-faint); font-size: 12px; padding: 4px; }

/* ---------- Standorte-Liste ---------- */
.row-add { display: flex; gap: 8px; margin-bottom: 16px; }
.row-add input { flex: 1 1 auto; height: 38px; padding: 0 11px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.locations-list { display: flex; flex-direction: column; gap: 10px; }
.loc-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.loc-card-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.loc-card-head input.loc-name { flex: 1 1 auto; height: 32px; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 0 8px; font-weight: 600; }
.loc-card-head input.loc-name:hover { border-color: var(--border); }
.loc-card-head input.loc-name:focus { border-color: var(--accent); background: var(--bg-elev2); outline: none; }
.loc-count { font-size: 12px; color: var(--text-faint); }
.loc-card-body { padding: 0 12px 12px; border-top: 1px solid var(--border); }
.spots { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.spot-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 999px; background: var(--bg-elev2); border: 1px solid var(--border); font-size: 12px; }
.spot-pill button { border: none; background: transparent; cursor: pointer; color: var(--text-faint); padding: 0 2px; }
.spot-pill button:hover { color: var(--danger); }
.spot-add { display: flex; gap: 6px; margin-top: 8px; }
.spot-add input { flex: 1; height: 30px; padding: 0 9px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.loc-plan { margin-top: 10px; }
.loc-plan img { max-width: 100%; max-height: 160px; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: zoom-in; display: block; }
.loc-plan-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.global-plan { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.global-plan-head { display: flex; align-items: center; }
.global-plan-head h3 { margin: 0; font-size: 15px; }
.global-plan .loc-plan img { max-height: 320px; }
.global-spots { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.global-spots .muted.small { margin: 4px 0 8px; font-size: 12px; }

/* ---------- Daten-Panel ---------- */
.data-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.data-section:last-child { border-bottom: none; }
.data-section h3 { margin: 0 0 6px; font-size: 14px; }
.data-section p { margin: 0 0 10px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.check input { width: auto; }
.import-report { margin-top: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg-elev2); border: 1px solid var(--border); font-size: 13px; }
.import-report ul { margin: 6px 0 0; padding-left: 18px; }
.danger-zone h3 { color: var(--danger); }

/* ---------- Overlay / Hilfe ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade var(--transition); }
.help-card { width: min(460px, 100%); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; padding: 18px; align-items: center; }
.help-grid kbd { justify-self: start; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 11px 18px; box-shadow: var(--shadow); z-index: 80;
  animation: toastin var(--transition);
}
.toast .btn.small {
  margin-left: 12px;
  background: color-mix(in srgb, var(--t-warn) 18%, transparent);
  border-color: color-mix(in srgb, var(--t-warn) 48%, transparent);
  color: var(--t-warn);
}
.toast .btn.small:hover {
  background: color-mix(in srgb, var(--t-warn) 28%, transparent);
  border-color: color-mix(in srgb, var(--t-warn) 70%, transparent);
}
.toast.error { border-color: var(--danger); }
@keyframes toastin { from { transform: translate(-50%, 12px); opacity: 0; } }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 30px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius); }

/* ---------- Lageplan & Marker ---------- */
.plan-canvas { position: relative; display: inline-block; line-height: 0; max-width: 100%; }
.plan-canvas img { display: block; max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.plan-canvas.plan-edit.placing { cursor: crosshair; }
.plan-canvas.plan-edit.placing img { outline: 2px dashed var(--accent); outline-offset: -2px; }

.plan-marker { position: absolute; transform: translate(-50%, -50%); z-index: 3; display: flex; flex-direction: column; align-items: center; }
.plan-marker:hover { z-index: 12; }
.plan-pin {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(0, 0, 0, .55);
  flex: none;
}

/* Marker in der Großansicht (mit Namen + Inhaltsliste) */
.plan-marker.view { cursor: pointer; }
.plan-marker.view .plan-label {
  margin-top: 5px; text-align: left;
  background: rgba(12, 15, 20, .9); color: #fff;
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 8px;
  padding: 5px 9px; min-width: 60px; max-width: 220px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.plan-marker.view.edge-right .plan-label { transform: translateX(calc(-50% + 7px)); }
.plan-marker.view.edge-left .plan-label { transform: translateX(calc(50% - 7px)); }
.plan-loc-name { font-weight: 700; font-size: 13px; line-height: 1.25; white-space: nowrap; }
.plan-loc-count { color: var(--accent); font-weight: 600; }
.plan-label-body { display: none; }
.plan-marker.view.open { z-index: 14; }
.plan-marker.view.open .plan-label-body { display: block; }
.plan-item-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: 11px; color: #c7d0db; max-height: 220px; overflow-y: auto; }
.plan-item-list li { line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.plan-item-list li.more { color: var(--accent); font-weight: 600; }
.plan-empty-loc { font-size: 11px; color: #8b94a1; margin-top: 5px; }

/* Marker im Bearbeiten-Modus (ziehbar, kompakt) */
.plan-marker.edit { flex-direction: row; gap: 5px; cursor: grab; touch-action: none; }
.plan-marker.edit.dragging { cursor: grabbing; z-index: 20; }
.plan-marker.edit .plan-tag {
  background: rgba(12, 15, 20, .9); color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 6px; white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, .16);
}
.plan-hint { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--accent); }
.btn.icon.active { color: var(--accent); }
.btn.icon.placing { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* Lageplan-Großansicht (Overlay) */
.planview { position: fixed; inset: 0; background: rgba(8, 10, 14, .95); z-index: 95; display: flex; flex-direction: column; animation: fade var(--transition); }
.plan-editbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.plan-edit-label { font-size: 13px; color: var(--text-dim); }
.plan-edit-select { min-width: 220px; }
.planview-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.planview-title { font-weight: 600; font-size: 15px; }
.planview-body { flex: 1 1 auto; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 24px; }
.planview-body .plan-canvas img { border: none; }
.plan-empty { margin: auto; color: var(--text-dim); text-align: center; }

/* --- Baum-Übersicht (Kategorien & Gegenstände) --------------------------- */
.treeview { background: var(--bg); }
.treeview .planview-bar { background: var(--bg-elev); }
.tree-bar-actions { display: flex; align-items: center; gap: 8px; }
.treeview-body { flex: 1 1 auto; overflow: auto; padding: 20px; }
.tree-wrap {
  max-width: 1100px; margin: 0 auto;
  columns: 3 320px; column-gap: 18px;
}
.tree-cat {
  break-inside: avoid; margin: 0 0 16px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  border-left: 4px solid var(--cat, #94a3b8);
}
.tree-cat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; cursor: pointer; user-select: none;
  transition: background var(--transition);
}
.tree-cat-head:hover { background: var(--bg-elev2); }
.tree-caret { color: var(--text-faint); font-size: 11px; width: 12px; transition: transform var(--transition); }
.tree-cat.collapsed .tree-caret { transform: rotate(-90deg); }
.tree-cat-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--cat, #94a3b8); flex: none; }
.tree-cat-name { font-weight: 600; font-size: 14px; flex: 1 1 auto; }
.tree-cat-count {
  font-size: 12px; color: var(--text-dim); background: var(--bg-elev2);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; flex: none;
}
.tree-items { list-style: none; margin: 0; padding: 4px 0 8px; }
.tree-cat.collapsed .tree-items { display: none; }
.tree-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 30px; position: relative; cursor: pointer;
  font-size: 13px; transition: background var(--transition);
}
.tree-item:hover { background: var(--accent-soft); }
.tree-item::before {
  content: ""; position: absolute; left: 19px; top: 0; bottom: 50%;
  width: 8px; border-left: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong); border-bottom-left-radius: 4px;
}
.tree-item:not(:last-child)::after {
  content: ""; position: absolute; left: 19px; top: 50%; bottom: 0;
  border-left: 1px solid var(--border-strong);
}
.tree-item-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item-loc { color: var(--text-dim); font-size: 12px; flex: none; }
.tree-item .badge { flex: none; }
.tree-empty-cat { padding: 6px 14px 10px 30px; color: var(--text-faint); font-size: 12px; font-style: italic; }
.tree-status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tree-status-dot.ok { background: var(--t-ok); }
.tree-status-dot.warn { background: var(--t-warn); }
.tree-status-dot.bad { background: var(--t-bad); }
.tree-status-dot.todo { background: var(--t-todo); }
@media (max-width: 760px) {
  .tree-wrap { columns: 1; }
  .treeview-body { padding: 12px; }
}

/* Druckkopf & Legende der Baum-Übersicht – am Bildschirm ausgeblendet */
.tree-print-head { display: none; }
.tree-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; break-inside: avoid; }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }

.loc-plan-state { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.loc-plan-state:not(:empty) { padding: 2px 8px; border-radius: 999px; background: var(--bg-elev2); border: 1px solid var(--border); }

/* ---------- Verwalten-Dropdown (Topbar) ---------- */
.menu-group { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 250px; padding: 6px; z-index: 60;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.menu-item {
  display: flex; align-items: center; gap: 9px;
  height: 36px; padding: 0 10px; text-align: left; white-space: nowrap;
  background: transparent; border: none; border-radius: 6px; cursor: pointer; color: inherit;
}
.menu-item:hover { background: var(--bg-elev2); }

/* ---------- Sortier-Steuerung (Filterbar) ---------- */
.sort-wrap { display: inline-flex; align-items: center; gap: 6px; margin-right: 4px; }
.sort-label { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.sort-wrap .filter { max-width: 150px; }
#f-sortdir { width: 30px; padding: 0; }

/* ---------- Inline-Bearbeitung (Tabelle) ---------- */
.col-expand { width: 34px; text-align: center; }
.expand-btn {
  background: transparent; border: none; cursor: pointer; color: var(--text-dim);
  font-size: 13px; line-height: 1; padding: 4px; transition: transform var(--transition), color var(--transition);
}
.expand-btn:hover { color: var(--text); }
.expand-btn.open { transform: rotate(90deg); color: var(--accent); }

.inline-name {
  width: 100%; min-width: 130px;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 5px 8px; font-weight: 550; color: var(--text);
}
.inline-name:hover { border-color: var(--border); }
.inline-name:focus { border-color: var(--accent); background: var(--surface); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.add-name::placeholder { color: var(--text-faint); font-weight: 400; }

.inline-sel {
  max-width: 200px; height: 30px; padding: 0 24px 0 8px;
  background: var(--surface); border: 1px solid transparent; border-radius: 6px;
  color: var(--text); cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 13px) 12px, calc(100% - 8px) 12px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.inline-sel:hover { border-color: var(--border-strong); }
.inline-sel:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); outline: none; }
.inline-sel.tone-ok { color: var(--t-ok); }
.inline-sel.tone-warn { color: var(--t-warn); }
.inline-sel.tone-todo { color: var(--t-todo); }
.inline-sel.tone-bad { color: var(--t-bad); }

.add-row > td { background: color-mix(in srgb, var(--accent) 6%, transparent); border-bottom: 2px solid var(--border-strong); }
.add-row .add-plus { color: var(--accent); font-weight: 700; }

/* ---------- Ausklapp-Detailzeile ---------- */
.detail-row > td { padding: 6px 14px 14px 46px; background: var(--bg-elev2); border-bottom: 1px solid var(--border); }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px 18px; }
.detail-field { display: flex; flex-direction: column; gap: 4px; margin: 0; font-size: 12px; color: var(--text-dim); }
.detail-field.full { grid-column: 1 / -1; }
.detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-faint); }
.detail-field .inline-sel { max-width: none; width: 100%; background: var(--surface); border-color: var(--border); }
.detail-static { padding: 6px 2px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.inline-comment {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px; color: var(--text); resize: vertical;
}
.inline-comment:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); outline: none; }

/* ---------- Lagerplatz-Auswahl (Spalte) ---------- */
.spot-pick {
  max-width: 190px; height: 30px; padding: 0 22px 0 9px;
  background: var(--surface); border: 1px solid transparent; border-radius: 6px;
  color: var(--text); cursor: pointer; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 13px) 12px, calc(100% - 8px) 12px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.spot-pick:hover { border-color: var(--border-strong); }
.spot-pick:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); outline: none; }
.spot-pick.empty { color: var(--text-faint); }

.spot-popover {
  position: fixed; z-index: 85; padding: 6px;
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.spot-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.spot-opt:hover { background: var(--bg-elev2); }
.spot-opt.on { color: var(--accent); }
.spot-opt input { width: auto; accent-color: var(--accent); cursor: pointer; }

/* ---------- Einstellungen: Options-Listen ---------- */
.option-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.option-row { display: flex; align-items: center; gap: 8px; }
.option-row .opt-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-faint); flex: 0 0 auto; }
.option-row .opt-name {
  flex: 1 1 auto; height: 32px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.option-row .opt-name:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); outline: none; }
.option-row .btn.icon { height: 30px; width: 30px; }
.option-row .loc-count { min-width: 22px; text-align: right; }
.opt-dot.tone-ok { background: var(--t-ok); }
.opt-dot.tone-warn { background: var(--t-warn); }
.opt-dot.tone-todo { background: var(--t-todo); }
.opt-dot.tone-bad { background: var(--t-bad); }
.opt-dot.tone-p1 { background: var(--t-p1); }
.opt-dot.tone-p2 { background: var(--t-p2); }
.opt-dot.tone-p3 { background: var(--t-p3); }
.opt-dot.tone-p4 { background: var(--t-p4); }

/* ---------- Fortschritt & Ohne-Platz-Filter ---------- */
.chip-toggle[data-active="1"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.progress { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.progress-bar { width: 90px; height: 7px; border-radius: 999px; background: var(--bg-elev2); border: 1px solid var(--border); overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--accent); transition: width var(--transition); }
.progress-text { font-size: 12px; color: var(--text-dim); }
.progress[data-done="1"] .progress-fill { background: var(--t-ok); }
.progress[data-done="1"] .progress-text { color: var(--t-ok); }

/* ---------- Fehlender Platz ---------- */
.inline-sel.loc-sel.missing {
  color: var(--t-bad);
  border-color: color-mix(in srgb, var(--t-bad) 55%, transparent);
  background-color: color-mix(in srgb, var(--t-bad) 10%, transparent);
}

/* ---------- Responsiv ---------- */
@media (max-width: 860px) {
  .brand h1 { display: none; }
  #btn-locations span, #btn-import span { display: none; }
}
@media (max-width: 920px) {
  .detail-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .sort-label { display: none; }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .search-wrap { order: 3; max-width: none; flex-basis: 100%; }
  .btn span { display: none; }
  .panel, .panel.wide { width: 100vw; }
  .grid-2 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }

  /* Lageplan mobil: größer + horizontal/vertikal verschiebbar */
  .planview-bar { padding: 10px 12px; }
  .planview-body {
    padding: 8px;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .planview-body .plan-canvas {
    width: max-content;
    max-width: none;
    display: block;
  }
  .planview-body .plan-canvas img {
    max-width: none;
    width: max(145vw, 920px);
    height: auto;
  }
  .plan-marker.view .plan-pin { width: 18px; height: 18px; }
  .plan-marker.view .plan-label { max-width: 190px; }

  /* Tabelle → Kartenansicht */
  .table-scroll { padding: 8px; }
  .items-table thead { display: none; }
  .items-table, .items-table tbody { display: block; }
  .items-table tbody tr:not(.detail-row) {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "expand name actions"
      "expand cat cat"
      "expand loc loc"
      "expand spot spot"
      "expand status status";
    align-items: center;
    column-gap: 8px;
    row-gap: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
  }
  .items-table tbody tr:not(.detail-row):hover { background: var(--bg-elev); }
  .items-table tbody tr:not(.detail-row) > td { display: block; padding: 0; border: none; }
  .items-table .col-expand { grid-area: expand; align-self: start; padding-top: 2px; }
  .items-table .cell-name { grid-area: name; font-size: 15px; }
  .items-table .cell-cat { grid-area: cat; white-space: normal; }
  .items-table .cell-loc { grid-area: loc; }
  .items-table .cell-spot { grid-area: spot; }
  .items-table .cell-status { grid-area: status; }
  .items-table .col-actions { grid-area: actions; width: auto; justify-self: end; }
  .items-table .cell-name input { font-size: 15px; }
  .items-table .cell-loc .inline-sel,
  .items-table .cell-status .inline-sel { max-width: 100%; }
  .items-table .cell-spot .spot-pick { max-width: 100%; width: 100%; }
  .items-table .row-actions { opacity: 1; }
  .items-table .row-actions .btn { height: 32px; width: 32px; }
  .items-table tbody tr.detail-row { display: block; margin: -4px 0 8px; }
  .items-table tbody tr.detail-row > td { display: block; padding: 0 12px 8px; }
}

/* ---------- Drucken ---------- */
.print-only { display: none; }
@media print {
  body { height: auto; overflow: visible; background: #fff; color: #000; }
  .topbar, .filterbar, .panel, .scrim, .overlay, .toast, .lightbox,
  .col-actions, .row-actions, #empty-state { display: none !important; }
  .print-only { display: block !important; }
  .table-scroll { overflow: visible; height: auto; }
  #print-header h1 { margin: 0 0 4px; font-size: 18px; }
  .print-meta { font-size: 11px; color: #333; margin-bottom: 10px; }
  .items-table { width: 100%; font-size: 11px; }
  .items-table thead th { position: static; color: #000; background: #fff; border-bottom: 1.5px solid #000; text-transform: none; }
  .items-table tbody td { color: #000; border-bottom: 1px solid #ccc; }
  .col-expand, .add-row { display: none !important; }
  tbody tr:hover, tbody tr.selected { background: none !important; box-shadow: none !important; }
  .badge { background: none !important; color: #000 !important; padding: 0; font-weight: 500; }
  .badge::before { display: none; }
  .tag { background: none; border: none; color: #000; padding: 0 4px 0 0; }
  .cat-dot { display: none; }
  /* Inline-Eingaben als reinen Text drucken */
  .inline-name, .inline-sel, .inline-comment, .spot-pick {
    border: none !important; background: none !important; color: #000 !important;
    appearance: none; padding: 0 !important; box-shadow: none !important; -webkit-appearance: none;
  }
  .spot-pick { background-image: none !important; }
  .detail-row > td { background: none !important; padding: 0 12px 8px 12px; }
  .detail-grid { grid-template-columns: repeat(4, 1fr); }
  .detail-label { color: #555; }
  @page { margin: 14mm; }

  /* --- Druckversion der Baum-Übersicht --------------------------------- */
  body.printing-tree .table-scroll,
  body.printing-tree #print-header,
  body.printing-tree .topbar,
  body.printing-tree .filterbar { display: none !important; }
  body.printing-tree .treeview[hidden] { display: block !important; }
  body.printing-tree .treeview {
    display: block !important; position: static; inset: auto;
    height: auto; background: #fff; color: #000; z-index: auto;
  }
  body.printing-tree .planview-bar { display: none !important; }
  body.printing-tree .treeview-body { display: block; overflow: visible; padding: 0; }
  body.printing-tree .tree-print-head { display: block; margin: 0 0 12px; }
  body.printing-tree .tree-print-head h1 { margin: 0 0 4px; font-size: 18px; color: #000; }
  body.printing-tree .tree-print-meta { font-size: 11px; color: #333; margin-bottom: 10px; }
  body.printing-tree .tree-legend-title { font-size: 12px; font-weight: 600; margin: 0 0 5px; }
  body.printing-tree .tree-legend {
    margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #000;
  }
  body.printing-tree .legend-item { color: #000; }
  body.printing-tree .tree-wrap { max-width: none; margin: 0; columns: 2; column-gap: 16px; }
  body.printing-tree .tree-cat {
    background: #fff !important; border: 1px solid #999; border-left-width: 4px;
    margin-bottom: 10px;
  }
  body.printing-tree .tree-cat-head { padding: 6px 8px; background: #fff !important; }
  body.printing-tree .tree-caret { display: none; }
  body.printing-tree .tree-cat-name { color: #000; font-size: 12px; }
  body.printing-tree .tree-cat-count { color: #000; background: #fff; border-color: #999; }
  /* Immer alles ausgeklappt drucken */
  body.printing-tree .tree-cat.collapsed .tree-items { display: block !important; }
  body.printing-tree .tree-items { padding: 2px 0 5px; }
  body.printing-tree .tree-item { padding: 2px 8px 2px 26px; color: #000; font-size: 11px; break-inside: avoid; }
  body.printing-tree .tree-item::before,
  body.printing-tree .tree-item::after { border-color: #999 !important; }
  body.printing-tree .tree-item-loc { color: #444; }
  body.printing-tree .tree-item:hover { background: none !important; }
  /* Farben (Kategorie- & Statuspunkte, Legende) exakt drucken */
  body.printing-tree .tree-cat,
  body.printing-tree .tree-cat-dot,
  body.printing-tree .tree-status-dot,
  body.printing-tree .legend-dot {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
