:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb; --line2: #f0f1f3;
  --accent: #1d4ed8; --accent-soft: #dbeafe; --warn: #b45309; --warn-soft: #fef3c7; --danger: #dc2626; --ok: #15803d;
  --weekend: rgba(100, 116, 139, .07); --today: #ef4444;
  --label-w: 230px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); }

/* Kopfleiste */
.top { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: #0f172a; color: #e2e8f0; flex-wrap: wrap; }
.top .brand { font-weight: 700; letter-spacing: .3px; }
.top select { background: #1e293b; color: #fff; border: 1px solid #334155; border-radius: 6px; padding: 4px 8px; max-width: 260px; }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; }
.top nav a { color: #cbd5e1; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.top nav a.active, .top nav a:hover { background: #1e293b; color: #fff; }
.top .spacer { flex: 1; }
.top .who { font-size: 12px; color: #94a3b8; text-align: right; line-height: 1.3; }
.top .who b { color: #e2e8f0; font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #fff; font-size: 11px; text-align: center; margin-left: 4px; }
.linkbtn { background: none; border: 0; color: #94a3b8; cursor: pointer; padding: 2px 4px; text-decoration: underline; font-size: 12px; }

main { padding: 14px 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar label { font-size: 12px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.toolbar select, .toolbar input[type=date] { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; margin-left: auto; }
.legend i { display: inline-block; width: 26px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Gantt */
.gantt-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: auto; height: calc(100vh - 150px); position: relative; }
.gantt { position: relative; }
.g-head { position: sticky; top: 0; z-index: 9; display: flex; background: #fff; border-bottom: 1px solid #d1d5db; }
.g-corner { position: sticky; left: 0; z-index: 10; width: var(--label-w); min-width: var(--label-w); background: #fff; border-right: 1px solid #d1d5db;
  display: flex; align-items: flex-end; padding: 6px 10px; font-weight: 600; color: var(--muted); font-size: 12px; }
.g-headtl > div { display: flex; }
.g-kw > div { border-right: 1px solid #d1d5db; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; padding: 4px 6px; white-space: nowrap; overflow: hidden; height: 24px; }
.g-kw small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.g-days > div { border-right: 1px solid var(--line2); text-align: center; font-size: 11px; line-height: 1.15; padding: 3px 0; height: 32px; overflow: hidden; }
.g-days > div.we { background: var(--weekend); }
.g-days > div.mon { border-left: 1px solid #d1d5db; }
.g-days > div.today { background: #fee2e2; color: var(--danger); font-weight: 700; }
.g-days b { display: block; font-size: 12px; }

.g-body { position: relative; }
.g-row { display: flex; border-bottom: 1px solid var(--line2); }
.g-label { position: sticky; left: 0; z-index: 7; width: var(--label-w); min-width: var(--label-w); background: #fff; border-right: 1px solid #d1d5db;
  padding: 4px 10px; display: flex; align-items: center; gap: 7px; font-size: 13px; }
.g-label .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.g-label .cnt { margin-left: auto; color: var(--muted); font-size: 11px; }
.g-label .warnc { color: var(--warn); font-size: 11px; font-weight: 600; }
.g-cat .g-label { background: #f8fafc; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: #475569; cursor: pointer; }
.g-cat .g-tl { background: #f8fafc; }
.g-tl { position: relative; }
.g-tl.clickable { cursor: copy; }
.g-bg { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.g-bg.we { background: var(--weekend); }
.g-bg.mon { border-left: 1px solid #e2e5ea; }
.g-bg.today { border-left: 2px solid var(--today); z-index: 2; }
.g-bg.half { border-left: 1px dotted #eef0f3; }

.bar { position: absolute; height: 24px; border-radius: 5px; color: #fff; font-size: 12px; padding: 0 6px; display: flex; align-items: center; gap: 4px;
  white-space: nowrap; overflow: hidden; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.15); z-index: 3; }
.bar:hover { filter: brightness(1.08); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.bar .co { opacity: .85; font-size: 11px; }
.bar.unchecked { border: 2px dashed var(--warn); color: #451a03 !important; font-weight: 600; }
.bar.unchecked::before { content: "⚠"; }
.bar.conflict { outline: 2.5px solid var(--danger); outline-offset: 1px; }
.bar.sel { outline: 3px solid #111827; outline-offset: 1px; }
.bar.dim { opacity: .25; }
svg.arrows { position: absolute; top: 0; pointer-events: none; z-index: 4; overflow: visible; }
svg.arrows path { fill: none; stroke: #475569; stroke-width: 1.4; }
svg.arrows path.conflict { stroke: var(--danger); stroke-width: 2; }

/* Dialog */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(720px, 96vw); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dh { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.dh .x { margin-left: auto; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.db { padding: 14px 18px; max-height: 70vh; overflow: auto; }
.df { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.df .left { margin-right: auto; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form .full { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.form input, .form select, .form textarea { padding: 7px 8px; border: 1px solid #d1d5db; border-radius: 6px; color: var(--text); background: #fff; }
.form input:disabled, .form select:disabled, .form textarea:disabled { background: #f3f4f6; }
.form .row { display: flex; gap: 6px; }
.form .row > *:first-child { flex: 1; }
.form .chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0; }
.checks label { flex-direction: row; gap: 5px; color: var(--text); font-size: 13px; align-items: center; }
.status { padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.status.unchecked { background: var(--warn-soft); color: #78350f; border: 1px solid #fcd34d; }
.status.checked { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.status.conflict { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.section { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.section h4 { margin: 0 0 8px; font-size: 13px; }
.deplist { list-style: none; padding: 0; margin: 0 0 8px; }
.deplist li { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.deplist li.conflict { border-color: #fca5a5; background: #fef2f2; }
.deplist li .dot { width: 9px; height: 9px; border-radius: 2px; }
.deplist li button { margin-left: auto; }
.meta { font-size: 11px; color: var(--muted); margin-top: 10px; }
.mic { border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; padding: 0 10px; }
.mic.rec { background: #fee2e2; border-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

/* Tabellen */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
h2 { margin: 0 0 12px; font-size: 18px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f9fafb; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; background: #f3f4f6; }
.pill.unchecked { background: var(--warn-soft); color: #92400e; }
.pill.checked { background: #dcfce7; color: #166534; }
.pill.conflict { background: #fee2e2; color: #991b1b; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--text); background: #fff; border: 1px solid var(--line); }
.tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tree { list-style: none; padding-left: 18px; margin: 0; }
.tree.root { padding-left: 0; }
.tree li > div { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.tree li > div .nm { min-width: 220px; }
pre.mail { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); padding: 10px; border-radius: 6px; font-size: 12px; }
.empty { color: var(--muted); padding: 20px; text-align: center; }

/* Login */
.login { max-width: 360px; margin: 12vh auto; background: #fff; border-radius: 10px; padding: 28px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login .form { grid-template-columns: 1fr; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 9px 16px; border-radius: 8px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; font-size: 13px; }
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); }

@media (max-width: 700px) {
  :root { --label-w: 130px; }
  .form { grid-template-columns: 1fr; }
  .legend { margin-left: 0; }
  .top .who { display: none; }
}
@media print {
  .top, .toolbar .btn, #toast { display: none; }
  .gantt-wrap { height: auto; overflow: visible; border: 0; }
}

/* Ziehen & Schieben */
.bar.editable { cursor: grab; touch-action: none; user-select: none; }
.bar .hd { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.bar .hd.l { left: 0; } .bar .hd.r { right: 0; }
.bar.editable:hover .hd { background: rgba(255,255,255,.35); }
.bar.dragging { cursor: grabbing; z-index: 8; box-shadow: 0 6px 16px rgba(0,0,0,.35); opacity: .92; }
.dragtip { position: fixed; z-index: 200; background: #111827; color: #fff; font-size: 12px; padding: 5px 9px; border-radius: 6px; pointer-events: none; white-space: nowrap; }
.dragtip.bad { background: var(--danger); }
.dragtip .warn { font-weight: 700; }
svg.arrows path.conflict { stroke-width: 2.4; stroke-dasharray: 6 3; animation: dash 0.8s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -9; } }
#toast.action { pointer-events: auto; display: flex; gap: 12px; align-items: center; }
#toast button { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 5px; padding: 3px 10px; cursor: pointer; font-size: 12px; }
#toast button:hover { background: rgba(255,255,255,.15); }

/* Grundriss */
.pl-layout { display: grid; grid-template-columns: 220px 1fr 290px; gap: 12px; align-items: start; }
.pl-side, .pl-list { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: calc(100vh - 110px); overflow: auto; }
.pl-side h4, .pl-list h4 { margin: 2px 0 8px; font-size: 13px; }
.pl-item { display: block; padding: 7px 9px; border-radius: 6px; text-decoration: none; color: var(--text); margin-bottom: 2px; }
.pl-item:hover { background: #f3f4f6; }
.pl-item.active { background: var(--accent-soft); }
.pl-main { min-width: 0; }
.pl-main .toolbar { margin-bottom: 8px; }
.pv-wrap { background: #e5e7eb; border: 1px solid var(--line); border-radius: 8px; overflow: auto; height: calc(100vh - 160px); position: relative; cursor: grab; }
.pv-wrap.panning { cursor: grabbing; }
.pv-wrap.adding, .pv-wrap.adding .pv-canvas { cursor: crosshair; }
.pv-canvas { position: relative; margin: 10px; touch-action: none; }
.pv-canvas img { width: 100%; height: 100%; display: block; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); user-select: none; pointer-events: none; }
.pin { position: absolute; width: 0; height: 0; z-index: 2; }
.pin .cone { position: absolute; width: 120px; height: 120px; left: -60px; top: -60px; border-radius: 50%; pointer-events: none;
  -webkit-mask: radial-gradient(circle, #000 35%, transparent 72%); mask: radial-gradient(circle, #000 35%, transparent 72%); }
.pin .dot { position: absolute; width: 26px; height: 26px; left: -13px; top: -13px; border-radius: 50%; background: #ea580c; color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer; }
.pin.done .dot { background: #16a34a; }
.pin.preview .dot { background: var(--accent); }
.pin.sel .dot { outline: 3px solid #111827; outline-offset: 1px; }
.pin .cam { position: absolute; left: 9px; top: -22px; font-size: 12px; pointer-events: none; }
.pin:hover { z-index: 3; }
.pl-pin { display: flex; gap: 8px; align-items: center; padding: 7px 6px; border-radius: 6px; cursor: pointer; border-bottom: 1px solid var(--line2); }
.pl-pin:hover, .pl-pin.active { background: #f3f4f6; }
.pl-pin .no { width: 22px; height: 22px; flex: none; border-radius: 50%; background: #ea580c; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.pl-pin .no.done { background: #16a34a; }
.pl-pin .tt { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.cmp-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.compass { position: relative; border-radius: 50%; border: 2px solid #cbd5e1; background: #f8fafc; cursor: crosshair; touch-action: none; flex: none; }
.compass .n { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); font-weight: 700; }
.cmp-cone { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.cmp-dot { position: absolute; width: 10px; height: 10px; left: calc(50% - 5px); top: calc(50% - 5px); border-radius: 50%; background: var(--accent); }
.cmp-ctl { display: flex; flex-direction: column; gap: 8px; }
.cmp-ctl label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #f3f4f6; }
.ph img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.ph.pending { outline: 2px dashed var(--accent); }
.ph .x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 94vw; max-height: 88vh; object-fit: contain; }
.lb-cap { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #e5e7eb; font-size: 13px; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff; border: 0; font-size: 36px; width: 50px; height: 70px; cursor: pointer; border-radius: 8px; }
.lb-prev { left: 14px; } .lb-next { right: 14px; }
.lb-dl { position: absolute; top: 14px; right: 18px; color: #e5e7eb; font-size: 13px; }
@media (max-width: 1100px) { .pl-layout { grid-template-columns: 1fr; } .pl-side, .pl-list { max-height: none; } .pv-wrap { height: 65vh; } }
