:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #6b7686;
  --border: #e1e5eb;
  --accent: #2f6df6;
  --accent-text: #ffffff;
  --danger: #d23b3b;
  --ok: #1f8a4c;
  --badge: #eaf0ff;
  --badge-text: #2455c7;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b2029;
    --text: #e6e9ef;
    --muted: #8d98a8;
    --border: #2a313d;
    --accent: #5b8cff;
    --accent-text: #0b1020;
    --danger: #ef6767;
    --ok: #4fc47f;
    --badge: #232c42;
    --badge-text: #9db8ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
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); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .9rem; }
h3 { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a, .userbox a { color: var(--muted); padding: .35rem .7rem; border-radius: 7px; white-space: nowrap; }
.topbar nav a:hover, .userbox a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.active, .userbox a.active { color: var(--text); background: var(--bg); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: .5rem; }
.userbox form { margin: 0; }
.linkbtn {
  background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit;
  padding: .35rem .7rem; border-radius: 7px;
}
.linkbtn:hover { background: var(--bg); color: var(--text); }

main { max-width: 1000px; margin: 0 auto; padding: 1.5rem; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* Karten */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1.25rem;
}
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 440px; }
.empty { padding: 2.5rem 1rem; text-align: center; }
.empty p { margin: .2rem 0; }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid var(--border); background: var(--surface); }
.flash.ok { border-color: var(--ok); color: var(--ok); }
.flash.error { border-color: var(--danger); color: var(--danger); }

/* Formulare */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .8rem; }
input[type=text], input[type=password], input[type=search] {
  display: block; width: 100%; margin-top: .25rem; padding: .55rem .7rem; font: inherit;
  color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
input:focus-visible, button:focus-visible, .dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filter { max-width: 240px; margin: 0; }
fieldset.picker { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem .3rem; margin: 1rem 0 .5rem; }
fieldset.picker legend { font-size: .8rem; color: var(--muted); padding: 0 .3rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem; margin: 0 .5rem .5rem 0; padding: .3rem .65rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--text);
  font-size: .88rem; cursor: pointer;
}
.chip:has(input:checked) { border-color: var(--accent); background: var(--badge); color: var(--badge-text); }
.row-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.row-form > label { margin-bottom: 0; flex: 1 1 200px; }
.row-form > .chip, .row-form > .btn { margin: 0 0 .1rem; }
.with-btn { display: flex; gap: .4rem; align-items: center; }
.with-btn input { margin-top: .25rem; }
form.inline { display: inline; margin: 0; }

/* Buttons */
.btn {
  display: inline-block; font: inherit; font-size: .9rem; cursor: pointer; padding: .5rem .9rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
  text-align: center; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.small { padding: .3rem .65rem; font-size: .82rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.block { display: block; width: 100%; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .name { word-break: break-word; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { margin-left: .25rem; }
.badge {
  display: inline-block; padding: .1rem .55rem; margin: .1rem .25rem .1rem 0; border-radius: 999px;
  background: var(--badge); color: var(--badge-text); font-size: .8rem;
}
.badge.all { background: var(--accent); color: var(--accent-text); }
.badge.none { background: transparent; border: 1px dashed var(--border); color: var(--muted); }

/* Upload */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.6rem 1rem; text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone p { margin: .15rem 0; }
.dropzone.over { border-color: var(--accent); background: var(--badge); }
.pick { display: inline; color: var(--accent); cursor: pointer; font-size: inherit; margin: 0; text-decoration: underline; }
.queue { list-style: none; margin: .5rem 0 0; padding: 0; }
.queue li { padding: .55rem 0; border-top: 1px solid var(--border); font-size: .88rem; }
.queue .row { display: flex; justify-content: space-between; gap: 1rem; }
.queue .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .state { color: var(--muted); white-space: nowrap; }
.queue .state.ok { color: var(--ok); }
.queue .state.err { color: var(--danger); }
.bar { height: 5px; border-radius: 3px; background: var(--border); margin-top: .35rem; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* Dialoge */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 1.5rem; width: min(480px, calc(100vw - 2rem));
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* Login */
.login-wrap { display: grid; place-items: center; min-height: 70vh; }
.login-card { width: min(380px, 100%); }
.login-card h1 { margin-bottom: .2rem; }
.login-card p { margin-top: 0; }

@media (max-width: 640px) {
  main { padding: 1rem; }
  .topbar { padding: .6rem 1rem; gap: .6rem; }
  #file-table th:nth-child(3), #file-table td:nth-child(3) { display: none; }
}
