/* ================================================================
   数据权限 / 查看他人 / 分享 / 管理员面板 / 只读模式
   ================================================================ */

/* ---------- 设置齿轮 ---------- */
#settingsGear {
    border: 0 !important;
    background: transparent !important;
    cursor: pointer !important;
    font-size: 1.05rem !important;
    padding: 2px 6px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: auto !important;
    position: relative !important;
    z-index: 100000 !important;
}

.top-header .title-area h1 {
    border-left: none !important;
    padding-left: 0 !important;
}

#settingsMenu {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100001;
    min-width: 150px;
    background: #fff;
    border: 1px solid #dce4ec;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(30,55,80,.16);
    padding: 6px;
}
#settingsMenu.show { display: block; }
#settingsMenu button {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .62rem;
    color: #263746;
}
#settingsMenu button:hover { background: #f1f6fb; }

/* ---------- 查看他人数据 ---------- */
#viewOtherPanel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(238,242,247,.96);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#viewOtherPanel.show { display: flex; }

/* ---------- 数据权限 ---------- */
#myAccessPanel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(238,242,247,.96);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#myAccessPanel.show { display: flex; }

/* ---------- 分享我的数据 ---------- */
#mySharePanel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(238,242,247,.96);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#mySharePanel.show { display: flex; }

/* ---------- 通用面板盒子 ---------- */
.access-box {
    width: min(430px, 100%);
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 12px 40px rgba(30,55,80,.16);
}
.access-box h3 { font-size: .95rem; color: #1a2a3a; margin-bottom: 8px; }
.access-desc { font-size: .6rem; color: #7b8a9a; line-height: 1.6; margin-bottom: 14px; }
.access-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dce4ec;
    border-radius: 10px;
    font-size: .68rem;
    outline: none;
    background: #fbfcfe;
    box-sizing: border-box;
}
.access-actions { display: flex; gap: 8px; margin-top: 12px; }
.access-actions .btn { flex: 1; }

.access-mode-row { display: flex; gap: 8px; margin: 12px 0; }
.access-mode-btn {
    flex: 1;
    padding: 10px 6px;
    border: 1px solid #dfe5ec;
    border-radius: 10px;
    background: #f7f9fb;
    cursor: pointer;
    font-size: .62rem;
}
.access-mode-btn.active {
    border-color: #2a7de1;
    background: #eaf4ff;
    color: #1d66b5;
}

#accessStatus {
    font-size: .6rem;
    color: #687687;
    line-height: 1.6;
    min-height: 20px;
    margin-top: 10px;
}

/* ---------- 管理员面板 ---------- */
#adminPanel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99992;
    background: rgba(238,242,247,.97);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#adminPanel.show { display: flex; }

.admin-box {
    width: min(900px, 100%);
    max-height: min(88vh, 760px);
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 12px 40px rgba(30,55,80,.16);
}
.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.admin-head h3 { font-size: .95rem; color: #1a2a3a; }
.admin-sub { font-size: .58rem; color: #7b8a9a; margin-bottom: 14px; }

.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.admin-stat { background: #f5f8fc; border-radius: 11px; padding: 10px; }
.admin-stat b { display: block; font-size: .9rem; color: #1d66b5; }
.admin-stat span { font-size: .52rem; color: #7b8a9a; }

.admin-table { width: 100%; border-collapse: collapse; font-size: .58rem; }
.admin-table th,
.admin-table td { padding: 9px 7px; border-bottom: 1px solid #edf1f5; text-align: left; }
.admin-table th { color: #718096; background: #f8fafc; font-weight: 600; }
.admin-online { color: #27ae60; font-weight: 600; }
.admin-offline { color: #9aa6b2; }

.admin-note {
    margin-top: 12px;
    padding: 9px 11px;
    border-radius: 9px;
    background: #fff8e8;
    color: #8a641c;
    font-size: .55rem;
    line-height: 1.6;
}

@media (max-width: 600px) {
    .admin-stats { grid-template-columns: repeat(2, 1fr); }
    .admin-box { padding: 16px; }
    .admin-table { font-size: .52rem; }
    .admin-table th,
    .admin-table td { padding: 7px 4px; }
}

/* ---------- 只读模式 ---------- */
#viewerBanner {
    display: none;
}
#viewerBanner.show {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 18px;
    z-index: 99999;
    background: #1d66b5;
    color: #fff;
    padding: 10px 16px;
    border-radius: 26px;
    font-size: .66rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,.22);
}
#viewerBanner button {
    background: rgba(255,255,255,.22);
    color: #fff;
    border: 0;
    padding: 5px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-size: .6rem;
    font-weight: 600;
}
#viewerBanner button:hover { background: rgba(255,255,255,.38); }

body.access-viewer .drag-area { display: none !important; }
body.access-viewer .top-header > .action-btns,
body.access-viewer .tool-library .lib-actions,
body.access-viewer .tool-library .lib-add-btn,
body.access-viewer .tool-library .trash-zone,
body.access-viewer .bottom-io { display: none !important; }

body.access-viewer #authUserBar.viewer-state { display: flex; align-items: center; gap: 6px; }
body.access-viewer #authUserBar.viewer-state #authUserEmail { color: #1d66b5; font-weight: 600; }
body.access-viewer #authUserBar.viewer-state .guest-login-btn { display: none !important; }
body.access-viewer { padding-top: 0; }