:root {
    --bg: #0b1018;
    --panel: #111827;
    --panel-2: #172033;
    --line: #273349;
    --text: #edf4ff;
    --muted: #94a3b8;
    --accent: #f51f3b;
    --good: #36c690;
    --danger: #ff5c72;
    --radius: 8px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
a { color: inherit; text-decoration: none; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0d1420;
    color: var(--text);
    padding: 11px 12px;
    font: inherit;
}
textarea { resize: vertical; }
.article-textarea {
    min-height: 480px;
    white-space: pre-wrap;
    line-height: 1.7;
}
label { display: grid; gap: 7px; color: #cbd5e1; font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: 0 22px 80px rgba(0,0,0,.36);
}
.auth-card h1 { margin: 0 0 8px; }
.auth-card p { color: var(--muted); }
.auth-card form, .stacked { display: grid; gap: 16px; }
.auth-link {
    display: inline-block;
    margin-top: 16px;
    color: #cbd5e1;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 4px;
}
.auth-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-actions .auth-link { margin-top: 14px; }
.password-field {
    position: relative;
    display: block;
    line-height: 1;
}
.password-field input {
    min-height: 44px;
    padding-right: 50px;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: 5px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #cbd5e1;
    transform: translateY(-50%);
}
.password-toggle:hover,
.password-toggle:focus-visible {
    border-color: var(--line);
    background: #172033;
    outline: 0;
}
.password-toggle svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.password-toggle.is-visible::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 2px;
    border-radius: 99px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(-38deg);
}
.button, button {
    border: 0;
    border-radius: 6px;
    padding: 11px 15px;
    font-weight: 900;
    cursor: pointer;
}
.button.primary, button.primary { background: var(--accent); color: #fff; }
.button.ghost { background: #1f2937; color: #e5edf8; }
.notice { padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); }
.notice.success { border-color: rgba(54,198,144,.35); background: rgba(54,198,144,.1); color: #9ff0ce; }
.notice.danger { border-color: rgba(255,92,114,.35); background: rgba(255,92,114,.1); color: #ffc0ca; }
.muted { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.danger-text { color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }
.admin-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.admin-sidebar {
    padding: 24px 18px;
    background: #080d14;
    border-right: 1px solid var(--line);
}
.admin-brand { display: block; font-size: 18px; font-weight: 950; margin-bottom: 28px; }
.admin-sidebar nav { display: grid; gap: 6px; }
.admin-sidebar a {
    padding: 12px 13px;
    border-radius: 6px;
    color: #cbd5e1;
}
.admin-sidebar a:hover { background: var(--panel-2); color: #fff; }
.admin-main { padding: 22px; min-width: 0; }
.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.admin-topbar p { margin: 0 0 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.admin-heading {
    display: flex;
    align-items: end;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}
.admin-heading p { margin: 0; color: var(--accent); font-weight: 900; text-transform: uppercase; letter-spacing: 1px; }
.admin-heading h1 { margin: 4px 0 0; font-size: 34px; letter-spacing: 0; }
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    overflow: auto;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-grid article {
    background: linear-gradient(180deg, var(--panel), #0e1522);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}
.stat-grid span { display: block; font-size: 34px; font-weight: 950; }
.stat-grid p { margin: 4px 0 0; color: var(--muted); }
.pill { display: inline-flex; padding: 5px 9px; background: #202b3f; border: 1px solid var(--line); border-radius: 99px; color: #dbeafe; font-size: 12px; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.actions button { padding: 0; background: transparent; color: var(--danger); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.form-main, .form-side { display: grid; gap: 16px; }
.button.small,
button.small {
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1;
}
.button.danger,
button.danger {
    background: rgba(255,92,114,.12);
    color: #ffc0ca;
    border: 1px solid rgba(255,92,114,.35);
}
.feed-manager {
    display: grid;
    gap: 18px;
}
.feed-form-panel,
.feed-sources-panel {
    width: 100%;
}
.panel-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}
.panel-title-row h2,
.feed-form-panel h2 {
    margin: 0;
}
.panel-subtitle {
    margin: 5px 0 0;
    max-width: 720px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}
.source-count {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid rgba(245,31,59,.35);
    background: rgba(245,31,59,.12);
    color: #ffd6dc;
    font-size: 12px;
    font-weight: 900;
}
.feed-table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d1420;
}
.feed-source-table {
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0;
}
.feed-source-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #141e2f;
    color: #b8c4d6;
    border-bottom: 1px solid #334158;
}
.feed-source-table th,
.feed-source-table td {
    padding: 15px 16px;
}
.feed-source-table tbody tr {
    background: #0f1725;
}
.feed-source-table tbody tr:nth-child(even) {
    background: #101a2a;
}
.feed-source-table tbody tr:hover {
    background: #152239;
}
.feed-source-table tbody tr:last-child td {
    border-bottom: 0;
}
.feed-main {
    min-width: 320px;
}
.feed-name {
    display: block;
    margin-bottom: 5px;
    color: #fff;
    font-size: 15px;
}
.feed-url {
    display: block;
    max-width: 560px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.feed-error {
    display: block;
    margin-top: 7px;
    color: #ffc0ca;
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.category-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #1d2638;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 800;
}
.pill-good {
    border-color: rgba(54,198,144,.35);
    background: rgba(54,198,144,.12);
    color: #9ff0ce;
}
.pill-muted {
    color: #bac6d7;
}
.feed-meta {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}
.feed-run-lines {
    min-width: 210px;
}
.feed-run-lines span {
    display: block;
    color: #d6e0ef;
    font-size: 13px;
    line-height: 1.55;
}
.feed-run-lines b {
    display: inline-block;
    min-width: 96px;
    color: var(--muted);
    font-size: 12px;
}
.feed-actions {
    min-width: 220px;
    justify-content: flex-end;
    gap: 8px;
}
.feed-actions form {
    margin: 0;
}
.feed-actions .button,
.feed-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 9px 12px;
}
.feed-actions button:not(.danger) {
    background: #243149;
    color: #f5f8ff;
}
.feed-actions button.primary {
    background: var(--accent);
    color: #fff;
}
.empty-table {
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
}
.feed-backup-panel {
    margin-top: 18px;
}
.feed-backup-table {
    min-width: 900px;
}
.backup-empty {
    margin: 0;
    padding: 16px;
    border: 1px dashed #3a465d;
    border-radius: 8px;
    background: #0d1420;
    color: var(--muted);
    line-height: 1.55;
}
.category-manager {
    display: grid;
    gap: 18px;
}
.category-form-panel,
.category-list-panel {
    width: 100%;
}
.category-form-panel h2 {
    margin: 0;
}
.category-table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d1420;
}
.category-source-table {
    min-width: 880px;
    border-collapse: separate;
    border-spacing: 0;
}
.category-source-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #141e2f;
    color: #b8c4d6;
    border-bottom: 1px solid #334158;
}
.category-source-table th,
.category-source-table td {
    padding: 15px 16px;
}
.category-source-table tbody tr {
    background: #0f1725;
}
.category-source-table tbody tr:nth-child(even) {
    background: #101a2a;
}
.category-source-table tbody tr:hover {
    background: #152239;
}
.category-source-table tbody tr:last-child td {
    border-bottom: 0;
}
.category-main strong {
    display: block;
    color: #fff;
    font-size: 15px;
}
.category-slug {
    display: inline-flex;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 5px 8px;
    border-radius: 6px;
    background: #111827;
    color: #f8d88a;
    font-size: 12px;
}
.category-sort {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 6px 9px;
    border-radius: 999px;
    background: #1d2638;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 900;
}
.category-description {
    max-width: 420px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-note {
    align-self: end;
    color: var(--muted);
    line-height: 1.55;
    font-size: 13px;
}
.check { display: flex; gap: 10px; align-items: center; }
.check input { width: auto; }
.deploy-note { margin-top: 18px; }
.settings-password-panel { margin-top: 18px; }
.deploy-note code {
    display: block;
    padding: 12px;
    border-radius: 6px;
    background: #0d1420;
    overflow-wrap: anywhere;
}
.helper-copy { color: var(--muted); line-height: 1.55; margin-top: 0; }
.ad-placement-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.ad-placement-card {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}
.ad-placement-card strong,
.ad-placement-card span {
    display: block;
}
.ad-placement-card span {
    color: #f8d88a;
    font-size: 12px;
    margin-top: 4px;
}
.ad-placement-card p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.45;
}
.ads-form-grid {
    margin-bottom: 18px;
}
label small {
    color: var(--muted);
    font-weight: 500;
    line-height: 1.45;
}
.ad-preview-panel {
    position: sticky;
    top: 18px;
}
.ad-preview-box {
    min-height: 250px;
    display: grid;
    place-items: center;
    border: 1px dashed #3a465d;
    border-radius: 8px;
    background: #0d1420;
    overflow: hidden;
    padding: 12px;
}
.ad-preview-box img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
}
.preview-empty {
    text-align: center;
    color: var(--muted);
}
.preview-empty strong {
    display: block;
    color: var(--text);
    font-size: 20px;
    margin-bottom: 8px;
}
.ad-admin-list {
    display: grid;
    gap: 12px;
}
.ad-admin-card {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0e1522;
}
.ad-admin-thumb {
    width: 120px;
    height: 82px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 6px;
    background: #111827;
    color: var(--muted);
}
.ad-admin-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ad-admin-card h3 { margin: 0 0 4px; }
.ad-admin-card p { margin: 0 0 8px; color: var(--muted); }
code { color: #f8d88a; }
@media (max-width: 900px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; }
    .stat-grid, .form-grid, .two-col, .ad-placement-grid, .ad-admin-card { grid-template-columns: 1fr; }
    .ad-preview-panel { position: static; }
}
