:root{
  --ink:#262626;
  --muted:#808080;
  --line:#bfbfbf;
  --frame:#9e9e9e;
  --bar1:#404040;
  --bar2:#6e6e6e;
  --paper:#ffffff;
  --bg:#5c5c5c;
  --panel:#33363b;
  --panel-2:#3c4047;
  --accent:#2f3338;
  --field:#2b2e33;
  --field-line:#565a61;
  --on:#1f8a5b;
}
*{ box-sizing:border-box; }
html,body{ margin:0; height:100%; }
body{
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  background:var(--bg);
  color:var(--ink);
}
button{ font-family:inherit; cursor:pointer; }
input,textarea{ font-family:inherit; }

/* ---------------- LOGIN ---------------- */
#login{
  position:fixed; inset:0;
  display:flex; align-items:center; justify-content:center;
  background:
    radial-gradient(1200px 600px at 50% -10%, #45484e 0%, #2c2e32 60%, #232427 100%);
  padding:24px;
  z-index:50;
}
.login-card{
  width:380px; max-width:100%;
  background:#fff;
  border-radius:4px;
  box-shadow:0 24px 70px rgba(0,0,0,.45);
  padding:34px 32px 26px;
}
.brand{
  display:flex; align-items:center; gap:11px;
  margin-bottom:22px;
}
.brand .mark{
  width:38px; height:38px; flex:0 0 auto;
  background:var(--bar1); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:15px; letter-spacing:.5px;
  border-radius:3px;
}
.brand .name{ line-height:1.15; }
.brand .name b{ display:block; font-size:15px; color:var(--ink); letter-spacing:.3px; }
.brand .name span{ font-size:11px; color:var(--muted); letter-spacing:.4px; }
.login-card h1{
  font-size:15px; margin:0 0 4px; color:var(--ink); font-weight:700;
}
.login-card p.sub{ margin:0 0 20px; font-size:12px; color:var(--muted); line-height:1.5; }
.field-group{ margin-bottom:14px; }
.field-group label{
  display:block; font-size:10px; font-weight:700; letter-spacing:.6px;
  text-transform:uppercase; color:var(--muted); margin-bottom:6px;
}
.field-group input{
  width:100%; padding:11px 12px; font-size:14px;
  border:1px solid #d4d4d4; border-radius:3px; color:var(--ink);
  background:#fafafa; outline:none;
}
.field-group input:focus{ border-color:var(--bar1); background:#fff; }
.btn-primary{
  width:100%; padding:12px; font-size:14px; font-weight:700; letter-spacing:.3px;
  background:var(--bar1); color:#fff; border:none; border-radius:3px;
  margin-top:6px;
}
.btn-primary:hover{ background:#2c2c2c; }
.login-error{
  color:#b3261e; font-size:12px; margin:10px 0 0; min-height:16px; text-align:center;
}
.login-note{
  margin-top:22px; padding-top:16px; border-top:1px solid #eee;
  font-size:10.5px; color:#a0a0a0; line-height:1.55;
}
.login-note code{ background:#f1f1f1; padding:1px 5px; border-radius:3px; color:#666; }

/* ---------------- APP SHELL ---------------- */
#app{ display:none; flex-direction:column; min-height:100%; }
#app.show{ display:flex; }

.topbar{
  position:sticky; top:0; z-index:30;
  background:var(--panel); color:#e8e8e8;
  display:flex; align-items:center; gap:16px;
  padding:10px 18px;
  box-shadow:0 1px 0 rgba(0,0,0,.4);
}
.topbar .brand .mark{ width:32px; height:32px; font-size:13px; }
.topbar .brand .name b{ color:#fff; font-size:13px; }
.topbar .brand .name span{ color:#9aa0a7; }
.topbar .spacer{ flex:1; }
.tool{
  display:inline-flex; align-items:center; gap:7px;
  background:var(--panel-2); color:#e8e8e8;
  border:1px solid #4c5159; border-radius:3px;
  padding:8px 13px; font-size:12.5px; font-weight:600;
}
.tool:hover{ background:#474c54; border-color:#5a606a; }
.tool.accent{ background:#e8e8e8; color:#23262a; border-color:#e8e8e8; }
.tool.accent:hover{ background:#fff; }
.tool.ghost{ background:transparent; border-color:transparent; color:#aeb4bb; }
.tool.ghost:hover{ color:#fff; background:#3c4047; }
.tool svg{ width:15px; height:15px; }

/* audit-kopf panel */
.kopf{
  background:var(--panel-2); color:#dfe2e6;
  border-bottom:1px solid #2a2c30;
  padding:14px 22px 16px;
}
.kopf .kopf-title{
  font-size:10px; font-weight:700; letter-spacing:.7px; text-transform:uppercase;
  color:#8b9199; margin-bottom:10px;
}
.kopf-grid{
  display:grid; grid-template-columns:repeat(4,1fr); gap:12px 18px;
  max-width:1100px;
}
.kopf-field label{
  display:block; font-size:9.5px; font-weight:700; letter-spacing:.5px;
  text-transform:uppercase; color:#8b9199; margin-bottom:5px;
}
.kopf-field input{
  width:100%; padding:8px 10px; font-size:13px;
  background:var(--field); color:#f0f0f0;
  border:1px solid var(--field-line); border-radius:3px; outline:none;
}
.kopf-field input:focus{ border-color:#8b9199; }

/* canvas / pages */
.canvas{
  flex:1; padding:28px 16px 80px;
  display:flex; flex-direction:column; align-items:center; gap:22px;
}
.dropzone{
  width:210mm; max-width:100%;
  border:2px dashed #8a8f96; border-radius:6px;
  background:rgba(255,255,255,.04);
  color:#d7dade; text-align:center;
  padding:34px 24px;
}
.dropzone.drag{ border-color:#fff; background:rgba(255,255,255,.12); }
.dropzone h2{ margin:0 0 6px; font-size:16px; color:#fff; }
.dropzone p{ margin:0 0 16px; font-size:12.5px; color:#b8bcc2; line-height:1.5; }
.dz-actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.count-pill{
  font-size:11px; color:#c3c7cc; background:rgba(0,0,0,.25);
  padding:4px 10px; border-radius:20px; display:inline-block; margin-top:14px;
}

/* A4 page */
.page{
  position:relative;
  width:210mm; min-height:297mm;
  background:var(--paper);
  padding:15mm 20mm;
  box-shadow:0 12px 40px rgba(0,0,0,.45);
  display:flex; flex-direction:column;
}
.page-tools{
  position:absolute; top:8px; right:8px;
  display:flex; gap:5px; z-index:5;
}
.page-tools button{
  width:28px; height:28px; border-radius:3px;
  border:1px solid #d8d8d8; background:#fff; color:#666;
  display:flex; align-items:center; justify-content:center; font-size:14px;
}
.page-tools button:hover{ background:#f2f2f2; color:#222; }
.page-tools button.del:hover{ background:#fde8e7; color:#b3261e; border-color:#f3c5c2; }
.page-index{
  position:absolute; top:8px; left:8px;
  font-size:10px; font-weight:700; letter-spacing:.5px; color:#bdbdbd;
}

.title-row{
  display:flex; align-items:baseline; gap:14px;
  border-bottom:2px solid var(--bar1); padding-bottom:7px; margin-bottom:14px;
}
.title-row h1{ margin:0; font-size:23px; letter-spacing:.5px; font-weight:700; color:var(--ink); }
.title-row .tag{ font-size:11px; color:#909090; letter-spacing:.3px; }

.fields{ display:grid; grid-template-columns:1fr 1fr; gap:8px 28px; margin-bottom:16px; }
.field-disp .lbl{
  font-size:9px; font-weight:700; letter-spacing:.6px; text-transform:uppercase;
  color:var(--muted); margin-bottom:5px;
}
.field-disp .val{
  font-size:13px; color:var(--ink); min-height:18px;
  border-bottom:1px solid var(--line); padding-bottom:4px;
}
.field-disp .val:empty::before{ content:""; }

.section-label{
  font-size:9px; font-weight:700; letter-spacing:.6px; text-transform:uppercase;
  color:var(--muted); margin:4px 0 6px;
}
.image-frame{
  align-self:flex-start; border:1.4px solid var(--frame); padding:8px; background:#fff;
}
.image-frame .img-box{
  display:flex; align-items:center; justify-content:center;
}
.image-frame .img-box.empty{
  width:58mm; height:78mm; background:#f2f2f2;
}
/* Bild in natürlichem Seitenverhältnis, gedeckelt – kein Beschnitt */
.image-frame img{ display:block; max-width:96mm; max-height:90mm; width:auto; height:auto; }

/* Foto + Aufnahmeort nebeneinander */
.photo-row{ display:flex; gap:16px; align-items:flex-start; }
.loc{ flex:1; min-width:0; display:flex; flex-direction:column; gap:11px; }
.loc-head{
  font-size:9px; font-weight:700; letter-spacing:.6px; text-transform:uppercase;
  color:var(--muted); padding-bottom:6px; border-bottom:1.4px solid var(--frame);
}
.loc-field{ display:flex; flex-direction:column; }
.loc-field.grow{ flex:1; }
.loc-field label{
  display:block; font-size:9px; font-weight:700; letter-spacing:.5px;
  text-transform:uppercase; color:#8c8c8c; margin-bottom:5px;
}
.loc-input{
  border:1px solid #c4c4c4; border-radius:3px; background:#fcfcfc;
  padding:9px 11px; font-size:13px; line-height:22px; color:var(--ink); outline:none;
}
.loc-input:focus{ border-color:#6f6f6f; background:#fff; box-shadow:inset 0 0 0 1px rgba(111,111,111,.25); }
.loc-input.area{ flex:1; min-height:42mm; }
.loc-input:empty::before{ content:attr(data-ph); color:#bcbcbc; }

.cat-head{ margin:18px 0 6px; font-size:9px; letter-spacing:.6px; text-transform:uppercase; color:var(--muted); font-weight:700; }
.cat-head em{ font-style:normal; color:#a6a6a6; font-weight:400; letter-spacing:.3px; }
.checks{
  display:grid; grid-template-columns:1fr 1fr 1fr;
  border-top:1px solid #d9d9d9; border-bottom:1px solid #d9d9d9; padding:9px 0;
}
.check{ display:flex; align-items:center; gap:9px; font-size:11.5px; cursor:pointer; user-select:none; }
.check .box{
  width:16px; height:16px; border:1.5px solid #555; flex:0 0 auto;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; line-height:1; color:#fff; background:#fff;
}
.check.on .box{ background:var(--bar1); border-color:var(--bar1); }
.check.on .box::after{ content:"✓"; }

.areas{ margin-top:14px; display:flex; flex-direction:column; gap:9px; }
.area{ border:1px solid var(--frame); }
.area .bar{ color:#fff; font-size:10.5px; font-weight:700; letter-spacing:.7px; text-transform:uppercase; padding:6px 10px; }
.area.desc .bar{ background:var(--bar1); }
.area.notes .bar{ background:var(--bar2); }
.area .body{
  min-height:40mm; padding:11px; font-size:13px; line-height:27px; color:var(--ink);
  outline:none;
  background:repeating-linear-gradient(to bottom,transparent,transparent 26px,#ededed 26px,#ededed 27px);
}
.area .body:empty::before{
  content:attr(data-ph); color:#b5b5b5; font-style:italic;
}

/* ---------------- AUDIT-LISTE ---------------- */
#list{ display:none; flex-direction:column; min-height:100%; }
#list.show{ display:flex; }
.list-wrap{ flex:1; padding:34px 20px 80px; max-width:1040px; margin:0 auto; width:100%; }
.list-head{ display:flex; align-items:center; gap:14px; margin-bottom:22px; }
.list-head h2{ margin:0; font-size:19px; color:#fff; font-weight:700; letter-spacing:.3px; }
.list-head .spacer{ flex:1; }
.list-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(290px,1fr)); gap:16px; }
.audit-card{
  background:#fff; border-radius:6px; padding:18px 18px 14px;
  box-shadow:0 6px 20px rgba(0,0,0,.28); cursor:pointer;
  display:flex; flex-direction:column; gap:4px; position:relative;
  transition:transform .12s, box-shadow .12s;
}
.audit-card:hover{ transform:translateY(-2px); box-shadow:0 12px 30px rgba(0,0,0,.34); }
.audit-card .ac-title{ font-size:15px; font-weight:700; color:var(--ink); padding-right:30px; }
.audit-card .ac-meta{ font-size:12px; color:var(--muted); line-height:1.5; }
.audit-card .ac-foot{ margin-top:10px; display:flex; align-items:center; gap:8px; font-size:11px; color:#9a9a9a; }
.audit-card .ac-badge{ background:var(--bar1); color:#fff; font-size:10px; font-weight:700; padding:3px 8px; border-radius:20px; }
.audit-card .ac-del{
  position:absolute; top:12px; right:10px; width:26px; height:26px; border-radius:4px;
  border:1px solid #e2e2e2; background:#fff; color:#999; display:flex; align-items:center; justify-content:center; font-size:13px;
}
.audit-card .ac-del:hover{ background:#fde8e7; color:#b3261e; border-color:#f3c5c2; }
.list-empty{
  border:2px dashed #8a8f96; border-radius:8px; padding:48px 24px; text-align:center; color:#cfd3d8;
}
.list-empty h3{ margin:0 0 8px; color:#fff; font-size:17px; }
.list-empty p{ margin:0 0 18px; font-size:13px; color:#b8bcc2; }
.btn-new{
  display:inline-flex; align-items:center; gap:8px;
  background:#e8e8e8; color:#23262a; border:none; border-radius:4px;
  padding:10px 16px; font-size:13px; font-weight:700; cursor:pointer;
}
.btn-new:hover{ background:#fff; }

/* editor back button + save status */
.editor-nav{ display:flex; align-items:center; gap:12px; }
.save-status{ font-size:11.5px; color:#9aa0a7; min-width:120px; }
.save-status.saving{ color:#cdb24a; }
.save-status.saved{ color:#7fb38f; }
.save-status.err{ color:#e08a82; }

#editor{ display:none; flex-direction:column; min-height:100%; }
#editor.show{ display:flex; }

/* ---------------- PRINT ---------------- */
@media print{
  @page{ size:A4; margin:0; }
  body{ background:#fff; }
  #login, .topbar, .kopf, .dropzone, .page-tools, .page-index{ display:none !important; }
  .canvas{ padding:0; gap:0; }
  .page{
    box-shadow:none; margin:0;
    width:210mm; min-height:297mm;
    page-break-after:always; break-after:page;
  }
  .page:last-child{ page-break-after:auto; break-after:auto; }
  .area .body:empty::before{ content:""; }
  .loc-input:empty::before{ content:""; }
}
