/* ============================================================
   后台管理 — 样式
   与前台同一套变量，偏工具向
   ============================================================ */

[hidden] {
    display: none !important;
}

body.adm {
    background: var(--bg);
}

/* ---------- 表单基础 ---------- */

.field {
    display: block;
    min-width: 0;
}

.field>span {
    display: block;
    margin-bottom: 5px;
    font-size: 11px;
    letter-spacing: .02em;
    color: var(--muted);
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
    -webkit-appearance: none;
    appearance: none;
}

textarea {
    resize: vertical;
    min-height: 56px;
}

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

select {
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 28px;
    cursor: pointer;
}

/* ---------- 按钮 ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 33px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: .01em;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .2s var(--ease), border-color .2s var(--ease),
        color .2s var(--ease), opacity .2s var(--ease);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: .55;
    cursor: default;
    transform: none;
}

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

.btn-primary:hover:not(:disabled) {
    background: #000;
}

.btn-ghost {
    background: #fff;
    border-color: var(--line-strong);
    color: var(--ink-2);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--ink-2);
    color: var(--ink);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    height: 25px;
    min-width: 25px;
    padding: 0 7px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fff;
    color: var(--muted);
    font-family: inherit;
    font-size: 11.5px;
    line-height: 1;
    cursor: pointer;
    transition: color .2s var(--ease), border-color .2s var(--ease),
        background-color .2s var(--ease);
}

.btn-icon:hover {
    color: var(--ink);
    border-color: var(--ink-2);
}

.btn-icon.danger:hover {
    color: #b3362b;
    border-color: #e7b6af;
    background: #fdf5f4;
}

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

.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 342px;
    padding: 28px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 30px 70px -46px rgba(22, 22, 26, .5);
}

.login-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 16px;
    border-radius: 11px;
    background: var(--ink);
}

.login-mark .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
}

.login-card h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -.02em;
}

.login-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.login-card .field {
    margin-top: 20px;
}

.login-card .btn-block {
    margin-top: 6px;
}

.login-back {
    display: block;
    margin-top: 16px;
    text-align: center;
    font-size: 11.5px;
    color: var(--muted);
}

.login-back:hover {
    color: var(--ink-2);
}

.form-error {
    min-height: 15px;
    margin: 8px 0 4px;
    font-size: 11.5px;
    line-height: 1.5;
    color: #b3362b;
}

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

.adm-top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(247, 246, 243, .88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.adm-top .inner {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 920px;
    margin: 0 auto;
    padding: 0 24px;
    height: 58px;
}

.adm-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .05em;
    color: var(--ink-2);
}

.adm-brand .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.save-state {
    font-size: 11.5px;
    color: var(--muted);
}

.save-state.is-dirty {
    color: var(--accent);
}

.adm-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* ---------- 主体 ---------- */

.adm-main {
    max-width: 920px;
    margin: 0 auto;
    padding: 22px 24px 64px;
}

.adm-note {
    margin: 0 0 14px;
    padding: 11px 14px;
    border: 1px solid #f0dcc4;
    border-radius: 11px;
    background: #fdf7ee;
    font-size: 12px;
    line-height: 1.65;
    color: #8a5a1e;
}

.panel {
    margin-bottom: 14px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-head h2 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -.005em;
}

.panel-head .btn {
    height: 29px;
    margin-left: auto;
    font-size: 12px;
}

.panel>.field {
    margin-top: 12px;
}

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

/* ---------- 分类编辑 ---------- */

.sec-card {
    margin-bottom: 10px;
    padding: 13px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 13px;
}

.sec-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sec-no {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10.5px;
    letter-spacing: .1em;
    color: var(--accent);
}

.sec-tools {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.items {
    display: grid;
    gap: 8px;
    margin: 10px 0;
}

.item-card {
    padding: 10px;
    background: #fbfaf8;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.item-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.item-top select {
    width: auto;
    height: 25px;
    padding: 0 24px 0 8px;
    font-size: 11.5px;
    border-radius: 7px;
    background-position: calc(100% - 12px) 50%, calc(100% - 7px) 50%;
}

.item-no {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10px;
    letter-spacing: .08em;
    color: var(--muted);
}

.it-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 104px;
    gap: 8px;
}

.it-grid .field>span {
    font-size: 10px;
}

.it-grid .full {
    grid-column: 1 / -1;
}

.it-grid input,
.it-grid select {
    font-size: 12.5px;
    padding: 7px 9px;
}

.add-item {
    width: 100%;
    height: 30px;
    font-size: 11.5px;
}

.empty-hint {
    padding: 22px 0;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

.sec-sum {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--muted);
}

.sec-card .sec-body {
    display: none;
}

.sec-card.is-open .sec-body {
    display: block;
}

/* ---------- 折叠区 ---------- */

details summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: "";
    width: 5px;
    height: 5px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform .2s var(--ease);
}

details[open] summary::before {
    transform: rotate(45deg);
}

details .btn {
    margin-top: 4px;
}

.adm-foot {
    margin: 20px 0 0;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
}

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

/* ---------- 飞书同步面板 ---------- */

.pill {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 10.5px;
    letter-spacing: .02em;
    color: var(--muted);
    white-space: nowrap;
}

.pill.on {
    color: #1c7a4c;
    border-color: #bde2cc;
    background: #f2fbf6;
}

.pill.err {
    color: #b3362b;
    border-color: #ecc3bd;
    background: #fdf5f4;
}

.panel-note {
    margin: -4px 0 14px;
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--muted);
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 12.5px;
    color: var(--ink-2);
    cursor: pointer;
}

.check input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.check-hint {
    font-size: 11px;
    color: var(--muted);
}

.fs-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.fs-info {
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--muted);
}

.fs-info.ok {
    color: #1c7a4c;
}

.fs-info.err {
    color: #b3362b;
}

.fs-log {
    margin: 12px 0 0;
    padding: 11px 12px;
    max-height: 220px;
    overflow: auto;
    background: #fbfaf8;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--ink-2);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---------- 响应式 ---------- */

@media (max-width: 720px) {
    .adm-main {
        padding: 16px 14px 56px;
    }

    .adm-top .inner {
        padding: 0 14px;
        gap: 8px;
    }

    .save-state {
        display: none;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .it-grid {
        grid-template-columns: 1fr 1fr;
    }

    .panel {
        padding: 14px;
    }
}
