/* ---------- Grundgerüst ---------- */
:root {
    --bg: #0f1115;
    --bg-2: #161a22;
    --card: #1c2129;
    --card-border: #262d38;
    --text: #e8ebf0;
    --muted: #8a93a3;
    --accent: #ff7a1a;
    --accent-2: #ffb347;
    --ok: #2fbf71;
    --err: #ff5c5c;
    --run: #4c9aff;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* hidden-Attribut muss auch gegen display:flex/block gewinnen */

html, body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(1200px 600px at 10% -10%, #2a1a0f 0%, var(--bg) 55%);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.mono { font-family: var(--mono); letter-spacing: .04em; }
.link { font-size: .9rem; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--bg-2);
    border-right: 1px solid var(--card-border);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 700; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand-logo {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-size: 1.2rem;
}
.brand-logo.big { width: 64px; height: 64px; font-size: 2rem; border-radius: 18px; margin: 0 auto .75rem; }

.nav { display: flex; flex-direction: column; gap: .25rem; }
.nav a {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem .8rem; border-radius: 10px;
    color: var(--muted); font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.04); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(255,122,26,.14); color: var(--accent-2); }
.nav-icon { width: 1.2rem; text-align: center; opacity: .9; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; }
.user-chip { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; }
.avatar {
    display: inline-grid; place-items: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: #2b3340; color: var(--text); font-size: .8rem; font-weight: 700;
}

.content { padding: 2rem 2.5rem; max-width: 1200px; width: 100%; }
.content-center { min-height: 100vh; display: grid; place-items: center; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head p { margin: 0; }

/* ---------- Karten ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-2 > .card { margin-bottom: 1.25rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; flex-direction: column; gap: .15rem; margin: 0; }
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-value.small { font-size: 1.25rem; }
.stat-sub { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .6rem 1.1rem; border-radius: 10px;
    border: 1px solid transparent; cursor: pointer;
    font: inherit; font-weight: 600; color: var(--text);
    background: #2b3340; transition: transform .08s ease, filter .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #ff9a3c); color: #1a0d03; }
.btn-ghost { background: transparent; border-color: var(--card-border); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.04); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-lg { padding: .9rem 1.6rem; font-size: 1.05rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { font-size: .9em; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field > span:first-child { font-size: .85rem; color: var(--muted); font-weight: 500; }
.field input, .field select {
    font: inherit; color: var(--text);
    background: var(--bg-2); border: 1px solid var(--card-border);
    border-radius: 10px; padding: .6rem .8rem; outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,122,26,.2); }
.field-error { color: var(--err); font-size: .8rem; }
.field-error:empty { display: none; }
.check { display: flex; align-items: center; gap: .55rem; margin-bottom: 1.1rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.alert { border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.alert-error { background: rgba(255,92,92,.1); border-color: rgba(255,92,92,.35); color: #ffb3b3; }
.alert-ok { background: rgba(47,191,113,.12); border-color: rgba(47,191,113,.35); color: #9fe6bf; }
.alert a { margin-left: .5rem; }

/* ---------- Login ---------- */
.login-card { width: min(400px, 92vw); padding: 2rem; }
.login-head { text-align: center; margin-bottom: 1.25rem; }
.login-head h1 { margin-bottom: .2rem; }

/* ---------- Dashboard ---------- */
.run-card { display: flex; flex-direction: column; gap: .75rem; }
.run-card .btn-lg { align-self: flex-start; }

.result {
    margin-top: .5rem; padding: 1rem 1.2rem; border-radius: 12px;
    background: rgba(47,191,113,.1); border: 1px solid rgba(47,191,113,.35);
    display: flex; flex-direction: column; gap: .25rem;
}
.result-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: #9fe6bf; }
.result-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.result-code { font-family: var(--mono); font-size: 2.2rem; font-weight: 700; letter-spacing: .08em; color: #d9ffe8; }

.log-card { display: flex; flex-direction: column; }
.log {
    flex: 1; min-height: 240px; max-height: 360px; overflow: auto; margin: 0;
    background: var(--bg); border: 1px solid var(--card-border); border-radius: 10px;
    padding: .8rem 1rem; font-family: var(--mono); font-size: .82rem; line-height: 1.55;
    white-space: pre-wrap; word-break: break-word;
}

.badge {
    display: inline-block; padding: .15rem .55rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; letter-spacing: .03em;
}
.badge-idle { background: #2b3340; color: var(--muted); }
.badge-run { background: rgba(76,154,255,.18); color: #9cc4ff; animation: pulse 1.2s ease-in-out infinite; }
.badge-ok { background: rgba(47,191,113,.18); color: #9fe6bf; }
.badge-err { background: rgba(255,92,92,.18); color: #ffb3b3; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; padding: .5rem .6rem; border-bottom: 1px solid var(--card-border); }
.table td { padding: .6rem .6rem; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255,255,255,.02); }

/* ---------- Balkendiagramm ---------- */
.bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: .5rem; align-items: end; height: 160px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: .25rem; height: 100%; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-stack { width: 100%; height: 100%; display: flex; flex-direction: column-reverse; justify-content: flex-start; border-radius: 6px 6px 2px 2px; overflow: hidden; }
.bar-seg { width: 100%; min-height: 3px; background: var(--uc, var(--accent)); box-shadow: inset 0 1px 0 rgba(255,255,255,.18); transition: height .3s ease; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .9rem; font-size: .85rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--uc); display: inline-block; }
.bar-value { font-size: .75rem; color: var(--text); height: 1em; }
.bar-label { font-size: .7rem; color: var(--muted); }

/* ---------- Responsiv ---------- */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 1rem; }
    .nav { flex-direction: row; }
    .sidebar-footer { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; }
    .content { padding: 1.25rem; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .bars { grid-template-columns: repeat(7, 1fr); height: 220px; }
    .bar-col:nth-child(-n+7) { display: none; }
}

/* ---------- Benutzerverwaltung ---------- */
.btn-danger { background: rgba(255,92,92,.15); border-color: rgba(255,92,92,.4); color: #ffb3b3; }
.btn-danger:hover { background: rgba(255,92,92,.28); }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; justify-content: flex-end; }
.inline { display: inline; margin: 0; }
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-form { display: flex; gap: .4rem; margin-top: .4rem; }
.inline-form input {
    font: inherit; color: var(--text); background: var(--bg-2);
    border: 1px solid var(--card-border); border-radius: 8px; padding: .35rem .6rem; width: 170px;
}

/* ---------- Benutzerfarben & Statistik ---------- */
.user-chip-inline {
    display: inline-block; padding: .1rem .55rem; border-radius: 999px;
    font-weight: 600; font-size: .85em; line-height: 1.5;
    color: var(--uc, var(--text)); background: var(--ucbg, #2b3340);
    border: 1px solid color-mix(in srgb, var(--uc, #fff) 45%, transparent);
}
.user-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.user-stat {
    display: block; padding: .8rem .9rem; border-radius: 12px; color: var(--text);
    background: var(--bg-2); border: 1px solid var(--card-border);
    border-left: 4px solid var(--uc); transition: background .15s ease, transform .08s ease;
}
.user-stat:hover { background: rgba(255,255,255,.04); text-decoration: none; transform: translateY(-1px); }
.user-stat.active { background: var(--ucbg); border-color: var(--uc); }
.user-stat-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .45rem; }
.user-stat-count { font-size: 1.35rem; font-weight: 700; color: var(--uc); }
.user-stat-count small { font-size: .7rem; font-weight: 500; }
.user-stat-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.user-stat-bar { height: 100%; min-width: 2px; border-radius: 999px; background: var(--uc); transition: width .3s ease; }
.user-stat-meta { margin-top: .4rem; }

/* ---------- Ersparnis ---------- */
.stat-fries { border-color: rgba(255,179,71,.35); background: linear-gradient(160deg, rgba(255,122,26,.14), var(--card) 70%); }
.stat-saved { border-color: rgba(47,191,113,.35); background: linear-gradient(160deg, rgba(47,191,113,.14), var(--card) 70%); }
.stat-saved .stat-value { color: #9fe6bf; }
.user-stat-saved { color: var(--text); }

/* ---------- Log-Werkzeuge ---------- */
.log-tools { display: inline-flex; align-items: center; gap: .5rem; }
.card-head h2 small { font-weight: 400; font-size: .8rem; margin-left: .3rem; }

/* ---------- Screenshot der Abschlussseite ---------- */
.result-shot { display: block; margin-top: .6rem; border-radius: 10px; overflow: hidden; border: 1px solid rgba(47,191,113,.35); background: #fff; }
.result-shot img { display: block; width: 100%; max-height: 320px; object-fit: cover; object-position: top; }
.result-shot:hover { filter: brightness(1.05); }
.shot-link img { display: block; width: 72px; height: 44px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--card-border); background: #fff; }
.shot-link:hover img { outline: 2px solid var(--accent); }
