/* =====================================================================
   瑶愿启动器 · 管理后台样式
   风格：粉色玻璃（与启动器呼应），但以信息密度与可读性优先。
   说明：所有颜色集中在 :root，改主题只动这一处。
   ===================================================================== */

:root {
    --pink-50: #fff6f9;
    --pink-100: #ffe7ef;
    --pink-200: #ffcede;
    --pink-300: #ffb0c9;
    --pink-400: #ff8fb4;
    --pink-500: #ff6fa5;
    --pink-600: #ef4f8b;
    --pink-700: #cf3a72;

    --ink: #3a2932;
    --ink-2: #6b5560;
    --ink-3: #9b8a93;

    --card: rgba(255, 255, 255, 0.74);
    --card-solid: #ffffff;
    --card-soft: rgba(255, 255, 255, 0.5);
    --line: rgba(255, 150, 190, 0.32);
    --line-strong: rgba(255, 120, 170, 0.5);

    --ok: #1f9d63;
    --ok-bg: rgba(31, 157, 99, 0.12);
    --warn: #b06a00;
    --warn-bg: rgba(255, 176, 32, 0.16);
    --danger: #d62a52;
    --danger-bg: rgba(214, 42, 82, 0.1);

    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 18px 40px -26px rgba(196, 44, 100, 0.45);
    --shadow-sm: 0 8px 20px -14px rgba(196, 44, 100, 0.4);
    --blur: saturate(150%) blur(16px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
    background:
        radial-gradient(1100px 620px at 8% -8%, #fff9fb 0%, rgba(255, 249, 251, 0) 60%),
        radial-gradient(900px 520px at 100% 0%, #ffe3ee 0%, rgba(255, 227, 238, 0) 55%),
        linear-gradient(165deg, #fff8fb 0%, #ffedf4 45%, #fdf4f8 100%);
    background-attachment: fixed;
}

/* 自定义背景：独立固定层，模糊只作用于图片，卡片与文字保持清晰。
   z-index 与 .shell / .login-wrap（都是 1）配合，靠 DOM 顺序压在内容下方。 */
.custom-bg,
.custom-bg-mask {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.custom-bg {
    /* 四周外扩，避免 blur 之后露出底层渐变 */
    inset: -16px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* 自定义背景下关掉内置光斑，避免和图片颜色打架 */
body.has-custom-bg .orbs {
    display: none;
}

/* 背景光斑：纯装饰，不接收事件，也不参与布局 */
.orbs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.orbs span {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.36;
}

/* 光斑只放在内容区（右侧），避免透过半透明侧栏在导航项上形成色块 */
.orbs span:nth-child(1) {
    width: 420px;
    height: 420px;
    top: -160px;
    left: 38%;
    background: #ffc7dd;
}

.orbs span:nth-child(2) {
    width: 360px;
    height: 360px;
    bottom: -120px;
    right: 6%;
    background: #ffd9e6;
}

.orbs span:nth-child(3) {
    width: 280px;
    height: 280px;
    top: 32%;
    right: -80px;
    background: #ffe6f0;
}

a {
    color: var(--pink-700);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--pink-500);
    outline-offset: 2px;
}

/* ============================ 布局 ============================ */

.shell {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100vh;
}

.sidebar {
    flex: 0 0 228px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 16px;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: var(--blur);
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 6px 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(150deg, var(--pink-400), var(--pink-600));
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    box-shadow: 0 10px 22px -12px rgba(239, 79, 139, 0.9);
}

.brand strong {
    display: block;
    font-size: 14px;
    letter-spacing: 0.02em;
}

.brand span {
    display: block;
    font-size: 11.5px;
    color: var(--ink-3);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 13.5px;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.8);
    color: var(--ink);
    text-decoration: none;
}

.nav-item.active {
    background: linear-gradient(120deg, rgba(255, 111, 165, 0.16), rgba(255, 255, 255, 0.85));
    color: var(--pink-700);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--pink-500);
}

.nav-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    opacity: 0.9;
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 6px 0;
    border-top: 1px dashed var(--line);
}

.sidebar-foot .who {
    font-size: 12.5px;
    color: var(--ink-2);
}

.sidebar-foot .who b {
    color: var(--ink);
}

.main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 22px 26px 56px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.topbar .sub {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--ink-3);
}

/* ============================ 卡片 ============================ */

.panel {
    background: var(--card);
    backdrop-filter: var(--blur);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    margin-bottom: 16px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.panel-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

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

.grid {
    display: grid;
    gap: 14px;
}

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

.stat {
    background: var(--card);
    backdrop-filter: var(--blur);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
}

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

.stat .value {
    margin: 4px 0 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
}

.stat .value small {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-3);
    margin-left: 3px;
}

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

.stat.accent {
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.9), rgba(255, 226, 237, 0.85));
    border-color: var(--line-strong);
}

/* ============================ 表格 ============================ */

.table-wrap {
    overflow-x: auto;
    margin: 0 -18px;
    padding: 0 18px;
}

table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 620px;
}

table.list th {
    text-align: left;
    font-weight: 600;
    font-size: 11.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-3);
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

table.list td {
    padding: 10px;
    border-bottom: 1px dashed var(--line);
    vertical-align: middle;
}

table.list tbody tr:hover td {
    background: rgba(255, 255, 255, 0.66);
}

table.list tbody tr:last-child td {
    border-bottom: none;
}

.cell-name {
    font-weight: 600;
    word-break: break-all;
}

.cell-sub {
    display: block;
    font-size: 11.5px;
    color: var(--ink-3);
    font-weight: 400;
}

.mono {
    font-family: Consolas, "SFMono-Regular", "Cascadia Mono", monospace;
    font-size: 12px;
    color: var(--ink-2);
}

.num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    white-space: nowrap;
}

.check-col {
    width: 34px;
}

input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--pink-500);
    cursor: pointer;
}

/* ============================ 按钮 ============================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 13.5px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease, opacity 0.16s ease;
    white-space: nowrap;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--pink-400), var(--pink-600));
    color: #fff;
    box-shadow: 0 12px 26px -14px rgba(239, 79, 139, 0.95);
}

.btn-primary:hover {
    box-shadow: 0 14px 28px -12px rgba(239, 79, 139, 0.95);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.78);
    border-color: var(--line);
    color: var(--ink-2);
}

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

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 10px 22px -16px rgba(214, 42, 82, 1);
}

.btn-danger:hover {
    background: #bd2147;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* ============================ 表单 ============================ */

.field {
    margin-bottom: 12px;
}

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 5px;
}

.field .help {
    display: block;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--ink-3);
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--pink-400);
    box-shadow: 0 0 0 3px rgba(255, 143, 180, 0.22);
}

textarea {
    resize: vertical;
    min-height: 76px;
    line-height: 1.5;
}

input[type="file"] {
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.75);
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-form .field {
    margin-bottom: 0;
    flex: 1 1 160px;
}

/* ============================ 上传区 ============================ */

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 16px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    text-align: center;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.dropzone:hover,
.dropzone.dragover {
    background: rgba(255, 240, 245, 0.9);
    border-color: var(--pink-500);
}

.dropzone strong {
    font-size: 13.5px;
}

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

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.progress {
    display: none;
    margin-top: 12px;
}

.progress.active {
    display: block;
}

.progress .track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--line);
    overflow: hidden;
}

.progress .bar {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--pink-300), var(--pink-600));
    transition: width 0.18s ease;
}

.progress .meta {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--ink-3);
}

/* ============================ 提示 / 徽章 ============================ */

.alert {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-bg);
    border-color: rgba(214, 42, 82, 0.28);
    color: #9d1436;
}

.alert-ok {
    background: var(--ok-bg);
    border-color: rgba(31, 157, 99, 0.26);
    color: #166b45;
}

.alert-warn {
    background: var(--warn-bg);
    border-color: rgba(176, 106, 0, 0.24);
    color: #7d4a00;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.7;
    white-space: nowrap;
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.badge-warn {
    background: var(--warn-bg);
    color: var(--warn);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-neutral {
    background: rgba(155, 138, 147, 0.14);
    color: var(--ink-2);
}

.badge-current {
    background: linear-gradient(135deg, var(--pink-400), var(--pink-600));
    color: #fff;
}

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

.small {
    font-size: 12px;
}

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

/* ============================ 登录页 ============================ */

.login-wrap {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 384px;
    background: var(--card);
    backdrop-filter: var(--blur);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 30px 60px -32px rgba(196, 44, 100, 0.5);
    padding: 30px 28px 26px;
}

.login-card .brand {
    justify-content: center;
    padding-bottom: 6px;
}

.login-card h1 {
    margin: 6px 0 4px;
    text-align: center;
    font-size: 18px;
}

.login-card .sub {
    margin: 0 0 20px;
    text-align: center;
    font-size: 12.5px;
    color: var(--ink-3);
}

.login-card .btn {
    width: 100%;
    margin-top: 4px;
    padding: 11px;
}

.login-foot {
    margin-top: 16px;
    text-align: center;
    font-size: 11.5px;
    color: var(--ink-3);
}

/* ============================ Toast ============================ */

.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(360px, calc(100vw - 32px));
}

.toast {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 11px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    box-shadow: 0 18px 38px -22px rgba(120, 30, 70, 0.55);
    font-size: 13px;
    color: var(--ink);
    animation: toast-in 0.2s ease-out;
}

.toast.out {
    animation: toast-out 0.18s ease-in forwards;
}

.toast::before {
    content: "";
    flex: 0 0 6px;
    align-self: stretch;
    border-radius: 999px;
    background: var(--pink-500);
}

.toast.ok::before {
    background: var(--ok);
}

.toast.error::before {
    background: var(--danger);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(6px);
    }
}

/* ============================ 对话框 ============================ */

dialog.rp-dialog {
    width: min(720px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 0;
    background: var(--card-solid);
    box-shadow: 0 40px 80px -40px rgba(120, 30, 70, 0.5);
    color: var(--ink);
}

dialog.rp-dialog::backdrop {
    background: rgba(74, 30, 50, 0.28);
    backdrop-filter: blur(3px);
}

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

.dialog-head h3 {
    margin: 0;
    font-size: 15px;
}

.dialog-body {
    padding: 16px 18px;
    max-height: min(62vh, 520px);
    overflow: auto;
}

.dialog-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px 16px;
    border-top: 1px solid var(--line);
}

.dialog-body pre {
    margin: 0;
    padding: 12px 14px;
    background: #fff8fb;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    color: #4a3540;
}

.icon-btn {
    border: none;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    color: var(--ink-3);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
}

.icon-btn:hover {
    background: var(--pink-100);
    color: var(--ink);
}

.confirm-text {
    margin: 0;
    white-space: pre-wrap;
    font-size: 13.5px;
    line-height: 1.7;
}

/* ============================ 工具类 ============================ */

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.row-between {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.spacer {
    flex: 1;
}

.nowrap {
    white-space: nowrap;
}

.filter-input {
    max-width: 240px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* HTMX 请求中的行内加载态 */
.htmx-request .btn[type="submit"],
.btn.htmx-request {
    opacity: 0.6;
    pointer-events: none;
}

.kv {
    display: grid;
    grid-template-columns: 148px minmax(0, 1fr);
    gap: 8px 14px;
    font-size: 13px;
}

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

.kv dd {
    margin: 0;
    word-break: break-all;
}

/* ============================ 响应式 ============================ */

@media (max-width: 900px) {
    .shell {
        flex-direction: column;
    }

    .sidebar {
        flex: none;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .brand {
        padding: 0;
        flex: 0 0 auto;
    }

    .brand div:last-child {
        display: none;
    }

    .nav {
        flex-direction: row;
        gap: 2px;
        flex: 0 0 auto;
    }

    .nav-item {
        padding: 7px 10px;
        font-size: 12.5px;
        white-space: nowrap;
    }

    .nav-item.active {
        box-shadow: inset 0 -2px 0 var(--pink-500);
    }

    .nav-icon {
        display: none;
    }

    .sidebar-foot {
        margin: 0 0 0 auto;
        flex-direction: row;
        align-items: center;
        padding: 0;
        border-top: none;
        flex: 0 0 auto;
    }

    .sidebar-foot .who {
        display: none;
    }

    .main {
        padding: 16px 14px 48px;
    }

    .topbar h1 {
        font-size: 18px;
    }

    .panel {
        padding: 14px;
        border-radius: 16px;
    }

    .table-wrap {
        margin: 0 -14px;
        padding: 0 14px;
    }

    .toast-stack {
        right: 12px;
        left: 12px;
        bottom: 12px;
        max-width: none;
    }

    .kv {
        grid-template-columns: 1fr;
        gap: 2px 0;
    }

    .kv dd {
        margin-bottom: 8px;
    }
}

/* ==================== 系统设置 · 自定义背景 ==================== */

.appearance-preview {
    width: 100%;
    height: 150px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: linear-gradient(165deg, #fff8fb, #ffedf4);
}

.appearance-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.appearance-empty {
    height: 100%;
    display: grid;
    place-items: center;
    color: #9b8a93;
    font-size: 13px;
}

.check-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.check-line input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--pink-500);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--pink-500);
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
