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

html, body {
  width: 100%; height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13px; color: #2c3e50; overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

#menubar {
  display: flex; align-items: center; flex-wrap: wrap;
  background: #1f2d3d; color: #e6e6e6; min-height: 34px;
  padding: 0 8px; border-bottom: 2px solid #14b8a6; z-index: 50;
  position: relative;
}

.menu-root { position: relative; }
.menu-title {
  display: inline-block; padding: 8px 14px; cursor: pointer;
  user-select: none; white-space: nowrap;
}
.menu-root:hover .menu-title, .menu-root.open .menu-title {
  background: #2e4a66; color: #fff;
}
.help-btn { margin-left: auto; }

.menu-drop {
  display: none; position: absolute; top: 100%; left: 0;
  background: #fff; color: #333; min-width: 170px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 100;
  border-radius: 3px; overflow: hidden;
}
.menu-root.open .menu-drop { display: block; }
.menu-item { padding: 8px 16px; cursor: pointer; white-space: nowrap; }
.menu-item:hover { background: #e6f7f5; color: #0f766e; }
.menu-sep { height: 1px; background: #ddd; margin: 3px 0; }

#main { display: flex; flex: 1; overflow: hidden; }

#sidebar {
  width: 320px; min-width: 260px; overflow-y: auto;
  background: #f4f7fa; border-right: 2px solid #d5dce3;
  padding: 8px; display: flex; flex-direction: column; gap: 8px;
}

.panel {
  background: #fff; border-radius: 6px; border: 1px solid #e3e8ee;
  padding: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.panel-title {
  font-weight: bold; font-size: 13px; margin-bottom: 8px;
  padding-left: 8px; border-left: 4px solid #14b8a6;
  color: #0f766e;
}

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  flex: 1; padding: 7px 6px; border: 1px solid #c3ccd5;
  border-radius: 4px; background: #fff; cursor: pointer;
  font-size: 12px; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: #eef4f9; }
.btn-primary { background: #14b8a6; border-color: #14b8a6; color: #fff; }
.btn-primary:hover { background: #0f9d8c; }
.btn-warn { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.btn-warn:hover { background: #d97706; }
.btn-danger { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; margin-top: 8px; }

.speed-row { display: flex; align-items: center; gap: 8px; }
.speed-row input[type="range"] { flex: 1; }
.speed-row input[type="number"] { width: 52px; padding: 4px; }
.speed-unit { color: #666; }

.cfg-grid {
  display: grid; grid-template-columns: 1fr 1.2fr; gap: 7px 8px;
  align-items: center;
}
.cfg-grid label { color: #555; font-size: 12px; }
.cfg-grid input[type="number"] {
  width: 100%; padding: 4px 6px; border: 1px solid #cbd5e1;
  border-radius: 4px; font-size: 13px;
}
.size-row { display: flex; align-items: center; gap: 4px; }
.size-row input { text-align: center; }

.stat-table { width: 100%; border-collapse: collapse; }
.stat-table td {
  padding: 5px 8px; border-bottom: 1px dashed #e5e9ef; font-size: 13px;
}
.stat-table td:nth-child(2) { text-align: right; font-weight: bold; color: #0f766e; }

.log-box {
  height: 180px; overflow-y: auto; font-size: 11px;
  background: #0f172a; color: #d1fae5; border-radius: 4px;
  padding: 6px; line-height: 1.5;
}
.log-box .log-item { border-bottom: 1px dashed #1e293b; }
.log-time { color: #64748b; margin-right: 5px; }
.log-ok { color: #4ade80; }
.log-run { color: #fbbf24; }
.log-wait { color: #93c5fd; }
.log-err { color: #f87171; }

#viewport {
  flex: 1; display: flex; flex-direction: column;
  background: #eef1f4; overflow: hidden; min-width: 0;
}

#zoom-tools {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: #fff; border-bottom: 1px solid #dde3ea;
  font-size: 12px; color: #555;
}
#zoom-tools input { width: 140px; }

#canvas-wrap {
  flex: 1; overflow: auto; padding: 12px;
  background: repeating-conic-gradient(#e8edf2 0 25%, #f3f6f9 0 50%)
    50% / 26px 26px;
}

#canvas {
  display: block; background: #fbfcfd;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
  transform-origin: top left; cursor: crosshair;
}

#viewport-tip {
  padding: 5px 12px; font-size: 11px; color: #6b7280;
  background: #fff; border-top: 1px solid #dde3ea;
}

.ctx-menu {
  position: fixed; z-index: 200; background: #fff; min-width: 150px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); border-radius: 4px;
  padding: 4px 0; font-size: 13px;
}
.ctx-menu .ctx-item { padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.ctx-menu .ctx-item:hover { background: #e6f7f5; color: #0f766e; }
.ctx-menu .ctx-sep { height: 1px; background: #e5e7eb; margin: 3px 0; }
.ctx-menu .ctx-title { padding: 5px 14px; font-weight: bold; color: #555; }

#modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
#modal-box {
  background: #fff; border-radius: 8px; min-width: 460px; max-width: 640px;
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
#modal-title {
  padding: 12px 16px; font-weight: bold; font-size: 14px;
  border-bottom: 1px solid #e5e7eb; color: #0f766e;
}
#modal-body { padding: 12px 16px; overflow-y: auto; flex: 1; }
#modal-foot {
  padding: 10px 16px; border-top: 1px solid #e5e7eb;
  display: flex; justify-content: flex-end; gap: 8px;
}

.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th, .tbl td {
  border: 1px solid #dde3ea; padding: 4px 6px; text-align: center;
}
.tbl th { background: #f0f5f9; position: sticky; top: 0; }

.tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; color: #fff; }
.tag-wait { background: #93c5fd; }
.tag-run { background: #f59e0b; }
.tag-done { background: #34d399; }
.tag-in { background: #ef4444; }
.tag-out { background: #1e88e5; }
.tag-move { background: #8e24aa; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; }
.legend .lg { display: flex; align-items: center; gap: 5px; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

.help-text { line-height: 1.8; font-size: 12px; color: #333; }
.help-text b { color: #0f766e; }
