:root {
    --red: #c8102e;
    --navy: #0f1c2e;
    --navy-2: #16263c;
    --ink: #152132;
    --text: #334155;
    --muted: #748296;
    --line: #e6eaf0;
    --bg: #f3f6fa;
    --card: #fff;
    --radius: 14px;
    --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.35; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
.admin-body { display: flex; min-height: 100vh; }

/* sidebar */
.admin-sidebar { position: fixed; inset: 0 auto 0 0; width: 238px; background: var(--navy); color: #a8b6c8; display: flex; flex-direction: column; z-index: 30; }
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.logo-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--red), #e8505f); color: #fff; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.admin-brand strong { display: block; color: #fff; font-size: 15px; }
.admin-brand small { font-size: 11px; color: #7f91a8; letter-spacing: .5px; }
.admin-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; overflow: auto; }
.admin-nav-item { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 10px; color: #a8b6c8; font-size: 13.5px; transition: .18s; }
.admin-nav-item svg { stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.admin-nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.admin-nav-item.active { background: linear-gradient(90deg, rgba(200, 16, 46, .9), rgba(200, 16, 46, .55)); color: #fff; box-shadow: 0 6px 16px rgba(200, 16, 46, .22); }
.admin-nav-item em { margin-left: auto; background: rgba(255, 255, 255, .18); color: #fff; font-style: normal; font-size: 11px; padding: 0 7px; border-radius: 999px; }
.admin-sidebar-foot { padding: 14px 20px 18px; border-top: 1px solid rgba(255, 255, 255, .07); display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.admin-sidebar-foot a { color: #7f91a8; }
.admin-sidebar-foot a:hover { color: #fff; }

.admin-main { margin-left: 238px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 14px 28px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.admin-topbar-left { display: flex; align-items: center; gap: 12px; }
.admin-topbar h1 { font-size: 19px; }
.admin-topbar span { font-size: 12px; color: var(--muted); }
.admin-topbar-right { display: flex; align-items: center; gap: 14px; }
.admin-site-link { font-size: 12.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.admin-site-link:hover { color: var(--red); border-color: #f2c6cf; }
.admin-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.admin-menu-toggle { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 16px; }
.admin-content { padding: 24px 28px 40px; flex: 1; }
.admin-footer { display: flex; justify-content: space-between; padding: 14px 28px; border-top: 1px solid var(--line); font-size: 12px; color: #8b98a8; background: #fff; }

.admin-flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; }
.admin-flash-success { background: #e9f8f0; color: #14754a; border: 1px solid #bfe9d5; }
.admin-flash-error { background: #fdecef; color: #a40d27; border: 1px solid #f6c6cf; }

/* cards / panels */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; }
.panel-head p { font-size: 12px; color: var(--muted); }
.panel-body { padding: 20px; }
.panel-body.flush { padding: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.mt-18 { margin-top: 18px; }
.mt-24 { margin-top: 24px; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden; }
.stat-card small { font-size: 12px; color: var(--muted); }
.stat-card strong { display: block; font-size: 30px; color: var(--ink); line-height: 1.2; margin-top: 4px; }
.stat-card .stat-delta { font-size: 12px; color: #0f8a5f; }
.stat-card::after { content: ""; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px; background: radial-gradient(circle, rgba(200, 16, 46, .08), transparent 65%); }
.stat-card:nth-child(2)::after { background: radial-gradient(circle, rgba(28, 110, 164, .1), transparent 65%); }
.stat-card:nth-child(3)::after { background: radial-gradient(circle, rgba(13, 138, 138, .1), transparent 65%); }
.stat-card:nth-child(4)::after { background: radial-gradient(circle, rgba(230, 160, 20, .12), transparent 65%); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent; background: #fff; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: .18s; white-space: nowrap; }
.btn:hover { opacity: .92; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #a80d26; }
.btn-outline { border-color: #d8dfe9; color: #46566a; }
.btn-outline:hover { border-color: var(--red); color: var(--red); }
.btn-danger { background: #fff1f3; color: var(--red); border-color: #f4c8d0; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

/* tables */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); background: #f8fafc; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 12px; letter-spacing: .3px; }
.table td { padding: 12px 14px; border-bottom: 1px solid #eff2f6; vertical-align: middle; }
.table tr:hover td { background: #fafbfd; }
.table .cell-title { font-weight: 600; color: var(--ink); max-width: 360px; }
.table .cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table .cell-sub { font-size: 11.5px; color: var(--muted); }
.table-img { width: 44px; height: 34px; border-radius: 6px; object-fit: cover; background: #f0f3f7; }
.sort-form { margin: 0; }
.sort-input { width: 64px; height: 32px; padding: 0 8px; text-align: center; font-size: 12.5px; -moz-appearance: textfield; }
.sort-input::-webkit-outer-spin-button, .sort-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.table-empty { padding: 34px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: #f1f4f8; color: #5b6b7f; white-space: nowrap; }
.badge-green { background: #e7f7ef; color: #0f7a4d; }
.badge-red { background: #fdeaee; color: var(--red); }
.badge-yellow { background: #fff5e2; color: #a26a00; }
.badge-blue { background: #eaf2fb; color: #1c6ea4; }
.badge-gray { background: #f1f4f8; color: #64748b; }

/* toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 8px; flex-wrap: wrap; }
.input, .select, .textarea { border: 1px solid #dbe2eb; border-radius: 8px; padding: 8px 11px; background: #fff; outline: none; color: var(--text); transition: .18s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200, 16, 46, .07); }
.input { height: 36px; }
.select { height: 36px; }
.textarea { width: 100%; resize: vertical; }
.toolbar .input { min-width: 200px; }

/* forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 12.5px; font-weight: 600; color: #46566a; margin-bottom: 6px; }
.form-field label em { color: var(--red); font-style: normal; }
.form-field .input, .form-field .select, .form-field .textarea { width: 100%; }
.form-field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.form-field .checkbox-row { display: flex; gap: 18px; align-items: center; height: 36px; }
.form-field .checkbox-row label { margin: 0; font-weight: 500; display: flex; gap: 6px; align-items: center; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.image-preview { width: 100%; max-width: 260px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #f4f7fb; }
.content-editor { min-height: 380px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; line-height: 1.8; }

/* tabs / chips */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 999px; font-size: 12.5px; color: #5b6b7f; background: #f1f4f8; }
.tab:hover { color: var(--red); }
.tab.active { background: var(--red); color: #fff; }

/* pager */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; color: #475569; background: #fff; }
.pager a:hover { border-color: var(--red); color: var(--red); }
.pager a.active { background: var(--red); color: #fff; border-color: var(--red); }

/* dashboard specifics */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.quick-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; transition: .18s; }
.quick-card:hover { border-color: #f3c3cd; box-shadow: 0 8px 20px rgba(200, 16, 46, .07); transform: translateY(-2px); }
.quick-card strong { font-size: 14px; color: var(--ink); }
.quick-card span { font-size: 12px; color: var(--muted); }
.log-list { display: flex; flex-direction: column; }
.log-item { padding: 11px 0; border-bottom: 1px dashed #edf0f5; font-size: 12.5px; display: flex; gap: 10px; align-items: flex-start; }
.log-item:last-child { border-bottom: 0; }
.log-item time { color: #97a2b1; flex-shrink: 0; width: 120px; }
.log-item .log-text { color: #46566a; }
.settings-section { margin-bottom: 22px; }
.settings-section h3 { font-size: 14px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.settings-grid .full { grid-column: 1 / -1; }
.mono { font-family: Consolas, monospace; background: #f6f8fb; border: 1px dashed #dbe2eb; border-radius: 8px; padding: 10px 12px; font-size: 12px; word-break: break-all; color: #334155; }
.ai-status { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, #223c5f, #0d1826 60%); padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 34px 32px; box-shadow: 0 30px 70px rgba(0, 0, 0, .35); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-brand .logo-mark { width: 44px; height: 44px; font-size: 20px; }
.login-brand strong { display: block; font-size: 16px; color: var(--ink); }
.login-brand small { font-size: 11.5px; color: var(--muted); }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.login-card .form-field { margin-bottom: 14px; }
.login-card .btn { height: 44px; width: 100%; font-size: 14px; margin-top: 6px; }
.login-error { background: #fdecef; color: #a40d27; border: 1px solid #f6c6cf; border-radius: 8px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .admin-sidebar { transform: translateX(-100%); transition: .25s; box-shadow: 20px 0 50px rgba(0, 0, 0, .3); }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-menu-toggle { display: block; }
    .admin-topbar { padding: 12px 18px; }
    .admin-content { padding: 18px; }
    .form-grid, .settings-grid { grid-template-columns: 1fr; }
    .admin-site-link { display: none; }
}
@media (max-width: 600px) {
    .stat-grid { grid-template-columns: 1fr; }
    .quick-grid { grid-template-columns: 1fr; }
    .admin-topbar h1 { font-size: 16px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar form { width: 100%; }
    .toolbar .input { min-width: 0; width: 100%; }
    .toolbar > div { width: 100%; }
    .toolbar > div .btn { flex: 1; justify-content: center; }
    .tabs { overflow-x: auto; flex-wrap: nowrap; }
    .tabs .tab { white-space: nowrap; }
    .panel-body { padding: 16px; }
    .panel-head { flex-direction: column; align-items: flex-start; gap: 8px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }
    .cell-actions { flex-wrap: wrap; }
    .settings-section { padding: 16px; }
}
