/* ============================================================
   Idmanos 管理后台样式
   与主站同一套语言：白底、细线、无阴影、克制
   ============================================================ */
:root {
    --bg: #fafafa;
    --sheet: #fff;
    --ink: #1b1b1b;
    --muted: #8f8f8f;
    --faint: #a8a8a8;
    --line: #e8e8e8;
    --line-soft: #f0f0f0;
    --danger: #b3261e;
    --ok: #1f7a4d;
    --warn: #8a6d1f;
    --radius: 10px;
}

* { box-sizing: border-box; }

/* 后台大量元素用 display:flex/grid，会覆盖 [hidden] 的 display:none —— 必须显式兜底 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body.adm {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

/* ---------- 登录 ---------- */
.adm-login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.adm-login {
    width: 100%; max-width: 380px; background: var(--sheet);
    border: 1px solid var(--line); border-radius: 14px; padding: 30px 26px;
}
.adm-login .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.adm-login .brand img { height: 20px; width: auto; }
.adm-login .brand span { font-size: 11px; letter-spacing: .18em; color: var(--faint); }
.adm-login h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.adm-login p.hint { margin: 0 0 20px; font-size: 12.5px; line-height: 1.7; color: var(--muted); }

.adm-field { margin-bottom: 14px; }
.adm-field label {
    display: block; font-size: 11.5px; letter-spacing: .06em;
    color: var(--muted); margin-bottom: 6px; text-transform: uppercase;
}
.adm-input, .adm-select, .adm-textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 8px; background: #fff; outline: none; transition: border-color .18s;
}
.adm-input:focus, .adm-select:focus, .adm-textarea:focus { border-color: var(--ink); }
.adm-textarea { min-height: 90px; resize: vertical; line-height: 1.65; }

.adm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: 999px; border: 1px solid transparent;
    background: var(--ink); color: #fff; font-size: 13px; font-weight: 500;
    transition: opacity .18s, background .18s;
    text-decoration: none;
}
.adm-btn:hover { opacity: .86; }
.adm-btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.adm-btn.ghost:hover { border-color: var(--ink); opacity: 1; }
.adm-btn.sm { padding: 6px 12px; font-size: 12px; }
.adm-btn.danger { background: #fff; color: var(--danger); border-color: #e6cbc9; }
.adm-btn.danger:hover { background: #fdf4f3; opacity: 1; }
.adm-btn.block { width: 100%; }
.adm-btn[disabled] { opacity: .45; cursor: not-allowed; }

.adm-msg { margin-top: 12px; font-size: 12.5px; line-height: 1.6; }
.adm-msg.err { color: var(--danger); }
.adm-msg.ok { color: var(--ok); }

/* ---------- 主框架 ---------- */
.adm-shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }

.adm-side {
    border-right: 1px solid var(--line); background: var(--sheet);
    padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.adm-side .brand { display: flex; align-items: center; gap: 9px; padding: 0 6px 18px; }
.adm-side .brand img { height: 17px; }
.adm-side .brand em { font-style: normal; font-size: 10px; letter-spacing: .16em; color: var(--faint); }
.adm-nav { display: flex; flex-direction: column; gap: 2px; }
.adm-nav button {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px;
    font-size: 13.5px; color: #4a4a4a; text-align: left; transition: background .16s, color .16s;
}
.adm-nav button:hover { background: #f5f5f5; color: var(--ink); }
.adm-nav button.on { background: var(--ink); color: #fff; }
.adm-nav .sep { height: 1px; background: var(--line-soft); margin: 10px 6px; }
.adm-nav .grp { font-size: 10.5px; letter-spacing: .12em; color: var(--faint); padding: 10px 10px 4px; }

.adm-main { min-width: 0; display: flex; flex-direction: column; }
.adm-top {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 16px 26px; border-bottom: 1px solid var(--line); background: rgba(250, 250, 250, .92);
    backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20;
}
.adm-top h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.adm-top .who { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); }
.adm-body { padding: 22px 26px 60px; }

/* 顶部警告条 */
.adm-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    border: 1px solid #efe2bf; background: #fdf9ee; color: #6f5a17;
    border-radius: 10px; padding: 11px 14px; font-size: 12.5px; line-height: 1.6; margin-bottom: 18px;
}
.adm-banner button {
    border: 1px solid #e0cf9a; background: #fff; border-radius: 999px;
    padding: 5px 12px; font-size: 12px; color: #6f5a17; white-space: nowrap;
}

/* ---------- 卡片 / 统计 ---------- */
.adm-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.adm-card {
    background: var(--sheet); border: 1px solid var(--line); border-radius: 12px;
    padding: 15px 16px; min-width: 0;
}
.adm-card .k { font-size: 11px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.adm-card .v { font-size: 25px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.adm-card .s { font-size: 11.5px; color: var(--faint); margin-top: 6px; }

.adm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.adm-panel {
    background: var(--sheet); border: 1px solid var(--line); border-radius: 12px;
    padding: 16px 18px; margin-bottom: 16px; min-width: 0;
}
.adm-panel h3 { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: .02em; }

/* 简易柱状图 */
.adm-bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 8px; }
.adm-bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; }
.adm-bars .bar i { display: block; width: 100%; background: var(--ink); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .82; }
.adm-bars .bar b { font-size: 9.5px; color: var(--faint); font-weight: 400; white-space: nowrap; }

/* ---------- 工具条 ---------- */
.adm-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.adm-tools .grow { flex: 1; min-width: 160px; }
.adm-tools .adm-input, .adm-tools .adm-select { padding: 8px 11px; }
.adm-tools .adm-select { width: auto; min-width: 120px; }

/* ---------- 表格 ---------- */
.adm-table-wrap { background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.adm-table th, .adm-table td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.adm-table th { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: #fcfcfc; white-space: nowrap; }
.adm-table tr:last-child td { border-bottom: 0; }
.adm-table tr:hover td { background: #fcfcfc; }
.adm-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.adm-table td.acts { text-align: right; white-space: nowrap; }
.adm-table .thumb {
    width: 42px; height: 42px; border-radius: 7px; object-fit: cover;
    background: #f2f2f2; border: 1px solid var(--line); display: block;
}
.adm-table .thumb-empty {
    width: 42px; height: 42px; border-radius: 7px; background: #f7f7f7;
    border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: var(--faint);
}
.adm-table .t { font-weight: 500; }
.adm-table .d { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

.adm-tag {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    border: 1px solid var(--line); font-size: 11px; color: #5f5f5f; white-space: nowrap;
}
.adm-tag.active, .adm-tag.paid, .adm-tag.sent, .adm-tag.ok { border-color: #bfe0cd; color: var(--ok); background: #f5fbf7; }
.adm-tag.hidden, .adm-tag.pending { border-color: #eee0bf; color: var(--warn); background: #fdfaef; }
.adm-tag.deleted, .adm-tag.failed, .adm-tag.refunded, .adm-tag.disabled { border-color: #e6cbc9; color: var(--danger); background: #fdf5f4; }

.adm-empty { padding: 44px 20px; text-align: center; color: var(--faint); font-size: 13px; }
.adm-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted); }

/* ---------- 抽屉 / 弹窗 ---------- */
.adm-overlay {
    position: fixed; inset: 0; background: rgba(20, 20, 20, .28);
    opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 100;
}
.adm-overlay.on { opacity: 1; pointer-events: auto; }
.adm-drawer {
    position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw);
    background: #fff; border-left: 1px solid var(--line); z-index: 101;
    transform: translateX(100%); transition: transform .26s cubic-bezier(.22, .61, .36, 1);
    display: flex; flex-direction: column;
}
.adm-drawer.on { transform: translateX(0); }
.adm-drawer header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.adm-drawer header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.adm-drawer .body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.adm-drawer footer { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }
.adm-icon-btn { border: 0; background: none; font-size: 18px; color: var(--muted); line-height: 1; padding: 4px 6px; }
.adm-icon-btn:hover { color: var(--ink); }

.adm-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 上传预览 */
.adm-upload {
    display: flex; align-items: center; gap: 14px; padding: 12px;
    border: 1px dashed var(--line); border-radius: 10px; background: #fcfcfc;
}
.adm-upload .pv {
    width: 78px; height: 78px; border-radius: 9px; object-fit: cover;
    background: #f2f2f2; border: 1px solid var(--line); flex: none;
}
.adm-upload .pv.empty { border-style: dashed; background: #f8f8f8; }
.adm-upload .meta { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
.adm-upload .meta code { font-size: 11px; color: var(--faint); word-break: break-all; }

/* 提示条 */
.adm-toast {
    position: fixed; left: 50%; top: 22px; transform: translate(-50%, -12px);
    background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px;
    font-size: 13px; opacity: 0; pointer-events: none; transition: .22s; z-index: 300;
    box-shadow: 0 8px 26px rgba(0, 0, 0, .16); max-width: 88vw; text-align: center;
}
.adm-toast.on { opacity: 1; transform: translate(-50%, 0); }
.adm-toast.err { background: #7a1f18; }

/* 空状态占位 */
.adm-loading { padding: 50px; text-align: center; color: var(--faint); font-size: 13px; }

/* Gumroad 页 */
.adm-sec { max-width: 760px; }
.adm-kv { display: flex; gap: 10px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.adm-kv .k { width: 130px; color: var(--muted); flex: none; }
.adm-kv .v { word-break: break-all; }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
    .adm-shell { grid-template-columns: 1fr; }
    .adm-side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px; }
    .adm-nav { flex-direction: row; overflow-x: auto; gap: 6px; }
    .adm-nav button { white-space: nowrap; width: auto; }
    .adm-nav .sep, .adm-nav .grp { display: none; }
    .adm-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .adm-grid2 { grid-template-columns: 1fr; }
    .adm-body { padding: 16px 16px 60px; }
    .adm-top { padding: 14px 16px; }
}

@media (max-width: 640px) {
    .adm-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
    .adm-card { padding: 12px; }
    .adm-card .v { font-size: 20px; }
    .adm-table-wrap { overflow-x: auto; }
    .adm-table { min-width: 620px; }
    .adm-form-row { grid-template-columns: 1fr; }
    .adm-top h2 { font-size: 15px; }
    .adm-top .who .mail { display: none; }
}

/* 图库选择网格 */
.adm-r2grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px;
}
.adm-r2cell {
    display: flex; flex-direction: column; gap: 5px; padding: 0; border: 1px solid var(--line);
    border-radius: 9px; overflow: hidden; background: #fff; cursor: pointer; text-align: left;
    transition: border-color .16s, transform .16s;
}
.adm-r2cell:hover { border-color: var(--ink); transform: translateY(-2px); }
.adm-r2cell img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: #f4f4f4; }
.adm-r2cell span {
    font-size: 10.5px; color: var(--muted); padding: 4px 6px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 640px) { .adm-r2grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
