/* 全站公共样式：基础变量、布局及共享组件。页面专用样式由各页面另行引用。 */
/* ============================================================
   全局字体变量 — 改一处即全局生效
   ============================================================ */
:root {
    /* 字体大小基准 */
    --fs-xs:      0.75rem;   /* 12px */
    --fs-sm:      0.875rem;  /* 14px */
    --fs-base:    1rem;      /* 16px */
    --fs-lg:      1.125rem;  /* 18px */
    --fs-xl:      1.25rem;   /* 20px */
    --fs-2xl:     1.5rem;    /* 24px */
    --fs-3xl:     1.875rem;  /* 30px */

    --content-max-width: 960px;

    --clr-primary:       #2563eb;
    --clr-primary-light: #4a5568;
    --clr-primary-dark:  #1d4ed8;

    /* 辅助色 */
    --clr-secondary:    #ed8936;
    --clr-success:      #48bb78;
    --clr-warning:      #ecc94b;
    --clr-danger:       #f56565;
    --clr-info:         #4299e1;

    /* 基础颜色 - 白色主题 */
    --clr-bg:            #ffffff;
    --clr-surface:       #ffffff;
    --clr-surface-light: #f1f5f9;
    --clr-border:        #d8e0ea;
    --clr-border-focus:  #cbd5e1;

    /* 文字颜色 */
    --clr-text:         #263342;
    --clr-text-muted:   #64748b;
    --clr-text-light:   #94a3b8;
    --clr-text-white:   #ffffff;

    /* 阴影和透明度 */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.08);

    --card-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    --nav-shadow: none;

    --clr-shadow: rgba(0, 0, 0, 0.06);
    --clr-overlay: rgba(0, 0, 0, 0.4);
    --clr-danger-dark:  #c53030;
    --clr-success-dark: #2f855a;

    /* 圆角和间距 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --gap-xs: 0.5rem;
    --gap-sm: 1rem;
    --gap-md: 1.5rem;
    --gap-lg: 2rem;

    /* 输入高度 */
    --input-h: 2.75rem;
}

/* ============================================================
   基础重置
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--clr-bg);
    color: var(--clr-text);
    font-size: var(--fs-base);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ============================================================
   通用容器
   ============================================================ */
.container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--gap-sm);
}

/* ============================================================
   页面标题
   ============================================================ */
.page-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--clr-text);
    text-align: center;
    margin-bottom: var(--gap-md);
    letter-spacing: 0;
}

/* ============================================================
   卡片
   ============================================================ */
.card {
    background: var(--clr-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    padding: var(--gap-sm);
    margin-bottom: var(--gap-sm);
    transition: box-shadow 0.2s ease;
    border: 1px solid var(--clr-border);
}
.card:hover {
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}
.card-title {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--clr-text);
    padding-bottom: var(--gap-xs);
    border-bottom: 1px solid var(--clr-border);
    margin-bottom: var(--gap-sm);
}
.card-badge {
    font-size: var(--fs-sm);
    font-weight: 400;
    color: var(--clr-text-muted);
    margin-left: 8px;
}

/* 卡片标题包含操作控件时，分隔线由整行承担，控件高度与标题文字一致。 */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.card-header > h2 {
    margin: 0;
    font: inherit;
}
.card-title .btn-group {
    display: flex;
    flex: none;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.card-title :is(.btn, select) {
    flex: none;
    width: auto;
    max-width: 100%;
    height: calc(var(--fs-lg) * 1.5);
    min-height: 0;
    padding: 0 8px;
    font-size: var(--fs-sm);
    line-height: 1.2;
    white-space: nowrap;
}

/* ============================================================
   表单
   ============================================================ */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-sm);
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--gap-sm);
    min-width: 0;
}

.form-group label {
    font-size: var(--fs-sm);
    font-weight: 400;
    color: var(--clr-text-muted);
    margin-bottom: 6px;
}

.form-group label .required {
    color: var(--clr-danger);
    margin-left: 2px;
}
.required {
    color: var(--clr-danger);
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="tel"],
input[type="search"],
textarea,
select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: var(--input-h);
    padding: 0 10px;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-base);
    font-weight: 400;
    font-family: inherit;
    color: var(--clr-text);
    background: var(--clr-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

/* 下拉框保留系统原生箭头，随浏览器和控件尺寸绘制。 */
select {
    -webkit-appearance: auto;
    appearance: auto;
}

textarea {
    height: auto;
    padding: 8px 10px;
    resize: vertical;
    line-height: 1.5;
    min-height: 96px;
    max-height: 480px;
    min-width: 100%;
    max-width: 100%;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

input:disabled,
textarea:disabled,
select:disabled {
    background: var(--clr-bg);
    color: var(--clr-text-muted);
    cursor: not-allowed;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--input-h);
    padding: 0 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--fs-base);
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--clr-primary-dark);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--clr-primary-dark);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.22);
}

.btn-danger {
    background: var(--clr-danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: var(--clr-danger-dark);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.22);
}

.btn-success {
    background: var(--clr-success);
    color: #fff;
}
.btn-success:hover:not(:disabled) {
    background: var(--clr-success-dark);
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.22);
}

.btn-outline {
    background: transparent;
    color: var(--clr-primary-dark);
    border: 1.5px solid var(--clr-primary-dark);
}
.btn-outline:hover:not(:disabled) {
    background: rgba(26, 32, 44, 0.06);
}

.btn-secondary {
    background: var(--clr-bg);
    color: var(--clr-text);
    border: 1.5px solid var(--clr-border);
}
.btn-secondary:hover:not(:disabled) {
    background: #e9edf3;
}

.btn-sm {

    padding: 0 12px;
    font-size: var(--fs-sm);
}

.btn-block { width: 100%; }

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-xs);
}

/* ============================================================
   右键菜单
   ============================================================ */
.context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    padding: 4px 0;
    display: none;
}

.context-menu.show { display: block; }

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: var(--fs-sm);
    cursor: pointer;
    color: var(--clr-text);
    transition: background 0.1s;
}
.context-menu-item:hover { background: var(--clr-bg); }
.context-menu-item.danger { color: var(--clr-danger); }
.context-menu-divider {
    height: 1px;
    background: var(--clr-border);
    margin: 4px 0;
}

/* ============================================================
   模态框
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--clr-overlay);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: var(--gap-sm);
}
.modal-overlay.show { display: flex; }

.modal {
    background: var(--clr-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--gap-sm) var(--gap-md);
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-primary);
    color: #fff;
}

.modal-header h3 {
    font-size: var(--fs-lg);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: var(--fs-2xl);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

.modal-body {
    padding: var(--gap-md);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: var(--gap-xs);
    justify-content: flex-end;
    padding: var(--gap-sm) var(--gap-md);
    border-top: 1px solid var(--clr-border);
}

/* ============================================================
   三级联动
   ============================================================ */
.linkage-box {
    display: flex;
    gap: var(--gap-xs);
    align-items: flex-start;
}

.linkage-box select {
    flex: 1;
    cursor: pointer;
}

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 440px;
    border-radius: var(--radius-md);
    border: 1px solid var(--clr-border);
}

.table-wrap.table-wrap-full {
    max-height: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    background: var(--clr-surface);
}

thead { background: var(--clr-bg); }
.table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--clr-bg);
}

th, td {
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
}

th {
    font-weight: 600;
    color: var(--clr-text);
    border-bottom: 2px solid var(--clr-border);
}

tbody tr {
    border-bottom: 1px solid var(--clr-border);
    transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ============================================================
   图片预览
   ============================================================ */
.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-xs);
}

.photo-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--clr-border);
    overflow: hidden;
    cursor: pointer;
}
.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-thumb .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.85);
    color: #fff;
    border: none;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   图片轮播
   ============================================================ */
.carousel {
    position: relative;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    user-select: none;
}

.carousel-img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: contain;
    display: block;
    max-height: 60vh;
    margin: 0 auto;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    font-size: var(--fs-xl);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 2;
}
.carousel-btn:hover { background: rgba(0, 0, 0, 0.75); }
.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }
.carousel-btn:disabled { opacity: 0.3; cursor: default; }

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px;
}
.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.carousel-dot.active { background: #fff; }

/* ============================================================
   全屏查看器
   ============================================================ */
.fullscreen-viewer {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 20000;
    align-items: center;
    justify-content: center;
}
.fullscreen-viewer.show { display: flex; }

.fullscreen-viewer img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
}

.fs-close {
    position: fixed;
    top: 12px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    font-size: var(--fs-xl);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20001;
}
.fs-close:hover { background: rgba(255,255,255,0.25); }

/* ============================================================
   Toast / 提示
   ============================================================ */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -12px);
    background: var(--clr-text);
    color: #fff;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    max-width: min(420px, calc(100vw - 32px));
    line-height: 1.5;
    text-align: center;
    overflow-wrap: anywhere;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}
.toast.error { background: var(--clr-danger); }
.toast.success { background: var(--clr-success); }
.toast.warning { background: #b45309; }

#catTextArea {
    font-size: var(--fs-sm);
    line-height: 1.5;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-family: monospace;
}

/* ============================================================
   标签徽章
   ============================================================ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: var(--fs-xs);
    font-weight: 600;
}
.badge-active    { background: #dcfce7; color: #15803d; }
.badge-disabled  { background: #fee2e2; color: #b91c1c; }
.badge-locked     { background: #fef9c3; color: #a16207; }

/* ============================================================
   状态栏 / 导航栏
   ============================================================ */
body > nav:not(.toc),
.nav-bar {
    background: var(--clr-surface);
    box-shadow: var(--nav-shadow);
    border-bottom: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: min(100%, var(--content-max-width));
    max-width: none;
    margin: 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 var(--gap-sm);
}

body > nav:not(.toc) {
    width: min(100%, var(--content-max-width));
}

.nav-left {
    flex-shrink: 0;
    font-size: var(--fs-lg);
    font-weight: 500;
    color: var(--clr-text-white);
    padding: 0 12px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.nav-left a {
    text-decoration: none;
    color: var(--clr-text);
    font-weight: 500;
    font-size: var(--fs-lg);
}
.nav-left a:hover {
    color: var(--clr-info);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.nav-user {
    flex-shrink: 0;
    font-size: var(--fs-lg);
    font-weight: 400;
    color: var(--clr-text);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.nav-user-arrow {
    font-size: var(--fs-lg);
    transition: transform 0.2s;
    line-height: 1;
}
.nav-user:hover {
    color: var(--clr-info);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.user-dropdown {
    display: none;
    position: absolute;
    padding: 8px 0;
    top: 100%;
    right: 8px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 300px;
    z-index: 1001;
}
.user-dropdown.show {
    display: block;
}
.user-dropdown-item {
    padding: 10px 16px;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: background 0.15s;
}
.user-dropdown-item:hover {
    background: var(--clr-bg);
}
.user-info-panel {
    padding: 0 16px 8px 16px;
    margin-bottom: 4px;
    user-select: text;
    cursor: text;
}
.info-row {
    display: flex;
    font-size: var(--fs-sm);
    line-height: 1.6;
    margin: 6px 0;
    color: var(--clr-text);
}
.info-row .info-label {
    width: 86px;
    flex-shrink: 0;
    color: var(--clr-text-muted);
    font-weight: normal;
}
.info-row .info-value {
    flex: 1;
    color: var(--clr-text);
    word-break: break-word;
}
.dropdown-divider {
    height: 1px;
    background: var(--clr-border);
    margin: 6px 0;
}
.logout-item {
    color: var(--clr-danger);
    cursor: pointer;
}
.logout-item:hover {
    background: var(--clr-bg);
}



#navLinks {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
}

#navLinks li {
    margin: 0;
}

#navLinks a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--clr-text);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: background-color 0.2s;
}

#navLinks a:hover {
    background-color: var(--clr-surface-light);
}

#navLinks a.active {
    background-color: var(--clr-primary);
    color: #fff;
}

/* ============================================================
   分隔线
   ============================================================ */
.divider {
    height: 1px;
    background: var(--clr-border);
    margin: var(--gap-sm) 0;
}

/* ============================================================
   搜索提示列表（拼音搜索）
   ============================================================ */
.pinyin-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    background: var(--clr-surface);
    border: 1.5px solid var(--clr-primary);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 500;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}
.pinyin-dropdown.show { display: block; }

.pinyin-item {
    padding: 8px 12px;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--clr-border);
}
.pinyin-item:last-child { border-bottom: none; }
.pinyin-item:hover { background: #eff6ff; }
.pinyin-item.selected { background: var(--clr-primary); color: #fff; }
.pinyin-item.selected span { color: rgba(255,255,255,0.8) !important; }
.pinyin-highlight { color: #dc2626 !important; font-weight: 700; }
.pinyin-item.selected .pinyin-highlight { color: #dc2626 !important; }

/* ============================================================
   Shared page layout utilities
   ============================================================ */
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.toolbar.toolbar-bottom { align-items: flex-end; }
.toolbar.toolbar-between { justify-content: space-between; }
.toolbar .form-group {
    flex: 1;
    min-width: 160px;
    margin-bottom: 0;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.empty,
.empty-tip {
    text-align: center;
    color: var(--clr-text-muted);
    padding: 24px;
}
.empty-tip {
    padding: var(--gap-lg) var(--gap-sm);
    font-size: var(--fs-sm);
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 18px;
}
.info-item {
    border-bottom: 1px solid var(--clr-border);
    padding-bottom: 8px;
}
.info-item.full-row { grid-column: 1 / -1; }
.info-label {
    color: var(--clr-text-muted);
    font-size: var(--fs-sm);
    margin-bottom: 2px;
}
.info-value { word-break: break-word; }
.info-value.multiline { white-space: pre-wrap; }
.status-badge,
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: #eef2ff;
    color: #3730a3;
    font-size: var(--fs-xs);
}
.badge-active { background: #dcfce7; color: #15803d; }
.badge-disabled { background: #fee2e2; color: #b91c1c; }
.badge-locked { background: #fef9c3; color: #a16207; }

input[type="datetime-local"] {
    width: 100%;
    height: var(--input-h);
    padding: 0 12px;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    font-family: inherit;
    color: var(--clr-text);
    background: var(--clr-surface);
}
input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.payload-box {
    white-space: pre-wrap;
    word-break: break-word;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: Consolas, monospace;
    font-size: var(--fs-sm);
}

.detail-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.52);
}
.detail-modal.show { display: flex; }
.detail-modal-card {
    width: min(1080px, 100%);
    height: min(760px, calc(100vh - 48px));
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.detail-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--clr-border);
}
.detail-modal-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.detail-modal-actions {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.detail-modal-actions .btn {
    flex: 0 0 auto;
}
.detail-modal iframe {
    flex: 1;
    min-height: 0;
    width: 100%;
    border: 0;
    background: #fff;
}

.linkage-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.linkage-row {
    display: flex;
    gap: 8px;
    align-items: center;
}


.form-row > .form-group {
    min-width: 0;
}

.form-row input,
.form-row select {
    min-width: 0;
    max-width: 100%;
}

.table-wrap tr.selected,
.table-wrap tr.selected:hover {
    background: #dbeafe !important;
    outline: 2px solid #60a5fa;
    outline-offset: -2px;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
    html { font-size: 15px; }

    .form-row {
        grid-template-columns: 1fr;
    }

    .btn-group {
        flex-direction: column;
    }

    .detail-modal-head {
        gap: 8px;
        padding: 10px 12px;
        flex-shrink: 0;
    }

    .detail-modal-actions {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .detail-modal-actions .btn {
        width: auto;
        height: 2.25rem;
        min-width: 0;
        padding: 0 10px;
        font-size: var(--fs-sm);
        white-space: nowrap;
    }

    .btn {
        height: var(--input-h);
        font-size: var(--fs-base);
    }

    .carousel-img {
        max-height: 45vh;
    }

    .modal {
        max-height: 95vh;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .detail-modal {
        align-items: stretch;
        justify-content: flex-start;
        padding: 0;
        height: 100vh;
        height: 100dvh;
    }

    .detail-modal-card {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .toolbar.toolbar-bottom {
        flex-direction: column;
        align-items: stretch;
    }

    .linkage-row {
        flex-direction: column;
    }

    .linkage-row select {
        width: 100%;
    }

    table {
        font-size: var(--fs-xs);
    }
    th, td {
        padding: 8px 10px;
    }
}


@media (max-width: 600px) and (orientation: portrait) {
    :root {
        --mobile-form-label-width: 86px;
    }

    .card .form-row,
    .modal-body .form-row,
    .toolbar .form-row {
        display: block;
    }

    .card .form-group,
    .modal-body .form-group,
    .toolbar .form-group {
        display: grid;
        grid-template-columns: var(--mobile-form-label-width) minmax(0, 1fr);
        gap: 10px;
        align-items: center;
        min-width: 0;
        margin-bottom: 10px;
    }

    .card .form-group > label,
    .modal-body .form-group > label,
    .toolbar .form-group > label {
        margin: 0;
        line-height: 1.35;
        text-align: right;
        align-self: center;
    }

    .card .form-group > input,
    .card .form-group > select,
    .card .form-group > textarea,
    .card .form-group > button,
    .card .form-group > .btn,
    .card .form-group > .btn-group,
    .card .form-group > .linkage-box,
    .card .form-group > .linkage-wrap,
    .card .form-group > .linkage-row,
    .modal-body .form-group > input,
    .modal-body .form-group > select,
    .modal-body .form-group > textarea,
    .modal-body .form-group > button,
    .modal-body .form-group > .btn,
    .modal-body .form-group > .btn-group,
    .modal-body .form-group > .linkage-box,
    .modal-body .form-group > .linkage-wrap,
    .modal-body .form-group > .linkage-row,
    .toolbar .form-group > input,
    .toolbar .form-group > select,
    .toolbar .form-group > textarea,
    .toolbar .form-group > button,
    .toolbar .form-group > .btn,
    .toolbar .form-group > .btn-group,
    .toolbar .form-group > .linkage-box,
    .toolbar .form-group > .linkage-wrap,
    .toolbar .form-group > .linkage-row {
        grid-column: 2;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .card .form-group > textarea,
    .modal-body .form-group > textarea,
    .toolbar .form-group > textarea {
        align-self: stretch;
    }

    .card .form-group > input[type="hidden"],
    .modal-body .form-group > input[type="hidden"],
    .toolbar .form-group > input[type="hidden"] {
        display: none;
    }}
@media (max-width: 640px) {
    .nav-bar {
        padding: 0 var(--gap-sm);
        min-height: 3rem;
    }

    .nav-left .home-link,
    .nav-center .home-link,
    .nav-user {
        padding: 0.4rem 0.8rem;
        font-size: var(--fs-sm);
    }

    .nav-center {
        display: none;
    }
}
@media (max-width: 480px) {
    html { font-size: 14px; }

    .container {
        padding: var(--gap-xs);
    }

    .card {
        padding: var(--gap-sm);
        border-radius: var(--radius-md);
    }
    .user-dropdown {
        min-width: 260px;
        right: 8px;
    }
    .info-row .info-label {
        width: 70px;
    }
}

/* ============================================================
   Tool portal shared layout
   ============================================================ */
:root {
    --tool-page-max-width: clamp(960px, 92vw, 1440px);
    --tool-accent: #c2252d;
    --tool-accent-dark: #a91f27;
    --tool-soft-bg: #f8fafc;
    --tool-soft-danger: #fffafa;
}

.tool-body,
.tool-body * {
    max-width: 100%;
}

.tool-body {
    margin: 0;
    min-height: 100vh;
    padding: 0 14px 14px;
    overflow-x: hidden;
    background: var(--clr-bg);
    color: #172033;
    font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans", Roboto, Helvetica, Arial, sans-serif;
}

.tool-page {
    width: min(100%, var(--tool-page-max-width));
    margin: 0 auto;
    display: grid;
    gap: 14px;
    min-width: 0;
}

.tool-topbar,
.tool-page-header {
    min-width: 0;
}

.tool-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    margin: 0 -14px 14px;
    background: var(--clr-surface);
    border-bottom: 0;
    box-shadow: var(--nav-shadow);
}

.tool-topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.tool-page-header {
    padding: 10px 2px 2px;
}

.tool-page-title {
    margin: 0;
    color: #111827;
    font-size: var(--fs-2xl);
    line-height: 1.25;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.tool-page-subtitle {
    margin: 8px 0 0;
    color: #667085;
    font-size: var(--fs-sm);
    line-height: 1.6;
}

.tool-panel {
    min-width: 0;
    padding: 16px;
    border: 1px solid #e4e9f1;
    border-radius: var(--radius-md);
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    overflow: hidden;
}

/* ============================================================
   工具页面共用导航、页签及按钮
   ============================================================ */
.tool-body .home-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: #1f2f46;
    font-size: var(--fs-sm);
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, transform 0.12s;
}


.tool-body .home-link:hover {
    border-color: #94a3b8;
    background: var(--tool-soft-bg);
}


.tool-body .home-link:active {
    transform: scale(0.98);
}


.tool-body .win-tabs {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
    padding: 0 8px;
    border-bottom: 1px solid #cbd5e1;
    background: #ffffff;
    margin-bottom: 0;
}


.tool-body .tab-btn {
    position: relative;
    min-height: 38px;
    min-width: 0;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    background: #f8fafc;
    color: #344256;
    font-size: var(--fs-sm);
    font-weight: 400;
    box-shadow: inset 0 -1px 0 #cbd5e1;
    transform: translateY(1px);
}


.tool-body .tab-btn.active {
    background: #ffffff;
    color: var(--tool-accent);
    min-height: 42px;
    border-color: #cbd5e1;
    box-shadow: 0 -1px 6px rgba(15, 23, 42, 0.05);
    z-index: 2;
}


.tool-body .tab-frame {
    min-width: 0;
    padding: 16px;
    border: 1px solid #cbd5e1;
    border-top: 0;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    background: #ffffff;
}


.tool-body .tab-pane {
    display: none;
    min-width: 0;
}


.tool-body .tab-pane.active {
    display: block;
}


.tool-body button {
    min-height: 42px;
    border: 0;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: transform 0.12s, background 0.12s, border-color 0.12s;
}


.tool-body button:active {
    transform: scale(0.98);
}


.tool-body button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}


.tool-body .btn-primary {
    background: var(--tool-accent);
    color: white;
}


.tool-body .btn-primary:hover {
    background: var(--tool-accent-dark);
}


.tool-body .btn-secondary {
    background: #ffffff;
    color: #1f2f46;
    border: 1px solid #cbd5e1;
}


.tool-body .btn-secondary:hover {
    border-color: #94a3b8;
    background: var(--tool-soft-bg);
}


.tool-body h2 {
    margin: 0;
    font-size: var(--fs-lg);
    line-height: 1.3;
}


@media (max-width: 720px) {
    .tool-body {
        padding: 10px;
    }


    .tool-panel {
        padding: 12px;
    }


    .tool-topbar,
.tool-topbar-left {
        align-items: flex-start;
    }


    .tool-topbar-left {
        gap: 10px;
    }


    .tool-page-title {
        font-size: var(--fs-xl);
    }


    .tool-body .home-link {
        padding: 0 10px;
    }


    .tool-body .win-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 0 4px;
    }


    .tool-body .tab-btn {
        padding: 0 10px;
    }


    .tool-body .tab-frame {
        padding: 12px;
    }

}

/* 从 PCD 提取的公共筛选条件列表，两页使用同一套标签和删除按钮。 */
.filter-tags{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 14px}
/* 筛选标签及右上角叉号统一采用第一版尺寸，并为叉号预留文字间距。 */
.filter-tag{position:relative;max-width:100%;padding:8px 29px 8px 10px;border:1px solid #bfdbfe;border-radius:5px;background:#eff6ff;color:#1e40af;font-size:13px;overflow-wrap:anywhere}
.filter-text{min-width:0;overflow-wrap:anywhere}
.filter-remove{position:absolute;right:1px;top:0;display:flex;align-items:center;justify-content:center;width:25px;height:25px;min-height:0;padding:0;border:0;border-radius:4px;background:transparent;color:#64748b;font:20px/1 sans-serif;cursor:pointer}
.filter-remove:hover,.filter-remove:focus-visible{background:#dbeafe;color:#b91c1c}
.filter-tags[hidden] { display: none; }

/* 公共筛选条：所有控件顺序排列，空间不够再换行；日期触发器与普通选择框等宽。 */
.filter-bar {
    --filter-control-width: 125px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.filter-bar > select,
.filter-bar > .date-picker,
.filter-criteria > select,
.filter-time > select,
.filter-time > .date-picker {
    flex: 0 1 var(--filter-control-width);
    width: var(--filter-control-width);
    min-width: 0;
}
.filter-bar .filter-operator {
    flex-basis: 85px;
    width: 85px;
}
.filter-bar .filter-value {
    flex: 1 1 150px;
    min-width: 0;
    max-width: 100%;
}
.filter-value > :is(input, select) {
    width: 100%;
    min-width: 0;
}
.filter-value > [hidden] {
    display: none;
}
.filter-bar > .btn,
.filter-entry > .btn,
.filter-time > .btn {
    flex: none;
    width: auto;
}
.filter-bar .date-picker .date-picker-trigger {
    gap: 4px;
    padding-inline: 6px;
}
.filter-criteria, .filter-entry, .filter-time {
    display: contents;
}
.filter-bar .filter-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 var(--input-h);
    width: var(--input-h);
    height: var(--input-h);
    min-height: var(--input-h);
    padding: 0;
    font: 20px/1 sans-serif;
}
/* 带时间条件的手机筛选区固定三行，三行共用完整宽度；加号保持正方形。 */
@media (max-width: 760px) {
    .filter-bar-mobile-rows {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }
    .filter-bar-mobile-rows > .filter-criteria,
    .filter-bar-mobile-rows > .filter-entry {
        display: grid;
        align-items: center;
        min-width: 0;
        gap: 8px;
    }
    .filter-bar-mobile-rows > .filter-criteria {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .filter-bar-mobile-rows .filter-criteria > select { width: 100%; }
    .filter-bar-mobile-rows > .filter-entry {
        grid-template-columns: minmax(0, 1fr) var(--input-h);
    }
    .filter-bar-mobile-rows > .filter-time {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }
    .filter-bar-mobile-rows .filter-time > :is(select, .date-picker) { width: 100%; }
    .filter-bar-mobile-rows .filter-time > .btn { padding-inline: 8px; }
    /* 窄屏优先保留完整的时间文字，去掉重复的日历图标，为三个控件留出空间。 */
    .filter-bar-mobile-rows .filter-time .date-picker-icon { display: none; }
    .filter-bar-mobile-rows .filter-time .date-picker-chevron { width: 12px; }
}

/* 公共详情弹窗：标题固定、内容独立滚动；边界回弹由 dialog.js 管理。 */
.dialog {
    width: min(720px, calc(100% - 24px));
    max-width: calc(100% - 24px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    background: var(--clr-surface);
    color: var(--clr-text);
    overscroll-behavior: contain;
}
.dialog[open] {
    display: flex;
    flex-direction: column;
}
.dialog::backdrop { background: var(--clr-overlay); }
.dialog-head {
    flex: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
    padding: 14px 18px;
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
}
.dialog-head h2 { margin: 0; font-size: var(--fs-xl); overflow-wrap: anywhere; }
.dialog-head h2:focus { outline: none; }
.dialog-close {
    flex: none;
    width: 40px;
    border: 0;
    background: none;
    font-size: 28px;
    color: var(--clr-text-muted);
    cursor: pointer;
}
.dialog-content {
    /* 必须用内容高度作基础；0% 会让 WebKit 的自适应高度弹窗压缩到只剩内边距。 */
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px 18px 18px;
    overflow-wrap: anywhere;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}
@media (max-width: 760px) {
    .dialog {
        height: calc(100vh - 24px);
        height: calc(100dvh - 24px);
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
    }
    .dialog-head, .dialog-content { padding-left: 12px; padding-right: 12px; }
}

/* ===== Shared date range picker ===== */
.date-picker {
    position: relative;
    display: inline-flex;
    width: auto;
    max-width: 100%;
    min-width: 0;
}

.date-picker .date-picker-trigger {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    height: var(--input-h);
    padding: 0 10px;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    background: var(--clr-surface);
    color: var(--clr-text);
    font: inherit;
    font-size: var(--fs-base);
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.date-picker .date-picker-trigger:hover,
.date-picker .date-picker-trigger-open {
    border-color: var(--clr-primary);
}

.date-picker .date-picker-trigger:focus-visible {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.date-picker-preset:focus-visible,
.date-picker-apply:focus-visible {
    outline: 2px solid var(--clr-primary);
    outline-offset: 2px;
}

.date-picker-icon,
.date-picker-chevron {
    flex: none;
    width: 16px;
    height: 16px;
    color: var(--clr-text-muted);
}

.date-picker-chevron {
    margin-left: auto;
    transition: transform 0.2s;
}

.date-picker-trigger-open .date-picker-chevron {
    transform: rotate(180deg);
}

.date-picker-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.date-picker-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: 340px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    background: var(--clr-surface);
    box-shadow: var(--shadow-lg);
}

.date-picker-dropdown[hidden],
.date-picker-error[hidden] {
    display: none;
}

.date-picker-presets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 8px;
}

.date-picker-dropdown .date-picker-preset {
    min-height: 32px;
    padding: 5px 8px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--clr-text-muted);
    font: inherit;
    font-size: var(--fs-sm);
    cursor: pointer;
}

.date-picker-dropdown .date-picker-preset:hover {
    background: var(--clr-surface-light);
    color: var(--clr-text);
}

.date-picker-dropdown .date-picker-preset-active,
.date-picker-dropdown .date-picker-preset-active:hover {
    background: #dbeafe;
    color: var(--clr-primary-dark);
    font-weight: 600;
}

.date-picker-divider {
    border-top: 1px solid var(--clr-border);
}

.date-picker-custom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr);
    align-items: end;
    gap: 8px;
    padding: 10px 12px 6px;
}

.date-picker-field {
    min-width: 0;
}

.date-picker-label {
    display: block;
    margin-bottom: 4px;
    color: var(--clr-text-muted);
    font-size: var(--fs-xs);
}

.date-picker-dropdown .date-picker-input {
    width: 100%;
    height: 36px;
    padding: 0 6px;
    font-size: var(--fs-sm);
}

.date-picker-separator {
    padding-bottom: 8px;
    color: var(--clr-text-muted);
    text-align: center;
}

.date-picker-error {
    padding: 0 12px;
    color: var(--clr-danger-dark);
    font-size: var(--fs-xs);
}

.date-picker-actions {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px 12px;
}

.date-picker-dropdown .date-picker-apply {
    width: auto;
    height: 34px;
    min-height: 34px;
    padding: 0 14px;
    font-size: var(--fs-sm);
}
/* ===== End shared date range picker ===== */


/* 公共固定导航栏，供成绩统计和执勤力量等页面复用。 */
body > nav.site-topbar { position: fixed; inset: 0 0 auto; z-index: 1000; display: block; width: 100%; max-width: none; height: auto; margin: 0; padding: 0; background: #fff; border-bottom: 1px solid var(--clr-border); }

.site-topbar-inner { max-width: var(--content-max-width); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.site-topbar .btn-group { display: flex; flex-direction: row; flex-wrap: nowrap; width: auto; gap: 8px; margin: 0; }

.site-topbar .btn { flex: none; width: auto; min-height: 40px; height: 40px; padding: 0 10px; white-space: nowrap; }

@media(max-width:760px) {
    .site-topbar-inner { padding-left: 8px; padding-right: 8px; }

}
