/* 每日学汉字 · 后台样式（无框架，一个人维护不需要再引一层抽象） */

:root {
    --ink: #23282d;
    --ink-2: #5b6570;
    --ink-3: #8b949e;
    --line: #e6e2dc;
    --bg: #f6f4f0;
    --card: #ffffff;
    --accent: #b5523a;
    --accent-soft: #fbeee9;
    --green: #2f7a52;
    --green-soft: #e8f4ec;
    --amber: #9a6b12;
    --amber-soft: #fdf3df;
    --red: #b03a2e;
    --red-soft: #fbeceb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(35, 40, 45, 0.06), 0 8px 24px rgba(35, 40, 45, 0.04);
}

* {
    box-sizing: border-box;
}

/*
 * hidden 必须压住一切 display 声明。
 * 教训：.modal 是 display:flex（居中弹窗），而 [hidden] 的 UA 样式优先级最低，
 * 结果页面一打开那个「空弹窗」就带着全屏遮罩盖在最上层，鼠标点哪儿都没反应。
 */
[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.01em;
}

button {
    font-family: inherit;
}

/* ---------------- 登录 ---------------- */

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 0%, #fffdf9 0%, #f3efe8 70%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 36px 32px 28px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    font-size: 30px;
    line-height: 56px;
    font-weight: 600;
}

.login-card h1 {
    font-size: 19px;
}

.login-sub {
    margin: 6px 0 26px;
    color: var(--ink-3);
    font-size: 13px;
}

.field {
    display: block;
    text-align: left;
    margin-bottom: 14px;
}

.field > span {
    display: block;
    font-size: 12px;
    color: var(--ink-2);
    margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-foot {
    margin-top: 18px;
    color: var(--ink-3);
    font-size: 12px;
}

.form-error {
    margin: 12px 0 0;
    color: var(--red);
    font-size: 13px;
    /* 错误里会带「请求地址 / 页面地址」两行，要能换行显示 */
    white-space: pre-line;
    word-break: break-all;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 58px;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.brand i {
    font-style: normal;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 500;
    vertical-align: 1px;
}

.tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.tab {
    border: 0;
    background: transparent;
    padding: 7px 12px;
    border-radius: 7px;
    color: var(--ink-2);
    font-size: 13.5px;
    cursor: pointer;
    white-space: nowrap;
}

.tab:hover {
    background: #f0ece5;
    color: var(--ink);
}

.tab.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.who {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.who-name {
    color: var(--ink-3);
    font-size: 12.5px;
}

/* ---------------- 通用 ---------------- */

.view {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 24px 64px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.card-head h2 {
    font-size: 14.5px;
}

.card-head .hint {
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 400;
}

.card-body {
    padding: 16px 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 13.5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover {
    background: #faf8f4;
    border-color: #d8d2c8;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: #9e4630;
    border-color: #9e4630;
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--ink-2);
}

.btn-ghost:hover {
    background: #f0ece5;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
    border-radius: 6px;
}

.btn-danger {
    color: var(--red);
    border-color: #e8c9c5;
    background: #fff;
}

.btn-danger:hover {
    background: var(--red-soft);
}

.btn-block {
    width: 100%;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.toolbar input[type='text'],
.toolbar input[type='search'],
.toolbar select {
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-size: 13.5px;
    color: var(--ink);
    outline: none;
}

.toolbar input:focus,
.toolbar select:focus {
    border-color: var(--accent);
}

.toolbar .grow {
    flex: 1;
}

/* ---------------- 概览 ---------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.stat .label {
    color: var(--ink-3);
    font-size: 12.5px;
}

.stat .value {
    margin-top: 4px;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.stat .sub {
    margin-top: 2px;
    color: var(--ink-3);
    font-size: 12px;
}

.stat.accent .value {
    color: var(--accent);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
}

@media (max-width: 900px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .topbar {
        gap: 12px;
        padding: 0 14px;
        overflow-x: auto;
    }
    .view {
        padding: 16px 14px 48px;
    }
}

.chart-box {
    padding: 8px 6px 0;
}

.chart-legend {
    display: flex;
    gap: 16px;
    padding: 0 12px 10px;
    color: var(--ink-3);
    font-size: 12px;
}

.chart-legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: -1px;
}

/* ---------------- 表格 ---------------- */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

th {
    text-align: left;
    font-weight: 500;
    color: var(--ink-3);
    font-size: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    background: #fcfbf9;
}

td {
    padding: 11px 12px;
    border-bottom: 1px solid #f1eee9;
    vertical-align: middle;
}

tbody tr:hover {
    background: #fcfbf8;
}

tbody tr.is-clickable {
    cursor: pointer;
}

td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.muted {
    color: var(--ink-3);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

.tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 20px;
    font-size: 11.5px;
    line-height: 1.7;
    white-space: nowrap;
}

.tag-free {
    background: #f0eee9;
    color: var(--ink-2);
}

.tag-pro {
    background: var(--amber-soft);
    color: var(--amber);
}

.tag-on {
    background: var(--green-soft);
    color: var(--green);
}

.tag-off {
    background: #f0eee9;
    color: var(--ink-3);
}

.tag-err {
    background: var(--red-soft);
    color: var(--red);
}

.zi {
    display: inline-block;
    min-width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fdfbf7;
    font-size: 19px;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px;
    color: var(--ink-3);
    font-size: 12.5px;
    border-top: 1px solid var(--line);
}

.empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--ink-3);
    font-size: 13px;
}

.loading {
    padding: 40px 16px;
    text-align: center;
    color: var(--ink-3);
    font-size: 13px;
}

/* ---------------- 弹层 ---------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(30, 30, 32, 0.36);
}

.modal-box {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(20, 20, 22, 0.24);
}

.modal-box.wide {
    max-width: 760px;
}

/* 用户头像：小程序存的是卡通 emoji（emoji:🦊），后台按码点算同一个底色，
 * 保证运营在后台看到的头像和用户手机上完全一致 */
.uav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--line);
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
    overflow: hidden;
    vertical-align: middle;
}

.uav img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 没设头像的退路：昵称首字，字号要小一点才塞得下 */
.uav-text {
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 500;
}

.uav-lg {
    width: 44px;
    height: 44px;
    font-size: 26px;
}

.uav-lg.uav-text {
    font-size: 18px;
}

/* 表格里「头像 + 昵称」的一行，两处列表和订单共用 */
.uname {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.modal-id {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--line);
}

.modal-head h3 {
    font-size: 15px;
}

.modal-head .sub {
    color: var(--ink-3);
    font-size: 12px;
    margin-top: 2px;
}

.modal-body {
    padding: 16px 20px 20px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 20px 18px;
}

.close-x {
    border: 0;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: var(--ink-3);
    cursor: pointer;
    padding: 4px;
}

.kv {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.kv .k {
    color: var(--ink-3);
    font-size: 12px;
}

.kv .v {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.section-title {
    margin: 18px 0 8px;
    font-size: 12.5px;
    color: var(--ink-3);
    letter-spacing: 0.04em;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 2px 9px;
    border-radius: 6px;
    background: #f5f2ec;
    font-size: 13px;
}

.chip b {
    font-weight: 500;
}

.chip small {
    color: var(--ink-3);
    margin-left: 4px;
    font-size: 11px;
}

.notice {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 12.5px;
    line-height: 1.55;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%);
    z-index: 90;
    max-width: 80vw;
    padding: 10px 16px;
    border-radius: 10px;
    background: #2b2f33;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.toast.is-error {
    background: #8f3026;
}

.row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.nowrap {
    white-space: nowrap;
}
