:root {
  --navy: #10233F; --petrol: #0B3B45; --cream: #F7F1E6; --orange: #F3A93C;
  --text: #1d2430; --muted: #66707c; --line: #e3e6ea; --bg: #f6f7f9; --white: #fff;
  --red: #b42318; --green: #1f7a4d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--petrol); }
h1 { font-size: 22px; margin: 0 0 16px; color: var(--navy); }
h2 { font-size: 16px; margin: 24px 0 10px; color: var(--navy); }
h1 span, .brand span { color: var(--orange); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Login */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.login-box label { display: block; font-weight: 600; margin: 16px 0 6px; }
.or { text-align: center; color: var(--muted); margin: 14px 0; }
.msg { min-height: 20px; margin: 14px 0 0; color: var(--muted); }

/* Layout */
.app { display: flex; min-height: 100%; }
.side { width: 220px; flex: none; background: var(--navy); color: #dfe5ee; display: flex; flex-direction: column; padding: 20px 0; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 20px; font-weight: 800; color: #fff; padding: 0 20px 20px; }
.brand small { display: block; font-size: 12px; font-weight: 500; color: #9fb0c6; }
.side nav a { display: flex; justify-content: space-between; align-items: center; color: #dfe5ee; text-decoration: none; padding: 9px 20px; }
.side nav a:hover { background: rgba(255,255,255,.06); }
.side nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.badge { font-weight: 600; font-size: 12px; color: var(--navy); background: var(--orange); border-radius: 10px; padding: 0 7px; }
.badge:empty { display: none; }
.me { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; color: #9fb0c6; word-break: break-all; }
.me .link { color: #fff; display: block; margin-top: 6px; }
.view { flex: 1; padding: 28px 32px 60px; max-width: 1200px; min-width: 0; }

/* Elemente */
.btn { display: inline-block; text-decoration: none; font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 8px; border: 1px solid #c9ced5; background: var(--white); color: var(--navy); cursor: pointer; text-align: center; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.btn.primary:hover { background: #0a323b; }
.btn.danger { background: var(--white); border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: #fdf3f2; }
.btn.block { display: block; width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--petrol); text-decoration: underline; cursor: pointer; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #c9ced5; border-radius: 8px; background: #fff; color: var(--text); }
textarea { min-height: 90px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: none; }
.row .grow { flex: 1; min-width: 200px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 16px; text-decoration: none; color: var(--text); display: block; }
.stat b { display: block; font-size: 28px; color: var(--navy); }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 0; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--navy); border-color: var(--navy); font-weight: 600; }

table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafbfc; }
.empty { padding: 30px; text-align: center; color: var(--muted); background: var(--white); border: 1px solid var(--line); border-radius: 10px; }

dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.status { font-weight: 600; }
.status.warn { color: #9a5b00; }
.status.bad { color: var(--red); }
.status.good { color: var(--green); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #eee; vertical-align: middle; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photos img { width: 140px; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 10px; background: #eef1f4; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.bubble.me { align-self: flex-end; background: #e2eef0; }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.bubble.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 10; max-width: 90vw; }
.toast.error { background: var(--red); }
.back { display: inline-block; margin-bottom: 12px; }

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; padding: 12px 0; }
  .side nav { display: flex; overflow-x: auto; }
  .side nav a { white-space: nowrap; padding: 8px 14px; }
  .brand { padding: 0 16px 10px; }
  .me { display: none; }
  .view { padding: 20px 16px 60px; }
  .grid2 { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 120px 1fr; }
}

/* Ausbau FIN-166 */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.note { padding: 10px 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.notes .note-input { margin-top: 10px; min-height: 70px; }
.ctx-order { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ctx-order:last-child { border-bottom: 0; }
.me #notify { margin: 0 0 10px; background: transparent; color: #fff; border-color: rgba(255,255,255,.35); font-size: 12px; padding: 6px 10px; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
dl.kv dd select { max-width: 100%; }
.split dl.kv { grid-template-columns: 105px minmax(0, 1fr); }

/* FIN-167 */
.lbl { display: block; font-weight: 600; margin: 12px 0 6px; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.check input { width: auto; }
.warn-num { color: var(--red) !important; }
.chat.tall { max-height: 640px; }
.bubble.reported { outline: 2px solid var(--red); }

/* FIN-168 Anhänge + Live */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att-img { width: 160px; height: 160px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.att-file { display: inline-block; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-decoration: none; color: var(--text); }
.pending { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { font-size: 12px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 14px; background: #fafbfc; }
label.btn { cursor: pointer; }
.live { display: block; font-size: 11px; color: #9fd8b5; margin-bottom: 8px; }
.live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3ec27a; margin-right: 6px; vertical-align: middle; }
