:root {
  --blue: #1e3a5f; --blue2: #2c5282; --red: #c0392b; --green: #1e8449; --amber: #d68910;
  --bg: #f1f4f8; --card: #fff; --text: #1a202c; --muted: #64748b; --line: #dbe2ea;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
a { color: var(--blue2); }

.layout { display: flex; min-height: 100vh; }
nav.side { width: 210px; flex: none; background: var(--blue); color: #fff; padding: 16px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
nav.side h1 { font-size: 18px; margin: 0 8px 14px; }
nav.side h1 small { display: block; font-weight: 400; opacity: .7; font-size: 12px; }
nav.side a { color: #dbe7f5; text-decoration: none; padding: 9px 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
nav.side a:hover { background: rgba(255, 255, 255, .1); }
nav.side a.on { background: #fff; color: var(--blue); font-weight: 700; }
nav.side .sp { flex: 1; }
nav.side .cnt { background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }
main { flex: 1; padding: 22px 26px 60px; min-width: 0; max-width: 1300px; }
h2.page { margin: 0 0 16px; font-size: 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h2.page .grow { flex: 1; }
h3 { margin: 22px 0 8px; font-size: 17px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.card > h3:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }

table { border-collapse: collapse; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f7f9fb; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.off td { opacity: .5; }
td.act { text-align: right; white-space: nowrap; }
.sub { color: var(--muted); font-size: 13px; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: #f1f5f9; }
.btn.primary { background: var(--blue2); border-color: var(--blue2); color: #fff; } .btn.primary:hover { background: var(--blue); }
.btn.danger { color: var(--red); } .btn.small { padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.pill { display: inline-block; border-radius: 10px; padding: 1px 9px; font-size: 12.5px; font-weight: 700; color: #fff; background: var(--muted); }
.pill.red, .pill.entnahme { background: var(--red); } .pill.yellow, .pill.korrektur { background: var(--amber); }
.pill.green, .pill.retour { background: var(--green); } .pill.eingang { background: var(--blue2); } .pill.none { background: #94a3b8; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); gap: 3px; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  border: 1px solid #c3ccd8; border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0;
}
textarea { width: 100%; min-height: 70px; }
.tools { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, 95vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(15, 23, 42, .5); }
dialog .dh { padding: 16px 20px; border-bottom: 1px solid var(--line); font-size: 18px; font-weight: 700; }
dialog .db { padding: 16px 20px; max-height: 70vh; overflow: auto; }
dialog .df { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
dialog .df .msg { flex: 1; color: var(--red); font-weight: 600; }
.fld { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; }
.fld > span { font-size: 13px; font-weight: 600; }
.fld small { color: var(--muted); }
.fld.chk { flex-direction: row; align-items: center; gap: 8px; }
.fld.chk > span { order: 2; font-weight: 400; font-size: 15px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.imgfld { display: flex; align-items: center; gap: 12px; }
.imgfld img, .thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #e2e8f0; display: block; }
.thumb { width: 44px; height: 44px; }
#map { height: 260px; border-radius: 10px; margin: 6px 0 12px; border: 1px solid var(--line); }

.tree a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.tree a:hover { background: #eaf0f7; } .tree a.on { background: var(--blue2); color: #fff; }
.layout2 { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.art { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.art .hd { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.art .hd .grow { flex: 1; }
.art table { font-size: 14px; }

.login { max-width: 360px; margin: 12vh auto; }
.login h1 { text-align: center; color: var(--blue); }
.login .fld input { padding: 10px 12px; font-size: 16px; }
.login .btn { width: 100%; padding: 11px; font-size: 16px; }
.err { color: var(--red); font-weight: 600; margin: 8px 0; min-height: 22px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; }
.mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; background: #f1f5f9; padding: 8px 10px; border-radius: 8px; display: block; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

@media (max-width: 860px) {
  .layout { flex-direction: column; } nav.side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  nav.side h1 { width: 100%; } .layout2 { grid-template-columns: 1fr; } main { padding: 14px; }
  .grid2 { grid-template-columns: 1fr; } table { display: block; overflow-x: auto; }
}
@media print {
  nav.side, .tools, .filters, .noprint, #toast { display: none !important; }
  body { background: #fff; } main { padding: 0; max-width: none; } .card, table { border-color: #999; }
}
