/* Storanger – Weboberfläche. Keine Inline-Styles (CSP). Hell/Dunkel über prefers-color-scheme. */
:root {
    --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef1f4; --border: #dde2e8;
    --text: #1c2430; --muted: #5f6b7a; --brand: #0f5c73; --brand-strong: #0b4758; --brand-contrast: #ffffff;
    --ok: #1f7a4d; --ok-bg: #e5f4ec; --warn: #8a5a00; --warn-bg: #fdf3dc; --error: #b42318; --error-bg: #fdecea;
    --archive: #5b3fa8; --archive-bg: #efeafb;
    --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11161c; --surface: #19202a; --surface-2: #212a35; --border: #2d3846;
        --text: #e6ebf1; --muted: #9aa7b6; --brand: #4fb3cf; --brand-strong: #7cc9de; --brand-contrast: #06232c;
        --ok: #6fd39f; --ok-bg: #16352a; --warn: #f2c46b; --warn-bg: #3a2f14; --error: #ff8a80; --error-bg: #3d1d1b;
        --archive: #c1adf5; --archive-bg: #2c2445; --shadow: none;
    }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 .4rem; display: flex; align-items: center; gap: .5rem; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .88em; overflow-wrap: anywhere; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.icon-folder { color: #c98a14; fill: rgba(201, 138, 20, .18); }
.icon-file { color: var(--muted); }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: .6rem max(1rem, env(safe-area-inset-left)); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--brand); color: var(--brand-contrast); font-weight: 800; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { color: var(--muted); font-weight: 450; font-size: .8rem; }
.brand-large .brand-mark { width: 2.6rem; height: 2.6rem; font-size: 1.3rem; }
.search { flex: 1 1 18rem; display: flex; align-items: center; gap: .4rem; max-width: 36rem; padding: 0 .7rem;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; padding: .45rem 0; outline: none; }
.search:focus-within { border-color: var(--brand); }
.account { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.account form { margin: 0; }
.account-name { font-size: .9rem; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-small { padding: .2rem .55rem; font-size: .85rem; }
.btn-block { width: 100%; justify-content: center; padding: .7rem; }
.ms-logo { width: 1.1rem; height: 1.1rem; }

/* Hinweise, Status, Badges */
.notice { display: flex; gap: .5rem; align-items: flex-start; padding: .7rem .9rem; margin: .8rem 0; border-radius: var(--radius);
    background: var(--surface-2); border: 1px solid var(--border); }
.notice-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.notice-error { background: var(--error-bg); color: var(--error); border-color: transparent; }
.notice-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; vertical-align: .1em; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-archive { background: var(--archive-bg); color: var(--archive); }
.status { margin: .8rem 0; padding: .6rem .8rem; border-radius: 8px; }
.status p { margin: 0; display: flex; align-items: center; gap: .4rem; font-weight: 600; }
.status ul { margin: .4rem 0 0 1.6rem; padding: 0; font-size: .9rem; }
.status-ok { background: var(--ok-bg); color: var(--ok); display: flex; align-items: center; gap: .4rem; font-weight: 600; }
.status-warn { background: var(--warn-bg); color: var(--warn); }

/* Übersicht */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; margin-top: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card-head { display: flex; gap: .7rem; align-items: flex-start; }
.card-head .icon { width: 1.6rem; height: 1.6rem; color: var(--brand); margin-top: .15rem; }
.card h2 { margin: 0; }
.card p { margin: .1rem 0 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .8rem 0 0; }
.stats dt { color: var(--muted); font-size: .75rem; }
.stats dd { margin: 0; font-weight: 650; }
.stats dd.stat-date { font-weight: 500; font-size: .88rem; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; margin-top: 1rem; }

/* Listen */
.crumbs { display: flex; flex-wrap: wrap; gap: .3rem; font-size: .9rem; margin-bottom: .4rem; }
.crumbs .sep { color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: .8rem; box-shadow: var(--shadow); }
.listing { width: 100%; border-collapse: collapse; }
.listing th, .listing td { padding: .5rem .8rem; text-align: left; border-bottom: 1px solid var(--border); }
.listing th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
.listing tr:last-child td { border-bottom: 0; }
.listing tbody tr:hover { background: var(--surface-2); }
.listing .num { text-align: right; white-space: nowrap; }
.listing td:nth-child(3), .listing td:nth-child(4) { white-space: nowrap; }
.name { display: inline-flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 500; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1rem; }

/* Dateidetails */
.title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; }
.title-row h1 { overflow-wrap: anywhere; }
.actions { display: flex; gap: .5rem; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: .8rem 1.5rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 1rem 0; }
.meta div:nth-child(2) { grid-column: 1 / -1; }
.meta dt { color: var(--muted); font-size: .78rem; }
.meta dd { margin: .1rem 0 0; }

/* Anmeldung */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-box { width: 100%; max-width: 26rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); }
.login-box h1 { margin-top: 1.2rem; }

@media (max-width: 640px) {
    .account-name { display: none; }
    .account { order: 2; }
    .search { order: 3; flex-basis: 100%; max-width: none; }
    .stats { grid-template-columns: 1fr 1fr; }
    .listing th:nth-child(3), .listing td:nth-child(3) { display: none; }
}

/* Verwaltung */
.subnav { display: flex; flex-wrap: wrap; gap: 1rem; border-bottom: 1px solid var(--border); padding-bottom: .6rem; margin-bottom: 1.2rem; font-size: .92rem; }
.subnav a { color: var(--muted); }
.subnav a.is-active { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }
.subnav a:last-child { margin-left: auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 1.2rem 0; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; font-size: 1.05rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .8rem 1rem; }
.form-grid label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; }
.form-grid input, .form-grid select { padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-weight: 400; }
.form-grid label small { font-weight: 400; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; }
.row-actions { display: flex; gap: .3rem; justify-content: flex-end; flex-wrap: wrap; }
.choice { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; }
.small { font-size: .82rem; }

/* Personen- und Gruppensuche */
.picker { position: relative; }
.vorschlaege { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin: .2rem 0 0; padding: .25rem; list-style: none;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 16rem; overflow-y: auto; }
.vorschlag { display: block; width: 100%; text-align: left; padding: .45rem .6rem; border: 0; border-radius: 7px; background: none;
    color: var(--text); font: inherit; font-weight: 400; cursor: pointer; }
.vorschlag:hover, .vorschlag:focus { background: var(--surface-2); }
.inline-field { display: flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 600; margin: .3rem 0 .8rem 1.9rem; }
.inline-field input { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-weight: 400; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 1rem; margin-left: 1.9rem; }
.inline-fields .inline-field { margin: .3rem 0 .8rem; }
.inline-field select { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-weight: 400; }
.such-fehler { color: var(--warn); font-weight: 600; }

/* Dateisymbole nach Typ */
.icon-f-word { color: #2b579a; }
.icon-f-excel { color: #217346; }
.icon-f-ppt { color: #c43e1c; }
.icon-f-pdf { color: #c0392b; }
.icon-f-image { color: #8e44ad; }
.icon-f-zip { color: #b7791f; }
.icon-f-text { color: #4b5563; }
.icon-f-code { color: #0f766e; }
.icon-f-mail { color: #1d4ed8; }
.icon-f-media { color: #be185d; }

/* Sortierbare Spalten und Filter */
.listing th a { display: inline-flex; align-items: center; gap: .25rem; color: inherit; }
.listing th a.is-sorted { color: var(--text); }
.filterbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .8rem 0 0; }
.filterbar input { flex: 1 1 14rem; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.tag { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; color: #fff; white-space: nowrap; }
.tag + .tag { margin-left: .25rem; }
.tag-remove { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 0 0 0 .3rem; }
.tagzeile { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .8rem 0; }
.tagzeile .tag { display: inline-flex; align-items: center; }
.tag-form { display: inline-flex; align-items: center; gap: .3rem; }
.tag-form select { padding: .25rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; }
.beschreibung { margin: .5rem 0 0; font-size: .92rem; }
.card textarea { width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; resize: vertical; }

/* Sammeldownload */
.listing th.tick, .listing td.tick { width: 2.2rem; text-align: center; padding-right: 0; }
.bulkbar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-top: .8rem; }
.zahl { display: inline-block; min-width: 1.35rem; padding: 0 .35rem; border-radius: 999px; background: var(--brand);
    color: var(--brand-contrast); font-size: .78rem; font-weight: 700; text-align: center; }

/* Stand vom … */
.stand { display: flex; align-items: center; gap: .35rem; }
.stand input { padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; }
.zeitband { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; }
@media (max-width: 860px) { .stand input { max-width: 10rem; } }

/* Gelöschte Dateien: im Archiv vorhanden, auf dem Fileserver nicht mehr */
.name.is-geloescht { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.btn.is-active { background: var(--surface-2); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.schnipsel { color: var(--muted); font-size: .85rem; margin-top: .25rem; line-height: 1.45; }
.schnipsel mark { background: var(--warn-bg); color: var(--text); padding: 0 .15rem; border-radius: 3px; }

/* KI-Suche */
.spinner { display: inline-block; width: .9em; height: .9em; margin-right: .4rem; vertical-align: -.1em;
    border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: dreh 1s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.antwort { white-space: pre-line; line-height: 1.6; }
