:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }

/* 顶部导航 */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 720px; margin: 0 auto; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; }
.topbar-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.nav-link { color: var(--muted); font-size: 14px; padding: 6px 2px; }
.nav-link:hover { color: var(--primary); }
.nav-exit { color: var(--danger); }
.user-chip { background: #eff6ff; color: var(--primary); border-radius: 999px; padding: 3px 10px; font-size: 13px; }

.page { max-width: 720px; margin: 0 auto; padding: 16px 14px 40px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-title { margin: 0 0 12px; font-size: 18px; }

/* 表单 */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=search], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 15px; font-family: inherit; background: #fff; color: var(--text); min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 42px; padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
    font-size: 15px; font-family: inherit; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-link { background: transparent; color: var(--primary); padding: 4px 0; min-height: 32px; }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.search-form { display: grid; grid-template-columns: 1fr 120px auto; gap: 8px; }
.search-form .btn { white-space: nowrap; }
.result-count { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* 数据库查看表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.db-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.db-table th, .db-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.db-table th { background: #f9fafb; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
.db-table td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.db-table tr:hover td { background: #f9fafb; }

/* 提示 */
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* 记录卡片 */
.record-list { display: grid; gap: 12px; }
.record-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.record-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.seq { font-size: 12px; color: var(--muted); background: #f3f4f6; border-radius: 6px; padding: 2px 8px; }
.name { font-weight: 700; font-size: 17px; }
.tag { font-size: 12px; color: var(--primary); background: #eff6ff; border-radius: 999px; padding: 2px 10px; }
.record-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 0 0 10px; font-size: 14px; }
.record-meta > div { min-width: 0; }
.record-meta .span-2 { grid-column: 1 / -1; }
.record-meta dt { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.record-meta dd { margin: 0; word-break: break-all; }
.remark-block { border-top: 1px dashed var(--border); padding-top: 10px; }
.remark-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.remark-view { font-size: 14px; margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.remark-edit textarea { margin-bottom: 8px; }
.remark-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-msg { font-size: 12px; color: var(--muted); }
.remark-history { margin-top: 10px; border-top: 1px dashed #fecaca; padding-top: 8px; }
.history-item { padding: 6px 0; border-bottom: 1px dotted #f3f4f6; font-size: 13px; }
.history-item:last-child { border-bottom: none; }
.history-user { color: #dc2626; font-weight: 500; }
.history-time { color: var(--muted); font-size: 12px; margin-left: 8px; }
.history-text { color: #4b5563; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.pager-info { font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); background: var(--card); border-radius: var(--radius); border: 1px dashed var(--border); }
.notice { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 28px 18px; text-align: center; color: #1e40af; }
.notice-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.notice p { margin: 0; font-size: 14px; line-height: 1.8; }

/* 登录页 */
.auth-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 20px 0; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 28px 22px; }
.auth-logo { text-align: center; font-size: 20px; font-weight: 700; }
.auth-sub { text-align: center; color: var(--muted); margin: 4px 0 22px; font-size: 14px; }
/* 导入页 */
.tips { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.tips h2 { font-size: 14px; margin: 0 0 6px; color: var(--text); }
.tips p { margin: 4px 0 10px; }
.tips code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; }
.error-detail { margin-bottom: 12px; font-size: 13px; }
.error-detail summary { cursor: pointer; color: var(--primary); }
.error-detail ul { max-height: 220px; overflow: auto; padding-left: 20px; }
.foot { text-align: center; color: #9ca3af; font-size: 12px; padding: 0 0 24px; }

/* 账号管理 */
.account-section { margin-bottom: 20px; }
.account-section h2 { font-size: 15px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.user-row { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.user-row summary { cursor: pointer; padding: 10px 12px; font-size: 14px; }
.user-role { font-size: 12px; color: var(--primary); background: #eff6ff; border-radius: 999px; padding: 2px 8px; margin-left: 8px; }
.user-body { padding: 0 12px 12px; border-top: 1px dashed var(--border); }
.user-meta { font-size: 12px; color: var(--muted); }
.inline-form { margin-top: 10px; }
.inline-form .btn { margin-right: 8px; }
.danger-zone { border-top: 1px dashed var(--border); margin-top: 12px; padding-top: 10px; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }

/* 手机适配 */
@media (max-width: 560px) {
    .search-form { grid-template-columns: 1fr 1fr; }
    .search-form input[type=search] { grid-column: 1 / -1; }
    .topbar-inner { padding: 10px 12px; }
    .brand { font-size: 14px; }
    .page { padding: 12px 10px 32px; }
    .record-meta { grid-template-columns: 1fr; }
}
