:root {
  --bg: #f4f6f9;
  --card: #fff;
  --text: #1d2433;
  --muted: #6b7385;
  --border: #e2e6ee;
  --primary: #2f6fed;
  --primary-dark: #1f56c4;
  --danger: #d6363f;
  --ok: #1f9d55;
  --warn: #c98a00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --card: #1b1f29; --text: #e6e9ef; --muted: #9aa3b5;
    --border: #2c3240; --primary: #5b8cff; --primary-dark: #7aa2ff;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; font-weight: 650; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .7rem; font-weight: 600; }
.card h2:first-child { margin-top: 0; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: normal; }
.right { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
[hidden] { display: none !important; }

.icon { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; flex-shrink: 0; }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem;
  background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); display: flex; gap: .5rem; align-items: center; }
.brand .icon { color: var(--primary); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a { padding: .4rem .8rem; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--bg); color: var(--text); }
.usermenu { display: flex; align-items: center; gap: .6rem; }
.usermenu form { margin: 0; }

.main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.plain-main { max-width: 640px; margin: 4rem auto; padding: 0 1rem; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem 1.5rem; margin-bottom: 1.2rem; }
.card.narrow { max-width: 620px; }
.login-card { max-width: 400px; margin: 0 auto; }
.login-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.2rem; }
.login-head .icon { width: 1.6rem; height: 1.6rem; color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .95rem;
  border: 1px solid var(--border); border-radius: 7px; background: var(--card); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: .3rem .65rem; font-size: .88rem; }
.btn-block { width: 100%; justify-content: center; margin-top: .6rem; }
.btn-icon {
  display: inline-flex; padding: .35rem; border: 0; background: transparent; color: var(--muted);
  border-radius: 6px; cursor: pointer;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); }

/* Formulare */
.form label { display: block; margin-bottom: .9rem; font-weight: 500; font-size: .93rem; }
.form input[type=text], .form input[type=password], .form input[type=email], .form select, .filter input, .filter select {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit;
  border: 1px solid var(--border); border-radius: 7px; background: var(--card); color: var(--text);
}
.filter { display: flex; gap: .5rem; align-items: center; }
.filter input, .filter select { margin: 0; width: auto; padding: .35rem .6rem; }
.form input:focus, .form select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.form small { display: block; color: var(--muted); font-weight: normal; margin-top: .25rem; }
.form label.check, .form label.radio { display: flex; gap: .5rem; align-items: center; }
.radio-row { display: flex; gap: 1.5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; align-items: end; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1rem .4rem; margin: 0 0 1rem; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: rgba(31, 157, 85, .1); border-color: rgba(31, 157, 85, .35); }
.alert-error { background: rgba(214, 54, 63, .08); border-color: rgba(214, 54, 63, .35); }
.alert-info { background: rgba(47, 111, 237, .08); border-color: rgba(47, 111, 237, .3); }

.checks { list-style: none; padding: 0; margin: 0 0 1rem; }
.checks li { padding: .2rem 0; }
.checks .ok { color: var(--ok); }
.checks .fail { color: var(--danger); font-weight: 600; }
.checks .warn { color: var(--warn); }
.meta { display: grid; grid-template-columns: 160px 1fr; gap: .3rem 1rem; margin: 1rem 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 500; background: var(--bg); border: 1px solid var(--border); color: var(--muted); vertical-align: middle; }
.badge-blue { background: rgba(47, 111, 237, .12); border-color: transparent; color: var(--primary); }
.badge-gray { opacity: .85; }
.action-delete, .action-login_failed, .action-user_delete, .action-folder_delete { color: var(--danger); }
.action-upload { color: var(--ok); }

/* Ordner-Übersicht */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.folder-tile {
  display: flex; flex-direction: column; gap: .35rem; padding: 1.2rem; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.folder-tile:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }
.folder-icon .icon { width: 2.2rem; height: 2.2rem; color: var(--primary); fill: rgba(47, 111, 237, .12); }
.folder-name { font-weight: 600; font-size: 1.05rem; word-break: break-word; }
.folder-meta { display: flex; gap: .3rem; flex-wrap: wrap; }
meter { width: 100%; height: .6rem; }
.quota { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.quota meter { max-width: 300px; }

/* Breadcrumbs */
.crumbs { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: 1.15rem; font-weight: 600; }
.crumbs span { color: var(--muted); font-weight: normal; }
.crumbs a { color: var(--text); }

/* Dateiliste */
.dropzone { position: relative; padding: 0; overflow: hidden; min-height: 200px; }
.drop-overlay {
  display: none; position: absolute; inset: 0; z-index: 5; align-items: center; justify-content: center;
  background: rgba(47, 111, 237, .1); border: 3px dashed var(--primary); border-radius: var(--radius);
  font-size: 1.3rem; font-weight: 600; color: var(--primary); backdrop-filter: blur(2px);
}
.dropzone.dragging .drop-overlay { display: flex; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .icon { width: 3rem; height: 3rem; opacity: .5; }

table { width: 100%; border-collapse: collapse; }
.files th, .files td, .table th, .table td { padding: .55rem .8rem; text-align: left; border-bottom: 1px solid var(--border); }
.files th, .table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.files tbody tr:hover, .table tbody tr:hover { background: var(--bg); }
.files tr:last-child td, .table tr:last-child td { border-bottom: 0; }
.files .name a { color: var(--text); display: inline-flex; gap: .5rem; align-items: center; word-break: break-all; }
.files .name .icon { color: var(--primary); }
.col-check { width: 2.5rem; }
.col-size { width: 7rem; white-space: nowrap; }
.col-date { width: 9.5rem; white-space: nowrap; }
.col-actions { width: 10rem; text-align: right; white-space: nowrap; }
.table.access td:not(:first-child), .table.access th:not(:first-child) { text-align: center; width: 9rem; }
tr.inactive { opacity: .55; }
.log .details { word-break: break-word; font-size: .9rem; }
.list-foot { padding: .6rem 1rem; margin: 0; border-top: 1px solid var(--border); }
.bulkbar { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; background: rgba(47, 111, 237, .08); border-bottom: 1px solid var(--border); }
.bulkbar span { flex: 1; font-weight: 500; }

.pager { display: flex; gap: .3rem; flex-wrap: wrap; }
.pager a { padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card); }
.pager a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Upload-Fortschritt */
.upload-panel { border-bottom: 1px solid var(--border); padding: .8rem 1rem; background: var(--bg); max-height: 280px; overflow: auto; }
.upload-head { display: flex; gap: .8rem; align-items: center; margin-bottom: .4rem; }
#upload-list { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
#upload-list li { display: grid; grid-template-columns: 1fr 140px 220px; gap: .8rem; align-items: center; padding: .2rem 0; }
#upload-list .u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#upload-list progress { width: 100%; }
#upload-list .u-status { color: var(--muted); }
#upload-list li.ok .u-status { color: var(--ok); }
#upload-list li.err .u-status { color: var(--danger); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: .6rem; padding: .6rem 1rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .main { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .col-date, .col-size { display: none; }
  .col-actions { width: auto; }
  #upload-list li { grid-template-columns: 1fr 80px; }
  #upload-list .u-status { grid-column: 1 / -1; }
  .table th:nth-child(n+3):not(:last-child), .table td:nth-child(n+3):not(:last-child) { display: none; }
}

.notify-toggle { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); cursor: pointer; }

/* Verschieben */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 1.4rem 1.6rem; width: min(520px, 92vw); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(10, 15, 25, .45); }
.dialog h2 { margin-top: 0; }
.dialog label { display: block; font-weight: 500; }
.dialog select { display: block; width: 100%; margin-top: .4rem; padding: .3rem; font: inherit; border: 1px solid var(--border); border-radius: 7px; background: var(--card); color: var(--text); }
.dialog select option { padding: .25rem .4rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
tr[draggable="true"] { cursor: grab; }
tr.dragging-row { opacity: .45; }
tr.drop-target td { background: rgba(47, 111, 237, .14); }
.crumbs a.drop-target { background: rgba(47, 111, 237, .18); border-radius: 5px; outline: 2px dashed var(--primary); outline-offset: 2px; }

/* Aufklappbare Ordner */
.files td.name { white-space: nowrap; }
.tree-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; margin-right: .1rem;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 4px; font-size: .85rem;
  transition: transform .15s; vertical-align: middle;
}
.tree-toggle:hover { background: var(--border); color: var(--text); }
.tree-toggle[aria-expanded="true"] { transform: rotate(90deg); }
.tree-spacer { display: inline-block; width: 1.5rem; }
tr.child-row { background: rgba(127, 127, 127, .035); }
tr.child-row td { font-size: .95em; }
tr.empty-row td { color: var(--muted); font-style: italic; }

/* Ablagefläche zum Zurückschieben */
.drop-here {
  display: flex; align-items: center; justify-content: center; gap: .5rem; margin: .6rem 1rem;
  padding: .9rem; border: 2px dashed var(--primary); border-radius: 8px; color: var(--primary); font-weight: 600;
  background: rgba(47, 111, 237, .05);
}
.drop-here.drop-target { background: rgba(47, 111, 237, .18); }
