:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #687386;
    --line: #dde3ea;
    --brand: #c41230;
    --brand-dark: #9b1028;
    --blue: #0b4f9c;
    --blue-dark: #07396f;
    --success: #157347;
    --error: #b42318;
    --warning: #a15c00;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--brand);
}

.topbar {
    align-items: center;
    background: #fff;
    border-bottom: 3px solid var(--brand);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
    display: flex;
    justify-content: space-between;
    padding: 16px clamp(16px, 4vw, 48px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.main-nav a {
    color: var(--blue-dark);
    font-size: 14px;
    font-weight: 700;
}

.main-nav a:hover {
    color: var(--brand);
}

.brand {
    color: var(--brand);
    font-size: 22px;
    font-weight: 700;
}

.page,
.article-page {
    margin: 0 auto;
    max-width: 1180px;
    padding: 32px clamp(16px, 4vw, 48px);
}

.article-page {
    max-width: 1280px;
}

.section-head {
    margin-bottom: 24px;
}

.eyebrow,
.label {
    color: var(--muted);
    font-size: 13px;
    letter-spacing: .04em;
    margin: 0 0 4px;
    text-transform: uppercase;
}

h1,
h2 {
    line-height: 1.15;
    margin: 0;
}

h1 {
    color: #101828;
    font-size: clamp(32px, 5vw, 52px);
}

h2 {
    border-left: 4px solid var(--brand);
    color: var(--blue-dark);
    font-size: 24px;
    padding-left: 10px;
}

.article-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.featured-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 22px;
}

.content-with-sidebar {
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) 300px;
}

.article-shell {
    align-items: start;
}

.ad-box {
    align-items: center;
    background: #f2f4f7;
    border: 1px dashed #98a2b3;
    border-radius: 8px;
    color: #667085;
    display: flex;
    justify-content: center;
    margin: 18px 0;
    min-height: 92px;
    padding: 16px;
    text-align: center;
}

.sidebar-ad {
    min-height: 260px;
    position: sticky;
    top: 84px;
}

.sidebar-box,
.source-strip {
    margin-top: 22px;
}

.link-list {
    display: grid;
    gap: 8px;
}

.link-list a {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.footer-nav {
    background: var(--blue-dark);
    border-top: 1px solid var(--line);
    color: #fff;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    padding: 24px;
}

.footer-nav a:hover {
    color: #ffd6de;
}

.article-card,
.controls-panel,
.filters,
.source-admin,
.source-row,
.stats > div,
.notice,
.empty,
.log {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.article-card {
    overflow: hidden;
    transition: box-shadow .15s ease, transform .15s ease;
}

.article-card:hover {
    box-shadow: 0 14px 32px rgba(15, 23, 42, .10);
    transform: translateY(-2px);
}

.article-card img,
.image-placeholder {
    aspect-ratio: 16 / 10;
    display: block;
    object-fit: cover;
    width: 100%;
}

.image-placeholder {
    align-items: center;
    background: #e8edf3;
    color: var(--muted);
    display: flex;
    justify-content: center;
}

.card-body {
    padding: 16px;
}

.meta {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 13px;
    gap: 10px;
    margin-bottom: 10px;
}

.card-body h2 {
    border-left: 0;
    color: var(--text);
    font-size: 20px;
    margin-bottom: 8px;
    padding-left: 0;
}

.card-body p,
.description {
    color: var(--muted);
    margin: 0;
}

.hero-image {
    border-radius: 8px;
    margin: 24px 0;
    max-height: 520px;
    object-fit: cover;
    width: 100%;
}

.content {
    background: var(--surface);
    border-radius: 8px;
    font-size: 18px;
    margin-top: 20px;
}

.content img {
    height: auto;
    max-width: 100%;
}

.back-link,
.source-line a {
    color: var(--brand);
    font-weight: 700;
}

.controls-panel {
    display: grid;
    gap: 14px;
    grid-template-columns: auto auto 1fr;
    margin-bottom: 20px;
    padding: 18px;
}

button {
    background: var(--brand);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    padding: 11px 16px;
}

button.secondary {
    background: var(--blue);
}

button.danger {
    background: var(--error);
}

button.small,
.button-link.small {
    font-size: 13px;
    padding: 7px 10px;
}

button:hover {
    background: var(--brand-dark);
}

label {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
}

input[type="url"],
input[type="text"],
textarea,
select {
    border: 1px solid var(--line);
    border-radius: 6px;
    min-width: 0;
    padding: 10px 12px;
    width: 100%;
}

textarea {
    font-family: inherit;
    resize: vertical;
}

.button-link {
    align-items: center;
    background: var(--blue);
    border-radius: 6px;
    color: #fff;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    padding: 10px 14px;
}

.home-sections,
.source-sections {
    display: grid;
    gap: 28px;
}

.filters {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(180px, 240px) minmax(180px, 240px) auto auto;
    margin-bottom: 22px;
    padding: 16px;
}

.manual-row {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr auto;
}

.stats {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 26px;
}

.stats > div {
    padding: 16px;
}

.stats strong {
    display: block;
    font-size: 21px;
}

.status-running,
.status-completed {
    color: var(--success);
}

.status-failed {
    color: var(--error);
}

.status-duplicate,
.status-inactive {
    color: var(--warning);
}

.status-active {
    color: var(--success);
}

.source-admin {
    margin-bottom: 24px;
    padding: 18px;
}

.source-admin h2 {
    margin-bottom: 14px;
}

.section-row {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-row h2,
.section-row .eyebrow {
    margin-bottom: 0;
}

.source-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.source-summary span,
.id-pill,
.category-pill,
.status-pill {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 7px 9px;
    white-space: nowrap;
}

.source-summary span {
    background: #eef2f6;
    color: #475467;
}

.source-form,
.source-edit {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.source-edit-head {
    align-items: center;
    display: flex;
    gap: 10px;
    grid-column: 1 / -1;
    justify-content: space-between;
}

.form-actions {
    align-items: end;
    display: flex;
    gap: 10px;
}

.source-list {
    display: grid;
    gap: 14px;
}

.source-row {
    padding: 14px;
}

.source-actions-row {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.source-table {
    table-layout: fixed;
}

.source-table th:nth-child(1),
.source-table td:nth-child(1) {
    width: 72px;
}

.source-table th:nth-child(2),
.source-table td:nth-child(2) {
    width: 210px;
}

.source-table th:nth-child(3),
.source-table td:nth-child(3) {
    width: 140px;
}

.source-table th:nth-child(5),
.source-table td:nth-child(5) {
    width: 110px;
}

.source-table th:nth-child(6),
.source-table td:nth-child(6) {
    width: 210px;
}

.source-table tbody tr {
    transition: background .15s ease;
}

.source-table tbody tr:hover {
    background: #fafbfc;
}

.source-name-cell {
    display: grid;
    gap: 3px;
}

.source-name-cell strong {
    overflow-wrap: anywhere;
}

.source-name-cell small {
    color: var(--muted);
    font-size: 12px;
}

.url-cell {
    color: #344054;
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.id-pill {
    background: #f2f4f7;
    color: #475467;
}

.category-pill {
    background: #fff4e5;
    color: #7a3e00;
}

.status-pill-active {
    background: #e7f6ec;
    color: var(--success);
}

.status-pill-approved,
.status-pill-moved_to_live {
    background: #e7f6ec;
    color: var(--success);
}

.status-pill-inactive {
    background: #fff7e6;
    color: var(--warning);
}

.status-pill-pending {
    background: #fff7e6;
    color: var(--warning);
}

.status-pill-rejected {
    background: #fff1f3;
    color: var(--error);
}

.status-pill-draft,
.status-pill-ai_generated {
    background: #eef2f6;
    color: #475467;
}

.status-pill-failed_to_move {
    background: #fff1f3;
    color: var(--error);
}

.status-pill-pending,
.status-pill-running {
    background: #fff7e6;
    color: var(--warning);
}

.status-pill-completed {
    background: #e7f6ec;
    color: var(--success);
}

.status-pill-failed {
    background: #fff1f3;
    color: var(--error);
}

.status-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.table-actions form {
    margin: 0;
}

.split {
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr);
}

.table-wrap {
    overflow-x: auto;
}

table {
    background: var(--surface);
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
}

.log-list {
    display: grid;
    gap: 10px;
    max-height: 640px;
    overflow: auto;
}

.log {
    padding: 12px;
}

.log span,
.log small {
    color: var(--muted);
    display: block;
    font-size: 12px;
}

.log p {
    margin: 5px 0;
}

.log-success {
    border-left: 4px solid var(--success);
}

.log-error {
    border-left: 4px solid var(--error);
}

.log-duplicate {
    border-left: 4px solid var(--warning);
}

.notice,
.empty {
    margin-bottom: 18px;
    padding: 14px 16px;
}

.error-notice {
    border-color: #fecdca;
    color: var(--error);
}

.ai-regenerator,
.approved-ai {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 28px;
    padding: 18px;
}

.ai-prompt {
    margin-bottom: 12px;
}

.checkbox-row {
    align-items: center;
    display: flex;
    gap: 8px;
    margin: 10px 0 14px;
}

.checkbox-row input {
    margin: 0;
}

.ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.ai-loading {
    background: #eef2f6;
    border-radius: 6px;
    color: #475467;
    margin-bottom: 14px;
    padding: 12px;
}

.ai-preview {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 18px;
}

.ai-preview h3 {
    font-size: 26px;
    line-height: 1.2;
    margin: 0 0 10px;
}

.ai-meta {
    color: var(--muted);
    margin: 0 0 14px;
}

@media (max-width: 850px) {
    .controls-panel,
    .stats,
    .split,
    .featured-grid,
    .content-with-sidebar,
    .manual-row,
    .filters,
    .source-form,
    .source-edit {
        grid-template-columns: 1fr;
    }

    .table-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .section-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .source-table {
        min-width: 860px;
    }
}
