:root {
  --bg: #f6f3ee; --panel: #ffffff; --ink: #2b2723; --muted: #736b62; --line: #e4ddd3;
  --accent: #b4533a; --accent-ink: #ffffff; --accent-soft: #f6e4dd;
  --ok: #2f7d4f; --ok-soft: #e1f1e6; --warn: #a86b00; --warn-soft: #fbefd5;
  --bad: #b3261e; --bad-soft: #f9e0de; --info: #2c5d8a; --info-soft: #e0ebf5;
  --radius: 10px; --shadow: 0 1px 3px rgba(40,30,20,.08), 0 4px 14px rgba(40,30,20,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: #2f2a25; color: #fff; }
.brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .2px; }
.crumb { color: #d9cfc4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.chip { background: #4a423a; color: #fff; border: 0; border-radius: 99px; padding: 5px 12px; cursor: pointer; }
.chip.busy::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 7px;
  border-radius: 50%; background: #f0b44c; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3 } to { opacity: 1 } }
.topbar .ghost { color: #fff; border-color: #6d635a; }

main { padding: 18px; max-width: 1600px; margin: 0 auto; }

button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 13px; }
button:hover { border-color: #cbbfb1; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.05); }
button.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
button.bad { background: #fff; color: var(--bad); border-color: #e5b3ae; }
button.ghost { background: transparent; }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

input[type=text], input[type=password], input:not([type]), select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.projcard { cursor: pointer; }
.projcard:hover { border-color: #cdbfae; }
.bar { height: 8px; background: #eee6dc; border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar > div { height: 100%; background: var(--ok); }
.bar.accent > div { background: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent;
  white-space: nowrap; }
.tabs a.active { color: var(--ink); border-color: var(--accent); font-weight: 600; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px;
  background: #eee6dc; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* Seitenansicht */
.pages { display: grid; grid-template-columns: 290px minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.pagelist { max-height: calc(100vh - 190px); overflow-y: auto; padding: 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.filters button { padding: 3px 9px; font-size: 13px; border-radius: 99px; }
.filters button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.pitem { display: grid; grid-template-columns: 46px 1fr; gap: 9px; padding: 6px; border-radius: 8px;
  cursor: pointer; align-items: center; border: 2px solid transparent; }
.pitem:hover { background: #f7f2ec; }
.pitem.sel { border-color: var(--accent); background: var(--accent-soft); }
.pitem img, .pitem .noimg { width: 46px; height: 65px; object-fit: contain; background: #faf8f5;
  border: 1px solid var(--line); border-radius: 3px; }
.pitem .noimg { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.pitem .t { font-size: 14px; line-height: 1.25; }
.pitem .t b { font-weight: 600; }
.pitem .bs { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 3px; }
.pitem.running { animation: runbg 1.2s infinite alternate; }
@keyframes runbg { from { background: #fff; } to { background: #fbecc9; } }

.viewer { text-align: center; }
.viewer .imgwrap { background: #e9e3da; border-radius: var(--radius); padding: 12px; min-height: 420px;
  display: flex; align-items: center; justify-content: center; gap: 8px; }
.viewer img.page { max-width: 100%; max-height: calc(100vh - 250px); box-shadow: 0 2px 10px rgba(0,0,0,.18);
  background: #fff; cursor: zoom-in; }
.viewer .spread img.page { max-width: 49%; }
.viewer .empty { color: var(--muted); padding: 40px; }
.viewhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); padding: 5px 11px; }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--ink); color: #fff; }

.side .section { margin-bottom: 14px; }
.side h3 { margin-top: 0; }
.comment { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; background: #fff; }
.comment.OPEN { border-left: 4px solid var(--accent); }
.comment.APPLIED { border-left: 4px solid var(--info); }
.comment.DONE { opacity: .65; }
.comment.SUGGESTED { border-left: 4px solid #d6a400; background: #fffaf0; }
.comment .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.alert { padding: 8px 11px; border-radius: 8px; margin-bottom: 10px; font-size: 14px; }
.alert.warn { background: var(--warn-soft); color: #6c4800; }
.alert.bad { background: var(--bad-soft); color: #7a1b15; }
.alert.info { background: var(--info-soft); color: #1f4466; }
.alert.ok { background: var(--ok-soft); color: #1d5234; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.actions button { text-align: left; }
.actions button.wide { grid-column: 1 / -1; }

/* Buchansicht */
.book { display: flex; flex-wrap: wrap; gap: 18px 26px; }
.spread { display: flex; gap: 2px; }
.bookpage { width: 118px; text-align: center; cursor: pointer; }
.bookpage .frame { width: 118px; height: 167px; background: #fff; border: 3px solid #d9d0c4; display: flex;
  align-items: center; justify-content: center; overflow: hidden; }
.bookpage img { max-width: 100%; max-height: 100%; }
.bookpage.approved .frame { border-color: var(--ok); }
.bookpage.rejected .frame { border-color: var(--bad); }
.bookpage.comments .frame { border-color: var(--accent); }
.bookpage.missing .frame { border-style: dashed; }
.bookpage.placeholder { visibility: hidden; }
.bookpage .n { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border: 3px solid; margin-right: 5px; vertical-align: -2px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 13px; color: var(--muted); font-weight: 600; }
table.list tr.done td { opacity: .55; }

.motifs .mrow { display: grid; grid-template-columns: 30px 1fr auto; gap: 6px; align-items: center; margin-bottom: 5px; }
.motifs .mrow .n { color: var(--muted); font-size: 13px; text-align: right; }
.motifs .mrow .btns { display: flex; gap: 3px; }
.motifs .mrow .btns button { padding: 4px 8px; }

.jobpanel { position: fixed; right: 16px; bottom: 16px; width: 420px; max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.18);
  z-index: 30; padding: 12px 14px; }
.jobpanel pre { max-height: 220px; overflow: auto; background: #faf7f3; border-radius: 6px; padding: 8px;
  font-size: 12px; white-space: pre-wrap; margin: 8px 0 0; }

.modal { position: fixed; inset: 0; background: rgba(30,25,20,.45); z-index: 50; display: flex;
  align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 20px; width: 640px; max-width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-box.wide { width: 1000px; }
.modal-box .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.radio { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.radio input { margin-right: 8px; }
.versions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.versions .v { border: 2px solid var(--line); border-radius: 8px; padding: 6px; text-align: center; font-size: 13px; }
.versions .v.cur { border-color: var(--accent); }
.versions img { width: 100%; height: 190px; object-fit: contain; background: #faf8f5; cursor: zoom-in; }
pre.report { white-space: pre-wrap; font-size: 12.5px; background: #faf7f3; padding: 10px; border-radius: 8px; max-height: 60vh; overflow: auto; }

.lightbox { position: fixed; inset: 0; background: rgba(15,12,10,.92); z-index: 60; overflow: auto; text-align: center; }
.lightbox img { max-width: 96vw; margin: 3vh auto; background: #fff; cursor: zoom-in; }
.lightbox img.zoom { max-width: none; width: 180vw; cursor: zoom-out; }
.lb-close { position: fixed; top: 12px; right: 14px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #2f2a25; color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 70; max-width: 90vw; box-shadow: var(--shadow); }
.toast.err { background: var(--bad); }

.login { max-width: 380px; margin: 10vh auto; }

@media (max-width: 1250px) {
  .pages { grid-template-columns: 250px minmax(0, 1fr); }
  .pages .side { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  main { padding: 10px; }
  .pages { grid-template-columns: 1fr; }
  .pagelist { max-height: 260px; }
  .grid2 { grid-template-columns: 1fr; }
  .viewer .imgwrap { min-height: 260px; }
}

img.orig { opacity: .55; filter: grayscale(.2); }
.viewer img.page.orig { opacity: .75; }
