/* ============================================================
   HJ_ToolHub 管理后台 · Material 3 皮肤层
   - 本文件只负责视觉（令牌 / 组件重绘），不改任何业务结构与逻辑
   - 依赖本地预编译 Tailwind（assets/admin-tailwind.css）提供布局工具类
   - 若后台模板新增了未收录的 Tailwind 类，需要用 tailwindcss CLI 重新构建
   ============================================================ */

:root {
    /* 主色：Google 蓝（Material 3 blue seed） */
    --md-primary: #0B57D0;
    --md-on-primary: #FFFFFF;
    --md-primary-container: #D3E3FD;
    --md-on-primary-container: #041E49;
    /* 次色 */
    --md-secondary: #00639B;
    --md-on-secondary: #FFFFFF;
    --md-secondary-container: #C2E7FF;
    --md-on-secondary-container: #001D35;
    /* 第三色 / 状态 */
    --md-tertiary: #7D5260;
    --md-tertiary-container: #FFD8E4;
    --md-error: #B3261E;
    --md-on-error: #FFFFFF;
    --md-error-container: #F9DEDC;
    --md-on-error-container: #410E0B;
    --md-success: #146C2E;
    --md-success-container: #C4EED0;
    --md-on-success-container: #0A5222;
    /* 表面：Google 中性色阶 */
    --md-surface: #F8FAFD;
    --md-on-surface: #1F1F1F;
    --md-surface-variant: #E3E9F0;
    --md-on-surface-variant: #444746;
    --md-surface-container-lowest: #FFFFFF;
    --md-surface-container-low: #F0F4F9;
    --md-surface-container: #E9EEF6;
    --md-surface-container-high: #E3E9F0;
    --md-surface-container-highest: #DDE3EA;
    --md-outline: #747775;
    --md-outline-variant: #C4C7C5;
    /* 形状 */
    --md-radius-xs: 8px;
    --md-radius-sm: 12px;
    --md-radius-md: 16px;
    --md-radius-lg: 20px;
    --md-radius-xl: 28px;
    /* 海拔 */
    --md-elev-1: 0 1px 2px rgba(0, 0, 0, .10), 0 1px 3px 1px rgba(0, 0, 0, .06);
    --md-elev-2: 0 1px 2px rgba(0, 0, 0, .12), 0 2px 6px 2px rgba(0, 0, 0, .08);
    --md-elev-3: 0 4px 8px 3px rgba(0, 0, 0, .10), 0 1px 3px rgba(0, 0, 0, .14);
}

/* ---------------- 基础 ---------------- */
html { -webkit-text-size-adjust: 100%; }

body.md3-body {
    margin: 0;
    min-height: 100svh;
    background: var(--md-surface-container-low);
    color: var(--md-on-surface);
    font-family: "Noto Sans SC", "Source Han Sans SC", "思源黑体", "PingFang SC",
        "Microsoft YaHei", "微软雅黑", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: .1px;
    -webkit-font-smoothing: antialiased;
}

body.md3-body * { box-sizing: border-box; }

body.md3-body ::selection { background: var(--md-primary-container); color: var(--md-on-primary-container); }

/* Tailwind 中的 primary 色统一收敛到 Material 主色（避免蓝/紫混用） */
body.md3-body .text-primary { color: var(--md-primary); }
body.md3-body .bg-primary { background-color: var(--md-primary); }
body.md3-body .border-primary { border-color: var(--md-primary); }
body.md3-body .ring-primary { --tw-ring-color: var(--md-primary); }
body.md3-body .focus\:border-primary:focus { border-color: var(--md-primary); }
body.md3-body .focus\:ring-primary:focus { --tw-ring-color: var(--md-primary); }
body.md3-body .hover\:bg-primary\/90:hover { background-color: var(--md-primary); }
body.md3-body .hover\:text-black:hover { color: var(--md-on-surface); }

body.md3-body ::-webkit-scrollbar { width: 10px; height: 10px; }
body.md3-body ::-webkit-scrollbar-thumb { background: #C6D2E6; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
body.md3-body ::-webkit-scrollbar-thumb:hover { background: #A9BAD4; background-clip: content-box; }
body.md3-body ::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 布局：导航抽屉 ---------------- */
.md3-drawer {
    position: fixed;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 272px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: var(--md-surface-container);
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 24px;
    box-shadow: 0 1px 2px rgba(31, 31, 31, .06), 0 12px 32px rgba(31, 31, 31, .14);
    transition: transform .28s cubic-bezier(.2, 0, 0, 1);
}

.md3-drawer-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 16px;
    flex-shrink: 0;
}

.md3-drawer-logo {
    width: 44px;
    height: 44px;
    padding: 8px;
    border-radius: 14px;
    object-fit: contain;
    background: var(--md-primary-container);
}

.md3-drawer-brand { min-width: 0; }

.md3-drawer-title {
    margin: 0;
    font-size: 16px;
    line-height: 22px;
    font-weight: 700;
    color: var(--md-on-surface);
    letter-spacing: 0;
}

.md3-drawer-sub {
    margin: 2px 0 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--md-on-surface-variant);
}

.md3-drawer-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 4px 0 12px;
    scrollbar-width: thin;
}

.md3-drawer .nav-group {
    margin: 20px 0 6px;
    padding: 0 16px;
    font-size: 11px;
    line-height: 16px;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--md-on-surface-variant);
    opacity: .85;
}

.md3-drawer .nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 52px;
    margin: 2px 0;
    padding: 0 20px;
    border-radius: 26px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    color: var(--md-on-surface-variant);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.md3-drawer .nav-item:hover {
    background: rgba(11, 87, 208, .08);
    color: var(--md-on-surface);
}

.md3-drawer .nav-item:active { background: rgba(11, 87, 208, .12); }

.md3-drawer .nav-item.active {
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
    font-weight: 600;
    box-shadow: none;
}

.md3-drawer .nav-item i {
    width: 20px;
    min-width: 20px;
    text-align: center;
    font-size: 16px;
    color: inherit;
}

.md3-drawer-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(121, 116, 126, .22);
    flex-shrink: 0;
}

.md3-drawer-foot .nav-item {
    height: 46px;
    margin-bottom: 8px;
    color: var(--md-on-surface-variant);
}

.md3-drawer-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 18px;
    cursor: pointer;
    transition: background-color .15s ease;
}

.md3-drawer-user:hover { background: rgba(11, 87, 208, .08); }
.md3-drawer-user:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }

.md3-user-more {
    margin-left: auto;
    font-size: 11px;
    color: var(--md-on-surface-variant);
    flex-shrink: 0;
}

.md3-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--md-surface-container-highest);
    border: 0;
    flex-shrink: 0;
}

.md3-drawer-userinfo { min-width: 0; }

.md3-user-name {
    margin: 0;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--md-on-surface);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.md3-user-role {
    margin: 1px 0 0;
    font-size: 11px;
    line-height: 15px;
    color: var(--md-on-surface-variant);
}

/* 移动端遮罩 */
.md3-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .32);
    z-index: 50;
}

@media (min-width: 1024px) {
    #sidebar-backdrop { display: none !important; }
}

/* ---------------- 布局：主区与顶栏 ---------------- */
.md3-shell {
    margin-left: 0;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background: var(--md-surface-container-low);
    transition: margin-left .28s cubic-bezier(.2, 0, 0, 1);
}

@media (min-width: 1024px) {
    .md3-shell { margin-left: 288px; }
}

.md3-top-app-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 64px;
    padding: 0 24px;
    background: rgba(248, 250, 253, .88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--md-outline-variant);
    box-shadow: 0 1px 3px rgba(31, 31, 31, .05);
}

.md3-app-title {
    margin: 0;
    font-size: 22px;
    line-height: 28px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--md-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.md3-menu-btn { display: inline-flex; }

@media (min-width: 1024px) {
    .md3-menu-btn { display: none !important; }
}

.md3-hide-sm { display: none; }

@media (min-width: 640px) {
    .md3-hide-sm { display: inline-flex; }
}

.md3-content {
    flex: 1 1 auto;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

@media (max-width: 640px) {
    .md3-content { padding: 16px; }
    .md3-top-app-bar { padding: 0 12px; }
    .md3-app-title { font-size: 20px; line-height: 26px; }
}

/* ---------------- 图标按钮 / 文字按钮 ---------------- */
.md3-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--md-on-surface-variant);
    cursor: pointer;
    font-size: 16px;
    transition: background-color .15s ease, color .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.md3-icon-btn:hover { background: rgba(11, 87, 208, .08); color: var(--md-on-surface); }
.md3-icon-btn:active { background: rgba(11, 87, 208, .12); }

.md3-text-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 20px;
    background: transparent;
    color: var(--md-primary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease;
    white-space: nowrap;
}

.md3-text-btn:hover { background: rgba(11, 87, 208, .08); }
.md3-text-btn i { font-size: 12px; }

/* 小尺寸图标按钮（表格 / 弹窗右上角） */
body.md3-body button[class*="w-7"][class*="h-7"],
body.md3-body button[class*="w-8"][class*="h-8"],
body.md3-body button[class*="w-9"][class*="h-9"] {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--md-on-surface-variant);
    cursor: pointer;
}

body.md3-body button[class*="w-7"][class*="h-7"]:hover,
body.md3-body button[class*="w-8"][class*="h-8"]:hover,
body.md3-body button[class*="w-9"][class*="h-9"]:hover {
    background: rgba(11, 87, 208, .08);
    color: var(--md-on-surface);
}

/* ---------------- 按钮：填充 / 描边 / 文字 ---------------- */
body.md3-body button,
body.md3-body label[class*="bg-"],
body.md3-body a[class*="bg-"] { font-family: inherit; }

body.md3-body button[class*="bg-black"]:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body button[class*="bg-primary"]:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body button[class*="bg-green-6"]:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body button[class*="bg-red-6"]:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body label[class*="bg-black"],
body.md3-body a[class*="bg-black"] {
    border: 1px solid transparent;
    border-radius: 20px;
    background: var(--md-primary);
    color: var(--md-on-primary);
    font-weight: 500;
    min-height: 36px;
    letter-spacing: .1px;
    cursor: pointer;
    box-shadow: none;
    transition: box-shadow .15s ease, filter .15s ease, background-color .15s ease;
    -webkit-tap-highlight-color: transparent;
}

body.md3-body.md3-body button[class*="bg-red-6"]:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item) {
    background: var(--md-error);
    color: var(--md-on-error);
}

body.md3-body.md3-body button[class*="bg-green-6"]:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item) {
    background: var(--md-success);
    color: #fff;
}

body.md3-body button[class*="bg-black"]:hover:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body button[class*="bg-primary"]:hover:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body button[class*="bg-green-6"]:hover:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body button[class*="bg-red-6"]:hover:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body label[class*="bg-black"]:hover,
body.md3-body a[class*="bg-black"]:hover {
    background: var(--md-primary);
    filter: brightness(1.06);
    box-shadow: var(--md-elev-1);
}

body.md3-body.md3-body button[class*="bg-red-6"]:hover:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item) { background: var(--md-error); }
body.md3-body.md3-body button[class*="bg-green-6"]:hover:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item) { background: var(--md-success); }

body.md3-body button[class*="bg-black"]:active:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body button[class*="bg-primary"]:active:not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item) {
    box-shadow: none;
    filter: brightness(.98);
}

body.md3-body button[class*="bg-black"]:disabled,
body.md3-body button[class*="bg-primary"]:disabled {
    opacity: .38;
    cursor: not-allowed;
    box-shadow: none;
}

/* 描边按钮：有 border 但不是实心填充（注意排除 hover:bg-* 的误判） */
body.md3-body button[class*="border"]:not([class*="bg-black"]):not([class*="bg-primary"]):not([class*="bg-green-6"]):not([class*="bg-red-6"]):not([class*="bg-gray-8"]):not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item):not([class*="w-7"]):not([class*="w-8"]):not([class*="w-9"]),
body.md3-body label[class*="border"]:not([class*="bg-black"]):not([class*="bg-primary"]):not(.lv-opt) {
    border: 1px solid var(--md-outline);
    border-radius: 20px;
    background: transparent;
    color: var(--md-primary);
    font-weight: 500;
    min-height: 36px;
    cursor: pointer;
    box-shadow: none;
    transition: background-color .15s ease, border-color .15s ease;
}

body.md3-body button[class*="border"]:hover:not([class*="bg-black"]):not([class*="bg-primary"]):not([class*="bg-green-6"]):not([class*="bg-red-6"]):not([class*="bg-gray-8"]):not(.dc-sub):not(.seg-btn):not(.lv-opt):not(.nav-item),
body.md3-body label[class*="border"]:hover:not([class*="bg-black"]):not([class*="bg-primary"]):not(.lv-opt) {
    background: rgba(11, 87, 208, .08);
    border-color: var(--md-primary);
}

/* 危险描边（撤销授权） */
body.md3-body button[class*="border-red"]:not([class*="bg-black"]):not([class*="bg-primary"]) {
    border-color: rgba(179, 38, 30, .5);
    color: var(--md-error);
}
body.md3-body button[class*="border-red"]:hover:not([class*="bg-black"]):not([class*="bg-primary"]) {
    background: rgba(179, 38, 30, .08);
    border-color: var(--md-error);
}

/* 表格 / 列表里的纯文字按钮 */
body.md3-body table button:not([class*="bg-"]):not([class*="border"]) {
    border: 0;
    border-radius: 8px;
    background: transparent;
    padding: 4px 8px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: none;
    transition: background-color .15s ease;
}
body.md3-body table button:not([class*="bg-"]):not([class*="border"]):hover { background: rgba(11, 87, 208, .08); }

/* ---------------- 卡片 / 面板 ---------------- */
body.md3-body.md3-body main div.bg-white {
    background: var(--md-surface-container-lowest);
    border: 1px solid var(--md-outline-variant);
    border-radius: var(--md-radius-md);
    box-shadow: none;
}

body.md3-body.md3-body main div.bg-white.rounded-md,
body.md3-body.md3-body main div.bg-white.rounded-lg { border-radius: var(--md-radius-md); }

/* 卡片内分隔线颜色统一 */
body.md3-body.md3-body main .border-gray-200,
body.md3-body.md3-body main .border-gray-100 { border-color: rgba(121, 116, 126, .22); }

/* 统计卡图标底板 */
body.md3-body.md3-body main span[class*="w-9"][class*="h-9"],
body.md3-body.md3-body main span[class*="w-8"][class*="h-8"] {
    border-radius: 12px;
    background: var(--md-primary-container);
    color: var(--md-primary);
}

/* 服务器状态进度条 */
#srv-cpu-bar,
#srv-mem-bar,
#dcv-progress-bar {
    background: var(--md-primary);
    border-radius: 999px;
}

/* ---------------- 表单控件 ---------------- */
body.md3-body input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
body.md3-body select,
body.md3-body textarea {
    height: 56px;
    padding: 0 16px;
    border: 1px solid var(--md-outline);
    border-radius: 8px;
    background: var(--md-surface-container-lowest);
    color: var(--md-on-surface);
    font-family: inherit;
    font-size: 15px;
    line-height: 22px;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

body.md3-body textarea {
    height: auto;
    min-height: 112px;
    padding: 16px;
    line-height: 22px;
    resize: vertical;
}

body.md3-body select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2349454F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

body.md3-body input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):hover,
body.md3-body select:hover,
body.md3-body textarea:hover { border-color: var(--md-on-surface-variant); }

body.md3-body input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
body.md3-body select:focus,
body.md3-body textarea:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: inset 0 0 0 1px var(--md-primary);
}

body.md3-body input::placeholder,
body.md3-body textarea::placeholder { color: #8A8491; }

/* ---------- Material 3 描边输入框：标签浮到边框缺口上 ---------- */
body.md3-body div:has(> label + input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"])),
body.md3-body div:has(> label + select),
body.md3-body div:has(> label + textarea) {
    position: relative;
    padding-top: 9px;
}

body.md3-body div:has(> label + input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"])) > label,
body.md3-body div:has(> label + select) > label,
body.md3-body div:has(> label + textarea) > label {
    position: absolute;
    top: 9px;
    left: 12px;
    z-index: 2;
    margin: 0;
    padding: 0 4px;
    background: var(--md-surface-container-lowest);
    color: var(--md-on-surface-variant);
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
    letter-spacing: .02em;
    white-space: nowrap;
    pointer-events: none;
    transform: translateY(-50%);
    transition: color .15s ease;
}

body.md3-body div:has(> input:focus) > label,
body.md3-body div:has(> select:focus) > label,
body.md3-body div:has(> textarea:focus) > label {
    color: var(--md-primary);
}

body.md3-body label {
    color: var(--md-on-surface-variant);
    font-weight: 500;
}

body.md3-body input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--md-primary);
    cursor: pointer;
}

body.md3-body input[type="color"] {
    padding: 4px !important;
    cursor: pointer;
}

/* ---------------- 表格 ---------------- */
body.md3-body main table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

body.md3-body main thead tr { background: var(--md-surface-container-low); }

body.md3-body main thead th {
    padding: 14px 16px;
    background: transparent;
    border-bottom: 1px solid var(--md-outline-variant);
    color: var(--md-on-surface-variant);
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    letter-spacing: .04em;
    text-align: left;
    white-space: nowrap;
}

body.md3-body main thead th:first-child { border-radius: 12px 0 0 12px; }
body.md3-body main thead th:last-child { border-radius: 0 12px 12px 0; }

body.md3-body main tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #EFEAF2;
    color: var(--md-on-surface);
    vertical-align: middle;
}

body.md3-body main tbody tr { transition: background-color .12s ease; }
body.md3-body main tbody tr:hover { background: #F3F7FE; }
body.md3-body main tbody tr:last-child td { border-bottom: 0; }
body.md3-body.md3-body main tbody td[colspan] { padding: 40px 16px; }

body.md3-body main td.text-center,
body.md3-body main th.text-center { text-align: center; }

/* ---------------- 状态徽章 ---------------- */
body.md3-body.md3-body main span[class*="bg-green-100"],
body.md3-body.md3-body main span[class*="bg-blue-100"],
body.md3-body.md3-body main span[class*="bg-amber-100"],
body.md3-body.md3-body main span[class*="bg-red-100"],
body.md3-body.md3-body main span[class*="bg-gray-100"].text-xs {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
    white-space: nowrap;
}

body.md3-body.md3-body main span[class*="bg-green-100"] { background: var(--md-success-container); color: var(--md-on-success-container); }
body.md3-body.md3-body main span[class*="bg-blue-100"] { background: #D7E3FF; color: #001B3E; }
body.md3-body.md3-body main span[class*="bg-amber-100"] { background: #FFE0B2; color: #4A2800; }
body.md3-body.md3-body main span[class*="bg-red-100"] { background: var(--md-error-container); color: var(--md-on-error-container); }
body.md3-body.md3-body main span[class*="bg-gray-100"].text-xs { background: var(--md-surface-container-high); color: var(--md-on-surface-variant); }

/* ---------------- 标签页（下载中心） ---------------- */
body.md3-body .dc-sub {
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    padding: 12px 18px;
    margin-bottom: -1px;
    color: var(--md-on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

body.md3-body .dc-sub:hover { background: rgba(11, 87, 208, .06); color: var(--md-on-surface); }

body.md3-body .dc-sub.font-semibold,
body.md3-body .dc-sub[class*="border-black"] {
    color: var(--md-primary);
    border-bottom-color: var(--md-primary);
    font-weight: 600;
}

/* ---------------- 分段按钮 / 级别选择 ---------------- */
body.md3-body .seg {
    display: inline-flex;
    border: 1px solid var(--md-outline);
    border-radius: 20px;
    overflow: hidden;
    background: transparent;
}

body.md3-body .seg-btn {
    border: 0;
    border-radius: 0;
    padding: 8px 20px;
    background: transparent;
    color: var(--md-on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

body.md3-body .seg-btn + .seg-btn { border-left: 1px solid var(--md-outline); }
body.md3-body .seg-btn:hover { background: rgba(11, 87, 208, .08); }

body.md3-body .seg-btn.active {
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
    font-weight: 600;
}

body.md3-body .lv-opt {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--md-outline);
    border-radius: 20px;
    background: transparent;
    color: var(--md-on-surface-variant);
    font-size: 13px;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

body.md3-body .lv-opt + .lv-opt { margin-left: 8px; }
body.md3-body .lv-opt:hover { background: rgba(11, 87, 208, .06); }

body.md3-body .lv-opt.active {
    border-color: var(--md-primary);
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
    font-weight: 600;
}

body.md3-body .lv-opt .lv-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------------- 开关 ---------------- */
body.md3-body .switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
    vertical-align: middle;
    flex-shrink: 0;
}

body.md3-body .switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

body.md3-body .switch i {
    position: absolute;
    inset: 0;
    background: var(--md-surface-container-highest);
    border: 2px solid var(--md-outline);
    border-radius: 32px;
    transition: background-color .18s ease, border-color .18s ease;
    cursor: pointer;
}

body.md3-body .switch i::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: var(--md-outline);
    border-radius: 50%;
    transition: transform .18s cubic-bezier(.2, 0, 0, 1), width .18s ease, height .18s ease, background-color .18s ease;
}

body.md3-body .switch input:checked + i {
    background: var(--md-primary);
    border-color: var(--md-primary);
}

body.md3-body .switch input:checked + i::after {
    background: var(--md-on-primary);
    transform: translateX(20px);
}

body.md3-body .switch input:focus-visible + i {
    box-shadow: 0 0 0 3px rgba(11, 87, 208, .24);
}

/* ---------------- 弹窗（Dialog） ---------------- */
#create-user-modal,
#confirm-modal,
#af-modal,
#dc-app-modal,
#dc-vers-modal,
#dc-ver-modal {
    background: rgba(0, 0, 0, .32);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.md3-dialog {
    background: var(--md-surface-container-low);
    border: 0;
    border-radius: var(--md-radius-xl);
    box-shadow: var(--md-elev-3);
}

.md3-dialog .bg-white { background: transparent; }

.md3-dialog .border-gray-200 { border-color: rgba(121, 116, 126, .22); }

.md3-dialog h3 {
    font-size: 17px;
    line-height: 24px;
    font-weight: 600;
    color: var(--md-on-surface);
    letter-spacing: 0;
}

/* ---------------- 管理员账号列表（侧栏用户卡片弹窗） ---------------- */
.admin-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--md-outline-variant);
    border-radius: 16px;
    background: var(--md-surface-container-lowest);
}

.admin-row:last-child { margin-bottom: 0; }

.admin-row-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--md-surface-container-high);
    flex-shrink: 0;
}

.admin-row-main { min-width: 0; flex: 1 1 auto; }

.admin-row-name {
    margin: 0;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--md-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-row-mail {
    margin: 2px 0 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--md-on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    margin-left: 6px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: .02em;
    vertical-align: middle;
    background: var(--md-primary-container);
    color: var(--md-primary);
}

.role-chip.super {
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
}

.role-chip.self {
    background: var(--md-surface-container-high);
    color: var(--md-on-surface-variant);
}

.admin-row-edit {
    flex-shrink: 0;
    min-height: 32px;
    padding: 0 14px;
    border: 1px solid var(--md-outline);
    border-radius: 20px;
    background: transparent;
    color: var(--md-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.admin-row-edit:hover {
    background: rgba(11, 87, 208, .08);
    border-color: var(--md-primary);
}

.admin-row-lock {
    flex-shrink: 0;
    padding: 0 6px;
    font-size: 12px;
    color: var(--md-on-surface-variant);
}

.admin-empty {
    margin: 0;
    padding: 28px 0;
    text-align: center;
    font-size: 13px;
    color: var(--md-on-surface-variant);
}

/* 弹窗内滚动条 */
.md3-dialog::-webkit-scrollbar { width: 8px; }

/* ---------------- 分页 / 信息行 ---------------- */
body.md3-body.md3-body main button[class*="px-3"][class*="border-gray-300"] {
    padding: 0 18px;
    min-height: 36px;
    font-size: 13px;
}

body.md3-body main button:disabled {
    opacity: .38;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------------- 涟漪 ---------------- */
.md3-ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: currentColor;
    opacity: .18;
    pointer-events: none;
    animation: md3-ripple .55s ease-out forwards;
    z-index: 0;
}

@keyframes md3-ripple {
    to { transform: scale(2.6); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .md3-ripple { display: none; }
    .md3-shell,
    .md3-drawer { transition: none; }
}

/* ============================================================
   门禁页（公开的 admin.html）
   ============================================================ */
.md3-gate {
    margin: 0;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1100px 620px at 50% -12%, #D3E3FD 0%, rgba(234, 221, 255, 0) 62%),
        var(--md-surface);
    color: var(--md-on-surface);
    font-family: "Noto Sans SC", "Source Han Sans SC", "思源黑体", "PingFang SC",
        "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

.md3-gate * { box-sizing: border-box; }
.md3-gate [hidden] { display: none !important; }

.md3-gate-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 32px 32px;
    background: var(--md-surface-container-lowest);
    border-radius: var(--md-radius-xl);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 18px 48px rgba(11, 87, 208, .14);
    text-align: center;
}

.md3-gate-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 26px;
    color: var(--md-primary);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .2px;
}

.md3-gate-brand img {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: block;
}

.md3-gate-card h1 {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 32px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--md-on-surface);
}

.md3-gate-card p {
    margin: 0;
    font-size: 14px;
    line-height: 21px;
    color: var(--md-on-surface-variant);
}

.md3-gate-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    background: var(--md-primary-container);
    color: var(--md-primary);
}

.md3-gate-icon.error { background: var(--md-error-container); color: var(--md-error); }
.md3-gate-icon.denied { background: #FFEAD6; color: #8B5000; }

.md3-linear {
    height: 4px;
    margin-top: 28px;
    border-radius: 2px;
    background: var(--md-surface-container-high);
    overflow: hidden;
}

.md3-linear > span {
    display: block;
    width: 40%;
    height: 100%;
    border-radius: 2px;
    background: var(--md-primary);
    animation: md3-indeterminate 1.2s cubic-bezier(.65, 0, .35, 1) infinite;
}

@keyframes md3-indeterminate {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(360%); }
}

.md3-gate-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 28px;
}

.md3-btn-filled,
.md3-btn-outlined,
.md3-btn-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 24px;
    border-radius: 22px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .15s ease, box-shadow .15s ease, filter .15s ease;
    text-decoration: none;
}

.md3-btn-filled {
    border: 1px solid transparent;
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.md3-btn-filled:hover { filter: brightness(1.06); box-shadow: var(--md-elev-1); }

.md3-btn-outlined {
    border: 1px solid var(--md-outline);
    background: transparent;
    color: var(--md-primary);
}

.md3-btn-outlined:hover { background: rgba(11, 87, 208, .08); border-color: var(--md-primary); }

.md3-btn-text {
    border: 0;
    background: transparent;
    color: var(--md-primary);
}

.md3-btn-text:hover { background: rgba(11, 87, 208, .08); }

@media (prefers-reduced-motion: reduce) {
    .md3-linear > span { animation: none; width: 100%; opacity: .6; }
}
