:root {
    --red: #d40000;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --soft: #f5f5f5;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Tahoma, Arial, sans-serif;
    background: #f4f4f4;
    color: var(--text);
    line-height: 1.8;
}

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

.wrap {
    width: min(1080px, calc(100% - 28px));
    margin-inline: auto;
}

.site-header {
    background: #fff;
    border-bottom: 3px solid var(--red);
}

.header-inner {
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 22px;
}

.brand {
    font-size: 28px;
    font-weight: 800;
    color: var(--red);
    letter-spacing: 0;
    white-space: nowrap;
}

.service-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}

.service-menu a {
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 15px;
}

.service-menu a:hover {
    background: var(--soft);
    color: var(--red);
}

.admin-link,
.plain-button,
.small-button,
.admin-action {
    border: 1px solid var(--line);
    background: #fff;
    color: #374151;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page { padding: 28px 0; }

.headline-box,
.article-card {
    background: #fff;
    border: 1px solid var(--line);
}

.box-title {
    border-bottom: 2px solid var(--red);
    padding: 0 16px;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.box-title h1,
.box-title h2 {
    margin: 0;
    font-size: 24px;
    color: var(--red);
}

.headline-list { padding: 0 16px 8px; }

.headline-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.headline-title {
    position: relative;
    display: block;
    padding-right: 18px;
    font-size: 21px;
    font-weight: 700;
}

.headline-title::before {
    content: "";
    position: absolute;
    right: 0;
    top: 18px;
    width: 8px;
    height: 8px;
    background: var(--red);
}

.headline-meta {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.headline-item p {
    margin: 6px 18px 0 0;
    color: #374151;
    font-size: 15px;
}

.empty { padding: 18px 0; color: var(--muted); }
.pagination { padding: 12px 16px 20px; }

.article-card {
    padding: 24px;
    margin-bottom: 22px;
}

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

.article-card h1 {
    margin: 0 0 14px;
    font-size: 34px;
    line-height: 1.45;
}

.article-summary {
    font-size: 19px;
    color: #374151;
    border-right: 4px solid var(--red);
    padding-right: 14px;
    margin: 0 0 18px;
}

.article-image {
    display: block;
    width: 100%;
    max-height: 460px;
    object-fit: cover;
    margin: 0 0 20px;
    border-radius: 4px;
}

.article-body {
    font-size: 18px;
    color: #111827;
}

.article-body p { margin: 0 0 18px; }
.article-body img { max-width: 100%; height: auto; }
.source-link { display: inline-flex; color: var(--red); margin-top: 16px; font-weight: 700; }
.related-box { margin-top: 22px; }

.admin-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.login-card {
    width: min(420px, calc(100% - 28px));
    background: #fff;
    border: 1px solid var(--line);
    padding: 24px;
}

.login-card h1 { margin: 0 0 18px; font-size: 22px; }
.login-card label { display: block; margin-bottom: 14px; }

.login-card input,
.admin-form input,
.admin-form select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font: inherit;
    background: #fff;
}

.login-card button,
.submit-button {
    border: 0;
    background: var(--red);
    color: #fff;
    padding: 11px 18px;
    border-radius: 4px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.login-card button { width: 100%; }

.alert,
.notice {
    padding: 10px;
    margin-bottom: 14px;
    border: 1px solid;
    background: #fff;
}

.alert { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.notice { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px;
}

.stats div {
    background: var(--soft);
    padding: 14px;
    border: 1px solid var(--line);
}

.stats strong { display: block; font-size: 28px; color: var(--red); }
.stats span { color: var(--muted); }

.admin-table {
    width: calc(100% - 32px);
    margin: 0 16px 20px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: right;
    vertical-align: top;
}

.admin-table td[dir="ltr"] {
    text-align: left;
    direction: ltr;
    word-break: break-all;
}

.actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.actions-cell form { margin: 0; }
.error-text { color: #b91c1c; font-size: 12px; max-width: 280px; }

.admin-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 18px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
    margin: 0;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
}

@media (max-width: 700px) {
    .header-inner {
        flex-wrap: wrap;
        padding: 12px 0;
    }

    .service-menu {
        order: 3;
        width: 100%;
    }

    .headline-title { font-size: 18px; }
    .stats,
    .admin-form { grid-template-columns: 1fr; }
    .article-card h1 { font-size: 25px; }
    .article-card { padding: 16px; }
}


/* Admin/newsreader expansion */
.admin-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    background: #fff;
    border-left: 1px solid var(--line);
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-brand {
    display: block;
    color: var(--red);
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 18px;
}

.admin-sidebar nav {
    display: grid;
    gap: 6px;
}

.admin-sidebar nav a {
    padding: 9px 12px;
    border-radius: 4px;
}

.admin-sidebar nav a:hover {
    background: var(--soft);
    color: var(--red);
}

.side-group {
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
}

.admin-main {
    padding: 18px;
}

.admin-topbar {
    background: #fff;
    border: 1px solid var(--line);
    padding: 12px 16px;
    margin-bottom: 14px;
}

.form-section {
    border-bottom: 1px solid var(--line);
    padding: 18px;
}

.form-section h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.admin-form.compact {
    padding: 0;
}

.admin-form .span-2 {
    grid-column: 1 / -1;
}

.admin-form small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.selector-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 6px;
}

.term-token-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.term-token-box input[type="text"] {
    flex: 1 1 220px;
    min-width: 180px;
    margin: 0;
    border: 0;
    padding: 6px;
    outline: 0;
}

.term-token {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 13px;
}

.term-token button {
    border: 0;
    background: transparent;
    color: #1d4ed8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.check-group {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.check-group label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.check-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.client-box-row {
    border: 1px solid var(--line);
    background: #fafafa;
    padding: 14px;
    margin-bottom: 12px;
}

.source-checks {
    display: grid;
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--line);
    background: #fff;
    padding: 10px;
}

.source-checks label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.source-checks input {
    width: auto;
    margin: 0;
}

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

.api-key-box {
    background: #f8fafc;
    border: 1px solid var(--line);
    padding: 10px;
    direction: ltr;
    text-align: left;
    word-break: break-all;
}

.small-button.danger,
.danger {
    color: #b91c1c;
    border-color: #fecaca;
}

.inner-title {
    border: 0;
    padding: 0;
    margin-bottom: 12px;
}

@media (max-width: 900px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        height: auto;
    }

    .selector-grid {
        grid-template-columns: 1fr;
    }
}


.input-group {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.input-group input {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group .small-button {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    white-space: nowrap;
}

.rss-preview {
    margin: 14px 18px 0;
    border: 1px solid var(--line);
    background: #fff;
    padding: 12px;
}

.preview-item {
    border-top: 1px solid var(--line);
    padding: 10px 0;
}

.preview-item:first-child {
    border-top: 0;
}

.is-hidden { display: none !important; }


.preview-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.small-text {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.9;
}

.selector-picker-layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 18px;
}

.selector-picker-panel {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 14px;
    position: sticky;
    top: 12px;
}

.selector-picker-panel label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.selector-picker-panel input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    background: #fff;
}

.picker-mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.picker-mode-buttons .active {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.selector-frame-box iframe {
    width: 100%;
    height: 78vh;
    border: 1px solid var(--line);
    background: #fff;
}

.selector-test-result {
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    background: #f8fafc;
    border: 1px solid var(--line);
    padding: 10px;
    max-height: 240px;
    overflow: auto;
}

.compact-actions {
    justify-content: stretch;
}

@media (max-width: 1000px) {
    .selector-picker-layout {
        grid-template-columns: 1fr;
    }

    .selector-picker-panel {
        position: static;
    }

    .selector-frame-box iframe {
        height: 65vh;
    }
}


.iframe-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    border-bottom: 0;
    background: #fff;
    padding: 8px 10px;
}

.overflow-frame {
    overflow: auto;
    background: #f8fafc;
    border: 1px solid var(--line);
}

.overflow-frame iframe {
    width: 1440px;
    max-width: none;
}

.filter-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
    gap: 12px;
    padding: 16px;
    align-items: end;
    border-bottom: 1px solid var(--line);
}
.filter-form label { margin: 0; }
.filter-form input,
.filter-form select,
.admin-edit-form input,
.admin-edit-form select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font: inherit;
    background: #fff;
}
.filter-actions { display: flex; gap: 8px; align-items: center; }
.tab-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tab-row a { border: 1px solid var(--line); padding: 8px 12px; border-radius: 4px; background: #fff; }
.tab-row a.active { border-color: var(--red); color: var(--red); font-weight: 700; }
.table-title { color: #111827; font-weight: 700; }
.table-url { color: var(--muted); font-size: 12px; max-width: 380px; overflow-wrap: anywhere; }
.success-button { color: #047857; border-color: #a7f3d0; }
.danger-button { color: #b91c1c; border-color: #fecaca; }
.muted-notice { margin: 12px 16px; }
.admin-preview-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-bottom: 12px; }
.admin-edit-form { padding: 16px; display: grid; gap: 14px; }
.admin-edit-form textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font: inherit;
}
@media (max-width: 900px) { .filter-form { grid-template-columns: 1fr; } }