:root {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --sidebar: #1f2430;
    --sidebar-hover: #2b3242;
    --primary: #e5484d;
    --primary-dark: #c93a3f;
    --text: #1f2430;
    --muted: #8a93a5;
    --border: #e6e9f0;
    --ok: #17a673;
    --warn: #e8a33d;
    --fail: #e5484d;
    --info: #3b82c4;
    --off: #98a0b3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

a { text-decoration: none; color: inherit; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* ---------- 登录 ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #232838 0%, #343c50 100%);
}
.login-box {
    width: 360px;
    background: #fff;
    border-radius: 12px;
    padding: 36px 32px 28px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
}
.login-head { text-align: center; margin-bottom: 24px; }
.login-head .brand-logo { margin: 0 auto 12px; }
.login-head h1 { font-size: 19px; margin: 0 0 6px; }
.login-head p { margin: 0; color: var(--muted); font-size: 13px; }
.login-form label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.login-form input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}
.login-form input:focus { border-color: var(--primary); }
.login-form button {
    width: 100%;
    height: 42px;
    margin-top: 22px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
}
.login-form button:hover { background: var(--primary-dark); }
.login-tip { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: #c8cdd9;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.brand-text strong { display: block; color: #fff; font-size: 14px; }
.brand-text small { color: var(--muted); font-size: 11px; }

.menu { flex: 1; overflow-y: auto; padding: 12px 0; }
.menu a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 18px;
    font-size: 13.5px;
    color: #b6bdcc;
    transition: background .15s;
}
.menu a:hover { background: var(--sidebar-hover); color: #fff; }
.menu a.active { background: var(--primary); color: #fff; }
.menu .ico { font-style: normal; width: 16px; text-align: center; opacity: .85; }
.menu-group {
    padding: 16px 18px 6px;
    font-size: 11px;
    letter-spacing: .5px;
    color: #6d768a;
    text-transform: uppercase;
}
.sidebar-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    font-size: 12px;
}
.sidebar-foot .user { color: #9aa3b5; }
.sidebar-foot .foot-link { color: #6d768a; }
.sidebar-foot .foot-link:hover { color: var(--primary); }
.sidebar-foot .foot-links { display: flex; gap: 14px; align-items: center; }
.sidebar-foot .foot-links .ico { display: none; font-style: normal; font-size: 14px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 58px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar-right { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.topbar-right::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
}
.content { padding: 20px 22px 40px; }

/* ---------- 卡片 / 统计 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.stat-card.accent { border-left: 3px solid var(--primary); }
.stat-label { display: block; font-size: 12px; color: var(--muted); }
.stat-value { display: block; font-size: 26px; font-weight: 600; margin: 6px 0 4px; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ---------- 面板 ---------- */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 18px;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 14px; margin: 0; font-weight: 600; }
.panel-body { padding: 16px 18px; }
/* 表格容器：窄屏时可横向滚动，避免列被裁切 */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap > .table { min-width: max-content; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: left;
    font-weight: 500;
    color: var(--muted);
    font-size: 12px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; }
.table .empty { text-align: center; color: var(--muted); padding: 26px 0; }
.table .token { font-family: monospace; font-size: 11px; color: var(--muted); word-break: break-all; max-width: 160px; }
.ops { white-space: nowrap; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11.5px;
    line-height: 18px;
    white-space: nowrap;
}
.badge.ok { background: rgba(23, 166, 115, .12); color: var(--ok); }
.badge.warn { background: rgba(232, 163, 61, .14); color: var(--warn); }
.badge.fail { background: rgba(229, 72, 77, .12); color: var(--fail); }
.badge.info { background: rgba(59, 130, 196, .12); color: var(--info); }
.badge.off { background: #eef0f4; color: var(--off); }

.link { color: var(--info); margin-right: 10px; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--fail); }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.search-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

input[type="text"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.inline-input { width: 100%; min-width: 160px; }

button, .btn {
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}
button:hover, .btn:hover { border-color: #cfd5e0; }
.btn.primary, button[type="submit"] {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn.primary:hover, button[type="submit"]:hover { background: var(--primary-dark); }

.tabs { display: flex; gap: 6px; }
.tabs a {
    padding: 6px 13px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--border);
}
.tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.pager { padding: 6px 0 20px; }
.pager ul { list-style: none; padding: 0; margin: 0; display: flex; gap: 5px; }
.pager li a, .pager li span {
    display: inline-block;
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    font-size: 13px;
}
.pager li span.current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 弹窗 ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 33, .5);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.show { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 10px;
    width: 440px;
    max-width: 100%;
    max-height: 88vh;
    overflow-y: auto;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-close { cursor: pointer; font-size: 22px; color: var(--muted); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; }
.modal-foot { margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }

.field { display: block; margin-bottom: 13px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select { width: 100%; }

.qrcode-box { text-align: center; padding: 10px 0; }
.qrcode-box img { width: 190px; height: 190px; border: 1px solid var(--border); border-radius: 8px; }
.qrcode-tip { font-size: 13px; color: var(--muted); margin-top: 10px; }
.qrcode-tip.ok { color: var(--ok); }
.qrcode-tip.fail { color: var(--fail); }

.code-area {
    width: 100%;
    height: auto;
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.6;
    border-radius: 6px;
}
.form-actions { margin-top: 14px; }
.doc-list { margin: 8px 0 0; padding-left: 20px; font-size: 13px; line-height: 2; color: var(--text); }

/* ---------- 提示 ---------- */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(31, 36, 48, .93);
    color: #fff;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 200;
    display: none;
}
.toast.show { display: block; }
.toast.ok { background: rgba(23, 166, 115, .95); }
.toast.fail { background: rgba(229, 72, 77, .95); }

@media (max-width: 860px) {
    .sidebar { width: 62px; }
    .brand-text,
    .menu a .txt,
    .menu-group,
    .sidebar-foot .user,
    .sidebar-foot .foot-links .txt { display: none; }
    .menu a { justify-content: center; padding: 12px 0; }
    .menu .ico { font-size: 17px; }
    .sidebar-foot { justify-content: center; padding: 12px 0; }
    /* 窄栏放不下中文，底栏改用图标 + title 提示 */
    .sidebar-foot .foot-links { gap: 16px; }
    .sidebar-foot .foot-links .ico { display: inline-block; }
    .sidebar-foot .foot-links a { display: inline-flex; align-items: center; justify-content: center; }
}
