/* 铁塔提料工具 网页版 —— 视觉规格严格复刻原 WinForms 界面
   所有颜色取自 MainForm.cs / CompareView.cs / ImageViewer.cs 的 Color.FromArgb 原值 */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #99a8b8;
  font-family: "Microsoft YaHei", "微软雅黑", "Segoe UI", sans-serif;
  font-size: 12px;
  color: #1c324b;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 应用外壳：模拟 FormBorderStyle.None + Padding(1) ---------- */
#app {
  position: fixed;
  inset: 6px;
  background: #e1eaf4;              /* 225,234,244 */
  border: 1px solid #7f8fa3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 34px rgba(20, 40, 70, .34);
}

/* ---------- 标题栏 (title Panel, Height 48, BackColor 0,114,235) ---------- */
#titlebar {
  height: 48px;
  flex: 0 0 48px;
  background: #0072eb;
  display: flex;
  align-items: center;
  user-select: none;
  -webkit-app-region: drag;
}
#brand {
  flex: 1 1 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding-left: 14px;
  color: #fff;
  font-size: 21px;                  /* 16pt Bold ≈ 21px */
  font-weight: 700;
  letter-spacing: .5px;
  cursor: default;
}
.winbtn {
  width: 46px;
  height: 48px;
  flex: 0 0 46px;
  background: transparent;
  border: 0;
  color: #fff;
  font-family: "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.winbtn:hover { background: rgba(255, 255, 255, .18); }
.winbtn.close:hover { background: #e81123; }

/* ---------- 工具栏 (FlowLayoutPanel, Height 46, BackColor 244,249,255) ---------- */
#toolbar {
  height: 46px;
  flex: 0 0 46px;
  background: #f4f9ff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 7px;
  border-bottom: 1px solid #dbe6f2;
  overflow: hidden;
}
.tbtn {
  height: 32px;
  flex: 0 0 auto;
  padding: 0 12px;
  background: #fff;
  color: #183e66;                   /* 24,62,102 */
  border: 1px solid #c0d6ec;        /* 192,214,236 */
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tbtn:hover:not(:disabled) { background: #eaf4ff; border-color: #8fb9e4; }
.tbtn:active:not(:disabled) { background: #dcecff; }
.tbtn:disabled { color: #97a7b8; background: #f6f8fb; border-color: #dde5ee; cursor: default; }

#search {
  width: 166px;
  height: 28px;
  flex: 0 0 166px;
  margin-left: 4px;
  padding: 0 8px;
  border: 1px solid #c0d6ec;
  border-radius: 2px;
  background: #fff;
  color: #1c324b;
  font-family: inherit;
  font-size: 12px;
  outline: none;
}
#search:focus { border-color: #0072eb; box-shadow: 0 0 0 2px rgba(0, 114, 235, .16); }
#search:disabled { background: #f2f5f9; }

#cancelButton {
  height: 30px;
  flex: 0 0 auto;
  padding: 0 14px;
  background: #fff;
  color: #183e66;
  border: 1px solid #c0d6ec;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
#cancelButton:disabled { color: #a8b6c6; background: #f6f8fb; cursor: default; }

/* ---------- 主体：左侧导航 + 分隔条 + 右侧工作区 ---------- */
#body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  background: #d9e5f2;              /* 217,229,242 */
}

#sidebar {
  width: 286px;
  flex: 0 0 286px;
  display: flex;
  flex-direction: column;
  background: #f9fcff;
  min-width: 160px;
}
#sidebarHeading {
  height: 40px;
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  padding-left: 12px;
  background: #eaf3fc;              /* 234,243,252 */
  color: #27476a;                   /* 39,71,106 */
  font-size: 12px;
}
#tree {
  flex: 1 1 auto;
  overflow: auto;
  background: #f9fcff;
  padding: 3px 0;
}
.tnode {
  display: flex;
  align-items: center;
  height: 30px;
  padding-right: 6px;
  white-space: nowrap;
  cursor: default;
  color: #2e425a;                   /* 46,66,90 */
  font-size: 12px;
}
.tnode:hover { background: #eef6ff; }
.tnode.selected { background: #cce4ff; }
.tnode.hasTable { color: #0072eb; }
.tnode .twist {
  width: 18px;
  flex: 0 0 18px;
  text-align: center;
  color: #6a7f96;
  font-size: 10px;
  cursor: pointer;
  user-select: none;
}
.tnode .twist:hover { color: #0072eb; }
.tnode .tlabel {
  overflow: hidden;
  text-overflow: ellipsis;
  /* 标签必须能收缩，否则长文件名会把整行撑开、右侧徽标被挤出可视区；
     min-width:0 是 flex 子项允许收缩的必要条件。 */
  min-width: 0;
  flex: 0 1 auto;
}
.tnode .badge {
  color: #8598ab; margin-left: 4px; font-size: 11px;
  flex: 0 0 auto;
}
/* 折叠提示行：明确告诉用户子项被折叠了，而不是"消失" */
.tnode-collapsed { color: #8598ab; font-size: 11px; font-style: italic; }
.tnode-collapsed:hover { background: #eef6ff; color: #0072eb; }

#splitter {
  width: 5px;
  flex: 0 0 5px;
  background: #d9e5f2;
  cursor: col-resize;
}
#splitter:hover { background: #b7d3ef; }

#work {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  background: #fff;
}

/* ---------- 图纸查看器 (ImageViewer, BackColor 234,240,247) ---------- */
#viewer {
  position: absolute;
  inset: 0;
  background: #eaf0f7;
  overflow: hidden;
  cursor: crosshair;
}
#viewer.visible { display: block; }
#viewer.hidden { display: none; }
#viewer.busy { cursor: wait; }

#viewerCanvas { position: absolute; left: 0; top: 0; }

#viewerHint {
  position: absolute;
  left: 40px;
  top: 55px;
  pointer-events: none;
  color: #3a526e;                   /* 58,82,110 */
}
#viewerHint .h1 {
  font-size: 23px;                  /* 17pt Bold */
  font-weight: 700;
  margin-bottom: 14px;
}
#viewerHint .h2 { font-size: 12px; line-height: 1.9; white-space: pre; }

#zoomLabel {
  position: absolute;
  left: 8px;
  bottom: 4px;
  width: 90px;
  height: 22px;
  line-height: 22px;
  color: #283c50;                   /* 40,60,80 */
  background: #ebf0f6;
  font-size: 11px;
  padding-left: 4px;
  pointer-events: none;
}

/* 框选提示气泡 */
#selHint {
  position: absolute;
  background: #00805a;              /* 0,128,90 */
  color: #fff;
  font-size: 11px;
  padding: 2px 6px 3px;
  white-space: nowrap;
  pointer-events: none;
  display: none;
}

/* 查看器右键菜单 */
.ctxmenu {
  position: fixed;
  z-index: 900;
  background: #f7faff;
  border: 1px solid #b9cde2;
  box-shadow: 2px 3px 10px rgba(20, 45, 80, .26);
  padding: 3px 0;
  min-width: 148px;
}
.ctxmenu .item {
  padding: 5px 18px 5px 22px;
  font-size: 12px;
  color: #1c324b;
  cursor: default;
  white-space: nowrap;
}
.ctxmenu .item:hover { background: #cce4ff; }
.ctxmenu .sep { height: 1px; background: #dde6ef; margin: 3px 6px; }

/* ---------- 核对视图 (CompareView) ---------- */
#compare {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #fff;
}
#compare.visible { display: flex; }

#summaryBar {
  height: 24px;
  flex: 0 0 24px;
  background: #eff7ff;              /* 239,247,255 */
  display: flex;
  align-items: center;
  padding: 0 6px 0 10px;
  font-size: 11px;
  color: #1c324b;
  overflow: hidden;
}
#summaryBar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cbtn {
  height: 28px;
  flex: 0 0 auto;
  padding: 0 11px;
  background: #fff;
  color: #1c324b;
  border: 1px solid #cedcea;        /* 206,220,234 */
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.cbtn:hover:not(:disabled) { background: #eef6ff; border-color: #9dbde0; }
.cbtn:disabled { color: #a8b6c6; background: #f7f9fc; cursor: default; }

#compareSplit {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

#gridWrap {
  flex: 0 0 0;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#gridScroll { flex: 1 1 auto; overflow: auto; position: relative; }

table.bomgrid {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  /* 列宽由 COLUMNS 常量决定，不能被容器压扁；不够宽时横向滚动 */
  width: max-content;
  min-width: 100%;
  font-size: 12px;
  background: #fff;
}
table.bomgrid col { min-width: 40px; }
table.bomgrid th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 38px;
  background: #eaf3fc;              /* 234,243,252 */
  color: #15385d;                   /* 21,56,93 */
  font-weight: 400;
  text-align: center;
  border-right: 1px solid #dbe4ee;  /* 219,228,238 */
  border-bottom: 1px solid #dbe4ee;
  padding: 0 6px;
  white-space: nowrap;
}
table.bomgrid td {
  height: 30px;
  border-right: 1px solid #dbe4ee;
  border-bottom: 1px solid #dbe4ee;
  padding: 0 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: #fff;
}
table.bomgrid tr.alt td { background: #eef7ff; }   /* 238,247,255 */
table.bomgrid td.c-part,
table.bomgrid td.c-material,
table.bomgrid td.c-spec { text-align: center; }
table.bomgrid td.c-remark,
table.bomgrid td.c-status { text-align: left; }
table.bomgrid td.c-num { text-align: right; }
table.bomgrid tr.selected td { background: #d3e7ff !important; color: #0f2743; }
table.bomgrid tr.warn td { background: #fff2c4 !important; }   /* 255,242,196 */
table.bomgrid tr.warn.selected td { background: #f3e2ad !important; }

td.cell-edit { padding: 0; }
td.cell-edit input {
  box-sizing: border-box;   /* 否则 100% 宽 + 左右内边距会溢出单元格，文字被裁 */
  width: 100%;
  height: 28px;
  border: 0;
  padding: 0 4px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  color: inherit;
  outline: none;
}
td.cell-edit input:focus { background: #fffbe8; box-shadow: inset 0 0 0 2px #0072eb; }
td.cell-edit.c-num input { text-align: right; }
td.cell-edit.c-part input,
td.cell-edit.c-material input,
td.cell-edit.c-spec input { text-align: center; }
td.cell-edit input.invalid { box-shadow: inset 0 0 0 2px #c0392b; }

#sourceWrap {
  flex: 0 0 0;
  min-width: 220px;
  display: flex;
  overflow: hidden;
  border-left: 6px solid #dce6f0;
}
#sourceScroll { flex: 1 1 auto; overflow: auto; background: #fff; position: relative; }
#sourceCanvas { display: block; }
#sourceVScroll {
  width: 18px;
  flex: 0 0 18px;
  background: #f1f5f9;
  border-left: 1px solid #dfe7ef;
}

/* ---------- 底部状态栏 (StatusStrip) ---------- */
#footer {
  height: 24px;
  flex: 0 0 24px;
  background: #fff;
  border-top: 1px solid #d5dfe9;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 12px;
  color: #1c324b;
}
#status { flex: 1 1 auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#engineStatus { flex: 0 0 auto; padding: 0 12px; color: #3f5670; white-space: nowrap; }
#progressOuter {
  width: 135px;
  height: 14px;
  flex: 0 0 135px;
  border: 1px solid #c3cfdb;
  background: #f4f7fa;
  overflow: hidden;
}
#progressBar { height: 100%; width: 0; background: #06b025; transition: width .12s linear; }
#footer .grip {
  width: 14px;
  flex: 0 0 14px;
  height: 14px;
  margin-left: 6px;
  background-image: radial-gradient(#98a8b8 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: .7;
}

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 34, 56, .36);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: #fff;
  border: 1px solid #9fb4ca;
  box-shadow: 0 14px 44px rgba(12, 30, 55, .4);
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}
.modal-head {
  height: 30px;
  flex: 0 0 30px;
  background: #f0f4f9;
  border-bottom: 1px solid #d9e2ec;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 10px;
  font-size: 12px;
  color: #1c324b;
}
.modal-head .x {
  width: 34px; height: 29px; border: 0; background: transparent;
  font-size: 14px; cursor: pointer; color: #4a5f76;
}
.modal-head .x:hover { background: #e81123; color: #fff; }
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-foot {
  flex: 0 0 auto;
  padding: 10px 16px 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn {
  height: 30px;
  padding: 0 16px;
  border-radius: 3px;
  border: 1px solid #d4dfec;        /* 212,223,236 */
  background: #fff;
  color: #1c324b;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.btn:hover { background: #f2f8ff; }
.btn.primary { background: #0072eb; border-color: #0072eb; color: #fff; }
.btn.primary:hover { background: #0061c9; }

/* 授权弹窗专用（复刻 LicenseDialog） */
#licenseModal { width: 760px; }
#licenseModal .lic-head {
  height: 96px;
  flex: 0 0 96px;
  background: #0072eb;
  padding: 17px 24px;
  color: #fff;
}
#licenseModal .lic-head h2 { margin: 0; font-size: 27px; font-weight: 700; }
#licenseModal .lic-head p { margin: 6px 0 0; font-size: 12px; color: #dcebff; }
#licenseModal .lic-body { padding: 18px 24px 12px; display: flex; flex-direction: column; gap: 12px; }
.machineRow {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f1f7ff;
  padding: 8px 10px;
}
.machineRow label { flex: 0 0 94px; color: #64768a; }
.machineRow input {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  font-family: Consolas, monospace;
  font-size: 13px;
  color: #1c324b;
  outline: none;
}
.lic-label { color: #1c324b; font-size: 12px; }
#licenseInput {
  height: 168px;
  width: 100%;
  resize: none;
  border: 1px solid #d4dfec;
  background: #f9fbfe;
  padding: 12px;
  font-family: Consolas, monospace;
  font-size: 13px;
  color: #1c324b;
  outline: none;
  line-height: 1.5;
}
#licenseInput:focus { border-color: #0072eb; }
#licenseFeedback { min-height: 18px; color: #64768a; font-size: 12px; }
#licenseFeedback.error { color: #b7302d; }

/* 行数复核弹窗 */
#reviewModal { width: 1080px; height: 740px; max-height: 92vh; }
#reviewBody { flex: 1 1 auto; display: flex; min-height: 0; }
#reviewList {
  width: 265px;
  flex: 0 0 265px;
  overflow: auto;
  border-right: 1px solid #dde5ee;
  background: #fff;
}
#reviewList .ritem {
  padding: 6px 10px;
  font-size: 12px;
  cursor: default;
  border-bottom: 1px solid #f0f4f8;
  color: #1c324b;
}
#reviewList .ritem:hover { background: #eef6ff; }
#reviewList .ritem.selected { background: #cce4ff; }
#reviewList .ritem.pending { color: #874f00; }
#reviewMain { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
#reviewText {
  height: 78px;
  flex: 0 0 78px;
  padding: 8px;
  border-bottom: 1px solid #dde5ee;
  font-size: 12px;
  line-height: 1.6;
  color: #1c324b;
  overflow: auto;
  white-space: pre-wrap;
}
#reviewImagePanel {
  flex: 1 1 auto;
  overflow: auto;
  background: #e1e8ef;              /* 225,232,239 */
  padding: 8px;
}
#reviewImagePanel img { display: block; background: #fff; box-shadow: 0 1px 5px rgba(0,0,0,.16); }

/* 通用提示框 */
#alertModal { width: 420px; }
#alertText { font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }

/* 滚动条（贴近 WinForms 观感） */
::-webkit-scrollbar { width: 15px; height: 15px; }
::-webkit-scrollbar-track { background: #f0f3f7; }
::-webkit-scrollbar-thumb { background: #c3ccd6; border: 3px solid #f0f3f7; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #a9b6c4; }
::-webkit-scrollbar-corner { background: #f0f3f7; }

.hidden { display: none !important; }
