:root {
    --bg: #f7f5f2;
    --panel: #ffffff;
    --ink: #2b2724;
    --muted: #8a8378;
    --line: #e5e0d8;
    --accent: #c0392b;
    --ok: #2e7d32;
    --fail: #c62828;
    --warn: #b26a00;
}

* { box-sizing: border-box; }

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

.page { display: flex; min-height: 100vh; }

.sidebar {
    width: 210px;
    flex-shrink: 0;
    padding: 1.2rem 1rem;
    background: #2b2724;
    color: #f3efe9;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar .brand { font-weight: 700; font-size: 1.05rem; }

.sidebar nav { display: flex; flex-direction: column; gap: .2rem; }

.sidebar nav a {
    color: #d8d2c8;
    text-decoration: none;
    padding: .4rem .6rem;
    border-radius: 6px;
}

.sidebar nav a:hover { background: #3a352f; }
.sidebar nav a.active { background: var(--accent); color: #fff; }

.logout-form { margin-top: auto; }

.link-button {
    background: none;
    border: none;
    color: #d8d2c8;
    cursor: pointer;
    padding: .4rem .6rem;
    font: inherit;
}
.link-button:hover { text-decoration: underline; }

.content { flex: 1; padding: 1.5rem 2rem; min-width: 0; }

h1 { font-size: 1.4rem; margin: 0 0 .8rem; }
h3 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; }
h4 { margin: .8rem 0 .4rem; }
h5 { margin: .8rem 0 .3rem; }

a { color: var(--accent); }

.centered {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 2rem 2.5rem;
    width: 22rem;
}

.login-card h1 { text-align: center; }

.login-card form { display: flex; flex-direction: column; gap: .8rem; }

.login-card label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; }

.form-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.2rem;
    display: flex;
    flex-wrap: wrap;
    gap: .9rem;
    align-items: flex-end;
}

.form-card label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; }
.form-card fieldset { border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 1rem; }
.form-card fieldset label { flex-direction: row; align-items: center; gap: .35rem; font-weight: 400; }

input, select, textarea, button {
    font: inherit;
    padding: .4rem .55rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
}

button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:disabled { opacity: .6; cursor: default; }
button.danger { background: var(--fail); border-color: var(--fail); color: #fff; }

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

table.data th, table.data td {
    text-align: left;
    padding: .45rem .7rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

table.data thead th { background: #f0ece5; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data.compact { width: auto; min-width: 24rem; margin: .3rem 0 .8rem; }

.mono { font-family: ui-monospace, "JetBrains Mono", monospace; font-size: .86rem; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--fail); }
.ok { color: var(--ok); }
.fail { color: var(--fail); }
.warn { color: var(--warn); display: block; }
.trunc { max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: #eee7dc;
}

.badge.parser-jina { background: #e3f2fd; color: #1565c0; }
.badge.parser-meta { background: #ede7f6; color: #5e35b1; }
.badge.kind-web { background: #eceff1; color: #455a64; }
.badge.kind-youtube { background: #ffebee; color: #c62828; }
.badge.kind-tiktok { background: #e0f7fa; color: #00838f; }
.badge.kind-instagram { background: #fce4ec; color: #ad1457; }
.badge.kind-image { background: #f3e5f5; color: #7b1fa2; }
.badge.status-queued, .badge.status-pending { background: #fff8e1; color: #b26a00; }
.badge.status-running { background: #e3f2fd; color: #1565c0; }
.badge.status-done { background: #e8f5e9; color: var(--ok); }
.badge.status-failed { background: #ffebee; color: var(--fail); }
.badge.status-cancelled, .badge.status-notapplicable, .badge.status-skipped { background: #eceff1; color: var(--muted); }
.badge.timer { background: #fff3e0; color: #e65100; margin-left: .4rem; }

.disabled-row { opacity: .5; }

.case-row { cursor: pointer; }
.case-row:hover td { background: #faf7f2; }
.case-detail-row > td { background: #fcfaf7; padding: 1rem 1.4rem; }

.step-chip {
    display: inline-block;
    margin: 0 .35rem .25rem 0;
    padding: .12rem .5rem;
    border-radius: 6px;
    font-family: ui-monospace, monospace;
    font-size: .78rem;
    background: #eee7dc;
}

.step-chip.ok { background: #e8f5e9; color: var(--ok); }
.step-chip.fail { background: #ffebee; color: var(--fail); }
.step-chip.skipped { background: #eceff1; color: var(--muted); }

.step-chip.running {
    background: #e3f2fd;
    color: #1565c0;
    animation: chip-pulse 1.4s ease-in-out infinite;
}

@keyframes chip-pulse {
    50% { opacity: .55; }
}

.case-detail pre {
    background: #2b2724;
    color: #e8e3da;
    padding: .8rem 1rem;
    border-radius: 8px;
    overflow-x: auto;
    max-height: 30rem;
    font-size: .8rem;
    white-space: pre-wrap;
    word-break: break-word;
}

details { margin: .3rem 0; }
details summary { cursor: pointer; color: var(--accent); }

.sub-recipe { border-left: 3px solid var(--line); padding-left: 1rem; margin: .8rem 0; }

.recipe-steps li { margin-bottom: .35rem; }

.wine-cards { display: flex; flex-wrap: wrap; gap: .8rem; }

.wine-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .8rem 1rem;
    max-width: 26rem;
}

.wine-title { display: flex; align-items: center; gap: .45rem; }

.wine-dot {
    width: .85rem;
    height: .85rem;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.2);
    display: inline-block;
}

.sanitize-issues { color: var(--warn); }

/* Extracted dish thumbnail (re-hosted from the parser) */
.thumb-block { display: flex; gap: .8rem; align-items: flex-start; flex-wrap: wrap; }

.thumb {
    display: block;
    max-width: 240px;
    max-height: 240px;
    width: auto;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    object-fit: cover;
}

.thumb-meta { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; min-width: 0; }

.thumb-url {
    max-width: 26rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    font-size: .78rem;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    align-items: start;
}

.compare-grid > div { min-width: 0; }

.compare-grid h4 {
    position: sticky;
    top: 0;
    background: #fcfaf7;
    padding: .3rem 0;
    z-index: 5;
}

@media (max-width: 1100px) {
    .compare-grid { grid-template-columns: 1fr; }
}

.delta-pos { color: var(--fail); }
.delta-neg { color: var(--ok); }

/* Item-per-item diff highlighting */
.diff-row td, .diff-row th { background: #fff6ee; }
.diff-cell { background: #ffe9d6; border-radius: 4px; }
.diff-soft { background: #fdf6e3; }
.diff-missing { color: var(--fail); font-weight: 600; white-space: nowrap; }
.badge.diff-badge { background: #ffe0b2; color: #b26a00; }
.badge.name-variant { background: #e8eaf6; color: #3949ab; font-weight: 400; margin-left: .3rem; }
.case-diff h5 { margin-top: 1rem; }

.accept-panel {
    background: #fffbf2;
    border: 1px solid #f0e0c0;
    border-radius: 8px;
    padding: .6rem .9rem;
    margin: .6rem 0;
}

.accept-line {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: .3rem 0;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--fail);
    color: #fff;
    padding: .6rem 2.5rem .6rem 1rem;
}

#blazor-error-ui a { color: #fff; }
#blazor-error-ui .dismiss { position: absolute; right: 1rem; cursor: pointer; }

input, select, textarea { max-width: 100%; }

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .page { flex-direction: column; }

    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: .3rem .6rem;
        padding: .5rem .8rem;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .sidebar .brand { font-size: .95rem; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: .1rem; }
    .sidebar nav a { padding: .3rem .5rem; font-size: .9rem; }
    .logout-form { margin-top: 0; margin-left: auto; }
    .link-button { padding: .3rem .4rem; font-size: .9rem; }

    .content { padding: 1rem .8rem; }
    h1 { font-size: 1.2rem; }

    /* Wide tables scroll sideways instead of blowing up the page. */
    table.data {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .trunc { max-width: 13rem; }

    .form-card { padding: .8rem; }
    .form-card label { width: 100%; }
    .form-card input:not([type="checkbox"]):not([type="radio"]),
    .form-card select,
    .form-card textarea { width: 100%; }
    .form-card fieldset { width: 100%; flex-wrap: wrap; }

    .login-card { width: auto; max-width: 92vw; padding: 1.5rem 1.2rem; }
    .wine-card { max-width: 100%; }
    .case-detail pre { max-height: 20rem; }
}
