/* 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; }
}
