* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
    font-size: 14px; color: #1f2937; background: #f5f7fa;
    -webkit-font-smoothing: antialiased;
}
.muted { color: #8a94a6; }
.small { font-size: 12px; }
.hidden { display: none !important; }
code { background: #eef2f7; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
    height: 72px; background: #fff; border-bottom: 1px solid #e6eaf0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
    width: 42px; height: 42px; border-radius: 10px;
    background: #2f5d45; color: #fff; font-size: 22px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: 1px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: #8a94a6; }
.status { font-size: 13px; display: flex; align-items: center; gap: 12px; }
.status b { color: #1769e0; }

/* ---------- Tab ---------- */
.tabs {
    display: flex; gap: 4px; background: #fff; padding: 0 24px;
    border-bottom: 1px solid #e6eaf0; overflow-x: auto;
}
.tabs button {
    border: 0; background: transparent; padding: 14px 18px; font-size: 14px;
    color: #5b6472; cursor: pointer; border-bottom: 3px solid transparent;
    white-space: nowrap; font-family: inherit;
}
.tabs button:hover { color: #1769e0; background: #f7f9fc; }
.tabs button.active { color: #1769e0; font-weight: 600; border-bottom-color: #1769e0; }

main { padding: 22px 26px 40px; }
.panel { display: none; }
.panel.active { display: block; }

/* ---------- 通用组件 ---------- */
.card {
    background: #fff; border: 1px solid #e6eaf0; border-radius: 12px;
    padding: 20px; box-shadow: 0 2px 10px rgba(30, 50, 80, .04); margin-bottom: 18px;
}
.card h2 { margin: 0 0 16px; font-size: 16px; }
.card h3 { margin: 18px 0 10px; font-size: 14px; color: #5b6472; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.btn {
    border: 1px solid #d5dce6; background: #fff; color: #334155;
    padding: 9px 16px; border-radius: 8px; cursor: pointer;
    font-size: 14px; font-family: inherit; white-space: nowrap;
}
.btn:hover { border-color: #1769e0; color: #1769e0; }
.btn.primary { background: #1769e0; border-color: #1769e0; color: #fff; font-weight: 600; }
.btn.primary:hover { background: #1259c4; }
.btn.ghost { background: transparent; border-style: dashed; color: #6b7280; }
.btn.danger { color: #dc2626; border-color: #f0c2c2; }
.btn.danger:hover { background: #fef2f2; }
.btn.mini { padding: 4px 9px; font-size: 12px; border-radius: 6px; }

input, select {
    font-family: inherit; font-size: 14px; color: #1f2937;
    border: 1px solid #d5dce6; border-radius: 8px; padding: 9px 11px;
    background: #fff; outline: none; width: 100%;
}
input:focus, select:focus { border-color: #1769e0; box-shadow: 0 0 0 3px rgba(23,105,224,.12); }
input[type="checkbox"] { width: auto; margin-right: 6px; vertical-align: middle; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #5b6472; }
.form-grid label em { color: #dc2626; font-style: normal; }
.form-grid label.check { flex-direction: row; align-items: center; color: #334155; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.tip {
    margin-top: 14px; padding: 10px 12px; border-radius: 8px;
    background: #f0f6ff; color: #1d4ed8; font-size: 12px; line-height: 1.6;
}
.tip:empty { display: none; }

/* ---------- 扫码区 ---------- */
.scan-hero {
    background: linear-gradient(120deg, #eef4ff 0%, #f3faf6 100%);
    border: 1px solid #dbe6f5; border-radius: 12px;
    padding: 20px 22px; margin-bottom: 18px;
}
.scan-hint { font-size: 14px; color: #42526b; margin-bottom: 12px; }
.scan-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.scan-input {
    flex: 1 1 320px; min-width: 220px; font-size: 20px; letter-spacing: 1px;
    padding: 13px 16px; border: 2px solid #1769e0; border-radius: 10px;
    font-weight: 600; width: auto;
}
.scan-input::placeholder { font-size: 15px; font-weight: 400; letter-spacing: 0; color: #9aa6b8; }
.scan-input:focus { border-color: #0f4fae; box-shadow: 0 0 0 4px rgba(23,105,224,.14); }
.scan-row .input { flex: 0 1 190px; width: auto; }
.scan-row .input.narrow { flex: 0 0 100px; }
.scan-meta { display: flex; align-items: center; gap: 20px; margin-top: 12px; font-size: 12px; color: #5b6472; flex-wrap: wrap; }
.scan-meta label { display: flex; align-items: center; gap: 2px; cursor: pointer; }

/* ---------- 封面 / 最近 ---------- */
.cover-box {
    height: 210px; border: 1px dashed #d5dce6; border-radius: 10px;
    background: #fafbfd; display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.cover-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.recent { list-style: none; margin: 0; padding: 0; max-height: 230px; overflow-y: auto; }
.recent li { padding: 8px 0; border-bottom: 1px solid #f0f2f6; font-size: 13px; }
.recent li:last-child { border-bottom: 0; }
.recent .r-title { color: #1f2937; }
.recent .r-meta { color: #9aa6b8; font-size: 11px; margin-left: 6px; }

/* ---------- 工具栏 / 表格 ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { flex: 1 1 320px; width: auto; }
.toolbar .muted { font-size: 13px; }
.table-wrap { overflow: auto; max-height: 62vh; border: 1px solid #edf0f4; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    position: sticky; top: 0; background: #f7f9fc; color: #5b6472;
    font-weight: 600; text-align: left; padding: 10px 12px;
    border-bottom: 1px solid #e6eaf0; white-space: nowrap; z-index: 1;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
tbody tr:hover { background: #f9fbff; }
tbody tr:last-child td { border-bottom: 0; }
.thumb { width: 32px; height: 44px; object-fit: cover; border-radius: 4px; background: #eef2f7; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; }
.tag.ok { background: #e8f6ee; color: #1a7f4b; }
.tag.warn { background: #fff3e0; color: #b45309; }
.tag.gray { background: #eef1f5; color: #64748b; }
.empty { padding: 40px; text-align: center; color: #9aa6b8; }

/* ---------- 统计 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
    background: #fff; border: 1px solid #e6eaf0; border-radius: 12px;
    padding: 18px 20px; box-shadow: 0 2px 10px rgba(30,50,80,.04);
}
.stat .label { font-size: 12px; color: #8a94a6; }
.stat .value { font-size: 28px; font-weight: 700; color: #1769e0; margin-top: 6px; }
.stat .unit { font-size: 12px; color: #9aa6b8; font-weight: 400; margin-left: 4px; }
.bars .bar-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; font-size: 13px; }
.bars .bar-row > span { flex: 0 0 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #5b6472; }
.bars .bar { flex: 1; background: #eef2f7; border-radius: 6px; height: 14px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: linear-gradient(90deg, #1769e0, #4d9bff); border-radius: 6px; }
.bars .bar-row b { flex: 0 0 45px; text-align: right; color: #334155; }

/* ---------- 导出 ---------- */
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 16px; }
.export-item { border: 1px solid #e6eaf0; border-radius: 10px; padding: 14px; }
.export-item h3 { margin: 0 0 6px; font-size: 14px; }
.export-item p { margin: 0 0 12px; font-size: 12px; }

/* ---------- Toast / Modal ---------- */
.toast {
    position: fixed; right: 24px; bottom: 24px; z-index: 100;
    background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 8px;
    font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
    opacity: 0; transform: translateY(10px); pointer-events: none;
    transition: opacity .2s, transform .2s; max-width: 420px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b91c1c; }
.toast.warn { background: #b45309; }
.modal-mask {
    position: fixed; inset: 0; background: rgba(20,30,45,.45); z-index: 90;
    display: flex; align-items: center; justify-content: center;
}
.modal {
    background: #fff; border-radius: 14px; padding: 24px; width: 640px;
    max-width: 92vw; max-height: 88vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.22);
}
.modal h2 { margin: 0 0 18px; font-size: 17px; }

/* ---------- 登录 ---------- */
.login-wrap {
    min-height: 100%; display: flex; align-items: center; justify-content: center;
    padding: 32px 16px;
}
.login-card {
    width: 100%; max-width: 400px; background: #fff; border: 1px solid #e6eaf0;
    border-radius: 14px; padding: 26px 28px 28px;
    box-shadow: 0 12px 32px rgba(31, 41, 55, .08);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand h1 { margin: 0; font-size: 20px; }
.login-brand p { margin: 2px 0 0; font-size: 12px; color: #8a94a6; }
.login-step { display: flex; flex-direction: column; gap: 14px; }
.login-step .form-actions { margin-top: 4px; flex-direction: column; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #5b6472; }
.field em { color: #dc2626; font-style: normal; }
.otp { letter-spacing: 6px; font-size: 18px; text-align: center; }
.login-register {
    display: flex; flex-direction: column; gap: 14px;
    padding: 14px; border: 1px dashed #d5dce6; border-radius: 10px;
}
.login-error {
    margin: 0; padding: 9px 12px; border-radius: 8px;
    background: #fef2f2; color: #b91c1c; font-size: 13px; line-height: 1.5;
}
.btn.block { width: 100%; }
input[readonly] { background: #f5f7fa; color: #5b6472; }

/* 登录方式切换 */
.login-tabs {
    display: flex; gap: 4px; margin: 4px 0 18px;
    border-bottom: 1px solid #e6eaf0;
}
.login-tabs button {
    border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px;
    color: #8a94a6; padding: 9px 12px; border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.login-tabs button:hover { color: #1769e0; }
.login-tabs button.active { color: #1769e0; font-weight: 600; border-bottom-color: #1769e0; }
