:root {
    --bg: #f7f8fa;
    --card: #ffffff;
    --border: #e2e6eb;
    --text: #1f2328;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #059669;
    --warn: #d97706;
    --log-bg: #0f172a;
    --log-text: #e2e8f0;
    --radius: 6px;
    --radius-lg: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
    background: #111827;
    color: #fff;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    border-bottom: 1px solid #0b1220;
}
.topbar .brand a {
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}
.topbar nav { display: flex; gap: 0.25rem; }
.topbar nav a {
    color: #cbd5e1;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
}
.topbar nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.topbar nav a.active { background: var(--primary); color: #fff; }

/* ── Layout ─────────────────────────────────────────────── */
.container {
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1.5rem 3rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.page-header h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.card h2 { margin-top: 0; font-size: 1.05rem; }

.empty {
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    color: var(--muted);
}

/* ── Flash ──────────────────────────────────────────────── */
.flashes { margin-bottom: 1rem; }
.flash {
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    border: 1px solid;
}
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius);
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.92rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: background 0.1s;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }

/* ── Tables ─────────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
th, td {
    text-align: left;
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
tbody tr:last-child td { border-bottom: none; }
.actions { white-space: nowrap; display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; }
.actions .test-result { flex-basis: 100%; font-size: 0.85rem; margin-top: 0.25rem; }

.test-result.ok { color: var(--success); }
.test-result.fail { color: var(--danger); }
.test-result.testing { color: var(--muted); }

/* ── Forms ──────────────────────────────────────────────── */
.form label {
    display: block;
    margin-bottom: 1rem;
}
.form label > span {
    display: block;
    font-weight: 500;
    margin-bottom: 0.3rem;
    font-size: 0.92rem;
}
.form label > span em { color: var(--danger); font-style: normal; }
.form small {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 0.3rem;
}
.form input[type="text"],
.form input[type="url"],
.form input[type="password"],
.form select,
.form textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
}
.form textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}
.form input:focus, .form textarea:focus, .form select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.form fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem 1rem;
    margin-bottom: 1rem;
}
.form legend { padding: 0 0.4rem; font-weight: 500; font-size: 0.92rem; }

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0.35rem 0;
}
.checkbox-row input { margin-top: 0.2rem; }

.site-checklist { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.4rem; }
.site-checklist .muted { margin-left: 0.4rem; font-size: 0.85rem; }

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ── Status pills ───────────────────────────────────────── */
.status {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-queued { background: #e5e7eb; color: #374151; }
.status-running { background: #dbeafe; color: #1e40af; }
.status-done { background: #d1fae5; color: #065f46; }
.status-failed { background: #fee2e2; color: #991b1b; }

/* ── Job detail ─────────────────────────────────────────── */
.job-meta dl {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.3rem 1rem;
    margin: 0;
}
.job-meta dt { font-weight: 500; color: var(--muted); font-size: 0.88rem; }
.job-meta dd { margin: 0; }

.card dl {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.35rem 1rem;
    margin: 0;
}
.card dt { font-weight: 500; color: var(--muted); font-size: 0.88rem; }
.card dd { margin: 0; }

.log {
    background: var(--log-bg);
    color: var(--log-text);
    padding: 1rem;
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    max-height: 500px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }
.muted { color: var(--muted); }
.error-text { color: var(--danger); }

/* ── LLM Council ────────────────────────────────────────── */
.council-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0 1.25rem;
}
.council-card {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    animation: fadein 0.25s ease-out;
}
.council-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}
.council-card header strong { font-size: 0.95rem; }
.council-card .score {
    font-size: 0.78rem;
    background: var(--primary);
    color: #fff;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}
.council-card .priority {
    font-size: 0.85rem;
    margin: 0.3rem 0;
    color: #374151;
}
.council-card .keypoints {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    color: #4b5563;
}
.council-card .keypoints li { margin-bottom: 0.2rem; }
.council-card.council-failed { border-left-color: var(--danger); background: #fef2f2; }
.council-card.council-unparseable { border-left-color: var(--warn); background: #fffbeb; }

.raw-fallback {
    margin-top: 0.5rem;
    font-size: 0.82rem;
}
.raw-fallback summary {
    cursor: pointer;
    color: var(--warn);
    font-weight: 500;
}
.raw-fallback pre {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow: auto;
}

.synthesis {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 0.85rem 1.1rem;
    margin-top: 0.75rem;
}
.synthesis h3 { margin-top: 0; font-size: 1rem; }
.synthesis ul { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }
.synthesis .brief {
    background: #fff;
    padding: 0.8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.5;
    margin: 0.5rem 0 0;
}

@keyframes fadein {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Topic suggestions ──────────────────────────────────── */
.topic-section { margin-bottom: 1rem; }
.suggest-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 0.25rem 0 0.5rem;
}
.suggest-bar .muted { font-size: 0.85rem; }
.suggest-status {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 0.55rem 0.8rem;
    font-size: 0.88rem;
    color: #78350f;
    margin: 0.5rem 0;
}
.suggest-status.fail {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.topic-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    margin: 0.5rem 0 0.75rem;
}
.topic-card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.8rem 0.95rem;
    animation: fadein 0.25s ease-out;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.topic-card.picked {
    border-color: var(--success);
    border-left-color: var(--success);
    background: #ecfdf5;
}
.topic-card header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}
.topic-card header strong { font-size: 0.95rem; line-height: 1.35; }
.topic-card .score {
    font-size: 0.75rem;
    background: var(--primary);
    color: #fff;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    flex-shrink: 0;
}
.topic-card .angle {
    margin: 0;
    font-size: 0.88rem;
    color: #374151;
    font-style: italic;
}
.topic-card dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.6rem;
    margin: 0;
    font-size: 0.82rem;
}
.topic-card dt { color: var(--muted); }
.topic-card dd { margin: 0; }
.topic-card .use-topic { align-self: flex-start; margin-top: 0.3rem; }

/* ── API key settings ───────────────────────────────────── */
.keys-table td { vertical-align: middle; }
.keys-table .center { text-align: center; }
.keys-table input[type="password"] {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.keys-table code {
    font-size: 0.82rem;
    background: #f3f4f6;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}
.keys-table .test-result {
    font-size: 0.78rem;
    margin-top: 0.3rem;
    max-width: 320px;
    word-break: break-word;
    line-height: 1.35;
}
.key-help { grid-template-columns: 240px 1fr; }
.key-help dt code { font-size: 0.82rem; background: #f3f4f6; padding: 0.1rem 0.35rem; border-radius: 3px; }
.key-help dd { color: #374151; }

/* ── Usage card ─────────────────────────────────────────── */
.right { text-align: right; }

.usage-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.6rem;
    margin: 0.75rem 0 1rem;
}
.usage-totals > div {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    display: flex;
    flex-direction: column;
}
.usage-totals strong {
    font-size: 1.1rem;
    color: var(--text);
}
.usage-totals small {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.usage-table { font-size: 0.88rem; }
.usage-table td, .usage-table th { padding: 0.5rem 0.7rem; }
.usage-table td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }

/* ── Article preview ────────────────────────────────────── */
.article-view-title { font-size: 1.1rem; color: var(--muted); font-weight: 500; margin: 0; }
.article-preview {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 3rem;
    max-width: 820px;
    margin: 0 auto;
    line-height: 1.7;
}
.article-preview .article-meta {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}
.article-preview .article-meta h1 {
    font-size: 2rem;
    margin: 0 0 0.5rem;
    line-height: 1.25;
}
.article-preview .meta-description {
    color: var(--muted);
    font-size: 1.05rem;
    margin: 0 0 1rem;
    font-style: italic;
}
.article-stats {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 0.8rem;
    font-size: 0.85rem;
    margin: 0;
}
.article-stats dt { color: var(--muted); }
.article-stats dd { margin: 0; }

.article-body h2 {
    font-size: 1.5rem;
    margin-top: 2.2rem;
    margin-bottom: 0.8rem;
    color: #111827;
}
.article-body h3 {
    font-size: 1.2rem;
    margin-top: 1.8rem;
    margin-bottom: 0.6rem;
}
.article-body p { margin: 0 0 1rem; }
.article-body ul, .article-body ol { margin: 0 0 1rem; padding-left: 1.5rem; }
.article-body li { margin-bottom: 0.35rem; }
.article-body strong { color: #111827; }
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius); margin: 1rem 0; }
.article-body figure { margin: 1.5rem 0; }
.article-body figure img { margin: 0; }
.article-body a { color: var(--primary); }

.article-faq {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.article-faq h2 { font-size: 1.4rem; margin-bottom: 1rem; }
.article-faq h3 { font-size: 1.05rem; margin: 1.25rem 0 0.4rem; color: #111827; }
.article-faq p { margin: 0 0 0.8rem; }

.article-preview .featured-image {
    margin: 0 0 2rem;
}
.article-preview .featured-image img {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
    display: block;
}

/* ── Article Table of Contents ──────────────────────────── */
.article-body .article-toc,
.article-preview .article-toc {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 1rem 1.25rem 1rem 1.5rem;
    margin: 1.5rem 0 2rem;
}
.article-toc-title {
    font-size: 0.95rem !important;
    margin: 0 0 0.6rem !important;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.article-toc > ul {
    margin: 0;
    padding-left: 1.15rem;
    counter-reset: toc-item;
}
.article-toc > ul > li {
    margin-bottom: 0.35rem;
    list-style: none;
    counter-increment: toc-item;
    position: relative;
}
.article-toc > ul > li::before {
    content: counter(toc-item) ".";
    position: absolute;
    left: -1.15rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.article-toc ul ul {
    margin: 0.3rem 0 0.3rem 0.25rem;
    padding-left: 1rem;
    font-size: 0.95em;
}
.article-toc ul ul li {
    list-style: disc;
    color: var(--muted);
    margin-bottom: 0.2rem;
}
.article-toc a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px dotted transparent;
    transition: border-color 0.1s;
}
.article-toc a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    text-decoration: none;
}
/* Smooth scroll when clicking a TOC link */
html { scroll-behavior: smooth; }
.article-body :target {
    scroll-margin-top: 1rem;
}

/* ── Job detail image thumbnails ────────────────────────── */
.job-images { margin-top: 1rem; }
.job-images h3 { font-size: 0.95rem; margin: 0 0 0.5rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.job-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.6rem;
}
.job-images-grid figure {
    margin: 0;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.job-images-grid img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    background: #e5e7eb;
}
.job-images-grid figcaption {
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
    color: var(--muted);
}
.job-images-grid a { display: block; }

/* ═══════════════════════════════════════════════════════════════════
   Product Content Builder — list / sources / detail / schemas.
   Added in Day 5 of the product builder feature.
   ═══════════════════════════════════════════════════════════════════ */

.status-discovering   { background: #eff6ff; color: #1e40af; }
.status-sources_ready { background: #f0fdf4; color: #15803d; }
.status-building      { background: #fef3c7; color: #92400e; }
.status-ready         { background: #ecfdf5; color: #065f46; }
.status-published     { background: #dbeafe; color: #1e3a8a; }

/* Active-state spinner used on detail page during Phase 1/2. */
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: product-spin 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes product-spin { to { transform: rotate(360deg); } }

/* Two-column detail layout: editable fields + right-side aside. */
.product-detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1rem;
    align-items: start;
}
.product-detail-aside { display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 900px) {
    .product-detail-grid { grid-template-columns: 1fr; }
}

/* One-card-per-field block. Source citation pinned to the right. */
.product-field-card { padding: 0.85rem 1rem; }
.product-field-card + .product-field-card { margin-top: 0.6rem; }
.product-field-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 0.6rem; margin-bottom: 0.2rem;
}
.product-field-head h3 {
    font-size: 1.02rem; font-weight: 600; margin: 0; color: var(--text);
}
.required-star { color: var(--danger); font-weight: 700; margin-left: 0.15rem; }
.product-field-source { font-size: 0.78rem; color: var(--muted); }
.product-field-desc { display: block; margin-bottom: 0.4rem; font-size: 0.82rem; }
.product-field-body {
    font-size: 0.95rem; line-height: 1.5; color: var(--text);
    border: 1px dashed transparent; border-radius: 6px; padding: 0.3rem 0.4rem;
    transition: border-color 80ms ease, background 80ms ease;
}
.product-field-body.editable-text:hover,
.product-field-body[contenteditable="true"]:hover {
    border-color: #e5e7eb; background: #fafbfc;
}
.product-field-body[contenteditable="true"]:focus {
    outline: none; border-color: var(--primary);
    background: #fff; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.product-field-body ul { margin: 0; padding-left: 1.2rem; }
.product-field-body li { padding: 0.15rem 0; }
.product-field-body dl { margin: 0; }
.product-field-body dl dt {
    font-weight: 600; margin-top: 0.5rem; color: var(--text);
}
.product-field-body dl dd { margin: 0.15rem 0 0.4rem 0.8rem; color: #374151; }
.product-field-body table.kv-table {
    width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
.product-field-body table.kv-table th,
.product-field-body table.kv-table td {
    border: 1px solid #e5e7eb; padding: 0.35rem 0.55rem; text-align: left;
}
.product-field-body table.kv-table th {
    background: #f9fafb; width: 40%; font-weight: 600;
}
.product-field-body pre {
    background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px;
    padding: 0.6rem; font-size: 0.82rem; overflow-x: auto; margin: 0;
}

/* Image picker — featured / gallery / candidate sections. */
.product-image-section { margin-top: 0.8rem; }
.product-image-section:first-child { margin-top: 0; }
.product-image-section > strong {
    display: block; font-size: 0.85rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem;
}
.product-image-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
}
.product-image-tile {
    position: relative; margin: 0;
    border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
    background: #f3f4f6;
}
.product-image-tile[data-role="featured"] { border-color: var(--primary); border-width: 2px; }
.product-image-tile[data-role="rejected"] { opacity: 0.45; filter: grayscale(0.7); }
.product-image-tile img {
    width: 100%; height: 110px; object-fit: cover; display: block;
    cursor: zoom-in;
}
.product-image-tile figcaption {
    padding: 0.25rem 0.4rem; font-size: 0.7rem; color: var(--muted);
    background: #fff; border-top: 1px solid var(--border);
}
.product-image-actions {
    position: absolute; top: 4px; right: 4px;
    display: flex; gap: 2px; opacity: 0; transition: opacity 80ms;
}
.product-image-tile:hover .product-image-actions { opacity: 1; }
.product-image-actions button {
    width: 26px; height: 26px; padding: 0; border: 0; border-radius: 4px;
    background: rgba(255, 255, 255, 0.92); color: #1f2328; cursor: pointer;
    font-size: 0.85rem; line-height: 1;
}
.product-image-actions button:hover { background: var(--primary); color: #fff; }

/* Lightbox — full-size image viewer. Triggered by clicking any tile. */
.product-image-lightbox {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none; align-items: center; justify-content: center;
    z-index: 9999; padding: 2rem;
    cursor: zoom-out;
}
.product-image-lightbox.show { display: flex; }
.product-image-lightbox img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    cursor: default;
    background: #fff;
}
.product-image-lightbox .lb-close {
    position: absolute; top: 1rem; right: 1.2rem;
    width: 40px; height: 40px;
    border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, 0.92); color: #111;
    font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.product-image-lightbox .lb-close:hover { background: #fff; }

/* HTMX top progress bar — animates while any AJAX request is in
   flight. .htmx-indicator is the standard HTMX hook (HTMX adds the
   .htmx-request class to the body during requests; the indicator
   becomes visible via the descendant selector below). */
#app-progress {
    position: fixed; top: 0; left: 0; right: 0;
    height: 3px; background: #2563eb;
    transform: scaleX(0); transform-origin: left;
    transition: transform 200ms ease;
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
}
.htmx-request #app-progress {
    transform: scaleX(0.7);
    opacity: 1;
    animation: app-progress-pulse 1.2s ease-in-out infinite;
}
@keyframes app-progress-pulse {
    0%   { transform: scaleX(0.1); }
    50%  { transform: scaleX(0.85); }
    100% { transform: scaleX(0.95); }
}

/* During an HTMX request, fade the body slightly so the user gets a
   secondary signal that something is happening — the progress bar
   alone is easy to miss above the fold. Fast transition so it
   doesn't look laggy on quick requests. */
body.htmx-request main { opacity: 0.7; transition: opacity 120ms ease; }
body main { transition: opacity 120ms ease; }

/* App-wide modal: replaces native confirm() / alert() popups.
   Promise-based, themeable, and keyboard-accessible (Esc to cancel,
   Enter on focused primary button to confirm). */
.app-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000; padding: 1rem;
    opacity: 0; transition: opacity 200ms ease;
}
.app-modal-backdrop.show { opacity: 1; }
.app-modal-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    max-width: 460px; width: 100%;
    padding: 1.4rem 1.5rem 1.1rem;
    transform: translateY(8px);
    transition: transform 200ms ease;
}
.app-modal-backdrop.show .app-modal-card { transform: translateY(0); }
.app-modal-title {
    font-size: 1.05rem; font-weight: 600;
    color: #111827;
    margin-bottom: 0.5rem;
}
.app-modal-backdrop.danger .app-modal-title { color: #b91c1c; }
.app-modal-message {
    font-size: 0.92rem;
    color: #374151;
    line-height: 1.55;
    margin-bottom: 1rem;
    white-space: pre-line;  /* honour \n in messages */
}
.app-modal-buttons {
    display: flex; justify-content: flex-end; gap: 0.5rem;
    flex-wrap: wrap;
}
.app-modal-btn {
    padding: 0.5rem 1.05rem;
    border-radius: 6px;
    font-size: 0.9rem; font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 80ms, transform 80ms;
}
.app-modal-btn:active { transform: translateY(1px); }
.app-modal-btn-secondary {
    background: #fff; color: #374151;
    border-color: #d1d5db;
}
.app-modal-btn-secondary:hover { background: #f9fafb; }
.app-modal-btn-primary {
    background: #2563eb; color: #fff;
}
.app-modal-btn-primary:hover { background: #1d4ed8; }
.app-modal-btn-primary:focus { outline: 2px solid #93c5fd; outline-offset: 2px; }
.app-modal-btn-danger {
    background: #dc2626; color: #fff;
}
.app-modal-btn-danger:hover { background: #b91c1c; }
.app-modal-btn-danger:focus { outline: 2px solid #fca5a5; outline-offset: 2px; }
@media (max-width: 480px) {
    .app-modal-card { padding: 1.1rem 1rem 0.9rem; }
    .app-modal-buttons { flex-direction: column-reverse; }
    .app-modal-buttons .app-modal-btn { width: 100%; }
}

/* QA findings card — non-blocking advisory list. Severity-coloured
   left border so the eye can scan critical-vs-warning at a glance. */
.qa-findings-card .qa-finding-list {
    list-style: none; padding: 0; margin: 0.8rem 0 0;
}
.qa-finding {
    padding: 0.55rem 0.7rem 0.55rem 0.9rem;
    margin: 0 0 0.45rem;
    border-radius: 4px;
    background: #f9fafb;
    border-left: 4px solid #9ca3af;
}
.qa-finding-critical { border-left-color: #dc2626; background: #fef2f2; }
.qa-finding-warning  { border-left-color: #d97706; background: #fffbeb; }
.qa-finding-info     { border-left-color: #2563eb; background: #eff6ff; }
.qa-finding-head {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    font-size: 0.78rem; margin-bottom: 0.25rem;
}
.qa-finding-badge {
    padding: 0.05rem 0.4rem; border-radius: 10px;
    font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.03em;
}
.qa-finding-badge-critical { background: #dc2626; color: #fff; }
.qa-finding-badge-warning  { background: #d97706; color: #fff; }
.qa-finding-badge-info     { background: #2563eb; color: #fff; }
.qa-finding-check { font-weight: 600; color: #1f2328; text-transform: capitalize; }
.qa-finding-field code {
    background: #fff; padding: 0 0.3rem; border-radius: 3px;
    border: 1px solid var(--border); font-size: 0.72rem;
}
.qa-finding-msg { font-size: 0.92rem; color: #1f2328; }
.qa-finding-suggestion { margin-top: 0.2rem; font-size: 0.85rem; }

/* Sources-used list (right column on detail page). */
.product-sources-list { list-style: none; padding: 0; margin: 0; font-size: 0.88rem; }
.product-sources-list li {
    padding: 0.3rem 0; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 0.4rem;
}
.product-sources-list li:last-child { border-bottom: 0; }
.product-source-ok   { color: var(--success); font-weight: 700; width: 14px; }
.product-source-fail { color: var(--danger);  font-weight: 700; width: 14px; }
.product-source-skip { color: var(--muted);   width: 14px; }
.product-source-type { font-size: 0.7rem; color: var(--muted); margin-left: auto; }
.product-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Toast for save success/failure. */
.product-toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 0.55rem 0.95rem; border-radius: 8px;
    background: var(--text); color: #fff; font-size: 0.85rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    opacity: 0; transform: translateY(8px); transition: all 160ms ease;
    pointer-events: none; z-index: 200;
}
.product-toast.show { opacity: 1; transform: translateY(0); }
.product-toast[data-kind="success"] { background: var(--success); }
.product-toast[data-kind="error"]   { background: var(--danger); }

/* Schema field-builder — slimmer table. */
#schema-fields-table input[type="text"],
#schema-fields-table select {
    width: 100%; padding: 0.3rem 0.45rem; font-size: 0.88rem;
    border: 1px solid var(--border); border-radius: 4px;
}
#schema-fields-table th { font-size: 0.78rem; }
#schema-fields-table td { padding: 0.25rem; vertical-align: middle; }

/* ═══════════════════════════════════════════════════════════════════
   Billing — /billing index page (current plan + plan picker).
   Day 9 of the SaaS conversion plan.
   ═══════════════════════════════════════════════════════════════════ */

.billing-summary {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1rem;
}

.billing-plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    padding: 0;
    background: transparent !important;  /* override .card bg */
    box-shadow: none !important;
    border: 0 !important;
}
.billing-plan-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex; flex-direction: column; gap: 0.6rem;
}
.billing-plan-current {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.billing-plan-name {
    font-size: 1.1rem; font-weight: 600; color: var(--text);
}
.billing-plan-price {
    font-size: 2rem; font-weight: 700; color: var(--text);
    line-height: 1.1;
}
.billing-plan-features {
    list-style: disc; margin: 0.4rem 0 0.4rem 1.1rem; padding: 0;
    color: #4b5563; font-size: 0.88rem; line-height: 1.6;
    flex: 1 1 auto;
}
.billing-plan-features strong { color: var(--text); }

/* Subscription-status pill colour mappings (re-uses .status base). */
.status-trialing  { background: #ecfdf5; color: #065f46; }
.status-active    { background: #ecfdf5; color: #065f46; }
.status-past_due  { background: #fef3c7; color: #92400e; }
.status-canceled  { background: #fef2f2; color: #991b1b; }
.status-none      { background: #f3f4f6; color: #6b7280; }

/* Backend pills + filter chips on the product list. Two backends, two
   colour treatments — Auto = neutral blue (Perplexity chain), DeepSeek
   = warmer purple-pink so the cheaper alternative is visually distinct
   without screaming. */
.backend-pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
    white-space: nowrap;
}
.backend-pill-auto     { background: #eff6ff; color: #1e40af; }
.backend-pill-deepseek { background: #f3e8ff; color: #6b21a8; }

/* Filter chips above the table — same colour family as the pills,
   border collapses to "active" treatment when the chip matches the
   current `?backend=` query param. */
.backend-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 0.82rem;
    text-decoration: none;
    transition: border-color 80ms ease, background 80ms ease;
}
.backend-chip:hover { background: #f9fafb; text-decoration: none; }
.backend-chip.active {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}
.backend-chip.active .muted { color: #cbd5e1; }
.backend-chip-auto.active     { background: #1e40af; border-color: #1e40af; }
.backend-chip-deepseek.active { background: #6b21a8; border-color: #6b21a8; }

/* ═══════════════════════════════════════════════════════════════════
   SEO Audit card — post-writer deterministic scoring, shown on the
   job detail page. Gradient badge mirrors the grade colour scale.
   ═══════════════════════════════════════════════════════════════════ */

.seo-score-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.1rem;
    border-radius: 12px;
    color: #fff;
    min-width: 110px;
    line-height: 1.1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.seo-grade-excellent  { background: linear-gradient(135deg, #059669 0%, #10b981 100%); }
.seo-grade-good       { background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%); }
.seo-grade-needs_work { background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%); }
.seo-grade-poor       { background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%); }
.seo-score-num   { font-size: 1.8rem; font-weight: 800; }
.seo-score-max   { font-size: 0.7rem; opacity: 0.85; margin-top: -0.15rem; }
.seo-score-grade { font-size: 0.72rem; font-weight: 600; margin-top: 0.3rem;
                   letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.95; }

.seo-summary-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.seo-pill {
    display: inline-flex;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.seo-pill-pass { background: #ecfdf5; color: #065f46; }
.seo-pill-warn { background: #fffbeb; color: #92400e; }
.seo-pill-fail { background: #fef2f2; color: #991b1b; }

.seo-details { margin-top: 0.75rem; padding: 0.4rem 0; border-top: 1px solid var(--border); }
.seo-details summary { cursor: pointer; padding: 0.3rem 0; user-select: none; }
.seo-details summary:hover { color: var(--primary); }
.seo-check-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex;
                  flex-direction: column; gap: 0.55rem; }
.seo-check {
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fafbfc;
}
.seo-check-fail { border-color: #fecaca; background: #fef2f2; }
.seo-check-warn { border-color: #fde68a; background: #fffbeb; }
.seo-check-pass { border-color: #bbf7d0; background: #f0fdf4; }
.seo-check-head { display: flex; justify-content: space-between; gap: 0.5rem;
                  align-items: baseline; font-size: 0.9rem; }
.seo-check-label { font-weight: 600; color: #1f2328; }
.seo-check-weight { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.seo-check-detail { font-size: 0.85rem; color: #4b5563; margin-top: 0.2rem; }
.seo-check-fix { font-size: 0.82rem; color: #374151; margin-top: 0.3rem;
                 padding-left: 0.5rem; border-left: 2px solid #d1d5db; }

.seo-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.35rem 1rem;
    font-size: 0.82rem;
    margin-top: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════
   Sidebar dashboard shell — added in Day 1 of the dashboard redesign.
   The old .topbar rules above remain intact for compatibility with any
   template still extending it, but authenticated views now render
   through the sidebar layout defined below.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --sidebar-bg: #ffffff;
    --sidebar-border: #e5e7eb;
    --sidebar-active: #eff6ff;
    --sidebar-active-text: #1d4ed8;
    --sidebar-width: 260px;
    --sidebar-section-title: #9ca3af;
    --sidebar-disabled: #9ca3af;
}

/* ── App shell: sidebar + main area as a two-column flex layout. ── */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.1rem 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand a {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text);
    font-weight: 700;
    font-size: 1.02rem;
    text-decoration: none;
}
.sidebar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}
/* Image-based brand mark. Standalone (no brand text next to it),
   so it can take the full sidebar header width. max-width keeps it
   from overflowing on narrow mobile sidebars. object-fit contain
   preserves aspect ratio so wide-form logos (logo + wordmark in one
   image) display without being squished. */
.sidebar-logo-img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 64px;
    object-fit: contain;
}
.sidebar-close {
    display: none; /* visible only on mobile */
    background: transparent;
    border: 0;
    color: var(--muted);
    padding: 0.2rem;
    border-radius: var(--radius);
    cursor: pointer;
}
.sidebar-close:hover { color: var(--text); background: #f3f4f6; }

.sidebar-nav {
    flex: 1 1 auto;
    padding: 0.75rem 0.6rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar-section { margin-top: 0.6rem; }
.sidebar-section:first-child { margin-top: 0; }
.sidebar-section-title {
    padding: 0.65rem 0.6rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--sidebar-section-title);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.sidebar-section-title .icon {
    width: 0.9em;
    height: 0.9em;
    color: var(--sidebar-section-title);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.52rem 0.75rem;
    border-radius: 8px;
    color: #374151;
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.2;
    transition: background 80ms ease, color 80ms ease;
}
.sidebar-link:hover {
    background: #f3f4f6;
    color: var(--text);
    text-decoration: none;
}
.sidebar-link .icon {
    width: 1.05em;
    height: 1.05em;
    color: #6b7280;
    flex-shrink: 0;
}
.sidebar-link:hover .icon { color: #374151; }
.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.sidebar-link.active .icon { color: var(--sidebar-active-text); }
.sidebar-link.disabled {
    color: var(--sidebar-disabled);
    cursor: not-allowed;
}
.sidebar-link.disabled .icon { color: var(--sidebar-disabled); }
.sidebar-link-label { flex: 1 1 auto; }
.sidebar-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: #f3f4f6;
    color: #6b7280;
    letter-spacing: 0.02em;
}

/* ── Footer: plan card + user row pinned to bottom of sidebar. ── */
.sidebar-footer {
    margin-top: auto;
    padding: 0.9rem 0.85rem 1rem;
    border-top: 1px solid var(--sidebar-border);
    background: linear-gradient(180deg, transparent 0%, #fafbfc 100%);
}

.plan-card {
    background: #f9fafb;
    border: 1px solid var(--sidebar-border);
    border-radius: 10px;
    padding: 0.7rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.plan-card.plan-empty {
    background: #fef2f2;
    border-color: #fecaca;
}
.plan-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.plan-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}
.plan-empty .plan-dot { background: var(--danger); }
.plan-name { font-weight: 600; color: var(--text); }
.plan-count {
    margin-left: auto;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.82rem;
}
.plan-empty .plan-count { color: var(--danger); }
.plan-progress {
    height: 4px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.plan-progress > span {
    display: block;
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    transition: width 200ms ease;
}
.plan-empty .plan-progress > span { background: var(--danger); }
.plan-meta {
    font-size: 0.76rem;
    color: var(--muted);
}
.btn-upgrade {
    margin-top: 0.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.48rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.btn-upgrade .icon { width: 0.95em; height: 0.95em; }
.btn-upgrade:disabled { opacity: 0.55; cursor: not-allowed; }

.sidebar-user {
    margin-top: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #1e40af;
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar-user-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.sidebar-user-email {
    font-size: 0.78rem;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--muted);
}

/* ── Main content pane to the right of the sidebar. ── */
.app-main {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

.app-topbar {
    background: #fff;
    border-bottom: 1px solid var(--sidebar-border);
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 56px;
}
.app-topbar-toggle {
    display: none; /* mobile only */
    background: transparent;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius);
    padding: 0.4rem;
    color: var(--muted);
    cursor: pointer;
}
.app-topbar-toggle:hover { color: var(--text); background: #f9fafb; }
.app-topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.app-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.app-container {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem;
    flex: 1 1 auto;
}

/* Backdrop is only visible on mobile, when body.sidebar-open is set. */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.4);
    z-index: 30;
}

/* ── Mobile: sidebar becomes an off-canvas drawer. ── */
@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 180ms ease;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .sidebar-close { display: inline-flex; }
    .app-topbar-toggle { display: inline-flex; }
    .app-container { padding: 1rem 1rem 2.5rem; }
}


/* ═══════════════════════════════════════════════════════════════
   VISUAL POLISH — Bundle C (additive overrides)
   These rules sit at the bottom of the file so they win the
   cascade and gently refine the existing design without rewriting
   foundations. Each block is self-contained: deletable in one
   chunk if a particular polish doesn't fit.
   ═══════════════════════════════════════════════════════════════ */

/* Design-token additions for elevation + transitions. The existing
   :root tokens cover colour and radius; these add the missing
   shadow + motion vocabulary so future components stay consistent. */
:root {
    --shadow-xs:  0 1px 1px rgba(15, 23, 42, 0.04);
    --shadow-sm:  0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md:  0 4px 12px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg:  0 12px 28px rgba(15, 23, 42, 0.12), 0 4px 10px rgba(15, 23, 42, 0.06);
    --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 120ms;
    --duration-base: 200ms;
}

/* Typography: tabular numbers for credits / scores / counts so the
   digits don't shift width when values change. system-ui already
   covers most platforms; the font-variant-numeric hint flips on
   tabular figures where the font supports them. */
body { font-feature-settings: "ss01", "cv11"; -webkit-font-smoothing: antialiased; }
.app-credits-pill,
.seo-score-num,
.qa-finding-badge,
.product-source-type,
.product-image-tile figcaption,
.app-modal-message strong,
table td,
table th {
    font-variant-numeric: tabular-nums;
}

/* Refined card: soft shadow instead of a flat border, slightly
   tighter padding rhythm. Border kept as a fallback for high-
   contrast / Windows high-contrast modes. */
.card {
    border-color: transparent;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--duration-base) var(--ease-out),
                transform var(--duration-base) var(--ease-out);
}
@media (prefers-color-scheme: dark) {
    .card { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
}

/* Buttons: subtle lift on hover, snappier focus ring. The existing
   .btn rules set background/colour; we layer motion + focus only. */
.btn {
    transition: background var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-xs); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn-primary:focus-visible { outline-color: #93c5fd; }
.btn-danger:focus-visible { outline-color: #fca5a5; }

/* Flashes: left-border accent + subtle elevation. Reads better when
   stacked next to the page heading. Existing colours preserved. */
.flash {
    border-left-width: 4px;
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
    padding: 0.7rem 0.95rem;
    display: flex; align-items: center; gap: 0.55rem;
}
.flash::before {
    content: ""; flex: 0 0 auto;
    width: 0; height: 0;  /* placeholder — icon-by-class below */
}
.flash-success { border-left-color: #10b981; }
.flash-error   { border-left-color: var(--danger); }
.flash.flash-info,
.flash:not(.flash-success):not(.flash-error) { border-left-color: var(--primary); }

/* Empty states: friendlier — soft tinted background instead of pure
   white-on-dashed, and a slightly larger primary line. */
.empty {
    background: linear-gradient(180deg, #fafbfc, #f5f7fa);
    border-style: solid;
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}
.empty strong, .empty h2, .empty h3 {
    color: var(--text);
    display: block;
    margin-bottom: 0.4rem;
}

/* Inputs / textareas / selects: consistent focus ring matching
   buttons. Many existing forms use bare <input> without a class,
   so we target the elements directly. */
input[type="text"], input[type="password"], input[type="email"],
input[type="url"], input[type="search"], input[type="number"],
textarea, select {
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow  var(--duration-fast) var(--ease-out);
}
input[type="text"]:focus, input[type="password"]:focus,
input[type="email"]:focus, input[type="url"]:focus,
input[type="search"]:focus, input[type="number"]:focus,
textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Status pills: smoother, with a tiny dot prefix for at-a-glance
   reading. The existing .status-* colour rules are inherited; we
   just refine the chip shape + add the dot. */
.status {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
    letter-spacing: 0.02em; text-transform: uppercase;
    line-height: 1.4;
}
.status::before {
    content: "";
    display: inline-block;
    width: 0.45rem; height: 0.45rem;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.65;
}

/* Tables: slightly more breathing room + zebra rows on dense
   tables. Targets specifically the data tables used in source
   picker and build list — leaves spec/key-value tables alone. */
.data-table tbody tr:nth-child(even) td {
    background: rgba(248, 250, 252, 0.6);
}
.data-table tbody tr {
    transition: background var(--duration-fast) var(--ease-out);
}
.data-table tbody tr:hover td {
    background: rgba(239, 246, 255, 0.7);
}

/* Spinner: smoother, less jittery. Pre-existing spinner kept; we
   refine the animation curve + size. */
.spinner {
    width: 22px; height: 22px;
    border: 2.5px solid #e5e7eb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Reduced-motion mode: respect user preference. Animations become
   instant; transitions become 1ms (effectively off) without
   breaking the visual states they drive. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .htmx-request #app-progress {
        animation: none;
        transform: scaleX(0.3);
    }
}

/* Print: drop nav, sidebar, buttons, and the QA panel from printed
   pages so a Ctrl+P on a build detail page produces a clean
   document. The native PDF/Word export still uses the dedicated
   /export route; this is a fallback for power users who Ctrl+P. */
@media print {
    .sidebar, .app-topbar, .product-actions, .qa-findings-card,
    #app-progress, .app-modal-backdrop, #publish-form,
    form[action*="/delete"], form[action*="/retry"],
    form[action*="/fill-missing"], form[action*="/qa-rerun"],
    form[action*="/find-more-sources"] {
        display: none !important;
    }
    .app-shell, .app-main, .app-container { padding: 0; margin: 0; max-width: 100%; }
    .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    body { background: #fff; }
}

