html, body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
}

/* ---------- Grundfarben (wie Logo, Kopfleiste und Startseite) ---------- */
:root {
    --ink: #2a2417; --ink-deep: #1c170e; --text: #3d3628; --muted: #6b6453; --muted-2: #8a826e;
    --gold: #b8923a; --gold-dark: #8a6a1f; --gold-hi: #e3c27a; --gold-soft: #fbf1d8;
    --line: #ece3cc; --line-strong: #ddd2b8; --page: #faf7f0; --card: #fff;
    --accent: var(--gold-dark); --danger: #a12a2a;
    --radius: 14px; --shadow: 0 1px 2px rgba(42, 36, 23, .04), 0 8px 24px rgba(42, 36, 23, .05);
}

/* Seiten mit Kopfleiste (MainLayout): warmer heller Grund, Inhalte auf weißen Karten.
   Startseite und Impressum (.landing) haben ihre eigene Gestaltung. */
body:has(> .content), body:has(main.content):not(:has(.landing)) { background: var(--page); }

.content {
    max-width: 66rem;
    margin: 0 auto;
    padding: 2.25rem 1.5rem 4rem;
    box-sizing: border-box;
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
.content h1 { margin: .25rem 0 1.25rem; color: var(--ink); font-size: 2rem; line-height: 1.15; font-weight: 800; letter-spacing: -0.03em; }
.content h2 { margin: 2.25rem 0 .85rem; color: var(--ink); font-size: 1.2rem; font-weight: 700; letter-spacing: -0.015em; }
.content h3 { color: var(--ink); }
.content a { color: var(--gold-dark); text-underline-offset: 2px; }
.content a:hover { color: var(--ink); }
.content code, .content pre { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9em; }
.content pre { background: var(--page); border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; overflow-x: auto; }

h1:focus {
    outline: none;
}

/* Quillarum-Logo: Startseite (Kopfleiste siehe nav.css) */
.hero-logo {
    display: block;
    width: 160px;
    height: 160px;
    margin-bottom: 1rem;
}

/* ---------- Tabellen ---------- */
.content table {
    border-collapse: separate; border-spacing: 0; width: 100%; margin: 0 0 1.25rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
    font-size: .94rem;
}
table { border-collapse: collapse; width: 100%; margin-bottom: 1rem; }
th, td { text-align: start; padding: .3rem .5rem; border-bottom: 1px solid #e3e7ed; }
.content th, .content td, .grid th, .grid td { text-align: start; padding: .75rem 1rem; border-bottom: 1px solid #f2ecdc; vertical-align: middle; }
.content th, .grid th {
    background: #fcf9f2; color: var(--muted); font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
    border-bottom-color: var(--line);
}
.content tbody tr:last-child td { border-bottom: 0; }
.content tbody tr:hover td { background: #fffcf4; }
.content td a { font-weight: 600; text-decoration: none; }
.content td a:hover { text-decoration: underline; }
th.n, td.n, .content th.n, .content td.n { text-align: end; font-variant-numeric: tabular-nums; }
.grid { border-collapse: collapse; width: 100%; margin-bottom: 1rem; }
.grid tr.inactive td { color: #a39a85; }
tr.past td { color: #a39a85; }

/* ---------- SuperAdmin: KI-Kosten, Kennzahlen ---------- */
.admin-nav { color: var(--muted); }
.periods a { margin-inline-end: 0.5rem; text-decoration: none; padding: .3rem .8rem; border-radius: 999px; border: 1px solid transparent; }
.periods a:hover { background: var(--gold-soft); }
.periods a.active { background: var(--ink); color: #fff; }
.range { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 0.5rem 0 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.tile {
    position: relative; overflow: hidden; display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.15rem 1.05rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tile::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; inset-inline-end: 0; height: 3px; background: linear-gradient(90deg, var(--gold-hi), var(--gold)); }
.tile span { color: var(--muted); font-size: .82rem; font-weight: 600; }
.tile strong { color: var(--ink-deep); font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted-2); }
.tile.bad strong, td.bad { color: #b00020; }

/* ---------- Hinweise ---------- */
.muted { color: var(--muted); }
.links, .hint { color: var(--muted); font-size: .9rem; }
.content p.hint { max-width: 52rem; }
.warn { color: #7a4a00; background: #fff4e0; border: 1px solid #f3dcb0; padding: .55rem .8rem; border-radius: 10px; }
.ok { color: #1b5e20; background: #edf7ee; border: 1px solid #cfe7d2; padding: .55rem .8rem; border-radius: 10px; }
.alert { padding: .8rem 1.05rem; border-radius: 12px; margin: 0 0 1.25rem; border: 1px solid; font-size: .95rem; }
.alert-error { background: #fdf0ef; color: #7a1c1c; border-color: #f1cdca; }
.alert-ok { background: #eff8f0; color: #1d5a2c; border-color: #cbe6d0; }
.alert-warn { background: #fff4e0; color: #7a4a00; border-color: #f3dcb0; }
.alert ul { margin: 0; padding-inline-start: 1.2rem; }
.alert a { color: inherit; font-weight: 600; }
span.alert { display: inline-block; padding: .2rem .6rem; margin: 0 .3rem .2rem 0; border-radius: 8px; font-size: .9rem; }
.validation-message { color: var(--danger); font-size: .85rem; }

/* ---------- Formulare ---------- */
.form {
    display: flex; flex-direction: column; gap: 1rem; max-width: 30rem; box-sizing: border-box;
}
.content .form:not(.inline) {
    padding: 1.5rem; margin: 0 0 1.25rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.form label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; font-weight: 600; color: var(--ink); }
.form label.check { display: block; position: relative; padding-inline-start: 1.6rem; font-weight: 400; color: var(--text); }
.form label.check input { position: absolute; inset-inline-start: 0; top: .2rem; margin: 0; }
.form input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), .form select, .form textarea,
.content input:is([type=text], [type=email], [type=password], [type=number], [type=tel], [type=search], [type=url], [type=date], [type=datetime-local], :not([type])),
.content select, .content textarea {
    padding: .6rem .8rem; box-sizing: border-box; max-width: 100%;
    border: 1px solid var(--line-strong); border-radius: 10px; background: #fffdf8; color: var(--ink-deep);
    font: inherit; font-size: .98rem; font-weight: 400; line-height: 1.4;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.content textarea { line-height: 1.5; }
.content input:not([type=checkbox]):not([type=radio]):hover, .content select:hover, .content textarea:hover { border-color: #cbbd97; }
.content input:focus, .content select:focus, .content textarea:focus {
    outline: none; border-color: var(--gold); background: #fff; box-shadow: 0 0 0 4px rgba(184, 146, 58, .16);
}
.content input:disabled { background: #f5f1e7; color: var(--muted); }
.content input[type=checkbox], .content input[type=radio] { accent-color: var(--gold-dark); width: 1rem; height: 1rem; }
.content input[type=color] { width: 3rem; height: 2.4rem; padding: .2rem; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; }
.content input[type=file] { font: inherit; font-size: .9rem; color: var(--muted); }
.content input[type=file]::file-selector-button {
    margin-inline-end: .8rem; padding: .55rem 1rem; border: 1px solid var(--line-strong); border-radius: 10px;
    background: var(--gold-soft); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.content input[type=file]::file-selector-button:hover { background: #f4e3b8; }
.content fieldset { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: .8rem; }
.content legend { padding: 0 .4rem; font-weight: 700; font-size: .85rem; color: var(--ink); }
form.inline { display: inline-flex; gap: .5rem; align-items: center; margin: 0 .5rem .5rem 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }

/* ---------- Knöpfe ---------- */
/* Grundform für alle Knöpfe ohne eigene Klasse; Mail-Ansicht (.ghost, .btn-primary …) gestaltet ihre selbst. */
button { padding: .5rem 1rem; border: 0; border-radius: 6px; background: var(--ink); color: #fff; cursor: pointer; font-size: 1rem; }
button.danger { background: var(--danger); }
button.link { background: none; color: var(--gold-dark); padding: 0; text-decoration: underline; font-size: inherit; }
:where(.content) button:where(:not([class]), .danger, .primary) {
    padding: .62rem 1.15rem; border-radius: 10px; font: inherit; font-size: .95rem; font-weight: 600; line-height: 1.3;
    transition: background-color .15s, box-shadow .15s;
}
:where(.content) button:where(:not([class]), .primary):hover:not(:disabled) { background: var(--ink-deep); box-shadow: 0 6px 16px rgba(42, 36, 23, .2); }
:where(.content) button.danger:hover:not(:disabled) { background: #861f1f; box-shadow: 0 6px 16px rgba(161, 42, 42, .2); }
:where(.content) button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
:where(.content) button:disabled { opacity: .5; cursor: default; }
:where(.content) button.link { font-weight: 600; text-decoration: none; }
:where(.content) button.link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

/* Signaturen (nutzt das Verfassen-Raster aus mail.css): Haken- und Knopfzeilen nicht in die schmale Feldspalte zwängen */
.compose-form .row label:has(> input[type=checkbox]) { width: auto; display: flex; align-items: center; gap: .55rem; padding: .7rem 0; color: var(--ink); font-size: .92rem; }
.compose-form .row label > input[type=checkbox] { accent-color: var(--gold-dark); width: 1rem; height: 1rem; margin: 0; }
.compose-form .row:has(> button) { padding: .8rem; border-bottom: 0; gap: 1rem; }
.compose-form .row:has(> textarea) { align-items: flex-start; padding-top: .6rem; padding-bottom: .6rem; }
.compose-form .row > textarea { flex: 1; min-width: 0; padding: .6rem .7rem; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; font-size: .92rem; background: #fffdf8; }
.compose-form > p.muted { margin: 0; padding: .7rem .8rem; font-size: .86rem; border-bottom: 1px solid var(--line); background: #fcf9f2; }
.compose-form .row > button.primary { padding: .6rem 1.2rem; border-radius: 10px; font-weight: 600; }

code.key { font-size: 1.05rem; letter-spacing: .05rem; }

.auth-logo { display: block; width: 96px; height: 96px; margin-bottom: 0.5rem; }
.rule-row { display:flex; gap:.4rem; align-items:center; margin:.3rem 0; flex-wrap:wrap }
.rule-row input:not([type=checkbox]) { flex:1; min-width:10rem }
.seed-bar { display:flex; gap:.35rem; align-items:center; flex-wrap:wrap; margin:.2rem 0 .6rem }
ul.plain { list-style:none; padding:0 } ul.plain li { margin:.4rem 0 }
.row-actions button + button { margin-inline-start:.6rem }
.qr { margin: .5rem 0; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--line); display: block; }

/* ---------- Handy ---------- */
@media (max-width: 40rem) {
    .content { padding: 1.5rem 1rem 3rem; }
    .content h1 { font-size: 1.65rem; }
    /* Breite Tabellen seitlich wischen statt die Seite zu sprengen */
    .content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .content th, .content td { padding: .65rem .8rem; }
    .content td:not([colspan]) { white-space: nowrap; }
    .content .form:not(.inline) { padding: 1.15rem; }
    .form { max-width: none; }
}

/* ---------- Abo-Stufen (Abo und Guthaben) ---------- */
.tier-pick { border: 0; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; }
.tier-pick legend { font-weight: 700; margin-bottom: .5rem; }
.tier-pick .tier { display: flex; flex-direction: column; gap: .15rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); cursor: pointer; }
.tier-pick .tier:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-hi); }
.tier-pick .tier strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.tier-pick .tier small { color: var(--muted); }
.tier-pick .tier-name { font-weight: 700; }
.tier-pick .tier-off { opacity: .5; cursor: not-allowed; }
.tile button { margin-top: .5rem; align-self: flex-start; }

/* Relevanz: Keyword hinzufügen (/admin/relevanz) */
.kw-add { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin: .8rem 0 1rem; }
.kw-add label { display: flex; flex-direction: column; gap: .2rem; font-size: .88rem; }
