/* ===== Theme Variables ===== */
:root {
    --bg-body: #f0f2f5;
    --bg-card: #fff;
    --bg-sidebar: #1e293b;
    --bg-input: #fff;
    --bg-hover: #f9fafb;
    --bg-table-head: #f8fafc;
    --bg-unread: #f0f7ff;
    --bg-code: #1e293b;
    --text-primary: #333;
    --text-secondary: #555;
    --text-muted: #888;
    --text-dimmed: #999;
    --text-heading: #1e293b;
    --border-color: #f0f0f0;
    --border-input: #d1d5db;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.08);
    --accent: #1976d2;
    --accent-hover: #1565c0;
    --accent-bg: rgba(25,118,210,0.1);
    --danger: #dc2626;
}
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --bg-input: #334155;
    --bg-hover: #334155;
    --bg-table-head: #1e293b;
    --bg-unread: #1e3a5f;
    --bg-code: #0f172a;
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-dimmed: #64748b;
    --text-heading: #f1f5f9;
    --border-color: #334155;
    --border-input: #475569;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --accent-bg: rgba(96,165,250,0.15);
    --danger: #f87171;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ===== Auth Pages ===== */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    width: 400px;
    max-width: 100%;
}
.auth-box h1 {
    text-align: center;
    font-size: 28px;
    color: var(--accent);
    margin-bottom: 4px;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
}
.auth-link {
    text-align: center;
    margin-top: 16px;
    color: var(--text-muted);
}

/* ===== Layout ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 236px;
    background: var(--bg-sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.sidebar-header {
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.sidebar-brand { min-width: 0; }
.sidebar-header h2 {
    font-size: 19px;
    font-weight: 700;
}
.sidebar-header p {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}
.sidebar-header a {
    color: #fff;
    text-decoration: none;
}
.sidebar-close {
    display: none;
    border: none;
    background: rgba(255,255,255,0.08);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}
.nav-menu {
    list-style: none;
    padding: 12px 10px;
    flex: 1;
}
.nav-menu li a {
    display: block;
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
}
.nav-menu li a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}
.nav-menu li.active a {
    background: rgba(25,118,210,0.3);
    color: #fff;
    box-shadow: inset 3px 0 0 #1976d2;
}
.nav-group {
    margin-bottom: 4px;
}
.nav-group details {
    margin: 0;
}
.nav-group-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 14px;
    list-style: none;
    user-select: none;
}
.nav-group-summary::-webkit-details-marker {
    display: none;
}
.nav-group-summary:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.nav-group-caret {
    font-size: 11px;
    opacity: .72;
    transition: transform .2s;
}
.nav-group details[open] .nav-group-caret {
    transform: rotate(180deg);
}
.nav-submenu {
    list-style: none;
    margin: 2px 0 4px;
    padding: 0 0 0 10px;
}
.nav-submenu li a {
    padding-left: 18px;
    font-size: 13px;
}
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 8px 0;
}
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.user-info a { color: #cbd5e1; font-size: 13px; }
.user-info a:hover { color: #fff; text-decoration: none; }
.btn-logout { color: #f87171 !important; }
.btn-theme {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.btn-theme:hover { opacity: 1; }
.sidebar-overlay,
.admin-mobilebar {
    display: none;
}

.main-content {
    flex: 1;
    min-width: 0;
    margin-left: 236px;
    padding: 24px;
    min-height: 100vh;
    background: var(--bg-body);
}
.main-content.full-width {
    margin-left: 0;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-heading);
    line-height: 1.2;
}
.header-actions {
    display: flex;
    gap: 8px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    padding: 20px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-card);
}
.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}
.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-input);
    text-decoration: none;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}
.btn-danger {
    color: var(--danger);
    border-color: #fca5a5;
}
.btn-danger:hover {
    background: #fef2f2;
    border-color: #dc2626;
}
.btn-warning {
    color: #b45309;
    border-color: #fcd34d;
}
.btn-warning:hover {
    background: #fffbeb;
    border-color: #f59e0b;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}
.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}
.btn-icon {
    padding: 4px 8px;
    border: none;
    background: none;
}
.btn-icon:hover {
    background: var(--bg-hover);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg-input);
    color: var(--text-primary);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.form-input {
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg-input);
    color: var(--text-primary);
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.flex-1 { flex: 1; }
.form-msg {
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-muted);
    min-height: 20px;
}
.form-msg.error { color: #dc2626; }
.form-msg.success { color: #16a34a; }
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar select {
    padding: 6px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.data-table th {
    background: var(--bg-table-head);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
}
.data-table tr:hover td {
    background: var(--bg-hover);
}
.data-table small {
    display: block;
    color: var(--text-dimmed);
    font-size: 12px;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 4px;
}

/* ===== Article List ===== */
.article-list {
    min-height: 50px;
}
.article-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}
.article-item:last-child {
    border-bottom: none;
}
.article-item.unread {
    background: var(--bg-unread);
    margin: 0 -20px;
    padding: 12px 20px;
    border-left: 3px solid var(--accent);
}
.article-main { flex: 1; min-width: 0; }
.article-title {
    display: block;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-heading);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.article-title:hover {
    color: var(--accent);
    text-decoration: none;
}
.unread .article-title {
    font-weight: 600;
}
.article-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-dimmed);
}
.article-meta .sub-name { color: var(--accent); }
.article-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ===== Batch Operations ===== */
.batch-bar {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--text-muted);
}
.batch-bar label { cursor: pointer; display: flex; align-items: center; gap: 6px; }
.article-check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin-right: 8px;
}
.badge-danger {
    background: #fde8e8;
    color: #c62828;
    cursor: help;
}

/* ===== Article Detail ===== */
.article-detail-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.article-detail-title {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 12px;
    color: var(--text-heading);
}
.article-detail-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.article-detail-meta a { color: var(--accent); }
.article-detail-actions {
    display: flex;
    gap: 8px;
}
.article-detail-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.article-detail-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
}
.article-detail-content a {
    color: var(--accent);
    word-break: break-all;
}
.article-detail-content p {
    margin-bottom: 12px;
}

/* ===== Subscription Items ===== */
.subs-list { min-height: 50px; }
.sub-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.sub-item:last-child { border-bottom: none; }
.sub-info strong { display: block; font-size: 14px; }
.sub-meta { font-size: 12px; color: var(--text-dimmed); }
.sub-actions { display: flex; gap: 4px; }

/* ===== Steps Bar ===== */
.steps-bar {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.step {
    flex: 1;
    text-align: center;
    padding: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dimmed);
    background: var(--bg-table-head);
    border-right: 1px solid var(--border-color);
}
.step:last-child { border-right: none; }
.step.active {
    background: var(--accent);
    color: #fff;
}
.step.done {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ===== Visual Selector ===== */
.selector-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-table-head);
    border-radius: 6px;
    align-items: center;
}
.selector-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.mode-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-left: auto;
    font-weight: 500;
}
.selector-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.selector-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 3px;
}
.selector-field input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-input);
    border-radius: 4px;
    font-size: 13px;
    font-family: monospace;
    outline: none;
    background: var(--bg-input);
    color: var(--text-primary);
}
.selector-field input:focus {
    border-color: var(--accent);
}
.preview-container {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--bg-card);
}
.preview-container iframe {
    width: 100%;
    height: 500px;
    border: none;
}
.help-text {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

/* ===== Pager ===== */
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--border-color);
}
.pager-info { font-size: 13px; color: var(--text-muted); }
.pager-btns { display: flex; gap: 8px; }

.admin-toast-root {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.admin-toast {
    min-width: 220px;
    max-width: 360px;
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .18s ease, transform .18s ease;
}

.admin-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.admin-toast-info { background: #334155; }
.admin-toast-success { background: #15803d; }
.admin-toast-error { background: #b91c1c; }

.app-toast-root {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1400;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.app-toast {
    min-width: 220px;
    max-width: 360px;
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .18s ease, transform .18s ease;
}

.app-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.app-toast-info { background: #334155; }
.app-toast-success { background: #15803d; }
.app-toast-error { background: #b91c1c; }

.app-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1450;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.app-confirm-card {
    width: min(420px, 100%);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 24px 56px rgba(15, 23, 42, 0.22);
    padding: 20px;
}

.app-confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 8px;
}

.app-confirm-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
}

.app-confirm-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.badge-primary { background: #e3f2fd; color: #1976d2; }
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-danger { background: #fde8e8; color: #c62828; }
.badge-muted { background: #f3f4f6; color: #999; }
.badge-warning { background: #fff3e0; color: #e65100; }

/* ===== Admin Utilities ===== */
body.admin-shell .main-content > :not(script):not(.modal) {
    width: 100%;
}
body.admin-shell .card {
    padding: 18px;
    border: 1px solid var(--border-color);
}
body.admin-shell .card > h3:first-child {
    margin-top: 0;
    margin-bottom: 14px;
}
body.admin-shell .card-header {
    margin-bottom: 14px;
    padding-bottom: 10px;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-start;
}
body.admin-shell .stats-grid {
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}
body.admin-shell .stat-card {
    padding: 10px 12px;
    text-align: center;
    border: 1px solid var(--border-color);
    min-height: 66px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
body.admin-shell .stat-number {
    font-size: 21px;
    line-height: 1.05;
}
body.admin-shell .stat-label {
    margin-top: 0;
    font-size: 12px;
    line-height: 1.25;
}
body.admin-shell .stat-card.stat-muted .stat-number {
    color: var(--text-heading);
}
body.admin-shell .stat-card.stat-watch {
    border-color: rgba(245, 158, 11, 0.34);
    background: linear-gradient(180deg, rgba(255, 251, 235, 0.88), var(--bg-card));
}
body.admin-shell .stat-card.stat-watch .stat-number {
    color: #b45309;
}
body.admin-shell .stat-card.stat-risk {
    border-color: rgba(220, 38, 38, 0.26);
    background: linear-gradient(180deg, rgba(254, 242, 242, 0.9), var(--bg-card));
}
body.admin-shell .stat-card.stat-risk .stat-number {
    color: #dc2626;
}
body.admin-shell .stat-card.stat-success {
    border-color: rgba(22, 163, 74, 0.22);
    background: linear-gradient(180deg, rgba(240, 253, 244, 0.88), var(--bg-card));
}
body.admin-shell .stat-card.stat-success .stat-number {
    color: #15803d;
}
body.admin-shell .page-header {
    gap: 12px;
}
body.admin-shell .header-actions {
    flex-wrap: wrap;
}
body.admin-shell .filter-bar {
    gap: 8px;
    margin-bottom: 14px;
}
body.admin-shell .filter-bar.admin-filter-primary {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-table-head);
}
body.admin-shell .filter-bar.admin-quick-views {
    align-items: center;
    margin-top: -6px;
    margin-bottom: 16px;
}
body.admin-shell .filter-bar.admin-quick-views .btn {
    min-height: 30px;
    padding: 5px 11px;
    border-radius: 999px;
    background: transparent;
}
body.admin-shell .filter-bar.admin-quick-views .btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
body.admin-shell .filter-bar input,
body.admin-shell .filter-bar select,
body.admin-shell .filter-bar button {
    min-height: 38px;
}
body.admin-shell .filter-bar input {
    flex: 1 1 260px;
}
body.admin-shell .filter-bar select {
    flex: 0 1 180px;
}
body.admin-shell .data-table th,
body.admin-shell .data-table td {
    padding: 8px 10px;
    font-size: 12.5px;
    vertical-align: top;
}
body.admin-shell .actions-cell {
    white-space: normal;
    flex-wrap: wrap;
    min-width: 150px;
}
body.admin-shell .data-table th {
    font-size: 11px;
    letter-spacing: .02em;
}
body.admin-shell .data-table small {
    max-width: none;
    white-space: normal;
    line-height: 1.4;
}
body.admin-shell .data-table code {
    font-size: 11px;
}
.table-wrap {
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}
.table-wrap .data-table {
    width: 100%;
    min-width: 680px;
}
.cell-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.cell-stack strong {
    color: var(--text-heading);
}
.badge-row,
.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
}
.metric-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.metric-pair {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-secondary);
}
.metric-pair strong {
    color: var(--text-heading);
}
.mini-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    color: var(--text-muted);
    font-size: 12px;
}
.mini-meta span {
    min-width: 0;
}
.admin-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.admin-split.align-start {
    align-items: start;
}
.admin-split.align-start > .card {
    align-self: start;
}
.admin-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    align-items: start;
}
.admin-form-grid .span-full {
    grid-column: 1 / -1;
}
.admin-form-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}
.admin-note {
    border: 1px solid #dbeafe;
    background: #eff6ff;
    color: #1d4ed8;
}
.admin-note strong {
    color: inherit;
}
.admin-gap-top {
    margin-top: 20px;
}
.admin-gap-bottom {
    margin-bottom: 14px;
}
.inline-note {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.info-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 100%;
}
.info-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
    align-items: start;
    gap: 6px 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.info-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.info-row span:first-child {
    color: var(--text-muted);
    flex-shrink: 0;
}
.info-row span:last-child {
    min-width: 0;
    text-align: left;
    word-break: break-word;
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.summary-grid.summary-grid-wide {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.summary-grid.admin-strategy-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.summary-card {
    min-width: 0;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-table-head);
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.summary-card.summary-card-wide {
    grid-column: 1 / -1;
    min-height: auto;
}
.summary-grid.admin-strategy-grid .summary-card,
.content-helper-card .summary-card,
.admin-priority-panel .summary-card {
    min-height: auto;
    padding: 12px 14px;
}
.summary-label {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 6px;
}
.summary-value {
    color: var(--text-heading);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    word-break: break-word;
}
.summary-value.summary-value-text {
    font-size: 14px;
    font-weight: 500;
}
.summary-meta {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}
.list-link {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: var(--bg-table-head);
    border-left: 3px solid var(--border-input);
    color: var(--text-primary);
    text-decoration: none;
}
.list-link:hover {
    text-decoration: none;
    background: var(--bg-hover);
}
.list-link.warn { border-left-color: #f59e0b; }
.list-link.danger { border-left-color: #dc2626; }
.list-link.info { border-left-color: var(--accent); }
.admin-scroll-area {
    max-height: 520px;
    overflow: auto;
    padding-right: 2px;
    scrollbar-gutter: stable;
}
.admin-scroll-area .table-wrap {
    overflow: visible;
}
.admin-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.admin-action-group-danger {
    padding-left: 10px;
    border-left: 1px solid var(--border-color);
}
.admin-table-actions {
    align-items: center;
}
.admin-card-natural .empty,
.admin-card-natural .loading {
    padding-block: 28px;
}
.admin-priority-panel {
    margin-bottom: 18px;
}
.content-helper-card {
    margin-top: -2px;
}
.content-helper-card .summary-meta,
.admin-priority-panel .summary-meta {
    line-height: 1.45;
}
.admin-nav.admin-nav-compact {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
}
.admin-nav.admin-nav-compact .admin-nav-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    grid-template-areas:
        "icon title"
        "icon desc";
    column-gap: 10px;
    padding: 13px 14px;
    box-shadow: none;
}
.admin-nav.admin-nav-compact .admin-nav-item:hover {
    transform: none;
    box-shadow: var(--shadow-card);
}
.admin-nav.admin-nav-compact .admin-nav-icon {
    grid-area: icon;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    border-radius: 8px;
    background: var(--bg-table-head);
    font-size: 20px;
}
.admin-nav.admin-nav-compact .admin-nav-title {
    grid-area: title;
    margin-bottom: 2px;
    font-size: 14px;
}
.admin-nav.admin-nav-compact .admin-nav-desc {
    grid-area: desc;
    font-size: 12px;
    line-height: 1.4;
}
.admin-section-toggle {
    margin-top: 18px;
}
.admin-section-toggle summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    color: var(--text-heading);
    cursor: pointer;
    list-style: none;
}
.admin-section-toggle summary::-webkit-details-marker {
    display: none;
}
.admin-section-toggle summary::after {
    content: "展开";
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}
.admin-section-toggle[open] summary::after {
    content: "收起";
}
.admin-section-toggle .admin-section-title {
    margin: 0;
}
[data-theme="dark"] body.admin-shell .stat-card.stat-watch {
    border-color: rgba(251, 191, 36, 0.28);
    background: linear-gradient(180deg, rgba(146, 64, 14, 0.18), var(--bg-card));
}
[data-theme="dark"] body.admin-shell .stat-card.stat-risk {
    border-color: rgba(248, 113, 113, 0.28);
    background: linear-gradient(180deg, rgba(127, 29, 29, 0.2), var(--bg-card));
}
[data-theme="dark"] body.admin-shell .stat-card.stat-success {
    border-color: rgba(74, 222, 128, 0.22);
    background: linear-gradient(180deg, rgba(20, 83, 45, 0.18), var(--bg-card));
}
[data-theme="dark"] body.admin-shell .stat-card.stat-watch .stat-number {
    color: #fbbf24;
}
[data-theme="dark"] body.admin-shell .stat-card.stat-risk .stat-number {
    color: #f87171;
}
[data-theme="dark"] body.admin-shell .stat-card.stat-success .stat-number {
    color: #4ade80;
}
.log-tail {
    background: var(--bg-table-head);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    max-height: 360px;
    overflow: auto;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
}
.log-tail-line {
    display: grid;
    grid-template-columns: 150px 56px 1fr;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    word-break: break-word;
}
.log-tail-line:last-child {
    border-bottom: none;
}
.log-tail-time,
.log-tail-level {
    color: var(--text-muted);
}
.admin-mobilebar {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -6px 0 14px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-card);
    position: sticky;
    top: 10px;
    z-index: 120;
}
.admin-mobilebar-meta {
    flex: 1;
    min-width: 0;
}
.admin-mobilebar-meta strong {
    display: block;
    font-size: 14px;
    color: var(--text-heading);
}
.admin-mobilebar-kicker {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.sidebar-toggle {
    border: 1px solid var(--border-input);
    background: var(--bg-card);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
}
.admin-mobile-theme {
    border: 1px solid var(--border-input);
    background: var(--bg-card);
    width: 38px;
    height: 38px;
    border-radius: 10px;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    width: 600px;
    max-width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
}
.modal-sm { width: 420px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-dimmed);
    padding: 0 4px;
}
.modal-close:hover { color: var(--text-primary); }

/* ===== Admin Nav ===== */
.admin-nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}
.admin-nav-item {
    display: block;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    text-decoration: none;
    transition: all 0.2s;
}
.admin-nav-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-2px);
    text-decoration: none;
}
.admin-nav-icon { font-size: 32px; display: block; margin-bottom: 8px; }
.admin-nav-title { display: block; font-size: 16px; font-weight: 600; color: var(--text-heading); margin-bottom: 4px; }
.admin-nav-desc { display: block; font-size: 13px; color: var(--text-muted); }
.admin-section-title {
    margin: 22px 0 12px;
    color: var(--text-heading);
    font-size: 18px;
    font-weight: 700;
}
.admin-section-title:first-child {
    margin-top: 0;
}

[data-theme="dark"] .admin-note {
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(96, 165, 250, 0.26);
    color: #93c5fd;
}

/* ===== Info Grid ===== */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.info-item label {
    display: block;
    font-size: 11px;
    color: var(--text-dimmed);
    margin-bottom: 2px;
}
.info-item span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ===== Misc ===== */
.loading {
    text-align: center;
    padding: 30px;
    color: var(--text-dimmed);
}
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dimmed);
    font-size: 14px;
}
.text-muted { color: var(--text-dimmed); }
.search-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}
.code-block {
    background: var(--bg-code);
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: 6px;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    overflow-x: auto;
    margin: 8px 0;
}

/* ===== User Top Nav (前台) ===== */
.user-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    z-index: 100;
    display: flex;
    align-items: center;
}
.user-nav-inner {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 0;
    height: 100%;
}
.user-nav-brand {
    font-size: 17px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    margin-right: 24px;
    white-space: nowrap;
    flex-shrink: 0;
}
.user-nav-brand:hover {
    color: var(--accent-hover);
    text-decoration: none;
}
.user-nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}
.user-nav-link {
    padding: 7px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    border-radius: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}
.user-nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.user-nav-link.active {
    color: var(--accent);
    background: var(--accent-bg);
    font-weight: 500;
}
.user-nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.user-plan-badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--accent-bg);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    cursor: default;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.45);
}
.user-plan-badge[data-plan-tone="free"] {
    background: #f2f4f8;
    color: #58657b;
    border-color: rgba(88,101,123,.12);
}
.user-plan-badge[data-plan-tone="basic"],
.user-plan-badge[data-plan-tone="default"] {
    background: rgba(37,99,235,.1);
    color: #1d4ed8;
    border-color: rgba(37,99,235,.12);
}
.user-plan-badge[data-plan-tone="pro"] {
    background: linear-gradient(135deg, rgba(245,158,11,.18), rgba(251,191,36,.28));
    color: #92400e;
    border-color: rgba(217,119,6,.18);
}
.user-plan-badge[data-plan-tone="admin"] {
    background: linear-gradient(135deg, rgba(127,29,29,.12), rgba(220,38,38,.16));
    color: #b91c1c;
    border-color: rgba(220,38,38,.18);
}
.user-dropdown-wrap { position: relative; }
.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.15s;
    white-space: nowrap;
}
.user-dropdown-btn:hover { background: var(--bg-hover); }
.user-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}
.user-dropdown-menu.open { display: block; }
.user-dropdown-item {
    display: block;
    padding: 9px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.1s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.user-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.user-dropdown-item.danger { color: var(--danger); }
.user-dropdown-item.danger:hover { background: #fef2f2; }
.user-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}
.user-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 76px 20px 40px;
    min-height: 100vh;
}

/* ===== Responsive ===== */
@media (max-width: 980px) {
    .user-plan-badge {
        display: none;
    }
    body.admin-shell {
        overflow-x: hidden;
    }
    body.admin-shell.admin-sidebar-open {
        overflow: hidden;
    }
    body.admin-shell .sidebar {
        width: min(84vw, 296px);
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        z-index: 320;
        box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
    }
    body.admin-shell.admin-sidebar-open .sidebar {
        transform: translateX(0);
    }
    body.admin-shell .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 310;
        background: rgba(15, 23, 42, 0.45);
        border: none;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
    }
    body.admin-shell.admin-sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }
    body.admin-shell .sidebar-close,
    body.admin-shell .admin-mobilebar {
        display: flex;
    }
    body.admin-shell .main-content {
        margin-left: 0;
        padding: 16px 14px 24px;
    }
    body.admin-shell .sidebar-footer {
        position: sticky;
        bottom: 0;
        background: var(--bg-sidebar);
    }
    body.admin-shell .table-wrap .data-table {
        min-width: 620px;
    }
    body.admin-shell .admin-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    body:not(.admin-shell) .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }
    body:not(.admin-shell) .nav-menu {
        display: flex;
        flex-wrap: wrap;
        padding: 5px;
    }
    body:not(.admin-shell) .nav-menu li a {
        padding: 6px 12px;
        font-size: 13px;
    }
    body:not(.admin-shell) .main-content {
        margin-left: 0;
        padding: 12px;
    }
    .admin-split {
        grid-template-columns: 1fr;
    }
    body.admin-shell .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    body.admin-shell .stat-card {
        min-height: 68px;
    }
    body.admin-shell .page-header,
    body.admin-shell .header-actions {
        width: 100%;
    }
    body.admin-shell .header-actions .btn {
        flex: 1 1 auto;
        text-align: center;
    }
    body.admin-shell .admin-nav {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    body.admin-shell .admin-nav-item {
        padding: 18px;
    }
    body.admin-shell .admin-form-grid,
    body.admin-shell .admin-form-grid.compact {
        grid-template-columns: 1fr;
    }
    body.admin-shell .info-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    body.admin-shell .mini-meta {
        flex-direction: column;
        gap: 3px;
    }
    body.admin-shell .log-tail-line {
        grid-template-columns: 1fr;
        gap: 2px;
    }
    body.admin-shell .pager {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    body.admin-shell .pager-btns {
        width: 100%;
        flex-wrap: wrap;
    }
    body.admin-shell .pager-btns .btn {
        flex: 1 1 auto;
    }
    body.admin-shell .table-wrap .data-table {
        min-width: 560px;
    }
    .selector-results {
        grid-template-columns: 1fr;
    }
    .info-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .filter-bar {
        flex-direction: column;
    }
    .data-table {
        display: block;
        overflow-x: auto;
    }
    .article-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .article-item.unread {
        margin: 0 -12px;
        padding: 12px;
    }
}
