/* =========================
   全局基础
========================= */
:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --border:#d9dde3;
  --text:#111827;
  --muted:#6b7280;
  --link:#2563eb;
  --radius:12px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,
    "PingFang SC","Microsoft Yahei",sans-serif;
  background:var(--bg);
  color:var(--text);
}

/* =========================
   页面布局（重点）
========================= */
.container{
  max-width:100%;
  margin:0;
  padding:10px;
}

/* 顶部栏固定，方便全屏 */
.topbar{
  position:sticky;
  top:0;
  z-index:20;
  background:#fff;
  border-bottom:1px solid #e5e7eb;
  padding:8px 10px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}

/* 标题不要太占空间 */
.h1{
  margin:4px 0 0;
  font-size:16px;
  font-weight:600;
}

/* 内容卡片 */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  margin-top:8px;
  padding:8px;
}

/* 表格卡片 = 主显示区 */
.card:has(#sheet){
  padding:6px;
}

/* =========================
   表格容器（核心）
========================= */
#sheet{
  width:100%;
  min-height:calc(100vh - 120px); /* 电脑端接近全屏 */
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:10px;
  overflow:hidden;
}

/* =========================
   Handsontable → WPS风格
========================= */
.handsontable{
  font-size:14px;
  color:#111827;
}

.handsontable .htCore{
  border-collapse:collapse;
}

.handsontable td,
.handsontable th{
  border-color:#d9dde3 !important;
}

.handsontable td{
  background:#fff;
  padding:6px 8px !important;
  line-height:20px;
}

.handsontable th{
  background:#f3f4f6 !important;
  color:#374151 !important;
  font-weight:600 !important;
}

/* 行号 / 列头 */
.handsontable .ht_clone_left th,
.handsontable .ht_clone_top th{
  background:#f3f4f6 !important;
}

/* 选中效果（像 WPS） */
.handsontable .currentRow,
.handsontable .currentCol{
  background:#f8fafc !important;
}

.handsontable .area{
  background: rgba(37, 99, 235, 0.08) !important;
}

.handsontable .highlight{
  background: rgba(37, 99, 235, 0.12) !important;
}

.handsontable .ht__active_highlight{
  outline:2px solid #2563eb !important;
  outline-offset:-2px;
}

/* 滚动条更像桌面软件 */
.handsontable ::-webkit-scrollbar{
  width:10px;
  height:10px;
}
.handsontable ::-webkit-scrollbar-thumb{
  background:#cfd6df;
  border-radius:10px;
}
.handsontable ::-webkit-scrollbar-track{
  background:#f6f7fb;
}

/* =========================
   Sheet 标签（底部）
========================= */
#sheetTabs{
  display:flex;
  gap:6px;
  padding:6px;
  border-top:1px solid #e5e7eb;
  background:#fafafa;
  overflow-x:auto;
}

#sheetTabs button{
  background:#374151;
  color:#fff;
  border:0;
  border-radius:8px;
  padding:6px 10px;
  font-size:13px;
  cursor:pointer;
  white-space:nowrap;
}
#sheetTabs button:hover{
  opacity:.9;
}

/* =========================
   通用控件
========================= */
button{
  border:0;
  border-radius:10px;
  padding:8px 12px;
  background:#111827;
  color:#fff;
  cursor:pointer;
  font-size:13px;
}
button:disabled{
  opacity:.6;
}

select{
  padding:6px 8px;
  border-radius:8px;
  border:1px solid #d1d5db;
  background:#fff;
}

.link{
  color:var(--link);
  text-decoration:none;
}

.badge{
  display:inline-block;
  padding:3px 8px;
  border-radius:999px;
  font-size:12px;
  background:#eef2ff;
  color:#3730a3;
}
.badge.ok{ background:#ecfdf5; color:#065f46; }
.badge.warn{ background:#fff7ed; color:#9a3412; }

.muted{
  color:var(--muted);
  font-size:12px;
}

/* =========================
   📱 手机端适配
========================= */
@media (max-width: 768px){
  .topbar{
    flex-direction:column;
    align-items:flex-start;
  }

  .right{
    width:100%;
    display:flex;
    flex-wrap:wrap;
    gap:6px;
  }

  #sheet{
    min-height:70vh; /* 手机不占满，留空间滚动 */
  }

  .handsontable{
    font-size:13px;
  }

  #sheetTabs{
    padding:6px 4px;
  }
}
