/* 灰豚行政 · 全站统一主题（管理后台） */

:root {
    --ht-primary: #6366f1;
    --ht-primary-2: #8b5cf6;
    --ht-bg: #0f172a;
    --ht-card: rgba(30, 41, 59, 0.78);
    --ht-border: rgba(255, 255, 255, 0.09);
    --ht-text: #f1f5f9;
    --ht-muted: #94a3b8;
    --ht-radius: 12px;
    --ht-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

body.ht-admin {
    padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px));
}

/* ---------- 顶栏导航 ---------- */
.site-nav-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.site-main-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: rgba(15, 23, 42, 0.65);
    border-radius: var(--ht-radius);
    padding: 4px;
    border: 1px solid var(--ht-border);
}

.site-main-toggle .toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ht-muted);
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    white-space: nowrap;
}

.site-main-toggle .toggle-btn:hover {
    color: var(--ht-text);
    background: rgba(255, 255, 255, 0.06);
}

.site-main-toggle .toggle-btn.active {
    background: linear-gradient(135deg, var(--ht-primary), var(--ht-primary-2));
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.site-main-toggle .toggle-btn-outline {
    border: 1px dashed rgba(148, 163, 184, 0.35);
    margin-left: 2px;
}

.site-help-btn {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.45);
    background: rgba(99, 102, 241, 0.12);
    color: #c7d2fe;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.site-help-btn:hover {
    background: rgba(99, 102, 241, 0.22);
    border-color: rgba(129, 140, 248, 0.7);
}

@media (max-width: 640px)
{
    .site-main-toggle .toggle-label { display: none; }
    .site-main-toggle .toggle-btn { padding: 10px 12px; }
    .site-help-btn span.help-text { display: none; }
}

/* ---------- 公告弹窗 ---------- */
.ht-announce-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s, visibility 0.25s;
}

.ht-announce-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ht-announce-overlay[hidden] {
    display: none !important;
    pointer-events: none !important;
}

.ht-announce-modal {
    width: min(560px, 100%);
    max-height: min(86vh, 720px);
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid var(--ht-border);
    border-radius: 16px;
    box-shadow: var(--ht-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.25s;
}

.ht-announce-overlay.show .ht-announce-modal {
    transform: translateY(0) scale(1);
}

.ht-announce-head {
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--ht-border);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.08));
}

.ht-announce-head h2 {
    font-size: 18px;
    font-weight: 800;
    color: var(--ht-text);
    margin: 0 0 4px;
}

.ht-announce-head p {
    font-size: 13px;
    color: var(--ht-muted);
    margin: 0;
}

.ht-announce-body {
    padding: 16px 22px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.ht-announce-section {
    margin-bottom: 16px;
}

.ht-announce-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ht-announce-section ul {
    margin: 0;
    padding-left: 18px;
    color: var(--ht-muted);
    font-size: 13px;
    line-height: 1.65;
}

.ht-announce-section li + li {
    margin-top: 4px;
}

.ht-announce-foot {
    padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--ht-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ht-announce-foot .note {
    font-size: 12px;
    color: var(--ht-muted);
    text-align: center;
}

.ht-announce-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.ht-btn {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s, transform 0.1s;
}

.ht-btn:active { transform: scale(0.98); }

.ht-btn-primary {
    background: linear-gradient(135deg, var(--ht-primary), var(--ht-primary-2));
    color: #fff;
}

.ht-btn-ghost {
    background: rgba(255, 255, 255, 0.06);
    color: var(--ht-muted);
    border: 1px solid var(--ht-border);
}

/* 统一按钮微交互 */
button, .btn, .tab {
    transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s;
}

button:active:not(:disabled), .tab:active {
    transform: scale(0.98);
}

/* ---------- 右上角用户菜单（管理/子管理页） ---------- */
.site-user-wrap {
    position: relative;
    z-index: 20;
    flex-shrink: 0;
    display: none;
}

.header.site-menu-open,
.uc-header.site-menu-open {
    z-index: 130;
}

.site-user-menu { position: relative; }

.site-user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--ht-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--ht-text);
    cursor: pointer;
    transition: all 0.2s;
    max-width: min(220px, 46vw);
}

.site-user-trigger:hover,
.site-user-trigger.open {
    border-color: rgba(99, 102, 241, 0.45);
    background: rgba(99, 102, 241, 0.12);
}

.site-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, var(--ht-primary), #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.site-user-avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.site-user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.site-user-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-user-chevron {
    font-size: 10px;
    color: var(--ht-muted);
    transition: transform 0.2s;
}

.site-user-trigger.open .site-user-chevron { transform: rotate(180deg); }

.site-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(280px, calc(100vw - 32px));
    max-height: min(70vh, 420px);
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    padding: 8px;
    z-index: 120;
}

.site-user-dropdown.is-fixed {
    z-index: 1000;
}

.header.site-menu-open {
    overflow: visible !important;
}

.site-dropdown-head {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--ht-border);
    margin-bottom: 6px;
}

.site-dropdown-name { font-size: 15px; font-weight: 700; word-break: break-all; }
.site-dropdown-sub { font-size: 12px; color: var(--ht-muted); margin-top: 2px; }

.site-role-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.site-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ht-text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.site-menu-item:hover { background: rgba(255, 255, 255, 0.06); }
.site-menu-item.danger { color: #fca5a5; }
.site-menu-item.danger:hover { background: rgba(239, 68, 68, 0.12); }

.site-dropdown-divider {
    height: 1px;
    background: var(--ht-border);
    margin: 6px 4px;
}

.site-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: transparent;
}

.site-hidden { display: none !important; }

.header-top-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

@media (max-width: 520px) {
    .site-user-name { display: none; }
    .site-user-trigger { padding-right: 8px; }
}

/* 修改密码弹窗 */
.site-pwd-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.site-pwd-modal {
    width: min(420px, 100%);
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid var(--ht-border);
    border-radius: 16px;
    box-shadow: var(--ht-shadow);
    padding: 20px;
}

.site-pwd-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.site-pwd-head h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ht-text);
}

.site-pwd-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ht-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.site-pwd-close:hover { color: var(--ht-text); }

.site-pwd-label {
    display: block;
    font-size: 12px;
    color: var(--ht-muted);
    margin: 0 0 6px;
}

.site-pwd-input {
    width: 100%;
    padding: 11px 12px;
    margin-bottom: 12px;
    border-radius: 10px;
    border: 1px solid var(--ht-border);
    background: #1e293b;
    color: var(--ht-text);
    font-size: 14px;
    color-scheme: dark;
}

.site-pwd-input:focus {
    outline: none;
    border-color: var(--ht-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.site-pwd-msg {
    min-height: 18px;
    font-size: 13px;
    margin: 4px 0 12px;
    color: #fca5a5;
}

.site-pwd-msg.ok { color: #6ee7b7; }

.site-pwd-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ---------- 全站滚动条（细窄、无箭头、主题色） ---------- */
:root {
    --ht-scrollbar-size: 6px;
    --ht-scrollbar-thumb: rgba(99, 102, 241, 0.45);
    --ht-scrollbar-thumb-hover: rgba(129, 140, 248, 0.72);
}

html {
    scrollbar-width: thin;
    scrollbar-color: var(--ht-scrollbar-thumb) transparent;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--ht-scrollbar-thumb) transparent;
}

*::-webkit-scrollbar {
    width: var(--ht-scrollbar-size);
    height: var(--ht-scrollbar-size);
}

*::-webkit-scrollbar-track {
    background: transparent;
    margin: 3px 0;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(
        180deg,
        rgba(99, 102, 241, 0.38) 0%,
        rgba(139, 92, 246, 0.5) 100%
    );
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 36px;
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(
        180deg,
        rgba(99, 102, 241, 0.58) 0%,
        rgba(139, 92, 246, 0.7) 100%
    );
    border-color: rgba(255, 255, 255, 0.1);
}

*::-webkit-scrollbar-thumb:active {
    background: linear-gradient(
        180deg,
        rgba(99, 102, 241, 0.75) 0%,
        rgba(139, 92, 246, 0.85) 100%
    );
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

*::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* 横向滚动条轨道略留白 */
*::-webkit-scrollbar-track:horizontal {
    margin: 0 3px;
}

/* 需要隐藏滚动条的区域（横向标签、统计卡片等） */
.ht-scrollbar-hidden,
.stats,
.tabs {
    scrollbar-width: none;
}

.ht-scrollbar-hidden::-webkit-scrollbar,
.stats::-webkit-scrollbar,
.tabs::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* ---------- 全站 range 滑块（温度等） ---------- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        rgba(99, 102, 241, 0.22) 0%,
        rgba(139, 92, 246, 0.35) 100%
    );
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ht-primary), var(--ht-primary-2));
    border: 2px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 14px rgba(99, 102, 241, 0.55);
}

input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        rgba(99, 102, 241, 0.22) 0%,
        rgba(139, 92, 246, 0.35) 100%
    );
    border: none;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ht-primary), var(--ht-primary-2));
    border: 2px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.45);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.08);
}

/* ---------- 考勤迟到标红 ---------- */
.attendance-late-row,
.mobile-card.attendance-late-card,
.uc-att-item.attendance-late,
.uc-att-day-item.attendance-late {
    outline: 2px solid #ef4444 !important;
    outline-offset: -2px;
    box-shadow:
        0 0 0 1px rgba(239, 68, 68, 0.45),
        0 0 24px rgba(239, 68, 68, 0.22) !important;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(127, 29, 29, 0.08)) !important;
}

.attendance-late-badge,
.uc-att-badge.late {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    vertical-align: middle;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
    animation: attendance-late-pulse 2s ease-in-out infinite;
}

.attendance-late-time,
.uc-att-time.late {
    color: #fca5a5;
    font-weight: 700;
}

.attendance-late-alert {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid rgba(239, 68, 68, 0.65);
    background: rgba(127, 29, 29, 0.28);
    color: #fecaca;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.55;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.18);
}

.attendance-late-alert.compact {
    margin: 0 0 10px;
    padding: 8px 10px;
    font-size: 12px;
}

#attendanceDetailModal tr.attendance-late-punch-row td {
    background: rgba(239, 68, 68, 0.12);
    border-top: 1px solid rgba(239, 68, 68, 0.25);
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
}

@keyframes attendance-late-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.35); }
    50% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.65); }
}
