/* WPS 2023 标题栏 + 加载 + 防老板遮罩 */
:root {
  --wps-bg: #F8F9FA;
  --wps-white: #FFFFFF;
  --wps-primary: #5CC5B6;
  --wps-border: #E0E0E0;
  --wps-border-dark: #C8C8C8;
  --wps-text: #333333;
  --wps-text-muted: #999999;
  --wps-header-bg: #F0F0F0;
  --wps-selection: #5CC5B6;
  --title-h: 32px;
  --font: "Microsoft YaHei", "微软雅黑", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: var(--font); font-size: 12px; color: var(--wps-text);
  background: var(--wps-bg);
}

.hidden { display: none !important; }

.wps-loader.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.wps-loader {
  position: fixed; inset: 0; background: var(--wps-white); z-index: 99999;
  display: flex; align-items: center; justify-content: center;
}
.wps-loader-inner { text-align: center; width: 240px; }
.wps-loader-logo { margin-bottom: 16px; }
.wps-loader-text { font-size: 16px; margin-bottom: 20px; font-weight: 500; }
.wps-loader-bar { height: 4px; background: #E8E8E8; border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.wps-loader-progress { height: 100%; width: 0; background: var(--wps-primary); border-radius: 2px; transition: width 0.25s ease; }
.wps-loader-hint { font-size: 11px; color: var(--wps-text-muted); }

.wps-app {
  display: flex; flex-direction: column;
  width: 100vw; height: 100vh; overflow: hidden;
}

.title-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--title-h); background: var(--wps-white);
  border-bottom: 1px solid var(--wps-border);
  padding: 0 8px; flex-shrink: 0; z-index: 10;
}
.title-bar-left { display: flex; align-items: center; gap: 8px; }
.doc-title { font-size: 12px; font-weight: 500; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-status { font-size: 11px; color: var(--wps-text-muted); }
.title-bar-right { display: flex; gap: 2px; }
.title-btn {
  width: 36px; height: 24px; border: none; background: transparent;
  font-size: 12px; color: #666; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
}
.title-btn:hover { background: #E8E8E8; }
.title-btn.close:hover { background: #E81123; color: #fff; }

.boss-mode .wps-logo { opacity: 0; width: 0; overflow: hidden; margin: 0; }
.boss-mode .brand-footer { visibility: hidden !important; }
.boss-mode #luckysheet { visibility: hidden; pointer-events: none; }
.boss-mode #cursorLayer { display: none; }

.sheet-area {
  flex: 1; position: relative; overflow: hidden; min-height: 0;
  background: var(--wps-white);
}
#luckysheet {
  position: absolute; inset: 0; margin: 0; padding: 0;
}

/* 防老板遮罩 - 像素级复刻 Luckysheet 网格 */
.boss-overlay {
  position: absolute; inset: 0; z-index: 200;
  background: var(--wps-white); overflow: auto;
  font-family: var(--font);
}
.boss-grid-wrap { display: flex; min-width: 100%; min-height: 100%; }
.boss-corner {
  width: 46px; min-width: 46px; height: 20px; min-height: 20px;
  background: var(--wps-header-bg); border-right: 1px solid var(--wps-border-dark);
  border-bottom: 1px solid var(--wps-border-dark); position: sticky; top: 0; left: 0; z-index: 4;
}
.boss-col-headers {
  display: flex; position: sticky; top: 0; z-index: 3;
  background: var(--wps-header-bg); border-bottom: 1px solid var(--wps-border-dark); height: 20px;
}
.boss-col-h {
  width: 73px; min-width: 73px; height: 20px; line-height: 20px; text-align: center;
  font-size: 11px; color: #666; border-right: 1px solid var(--wps-border-dark); font-weight: 500;
}
.boss-col-h.wide { width: 120px; min-width: 120px; }
.boss-body { display: flex; flex: 1; }
.boss-row-headers {
  position: sticky; left: 0; z-index: 2; background: var(--wps-header-bg);
  border-right: 1px solid var(--wps-border-dark);
}
.boss-row-h {
  width: 46px; height: 19px; line-height: 19px; text-align: center;
  font-size: 11px; color: #666; border-bottom: 1px solid var(--wps-border-dark); font-weight: 500;
}
.boss-cells { flex: 1; }
.boss-row { display: flex; height: 19px; }
.boss-cell {
  width: 73px; min-width: 73px; height: 19px; line-height: 19px;
  padding: 0 4px; font-size: 11px; border-right: 1px solid #E0E0E0;
  border-bottom: 1px solid #E0E0E0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.boss-cell.wide { width: 120px; min-width: 120px; }
.boss-cell.header { background: #F5F5F5; font-weight: 600; color: #666; }
.boss-cell.num { text-align: right; font-variant-numeric: tabular-nums; }

.boss-sheet-bar {
  position: sticky; bottom: 0; height: 28px; background: #fff;
  border-top: 1px solid var(--wps-border); display: flex; align-items: center; padding: 0 4px;
}
.boss-sheet-tab {
  padding: 0 14px; height: 28px; line-height: 28px; font-size: 11px;
  color: var(--wps-primary); font-weight: 500;
  border-bottom: 2px solid var(--wps-primary);
  background: rgba(92, 197, 182, 0.1);
}

.cursor-layer {
  position: absolute; inset: 0; pointer-events: none; z-index: 100; overflow: hidden;
}
.remote-cursor { position: absolute; width: 2px; height: 19px; transition: top 0.08s, left 0.08s; }
.remote-cursor-label {
  position: absolute; top: -16px; left: 0; font-size: 10px; color: #fff;
  padding: 0 4px; border-radius: 2px; white-space: nowrap; line-height: 14px;
}

.brand-footer {
  position: fixed; bottom: 2px; right: 8px; font-size: 9px;
  color: #E8E8E8; z-index: 50; pointer-events: none; letter-spacing: 1px;
  display: flex; align-items: center; gap: 10px;
}

.collab-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9px; color: #B0B0B0; pointer-events: auto;
}
.collab-status-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #ccc;
}
.collab-status.online .collab-status-dot {
  background: #5CC5B6;
  box-shadow: 0 0 0 2px rgba(92, 197, 182, 0.25);
  animation: collab-pulse 1.6s ease-in-out infinite;
}
.collab-status.offline .collab-status-dot { background: #FFB347; }
@keyframes collab-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.mgy-lazy-offer-btn {
  margin-top: 14px; padding: 8px 12px; border: 1px solid var(--wps-primary);
  background: #fff; color: var(--wps-primary); border-radius: 4px; cursor: pointer;
  font-size: 11px; width: 100%;
}
.mgy-lazy-offer-btn:hover { background: #f0faf8; }

.mgy-engine-gate {
  position: absolute; inset: 0; z-index: 800;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #f8f9fa 0%, #eef5f4 100%);
}
.mgy-engine-gate-card {
  text-align: center; max-width: 360px; padding: 28px 24px;
  background: #fff; border: 1px solid var(--wps-border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.mgy-engine-gate-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.mgy-engine-gate-desc { font-size: 12px; color: #666; line-height: 1.6; margin-bottom: 12px; }
.mgy-engine-gate-sync { font-size: 11px; color: #999; margin-bottom: 16px; }
.mgy-engine-gate-sync.ok { color: #3d9e8f; }
.mgy-engine-gate-sync.warn { color: #c8842d; }
.mgy-engine-gate-btn {
  display: block; width: 100%; padding: 10px 16px; border: none; border-radius: 4px;
  background: var(--wps-primary); color: #fff; font-size: 13px; cursor: pointer;
}
.mgy-engine-gate-btn:hover { filter: brightness(0.95); }
.mgy-engine-gate-link {
  margin-top: 10px; border: none; background: none; color: #6C9EFF;
  font-size: 11px; cursor: pointer; text-decoration: underline;
}
.mgy-engine-gate.loading { pointer-events: none; opacity: 0.92; }

@media (max-width: 768px) {
  .doc-status { display: none; }
  .auth-label { max-width: 72px; }
}

/* ===== 用户入口（融入 Luckysheet 工具栏右上角） ===== */
#luckysheet-wa-editor { position: relative !important; }

.mgy-auth-slot {
  position: absolute;
  top: 4px;
  right: 8px;
  z-index: 1200;
  font-family: var(--font);
  pointer-events: auto;
}

.auth-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 4px;
  border: 1px solid #E0E0E0;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, border-color 0.1s;
}
.auth-entry:hover {
  background: #E8F7F5;
  border-color: #5CC5B6;
}

.auth-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.auth-avatar.guest { opacity: 0.88; }
.auth-avatar svg { display: block; }

.auth-label {
  font-size: 11px;
  color: #333;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-caret { font-size: 9px; color: #999; }

.auth-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 2px;
  min-width: 120px;
  background: #fff;
  border: 1px solid #E0E0E0;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  overflow: hidden;
  z-index: 100100;
  pointer-events: auto;
}
.auth-menu button {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 12px;
  font-family: inherit;
  color: #333;
  cursor: pointer;
}
.auth-menu button:hover { background: #E8F7F5; color: #5CC5B6; }

.boss-mode .mgy-auth-slot { display: none !important; }

/* 登录 / 注册 / 个人中心弹层 */
.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.15);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-dialog {
  width: 360px;
  max-width: 92vw;
  background: #fff;
  border: 1px solid #E0E0E0;
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  font-family: var(--font);
}
.auth-dialog-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #F0F0F0;
  border-bottom: 1px solid #E0E0E0;
  font-size: 12px;
  font-weight: 500;
}
.auth-dialog-x {
  border: none;
  background: transparent;
  font-size: 18px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.auth-dialog-x:hover { color: #E81123; }
.auth-dialog-bd { padding: 16px 14px; }
.auth-dialog-bd label {
  display: block;
  font-size: 11px;
  color: #666;
  margin-bottom: 12px;
}
.auth-dialog-bd input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 8px;
  border: 1px solid #E0E0E0;
  border-radius: 2px;
  font-size: 12px;
  font-family: inherit;
}
.auth-dialog-bd input:focus {
  outline: none;
  border-color: #5CC5B6;
}
.auth-submit {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 3px;
  background: #5CC5B6;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
}
.auth-submit:hover { background: #4DB5A6; }
.auth-error { font-size: 11px; color: #E74C3C; margin-bottom: 8px; }
.auth-hint { font-size: 11px; color: #999; margin-bottom: 10px; }

