/* --- Bluttest UI --- */
:root {
    --bg: #0f172a;
    --bg-elev: #1e293b;
    --bg-card: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --ok: #22c55e;
    --low: #38bdf8;
    --high: #ef4444;
    --warn: #f59e0b;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f8fafc;
        --bg-elev: #ffffff;
        --bg-card: #ffffff;
        --border: #e2e8f0;
        --text: #0f172a;
        --text-muted: #64748b;
    }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Topbar ---- */
.topbar {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    gap: 2rem;
}
.brand {
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    color: var(--text);
}
.topbar nav {
    display: flex;
    gap: 1.25rem;
    margin-left: auto;
    align-items: center;
}
.topbar nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
}
.topbar nav a:hover { color: var(--text); }
.topbar .user {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}
.topbar .logout { color: var(--text-muted); }

main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}
footer {
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn:hover { background: var(--border); }
.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.btn.primary:hover { background: #2563eb; }
button {
    padding: 0.55rem 1.2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-family: var(--font);
}
button:hover { background: #2563eb; }

/* ---- Login ---- */
.login {
    max-width: 380px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.login h1 { margin: 0 0 1rem; font-size: 1.5rem; }
.login .hint { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.login form { display: flex; flex-direction: column; gap: 1rem; }
.login label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.login input {
    padding: 0.6rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font);
}
.login input:focus { border-color: var(--primary); outline: none; }
.error { color: var(--high); background: rgba(239,68,68,0.1); padding: 0.6rem; border-radius: 4px; margin-bottom: 1rem; }

/* ---- Test-Header ---- */
.test-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.test-header h1 { margin: 0 0 0.25rem; font-size: 1.75rem; }
.test-header .muted { color: var(--text-muted); font-size: 0.9rem; margin: 0; }
.test-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.test-nav select {
    padding: 0.55rem 0.75rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
}

/* ---- TOC / Sprungmarken ---- */
.toc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.toc-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.15s;
    border-left: 3px solid var(--cat-color, var(--primary));
}
.toc-link:hover { background: var(--cat-color, var(--primary)); color: white; }
.toc-ic { font-size: 0.95rem; }
.toc-cnt {
    background: rgba(148,163,184,0.2);
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.toc-link:hover .toc-cnt { background: rgba(255,255,255,0.25); }

/* ---- Categories: stacked, full-width; marker inside horizontal ---- */
.categories {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.category {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-left: 4px solid var(--cat-color, var(--primary));
    border-radius: 8px;
    padding: 1.25rem;
    scroll-margin-top: 5rem;  /* Sprungmarken landen unterhalb der sticky TOC */
}
.category h2 {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 600;
}
.markers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.6rem;
    align-items: start;
}
.marker {
    display: block;
    padding: 0.75rem 0.9rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, transform 0.1s;
    position: relative;
}
.marker:hover {
    border-color: var(--cat-color, var(--primary));
    transform: translateY(-1px);
}
.mk-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
    gap: 0.5rem;
}
.mk-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Trend-Pfeil groß + kräftig */
.mk-trend {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    margin-left: 0.35rem;
    background: var(--border);
    color: var(--text-muted);
}
.mk-trend.tr-good    { background: rgba(34,197,94,0.15);  color: var(--ok); }
.mk-trend.tr-bad     { background: rgba(239,68,68,0.15);  color: var(--high); }
.mk-trend.tr-neutral { background: rgba(148,163,184,0.12); color: var(--text-muted); }

/* Status-Badge oben rechts */
.st-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 800;
    flex-shrink: 0;
    line-height: 1;
}
.st-badge-ok   { background: var(--ok);   color: white; }
.st-badge-high { background: var(--high); color: white; }
.st-badge-low  { background: var(--low);  color: white; }

/* Filter-Chips */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.chip {
    padding: 0.45rem 0.9rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-family: var(--font);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.15s;
}
.chip:hover { border-color: var(--text-muted); color: var(--text); }
.chip.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.chip-count {
    display: inline-block;
    padding: 0.05rem 0.5rem;
    background: rgba(0,0,0,0.15);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}
.chip.is-active .chip-count { background: rgba(255,255,255,0.25); }
.mk-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}
.mk-value .mk-flag {
    font-size: 0.9rem;
    font-weight: 400;
}
.mk-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}
.mk-ref {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    min-height: 1em;
}
.mk-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 0.5rem;
    position: relative;
}
.mk-bar-inner {
    width: 8px;
    height: 8px;
    background: var(--cat-color, var(--primary));
    border-radius: 50%;
    position: absolute;
    top: -2px;
    transform: translateX(-50%);
}
.marker.st-high { border-color: var(--high); }
.marker.st-high .mk-flag { color: var(--high); }
.marker.st-high .mk-value { color: var(--high); }
.marker.st-low  { border-color: var(--low); }
.marker.st-low  .mk-flag { color: var(--low); }
.marker.st-low  .mk-value { color: var(--low); }

/* ---- Inline-Empfehlung pro Marker ---- */
.mk-advice {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
    padding: 0.55rem 0.65rem;
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    font-size: 0.82rem;
    line-height: 1.35;
}
.mk-advice-icon { flex-shrink: 0; font-size: 0.95rem; line-height: 1.2; }
.mk-advice-action { color: var(--text); font-weight: 500; }
.mk-advice-why { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.15rem; }

/* ---- Empty state ---- */
.empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}
.empty h1 { color: var(--text); margin-bottom: 0.5rem; }
.empty .btn { margin-top: 1.5rem; }

/* ---- Upload ---- */
.upload {
    max-width: 640px;
    margin: 0 auto;
    background: var(--bg-elev);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.upload h1 { margin-top: 0; }
.upload input[type="file"] {
    display: block;
    padding: 1rem;
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: 6px;
    width: 100%;
    margin-bottom: 1rem;
    color: var(--text);
}
.upload .muted { color: var(--text-muted); margin-bottom: 1.5rem; }
.imported { background: rgba(34,197,94,0.1); border: 1px solid var(--ok); padding: 1rem; border-radius: 6px; margin-bottom: 1.5rem; }
.imported h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.warn { color: var(--warn); }

/* ---- Marker detail ---- */
.back {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.back:hover { color: var(--text); }
.marker-detail h1 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.marker-detail .mk-icon { font-size: 1.5rem; }
.chart-wrap {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}
.history {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.history th, .history td {
    padding: 0.6rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.history th { background: var(--bg); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.03em; }
.history tr:last-child td { border-bottom: none; }
.history tr.st-high td { color: var(--high); }
.history tr.st-low  td { color: var(--low); }

/* ---- Recommendations ---- */
.recommend { max-width: 900px; margin: 0 auto; }
.recommend h1 { margin-bottom: 0.5rem; }
.rec-actions { margin-bottom: 1.5rem; }
.rec-block {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.rec-block h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.rec-block ul { margin: 0; padding-left: 1.25rem; }
.rec-block li { margin-bottom: 0.4rem; }
.concerns li.sev-high   { border-left: 3px solid var(--high); padding-left: 0.75rem; list-style: none; margin-left: -1.25rem; }
.concerns li.sev-medium { border-left: 3px solid var(--warn); padding-left: 0.75rem; list-style: none; margin-left: -1.25rem; }
.concerns li.sev-low    { border-left: 3px solid var(--text-muted); padding-left: 0.75rem; list-style: none; margin-left: -1.25rem; }
.trends li { list-style: none; padding: 0.3rem 0; }
.food-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}
.food-cols h3 { margin: 0 0 0.5rem; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.food-cols ul { list-style: none; padding: 0; }
.supps { list-style: none !important; padding: 0 !important; }
.supps li {
    background: var(--bg);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--primary);
}
.supps .dose { color: var(--text-muted); font-size: 0.9rem; margin-left: 0.5rem; }
.supps .reason { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.3rem; }
.disclaimer {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 1rem;
    background: rgba(245,158,11,0.08);
    border-radius: 6px;
    border-left: 3px solid var(--warn);
    margin-top: 2rem;
}

@media (max-width: 640px) {
    .categories { grid-template-columns: 1fr; }
    .food-cols { grid-template-columns: 1fr; }
    .topbar { padding: 0.6rem 1rem; }
    .test-header { flex-direction: column; }
}
