/* ============ STAI 统一风格（白底红 #e53935）============ */
:root {
    --red: #e53935;
    --red-dark: #c62828;
    --bg: #f7f8fa;
    --card: #ffffff;
    --text: #1d2129;
    --text2: #4e5969;
    --text3: #86909c;
    --border: #e2e5e8;
    --border-light: #e8e8e8;
    --green: #00b42a;
    --blue: #165dff;
    --orange: #ef6c00;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06);
    --radius: 14px;
    --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; }
html, body { background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============ 登录页 ============ */
.login-page { position: fixed; inset: 0; background: linear-gradient(160deg, #fff 0%, #f7f8fa 100%); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 10; }
.login-card { background: #fff; border-radius: 18px; padding: 40px 32px; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-card .logo { text-align: center; margin-bottom: 8px; }
.login-card .logo .mark { display: inline-flex; width: 56px; height: 56px; border-radius: 16px; background: var(--red); color: #fff; font-size: 28px; font-weight: 800; align-items: center; justify-content: center; }
.login-card h1 { color: var(--red); font-size: 24px; text-align: center; margin-bottom: 4px; }
.login-card .sub { color: var(--text3); font-size: 13px; text-align: center; margin-bottom: 26px; }
.login-card label { display: block; font-size: 14px; color: var(--text2); margin: 12px 0 6px; }
.login-card input { width: 100%; padding: 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 16px; outline: none; background: #fff; }
.login-card input:focus { border-color: var(--red); }
.login-card .btn-main { width: 100%; padding: 14px; background: var(--red); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 17px; font-weight: bold; margin-top: 22px; }
.login-card .btn-main:active { opacity: 0.85; }
.login-card .switch-line { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text3); }
.login-card .switch-line a { color: var(--red); }

/* ============ 顶部导航 ============ */
.top-bar { position: sticky; top: 0; z-index: 5; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; box-shadow: 0 1px 6px rgba(0,0,0,0.12); }
.top-bar .brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; }
.top-bar .brand .mark { display: inline-flex; width: 28px; height: 28px; border-radius: 8px; background: #fff; color: var(--red); font-size: 15px; font-weight: 800; align-items: center; justify-content: center; }
.top-bar .right { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.top-bar .right .btn { padding: 6px 14px; border: 1px solid rgba(255,255,255,0.7); background: transparent; color: #fff; border-radius: 8px; font-size: 13px; }
.top-bar .right .btn:active { background: rgba(255,255,255,0.15); }
.top-bar .menu-wrap { position: relative; }
.top-bar .menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); min-width: 120px; overflow: hidden; border: 1px solid var(--border); z-index: 10; }
.top-bar .menu-pop .menu-item { display: block; padding: 12px 16px; font-size: 14px; color: var(--text2); border-bottom: 1px solid var(--border-light); cursor: pointer; text-decoration: none; }
.top-bar .menu-pop .menu-item:last-child { border-bottom: none; }
.top-bar .menu-pop .menu-item:active { background: #f7f8fa; }

/* ============ 内容容器 ============ */
.container { max-width: 1080px; margin: 0 auto; padding: 16px; }

/* ============ 首页功能/统计卡 ============ */
.section-title { font-size: 16px; font-weight: 700; color: var(--text2); margin: 18px 0 10px; display: flex; align-items: center; gap: 6px; }
.section-title .dot { width: 6px; height: 16px; background: var(--red); border-radius: 3px; display: inline-block; }

/* ============ 书库网格 ============ */
.book-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.book-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; cursor: pointer; transition: transform .08s; }
.book-card:active { transform: scale(0.98); }
.book-card .title { font-size: 15px; font-weight: 600; line-height: 1.4; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card .meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text3); }
.book-card .price { color: var(--red); font-weight: 700; font-size: 16px; }
.book-card .price small { font-size: 11px; font-weight: 400; }

/* ============ 书库列表（多选）============ */
.book-list { display: flex; flex-direction: column; gap: 6px; }
.book-row { background: var(--card); border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; }
.book-row .cb { display: flex; align-items: center; flex-shrink: 0; }
.book-row .cb input { width: 16px; height: 16px; accent-color: var(--red); }
.book-row .t { flex: 1; min-width: 0; font-size: 14px; word-break: break-all; line-height: 1.35; }
.book-row .tag { flex-shrink: 0; white-space: nowrap; }
.book-row .btn { flex-shrink: 0; padding: 6px 12px; font-size: 13px; }
.zone-3 { background: #e8f1ff; color: var(--blue); }
.zone-5 { background: #fff0f0; color: var(--red); }

/* ============ 详情页 ============ */
.detail-head { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.detail-head h2 { font-size: 20px; margin-bottom: 10px; }
.detail-head .price-row { color: var(--red); font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.detail-head .price-row small { font-size: 13px; }
.detail-head .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.preview-box { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-top: 12px; }
.preview-box .ptitle { font-size: 15px; font-weight: 700; margin-bottom: 12px; color: var(--text2); }
.preview-box .ptext { font-size: 14px; line-height: 1.9; color: var(--text2); white-space: pre-wrap; word-break: break-word; }
.preview-box .more { color: var(--text3); font-size: 13px; text-align: center; margin-top: 12px; }

/* ============ 购物车/列表 ============ */
.list-card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.list-card .info { flex: 1; min-width: 0; }
.list-card .info .t { margin-bottom: 4px; word-break: break-all; }
.list-card .info .m { color: var(--text3); font-size: 12px; }
.list-card .actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.list-card .cb { display: flex; align-items: center; flex-shrink: 0; }
.list-card .cb input { width: 16px; height: 16px; accent-color: var(--red); }
.mybooks-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.mybooks-toolbar .cb-label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.mybooks-toolbar .cb-label input { width: 16px; height: 16px; accent-color: var(--red); }
.mybooks-toolbar .muted { color: var(--text3); font-size: 13px; }

/* ============ 按钮 ============ */
.btn { padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid transparent; }
.btn-main { background: var(--red); color: #fff; border: none; font-weight: 600; }
.btn-main:active { opacity: 0.85; }
.btn-main[disabled] { background: #f0a1a1; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-plain { background: #fff; color: var(--text2); border: 1px solid var(--border); }
.btn-green { background: var(--green); color: #fff; border: none; font-weight: 600; }
.btn-blue { background: var(--blue); color: #fff; border: none; font-weight: 600; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid var(--red); }

/* ============ 表单 ============ */
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 14px; color: var(--text2); margin-bottom: 6px; }
.form-item input, .form-item select, .form-item textarea { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; outline: none; background: #fff; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--red); }
.form-item textarea { min-height: 100px; resize: vertical; }
.form-item .hint { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* 多选勾选框 */
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: flex; align-items: center; gap: 5px; background: #fafafa; border: 1px solid #eee; border-radius: 8px; padding: 8px 14px; font-size: 13px; color: #555; cursor: pointer; }
.check input { width: auto; margin: 0; }

/* ============ 标签 ============ */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.tag.ok { background: #e6f7e6; color: var(--green); }
.tag.ban { background: #ffe6e6; color: var(--red); }
.tag.warn { background: #fff3e0; color: var(--orange); }
.tag.gray { background: #f0f0f0; color: var(--text3); }
.tag.blue { background: #e8f1ff; color: var(--blue); }

/* ============ 提示消息 ============ */
.msg { font-size: 14px; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; display: none; }
.msg.ok { background: #f0fff0; color: #3B6D11; border: 1px solid #c0e0c0; display: block; }
.msg.err { background: #fff0f0; color: var(--red); border: 1px solid #f0c0c0; display: block; }

/* ============ 空状态 ============ */
.empty { color: var(--text3); text-align: center; padding: 40px 16px; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty::before { content: "📭"; font-size: 48px; line-height: 1; opacity: 0.35; }

/* ============ 底部操作栏（移动端悬浮）============ */
.fixed-bar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 -1px 8px rgba(0,0,0,0.06); }
.fixed-bar .total { flex: 1; font-size: 15px; }
.fixed-bar .total .num { color: var(--red); font-weight: 700; font-size: 18px; }
.fixed-bar .total .num small { font-size: 12px; }

/* ============ 倒计时 ============ */
.countdown { font-size: 14px; color: var(--orange); font-weight: 700; }
.countdown.urgent { color: var(--red); }

/* ============ 筛选条 ============ */
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar select, .filter-bar input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; background: #fff; }
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--red); }
.filter-bar input.search { flex: 1; min-width: 120px; }

/* 手机端：搜索框独占一行，筛选下拉+刷新在第二排 */
@media (max-width: 767px) {
    .filter-bar input.search { flex-basis: 100%; width: 100%; }
    .filter-bar select { flex: 1; min-width: 0; }
    .filter-bar .btn { flex-shrink: 0; }
}

/* ============ 分类导航（横向滚动）============ */
.cat-nav { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.cat-nav::-webkit-scrollbar { display: none; }
.cat-nav .chip { flex-shrink: 0; padding: 8px 16px; border-radius: 20px; background: #fff; border: 1px solid var(--border); font-size: 13px; color: var(--text2); white-space: nowrap; }
.cat-nav .chip.active { background: var(--red); color: #fff; border-color: var(--red); }

/* ============ 管理端 ============ */
.admin-wrap { max-width: 1080px; margin: 0 auto; padding: 16px; }
.admin-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 14px; scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs .tab { flex-shrink: 0; padding: 10px 18px; border-radius: 20px; background: #fff; border: 1px solid var(--border); font-size: 14px; color: var(--text2); white-space: nowrap; }
.admin-tabs .tab.active { background: var(--red); color: #fff; border-color: var(--red); }
.panel { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 12px; }

/* 统计 */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat-card .n { font-size: 24px; font-weight: 800; color: var(--red); }
.stat-card .l { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* 表格（电脑端） */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-light); white-space: nowrap; }
th { color: var(--text3); font-weight: 600; font-size: 13px; background: #fafafa; }
td .op { display: flex; gap: 6px; flex-wrap: wrap; }

/* 全选栏 */
.select-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 14px; color: var(--text2); flex-wrap: wrap; }
.select-bar label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.select-bar input { width: auto; }
.select-bar .rand-group { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.select-bar .rand-group input { width: 64px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; text-align: center; outline: none; }
.select-bar .rand-group input:focus { border-color: var(--red); }

/* 文件上传框 */
.upload-box { border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px; text-align: center; color: var(--text3); cursor: pointer; font-size: 14px; }
.upload-box:hover { border-color: var(--red); color: var(--red); }
.upload-box .file-name { color: var(--text2); margin-top: 8px; font-weight: 600; }

/* 隐藏工具类 + 响应式显示控制 */
.hidden { display: none !important; }
@media (max-width: 767px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: flex !important; }
}

/* ============ 响应式：电脑端 ============ */
@media (min-width: 768px) {
    .container { padding: 24px; }
    .book-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
    .book-card { padding: 18px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .login-card { padding: 48px 40px; }
    .desktop-only { display: flex !important; }
    .mobile-only { display: none !important; }
}

@media (min-width: 480px) and (max-width: 767px) {
    .book-grid { grid-template-columns: repeat(3, 1fr); }
}

.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-gray { color: var(--text3); }
.text-bold { font-weight: 700; }
