:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #6b7385;
    --border: #e1e4ea;
    --primary: #c96442;
    --primary-text: #ffffff;
    --ok-bg: #e7f6ec;
    --ok-text: #1c6b3a;
    --err-bg: #fdecea;
    --err-text: #a12d22;
    --code-bg: #f0f2f5;
    --radius: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16181d;
        --surface: #1f2228;
        --text: #e6e8ec;
        --muted: #9aa1b0;
        --border: #2e323b;
        --primary: #d97757;
        --ok-bg: #173323;
        --ok-text: #7fd6a0;
        --err-bg: #3a1c1a;
        --err-text: #f1a097;
        --code-bg: #272b33;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--primary); }
.brand span { color: var(--text); }
nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
nav a {
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
}
nav a:hover { color: var(--text); background: var(--code-bg); }
nav a.active { color: var(--text); background: var(--code-bg); font-weight: 600; }

main { max-width: 1000px; margin: 24px auto; padding: 0 16px; }

h1, h2 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.card.narrow { max-width: 420px; margin: 48px auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 20px; color: inherit; text-decoration: none;
}
.stat strong { font-size: 1.8rem; line-height: 1.2; }
.stat span { color: var(--muted); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 500; }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }

input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    width: 100%;
}
input[type="checkbox"] { width: auto; }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
.grid .full { grid-column: 1 / -1; }
.row { display: flex; gap: 12px; align-items: flex-end; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; margin-bottom: 12px; }
form.row select { margin-bottom: 12px; }
.actions { display: flex; gap: 8px; margin-top: 4px; }

button, .button {
    display: inline-flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
button:hover, .button:hover { background: var(--code-bg); }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); }
button.small, .button.small { padding: 4px 10px; font-size: 13px; }
button.danger-outline { color: var(--err-text); }
button.link { border: 0; background: none; color: var(--muted); padding: 6px 12px; }
button.link:hover { color: var(--text); }
form.inline { display: inline; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 500; }
td.right, .right { text-align: right; white-space: nowrap; }
td.right > *, .right > * { margin-left: 4px; }

code, pre { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
code { background: var(--code-bg); padding: 2px 6px; border-radius: 5px; word-break: break-all; }
pre {
    background: var(--code-bg);
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
pre.result { max-height: 600px; overflow-y: auto; }
pre.result.error { color: var(--err-text); }
.copy { cursor: copy; position: relative; }
.copy.copied::after {
    content: "kopiert ✓"; position: absolute; right: 8px; top: 6px;
    font-family: system-ui, sans-serif; font-size: 12px; color: var(--ok-text);
}
code.copy.copied::after { top: -20px; right: 0; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.kv > span:nth-child(odd) { color: var(--muted); }
.token { display: flex; gap: 8px; align-items: center; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--code-bg); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.err { background: var(--err-bg); color: var(--err-text); }

.muted { color: var(--muted); }
.small-text { font-size: 13px; }

.account { border-top: 1px solid var(--border); padding: 14px 0; }
.account:first-of-type { border-top: 0; }
.account-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.calendars { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.calendars label { margin-bottom: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

@media (max-width: 700px) {
    .grid { grid-template-columns: 1fr; }
    .topbar { padding: 12px 16px; }
    .card { padding: 16px; }
    table, thead, tbody, tr, td { display: block; }
    thead { display: none; }
    tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
    td { border: 0; padding: 2px 0; }
    td.right { text-align: left; }
}
