:root {
  --bg: #f4f6fa; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-soft: #dbeafe; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --card: #131c2e; --text: #e2e8f0; --muted: #94a3b8; --line: #23304a;
    --accent: #60a5fa; --accent-soft: #1e3a5f; --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; text-decoration: none; }
.brand img { height: 34px; width: auto; display: block; }
.brand-sub { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase;
  line-height: 1; padding-left: .24em; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a { padding: 7px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
nav a.on { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; align-items: center; gap: 10px; }
select, input, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; }
input, textarea { width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 26px 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.center { max-width: 460px; margin: 40px auto; }
.center .card { padding: 24px; }
.loading { margin: 60px auto; width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 10px; padding: 8px 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.red { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { width: 100%; padding: 12px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { border: none; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.iconbtn:hover { background: var(--bg); color: var(--text); }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: #fef3c7; color: #92400e; } .badge.bad { background: #fee2e2; color: #991b1b; }
.badge.ok { background: #dcfce7; color: #166534; } .badge.grey { background: var(--bg); color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

/* Startseite: Kacheln */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer; text-align: center; color: var(--text); text-decoration: none; transition: transform .1s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; overflow: hidden;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 20px; }
.tile .ico img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.tile b { font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.tile small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tile .more { position: absolute; top: 4px; right: 4px; }
.tile .warnmark { position: absolute; top: 8px; left: 8px; }
.menu { position: fixed; z-index: 20; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 6px; min-width: 210px; }
.menu button { display: flex; width: 100%; gap: 8px; align-items: center; border: none; background: none; color: var(--text);
  font: inherit; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--bg); }
.menu .code { margin-left: auto; font-family: ui-monospace, Consolas, monospace; color: var(--accent); }
.menu hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.menu button[data-a="del"] { color: var(--bad); }
.toolbar .grp { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; white-space: nowrap; }

/* Löschen-Abfrage */
.delcard { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.delcard .ico { width: 44px; height: 44px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 18px; }
.delcard .ico img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.delcard small { display: block; color: var(--muted); font-size: 13px; }
.warnbox { background: color-mix(in srgb, var(--warn) 14%, transparent); border-left: 3px solid var(--warn); padding: 8px 10px; border-radius: 6px; }

/* Kategorien verwalten */
.catlist { display: grid; gap: 4px; max-height: 50vh; overflow: auto; margin: 4px 0 8px; }
.catrow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; }
.catrow:hover { background: var(--bg); }
.catrow .cn { flex: 1; overflow-wrap: anywhere; }
.catrow small { color: var(--muted); white-space: nowrap; }

/* Formulare */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.form label small { font-weight: 400; }
.two { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.pw { display: flex; gap: 6px; }
.pw input { font-family: ui-monospace, Consolas, monospace; }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter > div { height: 100%; width: 0; transition: width .2s; }
.icopick { display: flex; align-items: center; gap: 10px; }
.icopick .ico { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.icopick .ico img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

dialog { border: none; border-radius: 16px; padding: 0; background: var(--card); color: var(--text); width: min(560px, calc(100vw - 24px));
  box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(15,23,42,.5); }
dialog > div { padding: 20px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.recovery { font: 600 20px/1.6 ui-monospace, Consolas, monospace; letter-spacing: .06em; text-align: center; padding: 14px;
  border: 2px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); user-select: all; word-break: break-all; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 12px; }
.steps li { counter-increment: s; padding-left: 30px; position: relative; margin-bottom: 8px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; }
.factbox { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); padding: 0; overflow: hidden; margin-bottom: 14px; }
.factbox > div { padding: 12px 16px; border-right: 1px solid var(--line); }
.factbox > div:last-child { border-right: none; }
.factbox span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.factbox b { font-size: 22px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px); background: #0f172a; color: #fff;
  padding: 10px 16px; border-radius: 10px; transition: transform .2s; z-index: 30; max-width: calc(100vw - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- McFly Dokumente */
main { max-width: 1280px; }
.me #who { color: var(--muted); font-weight: 600; }
nav .count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 2px; border-radius: 99px; background: var(--warn); color: #fff;
  font-size: 12px; line-height: 18px; text-align: center; }
.login { text-align: center; } .login img { border-radius: 16px; margin-bottom: 8px; } .login .btn { margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; } .empty svg.i { width: 36px; height: 36px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 70%, var(--text)); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.tagc { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; }
.tagc button { border: none; background: none; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.chk { font-weight: 400 !important; gap: 8px; } .chk input { width: auto; }
.danger { color: var(--bad) !important; } .btn.ghost.danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.nowrap { white-space: nowrap; }
code { font: 13px ui-monospace, Consolas, monospace; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.info { margin-bottom: 12px; border-left: 4px solid var(--accent); } .info.bad { border-left-color: var(--bad); }
.okc { color: var(--ok); display: inline-flex; align-items: center; gap: 4px; }

/* Liste */
.listhead { padding: 4px 6px 6px; color: var(--muted); font-size: 14px; }
.drow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); }
.drow.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.drow .pick { width: 18px; height: 18px; flex: none; }
.drow .th { width: 52px; height: 68px; flex: none; border-radius: 6px; overflow: hidden; display: grid; place-items: center; background: var(--bg);
  border: 1px solid var(--line); color: var(--muted); }
.drow .th img { width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.drow .body { flex: 1; min-width: 0; color: var(--text); text-decoration: none; display: grid; gap: 3px; }
.drow .body b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drow .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.drow .snip { font-size: 13px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: #fde68a; color: #1f2937; border-radius: 3px; padding: 0 1px; }
.drow .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; text-align: right; }
.drow .side small { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.drow .side svg.i { width: 14px; height: 14px; }
.bulk { position: sticky; top: 64px; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; margin-bottom: 10px;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; }
.bulk b { margin-right: 6px; }
.uprow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 8px; }
.bar { width: 140px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; } .bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.drop { position: fixed; inset: 0; z-index: 40; background: rgba(37,99,235,.12); border: 3px dashed var(--accent); display: grid; place-items: center; pointer-events: none; }
.drop > div { background: var(--card); padding: 24px 32px; border-radius: 16px; box-shadow: var(--shadow); display: grid; place-items: center; gap: 8px; color: var(--accent); }
.drop svg.i { width: 40px; height: 40px; }

/* Ein Dokument */
.docbar { margin-bottom: 12px; }
.docgrid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.docgrid .side { position: sticky; top: 76px; }
.viewer { padding: 0; overflow: hidden; }
.tabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.tabs button { border: none; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }
#tabbody { padding: 14px; max-height: calc(100vh - 170px); overflow: auto; }
.pages { display: grid; gap: 12px; justify-items: center; }
.pages img { width: 100%; max-width: 820px; background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); }
.pages.big img { max-width: none; }
.textview .pg { margin-bottom: 14px; } .textview small { color: var(--muted); font-weight: 600; }
.textview pre { white-space: pre-wrap; word-break: break-word; font: 13px/1.45 ui-monospace, Consolas, monospace; margin: 4px 0 0; padding: 10px;
  background: var(--bg); border-radius: 8px; }
.translangs { margin-bottom: 12px; }
.tagbox { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.tagbox input { border: none; padding: 4px; flex: 1; min-width: 120px; width: auto; } .tagbox input:focus { outline: none; }
.form .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Scannen */
.scanpages { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin: 14px 0; }
.sp { padding: 8px; } .sp.busy { opacity: .5; pointer-events: none; }
.sp img { width: 100%; aspect-ratio: 1 / 1.414; object-fit: contain; background: var(--bg); border-radius: 6px; }
.sp .tools { gap: 2px; margin-top: 6px; } .sp .tools select { padding: 3px 4px; font-size: 12px; } .iconbtn.on { color: var(--accent); background: var(--accent-soft); }
.iconbtn:disabled { opacity: .35; cursor: default; }
tr.off { opacity: .55; }
.logbox { max-height: 420px; overflow: auto; font-size: 13px; }

@media (max-width: 900px) {
  .docgrid { grid-template-columns: 1fr; }
  .docgrid .side { position: static; }
  #tabbody { max-height: none; }
}
@media (max-width: 640px) {
  .drow { flex-wrap: wrap; gap: 8px 10px; }
  .drow .side { flex-direction: row; flex-basis: 100%; justify-content: flex-end; align-items: center; }
  .bar { width: 70px; }
  .bulk { top: 100px; }
}

@media print {
  .top, .noprint, #toast { display: none !important; }
  body, main { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #999; }
}
@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 10px; }
  nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .two { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 10px; }
  .tile .ico { width: 42px; height: 42px; }
  .hide-sm { display: none; }
}
