* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0f1419;
    --bg-soft: #1a2332;
    --panel: #1e2a3a;
    --panel-hover: #253344;
    --text: #e8edf2;
    --text-muted: rgba(232, 237, 242, 0.6);
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --border: rgba(255, 255, 255, 0.08);
    --radius: 12px;
    --font: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ========== LOGIN ========== */
.admin-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 420px; padding: 48px 40px; border-radius: 16px; border: 1px solid var(--border); background: var(--panel); }
.login-card h1 { font-size: 1.6rem; margin-bottom: 8px; }
.login-card .login-sub { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 32px; }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 6px; font-size: 0.9rem; color: var(--text-muted); font-weight: 600; }
.field input, .field textarea, .field select { width: 100%; padding: 14px 18px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); font: inherit; font-size: 1rem; outline: none; transition: border-color 0.2s; }
.field select option { background: var(--bg-soft); color: var(--text); }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 120px; }
.field-note { margin-top: 8px; color: var(--text-muted); font-size: 0.85rem; line-height: 1.6; }
.login-error { padding: 12px 16px; border-radius: 8px; background: rgba(239, 68, 68, 0.12); color: var(--danger); font-size: 0.9rem; margin-bottom: 18px; display: none; }

/* ========== BUTTONS ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 8px 18px; font-size: 0.88rem; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: rgba(255,255,255,0.06); }
.btn-danger { background: transparent; border-color: rgba(239, 68, 68, 0.3); color: var(--danger); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.12); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }

/* ========== ADMIN LAYOUT ========== */
html.admin-mode, html.admin-mode body { width: 100%; height: 100%; overflow: hidden; }
.admin-app { display: none; flex-direction: column; width: 100vw; height: 100vh; min-width: 0; }
.admin-header { display: flex; align-items: center; justify-content: space-between; padding: 0 28px; height: 60px; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.admin-header h1 { font-size: 1.1rem; display: flex; align-items: center; gap: 12px; }
.admin-header h1 a { color: var(--text-muted); font-size: 0.8rem; font-weight: 400; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border); transition: all 0.2s; }
.admin-header h1 a:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.admin-body { display: flex; width: 100%; height: calc(100vh - 60px); min-height: 0; }

.admin-sidebar { width: 210px; min-width: 210px; border-right: 1px solid var(--border); background: var(--bg-soft); padding: 12px 0; overflow-y: auto; flex-shrink: 0; }
.sidebar-item { display: flex; align-items: center; gap: 12px; padding: 12px 22px; cursor: pointer; font-size: 0.95rem; color: var(--text-muted); transition: all 0.15s; border: none; background: none; width: 100%; text-align: left; font-family: inherit; }
.sidebar-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.sidebar-item.active { color: var(--accent); background: rgba(59, 130, 246, 0.08); border-right: 3px solid var(--accent); }
.sidebar-item .sidebar-icon { width: 20px; text-align: center; font-size: 1.1rem; }

.admin-main { flex: 1; min-width: 0; overflow-y: auto; padding: 32px 48px; }
.panel { display: none; }
.panel.active { display: block; width: 100%; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.panel-header h2 { font-size: 1.4rem; }
.save-bar { position: sticky; bottom: 0; padding: 20px 0 8px; background: linear-gradient(transparent, var(--bg) 20%); display: flex; justify-content: flex-end; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field-group { margin-bottom: 28px; }
.field-group-title { font-size: 1rem; font-weight: 600; color: var(--accent); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.field-check { display: flex; align-items: center; gap: 10px; padding-top: 6px; }
.field-check input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.field-number { display: grid; grid-template-columns: 100px 100px 1fr; gap: 14px; align-items: end; }

/* ========== NEWS TABLE ========== */
.news-table { width: 100%; border-collapse: collapse; }
.news-table th, .news-table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.news-table th { color: var(--text-muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.news-table .title-cell { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-tag { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 0.78rem; font-weight: 600; }
.badge-tag-featured { background: rgba(245, 158, 11, 0.18); color: var(--warning); }
.badge-tag-normal { background: rgba(59, 130, 246, 0.14); color: var(--accent); }
.actions-cell { display: flex; gap: 8px; }
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-muted); font-size: 1rem; }

/* ========== MODAL ========== */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); align-items: center; justify-content: center; padding: 32px; overflow-y: auto; }
.modal-overlay.show { display: flex; }
.modal { width: 100%; max-width: 1000px; max-height: 90vh; display: flex; flex-direction: column; border-radius: 16px; border: 1px solid var(--border); background: var(--panel); animation: modalIn 0.2s ease; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 28px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h2 { font-size: 1.2rem; }
.modal-close { width: 36px; height: 36px; display: grid; place-items: center; border: none; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; }
.modal-close:hover { background: rgba(255,255,255,0.08); }
.modal-body { padding: 28px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 28px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* ========== TOAST ========== */
.toast { position: fixed; bottom: 28px; right: 28px; z-index: 100; padding: 14px 24px; border-radius: 10px; font-size: 0.95rem; font-weight: 600; transform: translateY(80px); opacity: 0; transition: all 0.3s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: rgba(34, 197, 94, 0.16); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--success); }
.toast.error { background: rgba(239, 68, 68, 0.16); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); }

.dynamic-list { display: flex; flex-direction: column; gap: 16px; }
.dynamic-item { padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-soft); }
.dynamic-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dynamic-item-title { font-size: 0.9rem; font-weight: 700; color: var(--text-muted); }
.btn-xs { padding: 6px 14px; font-size: 0.8rem; border-radius: 6px; }

@media (max-width: 900px) {
    .admin-sidebar { display: none; }
    .admin-main { padding: 24px 20px; }
    .field-row { grid-template-columns: 1fr; }
}
