:root {
    --bg: #f6f7f5;
    --surface: #ffffff;
    --text: #1d2420;
    --muted: #5d6862;
    --border: #dfe3df;
    --accent: #1f7a4d;
    --accent-hover: #186240;
    --warn-bg: #fff6e0;
    --warn: #8a5a00;
    --error-bg: #fdecec;
    --error: #a12a2a;
    --ok-bg: #e8f5ec;
    --ok: #1f6b42;
    --radius: 8px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141816; --surface: #1d2320; --text: #e4e9e5; --muted: #9aa59f; --border: #313a35;
        --accent: #3aa874; --accent-hover: #4cbc87;
        --warn-bg: #3a2f14; --warn: #f0c46a; --error-bg: #3c1d1d; --error: #f19a9a; --ok-bg: #17321f; --ok: #8fd6a9;
        color-scheme: dark;
    }
}
* { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 .5rem; }
a { color: var(--accent); }

.topbar {
    display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
    padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.route { color: var(--muted); font-size: .9rem; }
.topbar .logout { margin-left: auto; font-size: .9rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.lead { color: var(--muted); max-width: 46rem; }
.hint { color: var(--muted); font-size: .9rem; }
.accounts { color: var(--muted); margin-top: 0; }
.acct { font-weight: 600; color: var(--text); }

.email-field { max-width: 28rem; margin: 1.5rem 0 0; }
.email-field .hint { margin: -.5rem 0 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem 1.25rem; margin: 0; }
.card legend { font-weight: 700; padding: 0 .25rem; }
.server { margin: 0 0 1rem; color: var(--muted); font-family: ui-monospace, monospace; font-size: .85rem; }
.input { margin-bottom: .9rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type=email], input[type=password], input[type=text] {
    width: 100%; padding: .55rem .7rem; font: inherit; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error-message { color: var(--error); font-size: .85rem; }

.actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.actions form { margin: 0; }
.actions.sticky { position: sticky; top: 0; background: var(--bg); padding: .75rem 0; z-index: 2; border-bottom: 1px solid var(--border); }
.btn, button {
    display: inline-block; padding: .6rem 1.1rem; border-radius: 6px; font: inherit; font-weight: 600;
    border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover, button:hover { background: var(--accent-hover); }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.secondary:hover { background: var(--ok-bg); }
.btn.small { padding: .35rem .8rem; font-size: .9rem; }

.message, .notice { padding: .75rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; border: 1px solid transparent; }
.message { cursor: pointer; }
.message.hidden { display: none; }
.message.error, .notice.error { background: var(--error-bg); color: var(--error); }
.message.warning, .notice.warn { background: var(--warn-bg); color: var(--warn); }
.message.success, .notice.ok { background: var(--ok-bg); color: var(--ok); }
.message.info { background: var(--surface); border-color: var(--border); }
.notice.inline { display: inline-block; margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin: 1.25rem 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .num { display: block; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat.warn .num { color: var(--warn); }
.stat.ok .num { color: var(--ok); }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
table.folders { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.row-ok td:last-child { color: var(--ok); }
.row-missing td:last-child, .row-missing-folder td:last-child { color: var(--warn); }
.badge { display: inline-block; margin-left: .4rem; padding: 0 .45rem; font-size: .75rem; font-weight: 700; border-radius: 99px; background: var(--warn-bg); color: var(--warn); }

.progress-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin: 1.25rem 0; }
.progress-head { display: flex; gap: .75rem; align-items: center; margin-bottom: .75rem; }
.progress-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.progress-count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-bottom: 1rem; }
.bar-fill { height: 100%; background: var(--accent); transition: width .4s; }
.bar-fill.indeterminate { width: 30% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.stale-warning { color: var(--warn); }
.log {
    max-height: 22rem; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
    padding: .75rem; font-size: .8rem; white-space: pre-wrap; word-break: break-word; margin: 0 0 1rem;
}
@media (max-width: 640px) {
    th:nth-child(2), td:nth-child(2) { display: none; }
}

/* Ordnerauswahl */
th.sel, td.sel { width: 2.25rem; padding-right: 0; }
td.sel input, th.sel input { width: 1.05rem; height: 1.05rem; margin: .15rem 0 0; cursor: pointer; accent-color: var(--accent); }
.folder-label { display: inline; font-weight: 400; font-size: inherit; margin: 0; cursor: pointer; }
.row-unselected > td:not(.sel) { opacity: .5; }
.selection-summary { font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.selection-summary.over-quota { color: var(--warn); font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
