/* LJ Update-Zentrale */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e2e5ea;
    --text: #161a21;
    --muted: #667080;
    --primary: #1e40af;
    --primary-hover: #1a3794;
    --primary-text: #ffffff;
    --ok: #15803d;
    --ok-bg: #e7f6ec;
    --warn: #b45309;
    --warn-bg: #fdf1df;
    --err: #b91c1c;
    --err-bg: #fdeaea;
    --run: #1d4ed8;
    --run-bg: #e6edfd;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1218;
        --surface: #171b23;
        --surface-2: #1e232d;
        --border: #2a303c;
        --text: #e8ebf0;
        --muted: #949db0;
        --primary: #4f7cf7;
        --primary-hover: #6a90f8;
        --primary-text: #ffffff;
        --ok: #4ade80;
        --ok-bg: #12301f;
        --warn: #fbbf24;
        --warn-bg: #352812;
        --err: #f87171;
        --err-bg: #3a1717;
        --run: #93b4ff;
        --run-bg: #1a2747;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75em; }
img { max-width: 100%; display: block; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.text-warn { color: var(--warn); }
.inline { display: inline; }

/* Kopfzeile */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
    color: var(--muted);
    padding: 7px 12px;
    border-radius: 8px;
    white-space: nowrap;
    font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--surface-2); color: var(--text); }
.logout { margin: 0; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 28px 16px 120px; }

/* Bausteine */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.section-head h2 { margin: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: var(--err); opacity: .9; }
.btn-ghost-danger { color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 6px; }
.btn-link:hover { color: var(--text); }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
    content: "";
    position: absolute;
    width: 14px; height: 14px;
    border: 2px solid currentColor;
    border-color: var(--muted) transparent var(--muted) transparent;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.btn-primary.loading::after { border-color: #fff transparent #fff transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
    vertical-align: middle;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-run { background: var(--run-bg); color: var(--run); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

.tag {
    --c: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    font-weight: 500;
    color: var(--text);
}
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-err { background: var(--err-bg); color: var(--err); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }

/* Formulare */
.form { max-width: 720px; }
.form.narrow { max-width: 420px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field em { font-style: normal; font-weight: 400; }
.field small { display: block; margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}
input[type=color] { width: 40px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 400; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.inline-form { display: flex; gap: 8px; }
.inline-form select { min-width: 220px; }

/* Anmeldung */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 20px; }
.auth-brand h1 { margin: 0; font-size: 1.3rem; }
.auth-card { padding: 28px; }

/* Übersicht */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
}
.stat-num { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-warn .stat-num { color: var(--warn); }
.stat-err .stat-num { color: var(--err); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sort { color: var(--muted); font-size: .85rem; margin-right: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: .88rem;
    font-weight: 500;
}
.chip span { color: var(--muted); font-weight: 400; }
.chip:hover { text-decoration: none; border-color: var(--muted); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.active span { color: inherit; opacity: .7; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.site-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; margin: 0; }
.thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 10;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform .3s; }
.site-card:hover .thumb img { transform: scale(1.02); }
.thumb-empty {
    display: grid;
    place-items: center;
    height: 100%;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--muted);
    opacity: .5;
}
.thumb .badge { position: absolute; top: 10px; right: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.site-body { padding: 14px 16px 14px; display: flex; flex-direction: column; flex: 1; }
.site-name { font-size: 1rem; margin: 0; }
.site-name a { color: var(--text); }
.site-host { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: .8rem; color: var(--muted); }
.site-error, .site-warn { font-size: .82rem; margin: 8px 0 0; }
.site-error { color: var(--err); }
.site-warn { color: var(--warn); }
.site-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; padding-top: 12px; }
.site-actions { display: flex; gap: 6px; }

.empty { text-align: left; }
.steps { padding-left: 1.3em; margin: 0; }
.steps li { margin-bottom: 8px; }

/* Detailansicht */
.site-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; margin-bottom: 0; }
.shot { padding: 0; overflow: hidden; margin: 0 0 20px; }
.shot-frame { background: var(--surface-2); aspect-ratio: 16 / 10; overflow: hidden; }
.shot-frame img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.shot figcaption { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; }
.shot-empty { display: grid; place-items: center; height: 100%; min-height: 120px; color: var(--muted); text-align: center; padding: 16px; background: var(--surface-2); }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 12px; }
.info dt { color: var(--muted); font-size: .9rem; }
.info dd { margin: 0; font-weight: 500; }
.notes { white-space: normal; color: var(--muted); font-size: .9rem; }
.all-good { color: var(--ok); font-weight: 600; margin: 0; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.col-check { width: 32px; }

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; display: inline-block; width: 1em; color: var(--muted); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }

.runs { display: flex; flex-direction: column; gap: 8px; }
.run { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.run summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.run-date { font-weight: 600; }
.run-items { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.run-items li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 2px 8px; }
.ri-icon { font-weight: 700; text-align: center; }
.ri-ok .ri-icon { color: var(--ok); }
.ri-error .ri-icon { color: var(--err); }
.ri-running .ri-icon { color: var(--run); }
.ri-pending .ri-icon { color: var(--muted); }
.ri-label { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.ri-msg { grid-column: 2; color: var(--muted); }
.ri-error .ri-msg { color: var(--err); }

.compare-wrap { margin-top: 12px; }
.compare {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    margin-bottom: 12px;
    user-select: none;
}
.compare > img, .compare-before img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.compare-before { position: absolute; inset: 0; clip-path: inset(0 50% 0 0); }
.compare-before::after { content: ""; position: absolute; top: 0; bottom: 0; right: 0; }
.compare input[type=range] {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: ew-resize; margin: 0;
}
.compare-line { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); left: 50%; pointer-events: none; }
.compare-line::after {
    content: "⟷"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 32px; height: 32px; border-radius: 50%; background: #fff; color: #111;
    display: grid; place-items: center; font-size: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.compare-label { position: absolute; bottom: 10px; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; font-weight: 600; pointer-events: none; }
.compare-label-l { left: 10px; }
.compare-label-r { right: 10px; }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side-by-side figure { margin: 0; }
.side-by-side figcaption { font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.side-by-side img { border: 1px solid var(--border); border-radius: 8px; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; width: 100%; }

/* Formular-Seite */
.form-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(240px, 2fr); gap: 20px; align-items: start; }
.form-layout .form { max-width: none; }
.help { background: var(--surface-2); box-shadow: none; }
.danger { border-color: var(--err-bg); }

/* Kategorien */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cat-row:last-child { border-bottom: 0; }
.cat-row form { margin: 0; }
.cat-form { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }
.cat-form input[type=text] { max-width: 280px; }

/* Warteschlange */
.queue {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: min(420px, calc(100vw - 32px));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
    padding: 16px 18px;
    z-index: 50;
}
.queue-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.queue-head span { color: var(--muted); font-size: .85rem; }
.queue-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.queue-bar span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .4s; }
.queue.done .queue-bar span { background: var(--ok); }
.queue.failed .queue-bar span { background: var(--err); }
.queue-text { margin-top: 10px; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-hint { margin-top: 6px; font-size: .78rem; color: var(--muted); }

.toasts { position: fixed; left: 50%; top: 72px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(520px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: .9rem; animation: toast-in .2s ease-out; }
.toast-err { background: var(--err); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* Schmale Bildschirme */
@media (max-width: 900px) {
    .site-top, .form-layout { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .topbar-inner { gap: 12px; height: auto; padding: 10px 16px; flex-wrap: wrap; }
    .brand span { display: none; }
    .nav { order: 3; flex-basis: 100%; }
    .logout { margin-left: auto; }
    .wrap { padding-top: 20px; }
    h1 { font-size: 1.35rem; }
    .toolbar-actions { width: 100%; }
    .toolbar-actions .btn { flex: 1; }
    .side-by-side { grid-template-columns: 1fr; }
    .table th:nth-child(3), .table td:nth-child(3) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* Automatische Updates */
.auto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; margin-top: 8px; }
.auto-grid select { width: 100%; }
.auto-form > .check { margin: 0 0 12px; }
.auto-skip { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; min-width: 0; }
.auto-skip legend { padding: 0 6px; font-weight: 600; font-size: .9rem; }
.auto-skip p { margin: 0 0 8px; }
.skip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.skip-list .check { margin-top: 6px; min-width: 0; overflow-wrap: anywhere; }
.alert .inline-form { display: inline-flex; margin-left: 8px; vertical-align: middle; }
.site-auto { font-size: .8rem; margin: 6px 0 0; }
.auto-note { margin: 12px 0 0; }
.skip-list .check { align-items: flex-start; }
.skip-list .check input { margin-top: 3px; }
.hint { background: var(--surface-2); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.hint p { margin: 0 0 8px; }
.hint ol { margin: 0; padding-left: 20px; }
.hint li { margin: 4px 0; }
.ri-rolledback .ri-icon { color: var(--warn); }
.ri-rolledback .ri-msg { color: var(--warn); }
.ri-cancelled .ri-icon, .ri-cancelled .ri-label { color: var(--muted); }
.ri-action { margin: 4px 0 0; }
.run-items li .ri-action { grid-column: 2; }
.auto-sched { margin: 0 0 12px; color: var(--muted); }
.cron-log pre { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; max-height: 320px; overflow: auto; }
.foot { margin: 32px 0 8px; text-align: center; }
.foot a { color: inherit; }
.h3 { font-size: 1rem; margin: 18px 0 6px; }
.upd-list { margin: 0 0 12px; padding-left: 18px; }
.upd-list li { margin: 2px 0; }
.ver { border-top: 1px solid var(--border); padding-top: 4px; }
.ver:first-of-type { border-top: 0; }
.ver ul { margin: 0 0 10px; padding-left: 18px; }
.ver-current .h3 { color: var(--text); }
